Changed 9p and tatlas' to use a separately loaded texture.
This commit is contained in:
@@ -95,8 +95,6 @@ namespace RecrownedAthenaeum.UI.BookSystem
|
||||
{
|
||||
foreach (Page page in pages)
|
||||
{
|
||||
page.camera = camera;
|
||||
page.Initialize(assets, skin);
|
||||
orderedPages.Add(page);
|
||||
this.pages.Add(page.name, page);
|
||||
}
|
||||
|
@@ -3,7 +3,6 @@ using Microsoft.Xna.Framework.Graphics;
|
||||
using RecrownedAthenaeum.SpecialTypes;
|
||||
using RecrownedAthenaeum.UI.SkinSystem;
|
||||
using RecrownedAthenaeum.UI.SkinSystem.Definitions;
|
||||
using System;
|
||||
|
||||
namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
|
||||
{
|
||||
|
@@ -1,7 +1,5 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using RecrownedAthenaeum.UI.SkinSystem;
|
||||
using RecrownedAthenaeum.UI.SkinSystem.Definitions;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
|
@@ -2,7 +2,6 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using RecrownedAthenaeum.Input;
|
||||
using RecrownedAthenaeum.Render;
|
||||
using System;
|
||||
|
||||
namespace RecrownedAthenaeum.UI.Modular
|
||||
|
@@ -3,9 +3,7 @@ using System.Collections.Generic;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using RecrownedAthenaeum.Camera;
|
||||
using RecrownedAthenaeum.Render;
|
||||
using RecrownedAthenaeum.ScreenSystem;
|
||||
|
||||
namespace RecrownedAthenaeum.UI.Modular
|
||||
{
|
||||
@@ -16,32 +14,23 @@ namespace RecrownedAthenaeum.UI.Modular
|
||||
public class UIModuleGroup : UIModule
|
||||
{
|
||||
List<UIModule> modules = new List<UIModule>();
|
||||
Rectangle scissorBounds;
|
||||
RasterizerState scissorRasterizer;
|
||||
SpriteBatchSettings spriteBatchSettings;
|
||||
ScissorBox scissorBox;
|
||||
|
||||
/// <summary>
|
||||
/// Camera used by the module for cropping.
|
||||
/// Configuration for starting sprite batch after scissoring. Only used if cropping.
|
||||
/// </summary>
|
||||
public Camera2D camera;
|
||||
public SpriteBatchSettings spriteBatchSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a module group.
|
||||
/// </summary>
|
||||
/// <param name="crop">Whether or not to crop out of bounds. Default is false.</param>
|
||||
/// <param name="camera">What camera to use for cropping. Default is null and will use <see cref="Configuration"/>'s camera if crop is enabled.</param>
|
||||
/// <param name="spriteBatchSettings">The settings to be used that begins the batch.</param>
|
||||
public UIModuleGroup(bool crop = false, Camera2D camera = null, SpriteBatchSettings? spriteBatchSettings = null)
|
||||
public UIModuleGroup(bool crop = false)
|
||||
{
|
||||
if (spriteBatchSettings == null) spriteBatchSettings = Configuration.spriteBatchSettings;
|
||||
if (crop && camera == null) camera = Configuration.Camera2D;
|
||||
this.spriteBatchSettings = spriteBatchSettings.Value;
|
||||
this.camera = camera;
|
||||
this.spriteBatchSettings = Configuration.SpriteBatchSettings.Value;
|
||||
if (crop)
|
||||
{
|
||||
scissorRasterizer = new RasterizerState();
|
||||
scissorRasterizer.ScissorTestEnable = true;
|
||||
scissorBounds = new Rectangle();
|
||||
scissorBox = new ScissorBox();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,17 +40,10 @@ namespace RecrownedAthenaeum.UI.Modular
|
||||
/// <param name="batch">Batch used to draw the group.</param>
|
||||
public override void Draw(SpriteBatch batch)
|
||||
{
|
||||
if (scissorBounds != null)
|
||||
if (scissorBox != null)
|
||||
{
|
||||
batch.End();
|
||||
spriteBatchSettings.BeginSpriteBatch(batch);
|
||||
scissorBounds.Width = situation.Width;
|
||||
scissorBounds.Height = situation.Height;
|
||||
scissorBounds.X = situation.X;
|
||||
scissorBounds.Y = situation.Y;
|
||||
Rectangle scissor = scissorBounds;
|
||||
scissorBounds = batch.GraphicsDevice.ScissorRectangle;
|
||||
batch.GraphicsDevice.ScissorRectangle = scissor;
|
||||
scissorBox.Begin(Boundaries, batch, spriteBatchSettings);
|
||||
}
|
||||
|
||||
foreach (UIModule module in modules)
|
||||
@@ -75,11 +57,10 @@ namespace RecrownedAthenaeum.UI.Modular
|
||||
module.situation.Y = offsetY;
|
||||
}
|
||||
|
||||
if (scissorBounds != null)
|
||||
if (scissorBox != null)
|
||||
{
|
||||
batch.GraphicsDevice.ScissorRectangle = scissorBounds;
|
||||
batch.End();
|
||||
spriteBatchSettings.BeginSpriteBatch(batch);
|
||||
scissorBox.End();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,4 @@
|
||||
using RecrownedAthenaeum.UI.Modular.Modules.Interactive;
|
||||
using System;
|
||||
|
||||
namespace RecrownedAthenaeum.UI.SkinSystem.Definitions
|
||||
{
|
||||
|
@@ -1,5 +1,4 @@
|
||||
using RecrownedAthenaeum.UI.Modular.Modules.Interactive;
|
||||
using System;
|
||||
|
||||
namespace RecrownedAthenaeum.UI.SkinSystem.Definitions
|
||||
{
|
||||
|
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using RecrownedAthenaeum.SpecialTypes;
|
||||
using RecrownedAthenaeum.UI.SkinSystem.Definitions;
|
||||
|
@@ -156,23 +156,28 @@ namespace RecrownedAthenaeum.UI.SkinSystem
|
||||
{
|
||||
TextureAtlasDataReader textureAtlasDataReader = new TextureAtlasDataReader();
|
||||
FileInfo[] skinFiles = Directory.GetParent(path).GetFiles();
|
||||
Dictionary<string, string> fileNameWithPath = new Dictionary<string, string>();
|
||||
Dictionary<string, string> filePath = new Dictionary<string, string>();
|
||||
for (int i = 0; i < skinFiles.Length; i++)
|
||||
{
|
||||
fileNameWithPath.Add(skinFiles[i].Name, skinFiles[i].FullName);
|
||||
filePath.Add(skinFiles[i].Name, skinFiles[i].FullName);
|
||||
}
|
||||
TextureAtlasDataReader tatlasDataReader = new TextureAtlasDataReader();
|
||||
TextureAtlasData atlasData;
|
||||
using (FileStream fileStream = new FileStream(filePath[skinData.nameOfTextureAtlas], FileMode.Open))
|
||||
{
|
||||
atlasData = tatlasDataReader.ReadTextureAtlasData(new BinaryReader(fileStream));
|
||||
}
|
||||
TextureAtlasData atlasData = JsonConvert.DeserializeObject<TextureAtlasData>(fileNameWithPath[skinData.nameOfTextureAtlas]);
|
||||
Texture2D atlasTexture;
|
||||
using (FileStream stream = new FileStream(fileNameWithPath[atlasData.textureName], FileMode.Open))
|
||||
using (FileStream stream = new FileStream(filePath[atlasData.textureName], FileMode.Open))
|
||||
{
|
||||
atlasTexture = Texture2D.FromStream(graphicsDevice, stream);
|
||||
}
|
||||
TextureAtlas.Region[] regions = textureAtlasDataReader.GenerateAtlasRegionsFromData(atlasData, atlasTexture);
|
||||
TextureAtlas textureAtlas = new TextureAtlas(atlasTexture, regions);
|
||||
Texture2D cursorTexture;
|
||||
if (Path.HasExtension(skinData.cursorTextureName) && fileNameWithPath.ContainsKey(skinData.cursorTextureName))
|
||||
if (Path.HasExtension(skinData.cursorTextureName) && filePath.ContainsKey(skinData.cursorTextureName))
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileNameWithPath[skinData.cursorTextureName], FileMode.Open))
|
||||
using (FileStream stream = new FileStream(filePath[skinData.cursorTextureName], FileMode.Open))
|
||||
{
|
||||
cursorTexture = Texture2D.FromStream(graphicsDevice, stream);
|
||||
}
|
||||
|
Reference in New Issue
Block a user