Updated Tools accordingly to new pipeline structure.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using RecrownedGTK.Data;
|
||||
using RecrownedGTK.Pipeline.Information;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using SixLabors.ImageSharp.Processing;
|
||||
@@ -23,7 +23,7 @@ namespace RecrownedGTK.Tools.TextureAtlas
|
||||
int powLimit;
|
||||
Node masterNode;
|
||||
List<ImageHandler> imageHandlers;
|
||||
Dictionary<string, NinePatchData> ninePatchDictionary;
|
||||
Dictionary<string, NinePatchInfo> ninePatchDictionary;
|
||||
int tpl;
|
||||
int TexturePowerLength { get { return tpl; } set { TextureLength = (int)Math.Pow(2, value); tpl = value; } }
|
||||
public int TextureLength { get; private set; }
|
||||
@@ -65,11 +65,11 @@ namespace RecrownedGTK.Tools.TextureAtlas
|
||||
}
|
||||
else if (Path.GetExtension(paths[pathID]).ToLower() == ".9p")
|
||||
{
|
||||
if (ninePatchDictionary == null) ninePatchDictionary = new Dictionary<string, NinePatchData>();
|
||||
if (ninePatchDictionary == null) ninePatchDictionary = new Dictionary<string, NinePatchInfo>();
|
||||
ConsoleUtilities.WriteWrappedLine("Reading ninepatch data for: " + paths[pathID]);
|
||||
string serialized = File.ReadAllText(paths[pathID]);
|
||||
NinePatchData npData = JsonConvert.DeserializeObject<NinePatchData>(serialized);
|
||||
ninePatchDictionary.Add(npData.textureName, npData);
|
||||
NinePatchInfo npData = JsonConvert.DeserializeObject<NinePatchInfo>(serialized);
|
||||
ninePatchDictionary.Add(npData.name, npData);
|
||||
}
|
||||
}
|
||||
imageHandlers.Sort();
|
||||
@@ -103,9 +103,9 @@ namespace RecrownedGTK.Tools.TextureAtlas
|
||||
}
|
||||
if (ninePatchDictionary != null && ninePatchDictionary.ContainsKey(imageHandler.name))
|
||||
{
|
||||
NinePatchData npd = ninePatchDictionary[imageHandler.name];
|
||||
NinePatchInfo npd = ninePatchDictionary[imageHandler.name];
|
||||
imageHandler.ninePatchData = npd;
|
||||
if (npd.textureName.Contains("-texture"))
|
||||
if (npd.name.Contains("-texture"))
|
||||
{
|
||||
imageHandler.name = imageHandler.name.Remove(imageHandler.name.IndexOf("-texture"), 8);
|
||||
}
|
||||
@@ -123,7 +123,7 @@ namespace RecrownedGTK.Tools.TextureAtlas
|
||||
{
|
||||
GraphicsOptions gOptions = new GraphicsOptions();
|
||||
|
||||
TextureAtlasData.AtlasRegionData[] regions = new TextureAtlasData.AtlasRegionData[TexturesFound];
|
||||
TextureMapInfo.MapRegionInfo[] regions = new TextureMapInfo.MapRegionInfo[TexturesFound];
|
||||
|
||||
using (Image<Rgba32> atlasTexture = new Image<Rgba32>(TextureLength, TextureLength))
|
||||
{
|
||||
@@ -131,11 +131,11 @@ namespace RecrownedGTK.Tools.TextureAtlas
|
||||
|
||||
for (int i = 0; i < imageHandlers.Length; i++)
|
||||
{
|
||||
regions[i] = new TextureAtlasData.AtlasRegionData();
|
||||
ImageHandler ih = imageHandlers[i];
|
||||
regions[i] = new TextureMapInfo.MapRegionInfo();
|
||||
regions[i].SetBounds(ih.x, ih.y, ih.Width, ih.Height);
|
||||
regions[i].ninePatchData = ih.ninePatchData;
|
||||
if (regions[i].ninePatchData != null) regions[i].ninePatchData.textureName = null;
|
||||
regions[i].ninePatchInfo = ih.ninePatchData;
|
||||
if (!regions[i].ninePatchInfo.Equals(default(NinePatchInfo))) regions[i].ninePatchInfo.name = null;
|
||||
regions[i].name = Path.GetFileNameWithoutExtension(ih.name);
|
||||
using (Image<Rgba32> image = Image.Load<Rgba32>(ih.path))
|
||||
{
|
||||
@@ -148,20 +148,20 @@ namespace RecrownedGTK.Tools.TextureAtlas
|
||||
atlasTexture.SaveAsPng(stream);
|
||||
}
|
||||
}
|
||||
string serialized = JsonConvert.SerializeObject(new TextureAtlasData(atlasName + "-texture" + ".png", regions), Formatting.Indented);
|
||||
string serialized = JsonConvert.SerializeObject(new TextureMapInfo(atlasName + "-texture" + ".png", regions), Formatting.Indented);
|
||||
File.WriteAllText(output + "/" + atlasName + ".tatlas", serialized);
|
||||
}
|
||||
|
||||
public void SetNinePatch(string fileName, int a, int b, int c, int d)
|
||||
{
|
||||
NinePatchData ninePatchData = new NinePatchData(fileName, a, b, c, d);
|
||||
NinePatchInfo ninePatchData = new NinePatchInfo(fileName, a, b, c, d);
|
||||
RetrieveImageHandler(fileName).ninePatchData = ninePatchData;
|
||||
}
|
||||
|
||||
public void RemoveNinePatch(string name)
|
||||
{
|
||||
|
||||
RetrieveImageHandler(name).ninePatchData = null;
|
||||
RetrieveImageHandler(name).ninePatchData = default(NinePatchInfo);
|
||||
}
|
||||
|
||||
private ImageHandler RetrieveImageHandler(string name)
|
||||
@@ -265,7 +265,7 @@ namespace RecrownedGTK.Tools.TextureAtlas
|
||||
public int Width { get { return image.Width; } }
|
||||
public int Height { get { return image.Height; } }
|
||||
public int x, y;
|
||||
public NinePatchData ninePatchData;
|
||||
public NinePatchInfo ninePatchData;
|
||||
|
||||
internal ImageHandler(string path)
|
||||
{
|
||||
|
Reference in New Issue
Block a user