Changed 9p and tatlas' to use a separately loaded texture.
This commit is contained in:
parent
4add103f94
commit
e3535f5662
@ -5,22 +5,12 @@ using System.IO;
|
|||||||
|
|
||||||
namespace RecrownedAthenaeum.Pipeline.NinePatch
|
namespace RecrownedAthenaeum.Pipeline.NinePatch
|
||||||
{
|
{
|
||||||
[ContentImporter(".9p", DisplayName = "Nine Patch Importer", DefaultProcessor = "NinePatchProcessor")]
|
[ContentImporter(".9p", DisplayName = "Nine Patch Importer - RecrownedAthenaeum", DefaultProcessor = "NinePatchProcessor")]
|
||||||
internal class NinePatchImporter : ContentImporter<NinePatchImporter.Package>
|
internal class NinePatchImporter : ContentImporter<NinePatchData>
|
||||||
{
|
{
|
||||||
public override Package Import(string filename, ContentImporterContext context)
|
public override NinePatchData Import(string filename, ContentImporterContext context)
|
||||||
{
|
{
|
||||||
Package package;
|
return JsonConvert.DeserializeObject<NinePatchData>(File.ReadAllText(filename));
|
||||||
package.ninePatchData = JsonConvert.DeserializeObject<NinePatchData>(File.ReadAllText(filename));
|
|
||||||
package.textureBytes = File.ReadAllBytes(package.ninePatchData.textureName);
|
|
||||||
|
|
||||||
return package;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal struct Package
|
|
||||||
{
|
|
||||||
internal byte[] textureBytes;
|
|
||||||
internal NinePatchData ninePatchData;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,19 @@
|
|||||||
using Microsoft.Xna.Framework.Content.Pipeline;
|
using Microsoft.Xna.Framework.Content.Pipeline;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using RecrownedAthenaeum.Data;
|
using RecrownedAthenaeum.Data;
|
||||||
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.Pipeline.NinePatch
|
namespace RecrownedAthenaeum.Pipeline.NinePatch
|
||||||
{
|
{
|
||||||
[ContentImporter(DisplayName = "Nine Patch - RecrownedAthenaeum")]
|
[ContentImporter(DisplayName = "Nine Patch - RecrownedAthenaeum")]
|
||||||
class NinePatchProcessor : ContentProcessor<NinePatchImporter.Package, NinePatchProcessor.Package>
|
class NinePatchProcessor : ContentProcessor<NinePatchData, NinePatchData>
|
||||||
{
|
{
|
||||||
public override Package Process(NinePatchImporter.Package input, ContentProcessorContext context)
|
public override NinePatchData Process(NinePatchData input, ContentProcessorContext context)
|
||||||
{
|
{
|
||||||
Package package;
|
if (Path.GetFileNameWithoutExtension(context.SourceIdentity.SourceFilename) == Path.GetFileNameWithoutExtension(input.textureName)) throw new InvalidContentException("Ninepatch data and texture for the data can't have the same name.");
|
||||||
package.ninePatchDataBytes = Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(input.ninePatchData));
|
context.AddDependency(input.textureName);
|
||||||
package.textureBytes = input.textureBytes;
|
return input;
|
||||||
return package;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal struct Package
|
|
||||||
{
|
|
||||||
internal byte[] ninePatchDataBytes;
|
|
||||||
internal byte[] textureBytes;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,23 +2,25 @@
|
|||||||
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
|
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using RecrownedAthenaeum.Data;
|
using RecrownedAthenaeum.Data;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.Pipeline.NinePatch
|
namespace RecrownedAthenaeum.Pipeline.NinePatch
|
||||||
{
|
{
|
||||||
[ContentTypeWriter]
|
[ContentTypeWriter]
|
||||||
class NinePatchWriter : ContentTypeWriter<NinePatchProcessor.Package>
|
class NinePatchWriter : ContentTypeWriter<NinePatchData>
|
||||||
{
|
{
|
||||||
public override string GetRuntimeReader(TargetPlatform targetPlatform)
|
public override string GetRuntimeReader(TargetPlatform targetPlatform)
|
||||||
{
|
{
|
||||||
return "RecrownedAthenaeum.ContentReaders.NinePatchDataReader, RecrownedAthenaeum";
|
return "RecrownedAthenaeum.ContentReaders.NinePatchDataReader, RecrownedAthenaeum";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Write(ContentWriter output, NinePatchProcessor.Package value)
|
protected override void Write(ContentWriter output, NinePatchData value)
|
||||||
{
|
{
|
||||||
output.Write(value.textureBytes.Length);
|
output.Write(Path.GetFileNameWithoutExtension(value.textureName));
|
||||||
output.Write(value.textureBytes);
|
output.Write(value.left);
|
||||||
output.Write(value.ninePatchDataBytes.Length);
|
output.Write(value.right);
|
||||||
output.Write(value.ninePatchDataBytes);
|
output.Write(value.bottom);
|
||||||
|
output.Write(value.top);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,18 @@
|
|||||||
using Microsoft.Xna.Framework.Content.Pipeline;
|
using Microsoft.Xna.Framework.Content.Pipeline;
|
||||||
|
using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
|
||||||
|
using Microsoft.Xna.Framework.Content.Pipeline.Processors;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using RecrownedAthenaeum.Data;
|
using RecrownedAthenaeum.Data;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
||||||
{
|
{
|
||||||
[ContentImporter(".tatlas", DisplayName = "Texture Atlas Importer", DefaultProcessor = "TextureAtlasProcessor")]
|
[ContentImporter(".tatlas", DisplayName = "Texture Atlas Importer - RecrownedAthenaeum", DefaultProcessor = "TextureAtlasProcessor")]
|
||||||
internal class TextureAtlasImporter : ContentImporter<TextureAtlasImporter.Package>
|
internal class TextureAtlasImporter : ContentImporter<TextureAtlasData>
|
||||||
{
|
{
|
||||||
public override Package Import(string filename, ContentImporterContext context)
|
public override TextureAtlasData Import(string filename, ContentImporterContext context)
|
||||||
{
|
{
|
||||||
Package package;
|
return JsonConvert.DeserializeObject<TextureAtlasData>(File.ReadAllText(filename));
|
||||||
package.textureAtlasData = JsonConvert.DeserializeObject<TextureAtlasData>(File.ReadAllText(filename));
|
|
||||||
package.textureBytes = File.ReadAllBytes(package.textureAtlasData.textureName);
|
|
||||||
return package;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal struct Package
|
|
||||||
{
|
|
||||||
internal TextureAtlasData textureAtlasData;
|
|
||||||
internal byte[] textureBytes;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,21 @@
|
|||||||
using Microsoft.Xna.Framework.Content.Pipeline;
|
using Microsoft.Xna.Framework.Content.Pipeline;
|
||||||
|
using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
|
||||||
|
using Microsoft.Xna.Framework.Content.Pipeline.Processors;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using RecrownedAthenaeum.Data;
|
||||||
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
||||||
{
|
{
|
||||||
[ContentProcessor(DisplayName = "Texture Atlas - RecrownedAthenaeum")]
|
[ContentProcessor(DisplayName = "Texture Atlas - RecrownedAthenaeum")]
|
||||||
class TextureAtlasProcessor : ContentProcessor<TextureAtlasImporter.Package, TextureAtlasProcessor.Package>
|
class TextureAtlasProcessor : ContentProcessor<TextureAtlasData, TextureAtlasData>
|
||||||
{
|
{
|
||||||
public override Package Process(TextureAtlasImporter.Package input, ContentProcessorContext context)
|
public override TextureAtlasData Process(TextureAtlasData input, ContentProcessorContext context)
|
||||||
{
|
{
|
||||||
Package package;
|
if (context.SourceIdentity.SourceFilename == input.textureName) throw new InvalidContentException("Texture atlas data and texture file for the atlas can't have the same name.");
|
||||||
package.textureBytes = input.textureBytes;
|
context.AddDependency(input.textureName);
|
||||||
package.textureAtlasDataBytes = Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(input.textureAtlasData));
|
return input;
|
||||||
return package;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal struct Package
|
|
||||||
{
|
|
||||||
public byte[] textureBytes;
|
|
||||||
public byte[] textureAtlasDataBytes;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,41 @@
|
|||||||
using Microsoft.Xna.Framework.Content.Pipeline;
|
using Microsoft.Xna.Framework.Content.Pipeline;
|
||||||
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
|
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using RecrownedAthenaeum.Data;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
||||||
{
|
{
|
||||||
[ContentTypeWriter]
|
[ContentTypeWriter]
|
||||||
class TextureAtlasWriter : ContentTypeWriter<TextureAtlasProcessor.Package>
|
class TextureAtlasWriter : ContentTypeWriter<TextureAtlasData>
|
||||||
{
|
{
|
||||||
public override string GetRuntimeReader(TargetPlatform targetPlatform)
|
public override string GetRuntimeReader(TargetPlatform targetPlatform)
|
||||||
{
|
{
|
||||||
return "RecrownedAthenaeum.ContentReaders.TextureAtlasDataReader, RecrownedAthenaeum";
|
return "RecrownedAthenaeum.ContentReaders.TextureAtlasDataReader, RecrownedAthenaeum";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Write(ContentWriter output, TextureAtlasProcessor.Package value)
|
protected override void Write(ContentWriter output, TextureAtlasData value)
|
||||||
{
|
{
|
||||||
output.Write(value.textureBytes.Length);
|
output.Write(Path.GetFileNameWithoutExtension(value.textureName));
|
||||||
output.Write(value.textureBytes);
|
output.Write(value.regions.Length);
|
||||||
output.Write(value.textureAtlasDataBytes.Length);
|
|
||||||
output.Write(value.textureAtlasDataBytes);
|
for (int i = 0; i < value.regions.Length; i++)
|
||||||
|
{
|
||||||
|
output.Write(value.regions[i].name);
|
||||||
|
output.Write(value.regions[i].bounds.X);
|
||||||
|
output.Write(value.regions[i].bounds.Y);
|
||||||
|
output.Write(value.regions[i].bounds.Width);
|
||||||
|
output.Write(value.regions[i].bounds.Height);
|
||||||
|
bool hasNPatch = value.regions[i].ninePatchData != null;
|
||||||
|
output.Write(hasNPatch);
|
||||||
|
if (hasNPatch)
|
||||||
|
{
|
||||||
|
output.Write(value.regions[i].ninePatchData.left);
|
||||||
|
output.Write(value.regions[i].ninePatchData.right);
|
||||||
|
output.Write(value.regions[i].ninePatchData.bottom);
|
||||||
|
output.Write(value.regions[i].ninePatchData.top);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,6 @@ namespace RecrownedAthenaeum.Tools.NinePatchTools
|
|||||||
{
|
{
|
||||||
public class NinePatchCommand : EngineCommand
|
public class NinePatchCommand : EngineCommand
|
||||||
{
|
{
|
||||||
private enum SupportedExtensions
|
|
||||||
{
|
|
||||||
jpeg, jpg, png
|
|
||||||
}
|
|
||||||
|
|
||||||
public NinePatchCommand() : base("9p", "ninepatch", "9patch")
|
public NinePatchCommand() : base("9p", "ninepatch", "9patch")
|
||||||
{
|
{
|
||||||
@ -34,6 +30,7 @@ namespace RecrownedAthenaeum.Tools.NinePatchTools
|
|||||||
string imagePath, outPath;
|
string imagePath, outPath;
|
||||||
if (IndexOfArgument("-i", arguments) + 1 >= arguments.Length) throw new ArgumentException("Missing -i path after argument.");
|
if (IndexOfArgument("-i", arguments) + 1 >= arguments.Length) throw new ArgumentException("Missing -i path after argument.");
|
||||||
imagePath = arguments[IndexOfArgument("-i", arguments) + 1];
|
imagePath = arguments[IndexOfArgument("-i", arguments) + 1];
|
||||||
|
if (!File.Exists(imagePath)) throw new ArgumentException("Input file does not exist at " + imagePath + ".");
|
||||||
|
|
||||||
if (HasArgument(commandArguments[1], arguments))
|
if (HasArgument(commandArguments[1], arguments))
|
||||||
{
|
{
|
||||||
@ -51,10 +48,7 @@ namespace RecrownedAthenaeum.Tools.NinePatchTools
|
|||||||
NinePatchData npData = new NinePatchData(Path.GetFileName(imagePath), leftBound, rightBound, bottomBound, topBound);
|
NinePatchData npData = new NinePatchData(Path.GetFileName(imagePath), leftBound, rightBound, bottomBound, topBound);
|
||||||
string serialized = JsonConvert.SerializeObject(npData, Formatting.Indented);
|
string serialized = JsonConvert.SerializeObject(npData, Formatting.Indented);
|
||||||
|
|
||||||
if (!File.Exists(imagePath)) throw new ArgumentException("Input file does not exist at " + imagePath + ".");
|
File.Move(imagePath, Path.GetFileNameWithoutExtension(imagePath) + "-texture" + Path.GetExtension(imagePath));
|
||||||
SupportedExtensions extension;
|
|
||||||
if (!Enum.TryParse<SupportedExtensions>(Path.GetExtension(imagePath).ToLower().Substring(1), out extension)) throw new ArgumentException("Input file extension \"" + Path.GetExtension(imagePath).ToLower().Substring(1) + "\" not supported.");
|
|
||||||
|
|
||||||
File.WriteAllText(outPath + ".9p", serialized);
|
File.WriteAllText(outPath + ".9p", serialized);
|
||||||
|
|
||||||
ConsoleUtilities.WriteWrappedLine("Done. Written to \"" + outPath + "\" with values: left = " + leftBound + " right = " + rightBound + " top = " + topBound + " bottom = " + bottomBound);
|
ConsoleUtilities.WriteWrappedLine("Done. Written to \"" + outPath + "\" with values: left = " + leftBound + " right = " + rightBound + " top = " + topBound + " bottom = " + bottomBound);
|
||||||
|
@ -133,6 +133,7 @@ namespace RecrownedAthenaeum.Tools.TextureAtlas
|
|||||||
ImageHandler ih = imageHandlers[i];
|
ImageHandler ih = imageHandlers[i];
|
||||||
regions[i].SetBounds(ih.x, ih.y, ih.Width, ih.Height);
|
regions[i].SetBounds(ih.x, ih.y, ih.Width, ih.Height);
|
||||||
regions[i].ninePatchData = ih.ninePatchData;
|
regions[i].ninePatchData = ih.ninePatchData;
|
||||||
|
regions[i].ninePatchData.textureName = null;
|
||||||
regions[i].name = Path.GetFileNameWithoutExtension(ih.Name);
|
regions[i].name = Path.GetFileNameWithoutExtension(ih.Name);
|
||||||
using (Image<Rgba32> image = Image.Load<Rgba32>(ih.path))
|
using (Image<Rgba32> image = Image.Load<Rgba32>(ih.path))
|
||||||
{
|
{
|
||||||
@ -140,12 +141,12 @@ namespace RecrownedAthenaeum.Tools.TextureAtlas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Directory.CreateDirectory(output);
|
Directory.CreateDirectory(output);
|
||||||
using (FileStream stream = new FileStream(output + "/" + atlasName + ".png", FileMode.Create))
|
using (FileStream stream = new FileStream(output + "/" + atlasName + "-texture" + ".png", FileMode.Create))
|
||||||
{
|
{
|
||||||
atlasTexture.SaveAsPng(stream);
|
atlasTexture.SaveAsPng(stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string serialized = JsonConvert.SerializeObject(new TextureAtlasData(atlasName + ".png", regions), Formatting.Indented);
|
string serialized = JsonConvert.SerializeObject(new TextureAtlasData(atlasName + "-texture" + ".png", regions), Formatting.Indented);
|
||||||
File.WriteAllText(output + "/" + atlasName + ".tatlas", serialized);
|
File.WriteAllText(output + "/" + atlasName + ".tatlas", serialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using RecrownedAthenaeum.Camera;
|
using RecrownedAthenaeum.Camera;
|
||||||
using RecrownedAthenaeum.Render;
|
using RecrownedAthenaeum.Render;
|
||||||
using RecrownedAthenaeum.ScreenSystem;
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace RecrownedAthenaeum
|
namespace RecrownedAthenaeum
|
||||||
@ -24,10 +23,10 @@ namespace RecrownedAthenaeum
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static Camera2D Camera2D { set { camera2D = value; } get { if (camera2D == null) throw new InvalidOperationException("2D camera property requested as substitute but configuration does not have one."); return camera2D; } }
|
public static Camera2D Camera2D { set { camera2D = value; } get { if (camera2D == null) throw new InvalidOperationException("2D camera property requested as substitute but configuration does not have one."); return camera2D; } }
|
||||||
|
|
||||||
private static SpriteBatchSettings? beginBatchFunction;
|
private static SpriteBatchSettings? spriteBatchSettings;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The begin sprite batch to use for custom begins and consistency.
|
/// The begin sprite batch to use for custom begins and consistency.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static SpriteBatchSettings? spriteBatchSettings { set { beginBatchFunction = value.Value; } get { if (!beginBatchFunction.HasValue) throw new InvalidOperationException("No default begin batch has been set yet has been requested."); return beginBatchFunction; } }
|
public static SpriteBatchSettings? SpriteBatchSettings { set { spriteBatchSettings = value.Value; } get { if (!spriteBatchSettings.HasValue) throw new InvalidOperationException("No default begin batch has been set yet has been requested."); return spriteBatchSettings; } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,15 @@
|
|||||||
using Microsoft.Xna.Framework.Content;
|
using Microsoft.Xna.Framework.Content;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using RecrownedAthenaeum.Data;
|
|
||||||
using RecrownedAthenaeum.SpecialTypes;
|
using RecrownedAthenaeum.SpecialTypes;
|
||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.ContentReaders
|
namespace RecrownedAthenaeum.ContentReaders
|
||||||
{
|
{
|
||||||
class NinePatchDataReader : ContentTypeReader<NinePatch>
|
class NinePatchDataReader : ContentTypeReader<NinePatch>
|
||||||
{
|
{
|
||||||
public static GraphicsDevice graphicsDevice;
|
|
||||||
|
|
||||||
protected override NinePatch Read(ContentReader input, NinePatch existingInstance)
|
protected override NinePatch Read(ContentReader input, NinePatch existingInstance)
|
||||||
{
|
{
|
||||||
if (graphicsDevice == null) graphicsDevice = Configuration.GraphicsDeviceManager.GraphicsDevice;
|
Texture2D texture = input.ContentManager.Load<Texture2D>(input.ReadString());
|
||||||
Texture2D texture;
|
NinePatch ninePatch = new NinePatch(texture, input.ReadInt32(), input.ReadInt32(), input.ReadInt32(), input.ReadInt32());
|
||||||
using (MemoryStream stream = new MemoryStream(input.ReadBytes(input.ReadInt32())))
|
|
||||||
{
|
|
||||||
texture = Texture2D.FromStream(graphicsDevice, stream);
|
|
||||||
}
|
|
||||||
NinePatchData ninePatchData = JsonConvert.DeserializeObject<NinePatchData>(Encoding.ASCII.GetString(input.ReadBytes(input.ReadInt32())));
|
|
||||||
NinePatch ninePatch = new NinePatch(texture, ninePatchData.left, ninePatchData.right, ninePatchData.bottom, ninePatchData.top);
|
|
||||||
return ninePatch;
|
return ninePatch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,34 +1,44 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Content;
|
using Microsoft.Xna.Framework.Content;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using RecrownedAthenaeum.Data;
|
using RecrownedAthenaeum.Data;
|
||||||
using RecrownedAthenaeum.SpecialTypes;
|
using RecrownedAthenaeum.SpecialTypes;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.ContentReaders
|
namespace RecrownedAthenaeum.ContentReaders
|
||||||
{
|
{
|
||||||
class TextureAtlasDataReader : ContentTypeReader<TextureAtlas>
|
class TextureAtlasDataReader : ContentTypeReader<TextureAtlas>
|
||||||
{
|
{
|
||||||
public static GraphicsDevice graphicsDevice;
|
|
||||||
|
|
||||||
protected override TextureAtlas Read(ContentReader input, TextureAtlas existingInstance)
|
protected override TextureAtlas Read(ContentReader input, TextureAtlas existingInstance)
|
||||||
{
|
{
|
||||||
if (graphicsDevice == null) graphicsDevice = Configuration.GraphicsDeviceManager.GraphicsDevice;
|
TextureAtlasData atlasData = ReadTextureAtlasData(input);
|
||||||
TextureAtlasData atlasData;
|
Texture2D atlasTexture = input.ContentManager.Load<Texture2D>(atlasData.textureName);
|
||||||
Texture2D atlasTexture;
|
|
||||||
using (MemoryStream stream = new MemoryStream(input.ReadBytes(input.ReadInt32())))
|
|
||||||
{
|
|
||||||
atlasTexture = Texture2D.FromStream(graphicsDevice, stream);
|
|
||||||
}
|
|
||||||
string serialized = Encoding.ASCII.GetString(input.ReadBytes(input.ReadInt32()));
|
|
||||||
atlasData = JsonConvert.DeserializeObject<TextureAtlasData>(serialized);
|
|
||||||
TextureAtlas atlas = new TextureAtlas(atlasTexture, GenerateAtlasRegionsFromData(atlasData, atlasTexture));
|
TextureAtlas atlas = new TextureAtlas(atlasTexture, GenerateAtlasRegionsFromData(atlasData, atlasTexture));
|
||||||
|
|
||||||
return atlas;
|
return atlas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TextureAtlasData ReadTextureAtlasData(BinaryReader reader)
|
||||||
|
{
|
||||||
|
string textureName = reader.ReadString();
|
||||||
|
TextureAtlasData.AtlasRegionData[] regions = new TextureAtlasData.AtlasRegionData[reader.ReadInt32()];
|
||||||
|
for (int i = 0; i < regions.Length; i++)
|
||||||
|
{
|
||||||
|
regions[i] = new TextureAtlasData.AtlasRegionData();
|
||||||
|
regions[i].name = reader.ReadString();
|
||||||
|
regions[i].bounds = new Rectangle(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32());
|
||||||
|
if (reader.ReadBoolean())
|
||||||
|
{
|
||||||
|
regions[i].ninePatchData = new NinePatchData(null, reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TextureAtlasData atlasData = new TextureAtlasData(textureName, regions);
|
||||||
|
|
||||||
|
return atlasData;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generates region given <see cref="TextureAtlasData"/>.
|
/// Generates region given <see cref="TextureAtlasData"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using Microsoft.Xna.Framework.Content;
|
using Microsoft.Xna.Framework.Content;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
|
||||||
using RecrownedAthenaeum.ContentSystem;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
@ -30,7 +30,7 @@ namespace RecrownedAthenaeum.Data
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Data object that contains information about the region ninepatch situation of a given region in an atlas.
|
/// Data object that contains information about the region ninepatch situation of a given region in an atlas.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class AtlasRegionData
|
public struct AtlasRegionData
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Name of the region for referencial purposes.
|
/// Name of the region for referencial purposes.
|
||||||
|
@ -51,9 +51,10 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Render\ScissorBox.cs" />
|
||||||
<Compile Include="Render\SpriteBatchSettings.cs" />
|
<Compile Include="Render\SpriteBatchSettings.cs" />
|
||||||
<Compile Include="View\Camera3D.cs" />
|
<Compile Include="Render\Camera3D.cs" />
|
||||||
<Compile Include="View\Camera2D.cs" />
|
<Compile Include="Render\Camera2D.cs" />
|
||||||
<Compile Include="ContentSystem\ContentData.cs" />
|
<Compile Include="ContentSystem\ContentData.cs" />
|
||||||
<Compile Include="ContentSystem\ContentManagerController.cs" />
|
<Compile Include="ContentSystem\ContentManagerController.cs" />
|
||||||
<Compile Include="ContentSystem\IContentPathResolver.cs" />
|
<Compile Include="ContentSystem\IContentPathResolver.cs" />
|
||||||
@ -99,5 +100,8 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="View\" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
@ -1,10 +1,5 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.Camera
|
namespace RecrownedAthenaeum.Camera
|
||||||
{
|
{
|
||||||
@ -14,7 +9,7 @@ namespace RecrownedAthenaeum.Camera
|
|||||||
public class Camera3D
|
public class Camera3D
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The zoom of the camera.
|
/// The scale for the world.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float worldScale = 1f;
|
public float worldScale = 1f;
|
||||||
|
|
@ -2,7 +2,6 @@
|
|||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using RecrownedAthenaeum.Camera;
|
using RecrownedAthenaeum.Camera;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.Render
|
namespace RecrownedAthenaeum.Render
|
||||||
{
|
{
|
||||||
|
41
RecrownedAthenaeum/Render/ScissorBox.cs
Normal file
41
RecrownedAthenaeum/Render/ScissorBox.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
|
||||||
|
namespace RecrownedAthenaeum.Render
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Box that crops off anything outside of the bounds.
|
||||||
|
/// </summary>
|
||||||
|
public class ScissorBox
|
||||||
|
{
|
||||||
|
|
||||||
|
SpriteBatch spriteBatch;
|
||||||
|
Rectangle currentScissorRect;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Starts spritebatch with scissoring enabled.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rectangle"></param>
|
||||||
|
/// <param name="spriteBatch"></param>
|
||||||
|
/// <param name="spriteBatchSettings">The settings for using the <see cref="SpriteBatch"/> to perform the scissor.</param>
|
||||||
|
public void Begin(Rectangle rectangle, SpriteBatch spriteBatch, SpriteBatchSettings? spriteBatchSettings = null)
|
||||||
|
{
|
||||||
|
if (spriteBatchSettings == null) spriteBatchSettings = Configuration.SpriteBatchSettings;
|
||||||
|
|
||||||
|
this.spriteBatch = spriteBatch;
|
||||||
|
spriteBatchSettings.Value.rasterizerState.ScissorTestEnable = true;
|
||||||
|
spriteBatchSettings.Value.BeginSpriteBatch(spriteBatch);
|
||||||
|
currentScissorRect = spriteBatch.GraphicsDevice.ScissorRectangle;
|
||||||
|
spriteBatch.GraphicsDevice.ScissorRectangle = rectangle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ends the scissoring and spritebatch.
|
||||||
|
/// </summary>
|
||||||
|
public void End()
|
||||||
|
{
|
||||||
|
spriteBatch.GraphicsDevice.ScissorRectangle = currentScissorRect;
|
||||||
|
spriteBatch.End();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,5 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.Render
|
namespace RecrownedAthenaeum.Render
|
||||||
{
|
{
|
||||||
@ -46,8 +41,28 @@ namespace RecrownedAthenaeum.Render
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The transformation matrix to use.
|
/// The transformation matrix to use.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Matrix transformMatrix;
|
public Matrix? transformMatrix;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// See <see cref="SpriteBatch.Begin(SpriteSortMode, BlendState, SamplerState, DepthStencilState, RasterizerState, Effect, Matrix?)"/> for uses and defaults.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="spriteSortMode"></param>
|
||||||
|
/// <param name="blendState"></param>
|
||||||
|
/// <param name="samplerState"></param>
|
||||||
|
/// <param name="depthStencilState"></param>
|
||||||
|
/// <param name="rasterizerState"></param>
|
||||||
|
/// <param name="effect"></param>
|
||||||
|
/// <param name="transformMatrix"></param>
|
||||||
|
public SpriteBatchSettings(SpriteSortMode spriteSortMode = SpriteSortMode.Deferred, BlendState blendState = null, SamplerState samplerState = null, DepthStencilState depthStencilState = null, RasterizerState rasterizerState = null, Effect effect = null, Matrix? transformMatrix = null)
|
||||||
|
{
|
||||||
|
this.spriteSortMode = spriteSortMode;
|
||||||
|
this.blendState = blendState;
|
||||||
|
this.samplerState = samplerState;
|
||||||
|
this.depthStencilState = depthStencilState;
|
||||||
|
this.rasterizerState = rasterizerState;
|
||||||
|
this.effect = effect;
|
||||||
|
this.transformMatrix = transformMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Begins the given sprite batch with the current set of settings.
|
/// Begins the given sprite batch with the current set of settings.
|
||||||
|
@ -81,7 +81,6 @@ namespace RecrownedAthenaeum.ScreenSystem
|
|||||||
{
|
{
|
||||||
SpriteBatchSettings basicSettings = new SpriteBatchSettings();
|
SpriteBatchSettings basicSettings = new SpriteBatchSettings();
|
||||||
basicSettings.effect = camera.BasicEffect;
|
basicSettings.effect = camera.BasicEffect;
|
||||||
basicSettings.blendState = BlendState.Additive;
|
|
||||||
basicSettings.samplerState = null;
|
basicSettings.samplerState = null;
|
||||||
spriteBatchSettings = basicSettings;
|
spriteBatchSettings = basicSettings;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ namespace RecrownedAthenaeum.SpecialTypes
|
|||||||
/// <param name="spriteBatchSettings">The sprite batch settings to use to begin the batch in after drawing the ninepatch.</param>
|
/// <param name="spriteBatchSettings">The sprite batch settings to use to begin the batch in after drawing the ninepatch.</param>
|
||||||
public void Draw(SpriteBatch spriteBatch, Color color, Rectangle destination, SpriteBatchSettings? spriteBatchSettings = null)
|
public void Draw(SpriteBatch spriteBatch, Color color, Rectangle destination, SpriteBatchSettings? spriteBatchSettings = null)
|
||||||
{
|
{
|
||||||
if (spriteBatchSettings == null) spriteBatchSettings = Configuration.spriteBatchSettings;
|
if (spriteBatchSettings == null) spriteBatchSettings = Configuration.SpriteBatchSettings;
|
||||||
spriteBatch.End();
|
spriteBatch.End();
|
||||||
|
|
||||||
SpriteBatchSettings ss = spriteBatchSettings.Value;
|
SpriteBatchSettings ss = spriteBatchSettings.Value;
|
||||||
|
@ -95,8 +95,6 @@ namespace RecrownedAthenaeum.UI.BookSystem
|
|||||||
{
|
{
|
||||||
foreach (Page page in pages)
|
foreach (Page page in pages)
|
||||||
{
|
{
|
||||||
page.camera = camera;
|
|
||||||
page.Initialize(assets, skin);
|
|
||||||
orderedPages.Add(page);
|
orderedPages.Add(page);
|
||||||
this.pages.Add(page.name, page);
|
this.pages.Add(page.name, page);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ using Microsoft.Xna.Framework.Graphics;
|
|||||||
using RecrownedAthenaeum.SpecialTypes;
|
using RecrownedAthenaeum.SpecialTypes;
|
||||||
using RecrownedAthenaeum.UI.SkinSystem;
|
using RecrownedAthenaeum.UI.SkinSystem;
|
||||||
using RecrownedAthenaeum.UI.SkinSystem.Definitions;
|
using RecrownedAthenaeum.UI.SkinSystem.Definitions;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
|
namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using RecrownedAthenaeum.UI.SkinSystem;
|
|
||||||
using RecrownedAthenaeum.UI.SkinSystem.Definitions;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
using RecrownedAthenaeum.Input;
|
using RecrownedAthenaeum.Input;
|
||||||
using RecrownedAthenaeum.Render;
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.UI.Modular
|
namespace RecrownedAthenaeum.UI.Modular
|
||||||
|
@ -3,9 +3,7 @@ using System.Collections.Generic;
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
using RecrownedAthenaeum.Camera;
|
|
||||||
using RecrownedAthenaeum.Render;
|
using RecrownedAthenaeum.Render;
|
||||||
using RecrownedAthenaeum.ScreenSystem;
|
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.UI.Modular
|
namespace RecrownedAthenaeum.UI.Modular
|
||||||
{
|
{
|
||||||
@ -16,32 +14,23 @@ namespace RecrownedAthenaeum.UI.Modular
|
|||||||
public class UIModuleGroup : UIModule
|
public class UIModuleGroup : UIModule
|
||||||
{
|
{
|
||||||
List<UIModule> modules = new List<UIModule>();
|
List<UIModule> modules = new List<UIModule>();
|
||||||
Rectangle scissorBounds;
|
ScissorBox scissorBox;
|
||||||
RasterizerState scissorRasterizer;
|
|
||||||
SpriteBatchSettings spriteBatchSettings;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Camera used by the module for cropping.
|
/// Configuration for starting sprite batch after scissoring. Only used if cropping.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Camera2D camera;
|
public SpriteBatchSettings spriteBatchSettings;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a module group.
|
/// Creates a module group.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="crop">Whether or not to crop out of bounds. Default is false.</param>
|
/// <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>
|
public UIModuleGroup(bool crop = false)
|
||||||
/// <param name="spriteBatchSettings">The settings to be used that begins the batch.</param>
|
|
||||||
public UIModuleGroup(bool crop = false, Camera2D camera = null, SpriteBatchSettings? spriteBatchSettings = null)
|
|
||||||
{
|
{
|
||||||
if (spriteBatchSettings == null) spriteBatchSettings = Configuration.spriteBatchSettings;
|
this.spriteBatchSettings = Configuration.SpriteBatchSettings.Value;
|
||||||
if (crop && camera == null) camera = Configuration.Camera2D;
|
|
||||||
this.spriteBatchSettings = spriteBatchSettings.Value;
|
|
||||||
this.camera = camera;
|
|
||||||
if (crop)
|
if (crop)
|
||||||
{
|
{
|
||||||
scissorRasterizer = new RasterizerState();
|
scissorBox = new ScissorBox();
|
||||||
scissorRasterizer.ScissorTestEnable = true;
|
|
||||||
scissorBounds = new Rectangle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,17 +40,10 @@ namespace RecrownedAthenaeum.UI.Modular
|
|||||||
/// <param name="batch">Batch used to draw the group.</param>
|
/// <param name="batch">Batch used to draw the group.</param>
|
||||||
public override void Draw(SpriteBatch batch)
|
public override void Draw(SpriteBatch batch)
|
||||||
{
|
{
|
||||||
if (scissorBounds != null)
|
if (scissorBox != null)
|
||||||
{
|
{
|
||||||
batch.End();
|
batch.End();
|
||||||
spriteBatchSettings.BeginSpriteBatch(batch);
|
scissorBox.Begin(Boundaries, batch, spriteBatchSettings);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (UIModule module in modules)
|
foreach (UIModule module in modules)
|
||||||
@ -75,11 +57,10 @@ namespace RecrownedAthenaeum.UI.Modular
|
|||||||
module.situation.Y = offsetY;
|
module.situation.Y = offsetY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scissorBounds != null)
|
if (scissorBox != null)
|
||||||
{
|
{
|
||||||
batch.GraphicsDevice.ScissorRectangle = scissorBounds;
|
scissorBox.End();
|
||||||
batch.End();
|
|
||||||
spriteBatchSettings.BeginSpriteBatch(batch);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using RecrownedAthenaeum.UI.Modular.Modules.Interactive;
|
using RecrownedAthenaeum.UI.Modular.Modules.Interactive;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.UI.SkinSystem.Definitions
|
namespace RecrownedAthenaeum.UI.SkinSystem.Definitions
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using RecrownedAthenaeum.UI.Modular.Modules.Interactive;
|
using RecrownedAthenaeum.UI.Modular.Modules.Interactive;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.UI.SkinSystem.Definitions
|
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 Microsoft.Xna.Framework.Graphics;
|
||||||
using RecrownedAthenaeum.SpecialTypes;
|
using RecrownedAthenaeum.SpecialTypes;
|
||||||
using RecrownedAthenaeum.UI.SkinSystem.Definitions;
|
using RecrownedAthenaeum.UI.SkinSystem.Definitions;
|
||||||
|
@ -156,23 +156,28 @@ namespace RecrownedAthenaeum.UI.SkinSystem
|
|||||||
{
|
{
|
||||||
TextureAtlasDataReader textureAtlasDataReader = new TextureAtlasDataReader();
|
TextureAtlasDataReader textureAtlasDataReader = new TextureAtlasDataReader();
|
||||||
FileInfo[] skinFiles = Directory.GetParent(path).GetFiles();
|
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++)
|
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;
|
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);
|
atlasTexture = Texture2D.FromStream(graphicsDevice, stream);
|
||||||
}
|
}
|
||||||
TextureAtlas.Region[] regions = textureAtlasDataReader.GenerateAtlasRegionsFromData(atlasData, atlasTexture);
|
TextureAtlas.Region[] regions = textureAtlasDataReader.GenerateAtlasRegionsFromData(atlasData, atlasTexture);
|
||||||
TextureAtlas textureAtlas = new TextureAtlas(atlasTexture, regions);
|
TextureAtlas textureAtlas = new TextureAtlas(atlasTexture, regions);
|
||||||
Texture2D cursorTexture;
|
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);
|
cursorTexture = Texture2D.FromStream(graphicsDevice, stream);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user