diff --git a/src/BizHawk.Bizware.BizwareGL/ArtManager.cs b/src/BizHawk.Bizware.BizwareGL/ArtManager.cs index 79c19ad85b..a247a38955 100644 --- a/src/BizHawk.Bizware.BizwareGL/ArtManager.cs +++ b/src/BizHawk.Bizware.BizwareGL/ArtManager.cs @@ -83,16 +83,16 @@ namespace BizHawk.Bizware.BizwareGL var results = TexAtlas.PackAtlas(atlasItems); // this isn't supported yet: - if (results.Atlases.Count > 1) + if (results.Count > 1) throw new InvalidOperationException("Art files too big for atlas"); // prepare the output buffer - BitmapBuffer bmpResult = new BitmapBuffer(results.Atlases[0].Size); + BitmapBuffer bmpResult = new BitmapBuffer(results[0].Size); //for each item, copy it into the output buffer and set the tex parameters on them for (int i = 0; i < atlasItems.Count; i++) { - var item = results.Atlases[0].Items[i]; + var item = results[0].Items[i]; var artAndBitmap = (KeyValuePair)item.Item; var art = artAndBitmap.Key; var bitmap = artAndBitmap.Value; diff --git a/src/BizHawk.Bizware.BizwareGL/TexAtlas.cs b/src/BizHawk.Bizware.BizwareGL/TexAtlas.cs index 55f53b2c10..52741a0ed2 100644 --- a/src/BizHawk.Bizware.BizwareGL/TexAtlas.cs +++ b/src/BizHawk.Bizware.BizwareGL/TexAtlas.cs @@ -31,25 +31,14 @@ namespace BizHawk.Bizware.BizwareGL public readonly List nodes = new List(); } - public class PackedAtlasResults - { - public class SingleAtlas - { - public Size Size; - public List Items; - } - public List Atlases = new List(); - } - public static int MaxSizeBits = 16; /// /// packs the supplied RectItems into an atlas. Modifies the RectItems with x/y values of location in new atlas. /// - public static PackedAtlasResults PackAtlas(IEnumerable items) + public static IReadOnlyList<(Size Size, List Items)> PackAtlas(IReadOnlyCollection items) { - var ret = new PackedAtlasResults(); - ret.Atlases.Add(new PackedAtlasResults.SingleAtlas()); + List<(Size Size, List Items)> atlases = new(); // initially, we'll try all the items; none remain var currentItems = new List(items); @@ -132,17 +121,14 @@ namespace BizHawk.Bizware.BizwareGL } //we found a fit. setup this atlas in the result and drop the items into it - var atlas = ret.Atlases[ret.Atlases.Count - 1]; - atlas.Size.Width = tfpFinal.w; - atlas.Size.Height = tfpFinal.h; - atlas.Items = new List(currentItems); + atlases.Add((new Size(tfpFinal.w, tfpFinal.h), new List(currentItems))); foreach (var item in currentItems) { object o = item.Item; var node = tfpFinal.nodes.Find((x) => x.ri == item); item.X = node.x; item.Y = node.y; - item.TexIndex = ret.Atlases.Count - 1; + item.TexIndex = atlases.Count - 1; } //if we have any items left, we've got to run this again @@ -153,14 +139,11 @@ namespace BizHawk.Bizware.BizwareGL currentItems.AddRange(remainItems); remainItems.Clear(); - ret.Atlases.Add(new PackedAtlasResults.SingleAtlas()); goto RETRY; } - if (ret.Atlases.Count > 1) - Console.WriteLine("Created animset with >1 texture ({0} textures)", ret.Atlases.Count); - - return ret; + if (atlases.Count > 1) Console.WriteLine($"Created animset with >1 texture ({atlases.Count} textures)"); + return atlases; } // original file: RectangleBinPack.cpp