From 072c3d511be1100ad5d11ea7b5fdff3f18ff8273 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Tue, 21 May 2019 12:10:57 -0700 Subject: [PATCH] Fully fixed the TextureManager scan this time. Issue was with the texture2DConverter.cs file. --- .../Objects/Furniture/FurnitureFactory.cs | 28 ++-- .../Framework/Graphics/Texture2DExtended.cs | 24 +++- .../Framework/Graphics/TextureManager.cs | 136 +++++++++++++++++- .../Converters/Texture2DConverter.cs | 4 +- GeneralMods/Revitalize/ModCore.cs | 28 ++-- 5 files changed, 186 insertions(+), 34 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/FurnitureFactory.cs b/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/FurnitureFactory.cs index de4410b8..aa7bc8a7 100644 --- a/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/FurnitureFactory.cs +++ b/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/FurnitureFactory.cs @@ -48,13 +48,13 @@ namespace Revitalize.Framework.Factories.Objects private static void SerializeLamps() { - LampTileComponent lampTop = new LampTileComponent(new BasicItemInformation("Oak Lamp", "A basic wooden light", "Lamps", Color.Brown, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Lamps.OakLamp", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Lamp").texture, Color.White, 0, true, typeof(Framework.Objects.Furniture.LampTileComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Lamp"), new Animation(new Rectangle(0, 0, 16, 16))), Color.White, true, new Framework.Utilities.InventoryManager(), new LightManager())); - LampTileComponent lampMiddle = new LampTileComponent(new BasicItemInformation("Oak Lamp", "A basic wooden light", "Lamps", Color.Brown, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Lamps.OakLamp", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Lamp").texture, Color.White, 0, true, typeof(Framework.Objects.Furniture.LampTileComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Lamp"), new Animation(new Rectangle(0, 16, 16, 16))), Color.White, false, new Framework.Utilities.InventoryManager(), new LightManager())); - LampTileComponent lampBottom = new LampTileComponent(new BasicItemInformation("Oak Lamp", "A basic wooden light", "Lamps", Color.Brown, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Lamps.OakLamp", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Lamp").texture, Color.White, 0, true, typeof(Framework.Objects.Furniture.LampTileComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Lamp"), new Animation(new Rectangle(0, 32, 16, 16))), Color.White, false, new Framework.Utilities.InventoryManager(), new LightManager())); + LampTileComponent lampTop = new LampTileComponent(new BasicItemInformation("Oak Lamp", "A basic wooden light", "Lamps", Color.Brown, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Lamps.OakLamp", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Lamp").texture, Color.White, 0, true, typeof(Framework.Objects.Furniture.LampTileComponent), null, new AnimationManager(TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Lamp"), new Animation(new Rectangle(0, 0, 16, 16))), Color.White, true, new Framework.Utilities.InventoryManager(), new LightManager())); + LampTileComponent lampMiddle = new LampTileComponent(new BasicItemInformation("Oak Lamp", "A basic wooden light", "Lamps", Color.Brown, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Lamps.OakLamp", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Lamp").texture, Color.White, 0, true, typeof(Framework.Objects.Furniture.LampTileComponent), null, new AnimationManager(TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Lamp"), new Animation(new Rectangle(0, 16, 16, 16))), Color.White, false, new Framework.Utilities.InventoryManager(), new LightManager())); + LampTileComponent lampBottom = new LampTileComponent(new BasicItemInformation("Oak Lamp", "A basic wooden light", "Lamps", Color.Brown, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Lamps.OakLamp", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Lamp").texture, Color.White, 0, true, typeof(Framework.Objects.Furniture.LampTileComponent), null, new AnimationManager(TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Lamp"), new Animation(new Rectangle(0, 32, 16, 16))), Color.White, false, new Framework.Utilities.InventoryManager(), new LightManager())); lampMiddle.lights.addLight(new Vector2(Game1.tileSize), new LightSource(4, new Vector2(0, 0), 2.5f, Color.Orange.Invert()), lampMiddle); - LampMultiTiledObject lamp = new LampMultiTiledObject(new BasicItemInformation("Oak Lamp", "A basic wooden light", "Lamps", Color.Brown, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Lamps.OakLamp", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Lamp").texture, Color.White, 0, true, typeof(Framework.Objects.Furniture.LampTileComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Lamp"), new Animation(new Rectangle(0, 0, 16, 16))), Color.White, true, new Framework.Utilities.InventoryManager(), new LightManager())); + LampMultiTiledObject lamp = new LampMultiTiledObject(new BasicItemInformation("Oak Lamp", "A basic wooden light", "Lamps", Color.Brown, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Lamps.OakLamp", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Lamp").texture, Color.White, 0, true, typeof(Framework.Objects.Furniture.LampTileComponent), null, new AnimationManager(TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Lamp"), new Animation(new Rectangle(0, 0, 16, 16))), Color.White, true, new Framework.Utilities.InventoryManager(), new LightManager())); lamp.addComponent(new Vector2(0, -2), lampTop); lamp.addComponent(new Vector2(0, -1), lampMiddle); lamp.addComponent(new Vector2(0, 0), lampBottom); @@ -128,7 +128,7 @@ namespace Revitalize.Framework.Factories.Objects private static void SerializeChairs() { - Framework.Objects.Furniture.ChairTileComponent chairTop = new Framework.Objects.Furniture.ChairTileComponent(new BasicItemInformation("Oak Chair", "A basic wooden chair", "Chairs", Color.Brown, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Chairs.OakChair", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(Framework.Objects.Furniture.ChairTileComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 0, 16, 16)), new Dictionary>() { + Framework.Objects.Furniture.ChairTileComponent chairTop = new Framework.Objects.Furniture.ChairTileComponent(new BasicItemInformation("Oak Chair", "A basic wooden chair", "Chairs", Color.Brown, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Chairs.OakChair", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(Framework.Objects.Furniture.ChairTileComponent), null, new AnimationManager(TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 0, 16, 16)), new Dictionary>() { { "Default_" + (int)Framework.Enums.Direction.Down , new List() { new Animation(new Rectangle(0,0,16,16)) @@ -170,7 +170,7 @@ namespace Revitalize.Framework.Factories.Objects } } }, "Default_" + (int)Framework.Enums.Direction.Down), Color.White, true, new Framework.Utilities.InventoryManager(), new LightManager()), new Framework.Objects.InformationFiles.Furniture.ChairInformation(false)); - Framework.Objects.Furniture.ChairTileComponent chairBottom = new Framework.Objects.Furniture.ChairTileComponent(new BasicItemInformation("Oak Chair", "A basic wooden chair", "Chairs", Color.Brown, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Chairs.OakChair", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Framework.Graphics.TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(Framework.Objects.Furniture.ChairTileComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 16, 16, 16)), new Dictionary>() { + Framework.Objects.Furniture.ChairTileComponent chairBottom = new Framework.Objects.Furniture.ChairTileComponent(new BasicItemInformation("Oak Chair", "A basic wooden chair", "Chairs", Color.Brown, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Chairs.OakChair", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Framework.Graphics.TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(Framework.Objects.Furniture.ChairTileComponent), null, new AnimationManager(TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 16, 16, 16)), new Dictionary>() { { "Default_" + (int)Framework.Enums.Direction.Down , new List() { new Animation(new Rectangle(0,16,16,16)) @@ -212,7 +212,7 @@ namespace Revitalize.Framework.Factories.Objects } } }, "Default_" + (int)Framework.Enums.Direction.Down), Color.White, false, new Framework.Utilities.InventoryManager(), new LightManager()), new Framework.Objects.InformationFiles.Furniture.ChairInformation(true)); - Framework.Objects.Furniture.ChairMultiTiledObject oakChair = new Framework.Objects.Furniture.ChairMultiTiledObject(new BasicItemInformation("Oak Chair", "A wood chair you can place anywhere.", "Chair", Color.White, -300, 0, true, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Chairs.OakChair", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(Revitalize.Framework.Objects.Furniture.ChairMultiTiledObject), null, new AnimationManager(), Color.White, false, new Framework.Utilities.InventoryManager(), new LightManager())); + Framework.Objects.Furniture.ChairMultiTiledObject oakChair = new Framework.Objects.Furniture.ChairMultiTiledObject(new BasicItemInformation("Oak Chair", "A wood chair you can place anywhere.", "Chair", Color.White, -300, 0, true, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Chairs.OakChair", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(Revitalize.Framework.Objects.Furniture.ChairMultiTiledObject), null, new AnimationManager(), Color.White, false, new Framework.Utilities.InventoryManager(), new LightManager())); ChairFactoryInfo top = new ChairFactoryInfo(chairTop); ChairFactoryInfo bottom = new ChairFactoryInfo(chairBottom); @@ -261,14 +261,14 @@ namespace Revitalize.Framework.Factories.Objects private static void SerializeTableFiles() { - TableTileComponent upperLeft = new TableTileComponent(new BasicItemInformation("Oak Table", "A simple oak table to hold things.", "Tables", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Tables.OakTable", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Table").texture, Color.White, 0, true, typeof(TableTileComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Table"), new Animation(new Rectangle(0, 0, 16, 16), -1)), Color.White, true, new Utilities.InventoryManager(), new LightManager()), new Framework.Objects.InformationFiles.Furniture.TableInformation(true)); - TableTileComponent upperRight = new TableTileComponent(new BasicItemInformation("Oak Table", "A simple oak table to hold things.", "Tables", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Tables.OakTable", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Table").texture, Color.White, 0, true, typeof(TableTileComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Table"), new Animation(new Rectangle(16, 0, 16, 16), -1)), Color.White, true, new Utilities.InventoryManager(), new LightManager()), new Framework.Objects.InformationFiles.Furniture.TableInformation(true)); - TableTileComponent centerLeft = new TableTileComponent(new BasicItemInformation("Oak Table", "A simple oak table to hold things.", "Tables", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Tables.OakTable", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Table").texture, Color.White, 0, true, typeof(TableTileComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Table"), new Animation(new Rectangle(0, 16, 16, 16), -1)), Color.White, false, new Utilities.InventoryManager(), new LightManager()), new Framework.Objects.InformationFiles.Furniture.TableInformation(true)); - TableTileComponent centerRight = new TableTileComponent(new BasicItemInformation("Oak Table", "A simple oak table to hold things.", "Tables", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Tables.OakTable", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Table").texture, Color.White, 0, true, typeof(TableTileComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Table"), new Animation(new Rectangle(16, 16, 16, 16), -1)), Color.White, false, new Utilities.InventoryManager(), new LightManager()), new Framework.Objects.InformationFiles.Furniture.TableInformation(true)); - TableTileComponent bottomLeft = new TableTileComponent(new BasicItemInformation("Oak Table", "A simple oak table to hold things.", "Tables", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Tables.OakTable", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Table").texture, Color.White, 0, true, typeof(TableTileComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Table"), new Animation(new Rectangle(0, 32, 16, 16), -1)), Color.White, false, new Utilities.InventoryManager(), new LightManager()), new Framework.Objects.InformationFiles.Furniture.TableInformation(true)); - TableTileComponent bottomRight = new TableTileComponent(new BasicItemInformation("Oak Table", "A simple oak table to hold things.", "Tables", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Tables.OakTable", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Table").texture, Color.White, 0, true, typeof(TableTileComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Table"), new Animation(new Rectangle(16, 32, 16, 16), -1)), Color.White, false, new Utilities.InventoryManager(), new LightManager()), new Framework.Objects.InformationFiles.Furniture.TableInformation(true)); + TableTileComponent upperLeft = new TableTileComponent(new BasicItemInformation("Oak Table", "A simple oak table to hold things.", "Tables", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Tables.OakTable", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Table").texture, Color.White, 0, true, typeof(TableTileComponent), null, new AnimationManager(TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Table"), new Animation(new Rectangle(0, 0, 16, 16), -1)), Color.White, true, new Utilities.InventoryManager(), new LightManager()), new Framework.Objects.InformationFiles.Furniture.TableInformation(true)); + TableTileComponent upperRight = new TableTileComponent(new BasicItemInformation("Oak Table", "A simple oak table to hold things.", "Tables", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Tables.OakTable", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Table").texture, Color.White, 0, true, typeof(TableTileComponent), null, new AnimationManager(TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Table"), new Animation(new Rectangle(16, 0, 16, 16), -1)), Color.White, true, new Utilities.InventoryManager(), new LightManager()), new Framework.Objects.InformationFiles.Furniture.TableInformation(true)); + TableTileComponent centerLeft = new TableTileComponent(new BasicItemInformation("Oak Table", "A simple oak table to hold things.", "Tables", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Tables.OakTable", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Table").texture, Color.White, 0, true, typeof(TableTileComponent), null, new AnimationManager(TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Table"), new Animation(new Rectangle(0, 16, 16, 16), -1)), Color.White, false, new Utilities.InventoryManager(), new LightManager()), new Framework.Objects.InformationFiles.Furniture.TableInformation(true)); + TableTileComponent centerRight = new TableTileComponent(new BasicItemInformation("Oak Table", "A simple oak table to hold things.", "Tables", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Tables.OakTable", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Table").texture, Color.White, 0, true, typeof(TableTileComponent), null, new AnimationManager(TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Table"), new Animation(new Rectangle(16, 16, 16, 16), -1)), Color.White, false, new Utilities.InventoryManager(), new LightManager()), new Framework.Objects.InformationFiles.Furniture.TableInformation(true)); + TableTileComponent bottomLeft = new TableTileComponent(new BasicItemInformation("Oak Table", "A simple oak table to hold things.", "Tables", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Tables.OakTable", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Table").texture, Color.White, 0, true, typeof(TableTileComponent), null, new AnimationManager(TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Table"), new Animation(new Rectangle(0, 32, 16, 16), -1)), Color.White, false, new Utilities.InventoryManager(), new LightManager()), new Framework.Objects.InformationFiles.Furniture.TableInformation(true)); + TableTileComponent bottomRight = new TableTileComponent(new BasicItemInformation("Oak Table", "A simple oak table to hold things.", "Tables", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Tables.OakTable", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Table").texture, Color.White, 0, true, typeof(TableTileComponent), null, new AnimationManager(TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Table"), new Animation(new Rectangle(16, 32, 16, 16), -1)), Color.White, false, new Utilities.InventoryManager(), new LightManager()), new Framework.Objects.InformationFiles.Furniture.TableInformation(true)); - TableMultiTiledObject obj = new TableMultiTiledObject(new BasicItemInformation("Oak Table", "A simple oak table to hold things.", "Tables", Color.White, -300, 0, false, 350, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Tables.OakTable", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Table").texture, Color.White, 0, true, typeof(TableMultiTiledObject), null, new AnimationManager(), Color.White, false, new Utilities.InventoryManager(), new LightManager())); + TableMultiTiledObject obj = new TableMultiTiledObject(new BasicItemInformation("Oak Table", "A simple oak table to hold things.", "Tables", Color.White, -300, 0, false, 350, Vector2.Zero, true, true, "Omegasis.Revitalize.Furniture.Tables.OakTable", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers[ModCore.Manifest.UniqueID]["Furniture"].getTexture("Oak Table").texture, Color.White, 0, true, typeof(TableMultiTiledObject), null, new AnimationManager(), Color.White, false, new Utilities.InventoryManager(), new LightManager())); TableFactoryInfo uL = new TableFactoryInfo(upperLeft); TableFactoryInfo uR = new TableFactoryInfo(upperRight); diff --git a/GeneralMods/Revitalize/Framework/Graphics/Texture2DExtended.cs b/GeneralMods/Revitalize/Framework/Graphics/Texture2DExtended.cs index e78447f2..6c41ccc6 100644 --- a/GeneralMods/Revitalize/Framework/Graphics/Texture2DExtended.cs +++ b/GeneralMods/Revitalize/Framework/Graphics/Texture2DExtended.cs @@ -12,6 +12,7 @@ namespace Revitalize.Framework.Graphics public string modID; public ContentSource source; private readonly IModHelper helper; + private readonly IContentPack content; /// Empty/null constructor. public Texture2DExtended() @@ -54,9 +55,30 @@ namespace Revitalize.Framework.Graphics this.source = contentSource; } + public Texture2DExtended(IContentPack content, string path) + { + this.Name = Path.GetFileNameWithoutExtension(path); + this.path = path; + this.content = content; + this.texture = content.LoadAsset(path); + this.helper = null; + this.modID = content.Manifest.UniqueID; + } + public Texture2DExtended Copy() { - return new Texture2DExtended(this.helper, this.modID, this.path); + if (this.helper != null) + { + return new Texture2DExtended(this.helper, this.modID, this.path); + } + else if (this.content != null) + { + return new Texture2DExtended(this.content, this.path); + } + else + { + throw new System.Exception("Trying to copy a texture that isn't from a mod or a content pack!!!"); + } } public IModHelper getHelper() diff --git a/GeneralMods/Revitalize/Framework/Graphics/TextureManager.cs b/GeneralMods/Revitalize/Framework/Graphics/TextureManager.cs index caade4d7..5cc0de73 100644 --- a/GeneralMods/Revitalize/Framework/Graphics/TextureManager.cs +++ b/GeneralMods/Revitalize/Framework/Graphics/TextureManager.cs @@ -1,20 +1,28 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using StardewModdingAPI; +using StardewValley; namespace Revitalize.Framework.Graphics { public class TextureManager { - public static Dictionary TextureManagers = new Dictionary(); + public static Dictionary> TextureManagers = new Dictionary>(); public Dictionary textures; - public TextureManager() + public string name; + + public TextureManager(string Name) { + this.name = Name; this.textures = new Dictionary(); } @@ -34,10 +42,128 @@ namespace Revitalize.Framework.Graphics throw new Exception("Error, texture name not found!!!"); } - public static void addTexture(string managerName, string textureName, Texture2DExtended Texture) + + /// + /// Content pack search. + /// + public void searchForTextures(IContentPack content) { - Texture.texture.Name = managerName + '.' + textureName; - TextureManagers[managerName].addTexture(textureName, Texture); + string path = content.DirectoryPath; + this.searchDirectories(path, "", content); + } + + /// + /// Non-Content pack search. + /// + public void searchForTextures() + { + string path = ModCore.ModHelper.DirectoryPath; + this.searchDirectories(path, "", ModCore.Manifest); + } + + private void searchDirectories(string path, string relativePath, IManifest manifest) + { + string[] dirs = Directory.GetDirectories(path); + string[] files = Directory.GetFiles(path); + + string[] extensions = new string[2] + { + ".png", + ".jpg" + }; + + foreach (string directory in dirs) + { + string combo = string.IsNullOrEmpty(relativePath) ? Path.GetFileName(directory) : Path.Combine(relativePath, Path.GetFileName(directory)); + this.searchDirectories(directory, combo, manifest); + } + + foreach (string file in files) + { + if (extensions.Contains(Path.GetExtension(file))) + { + this.processFoundTexture(file, relativePath); + + } + } + + } + private void searchDirectories(string path, string relativePath, IContentPack ContentPack) + { + string[] dirs = Directory.GetDirectories(path); + string[] files = Directory.GetFiles(path); + + string[] extensions = new string[2] + { + ".png", + ".jpg" + }; + + foreach (string directory in dirs) + { + string combo = string.IsNullOrEmpty(relativePath) ? Path.GetFileName(directory) : Path.Combine(relativePath, Path.GetFileName(directory)); + this.searchDirectories(directory, combo, ContentPack); + } + + foreach (string file in files) + { + if (extensions.Contains(Path.GetExtension(file))) + { + this.processFoundTexture(file, relativePath, ContentPack); + + } + } + + } + + private void processFoundTexture(string file, string relativePath) + { + Texture2DExtended textureExtended = new Texture2DExtended(ModCore.ModHelper, ModCore.Manifest, Path.Combine(relativePath, Path.GetFileName(file))); + + ModCore.log("Found texture: " + textureExtended.Name); + + textureExtended.texture.Name = ModCore.Manifest.UniqueID+"_"+this.name + "_" + textureExtended.Name; + + this.addTexture(textureExtended.Name, textureExtended); + } + + private void processFoundTexture(string file, string relativePath, IContentPack ContentPack) + { + Texture2DExtended textureExtended = new Texture2DExtended(ContentPack, Path.Combine(relativePath, Path.GetFileName(file))); + + textureExtended.texture.Name = ContentPack.Manifest.UniqueID + "_" + this.name + "_" + textureExtended.Name; + ModCore.log("Found texture: " + textureExtended.Name); + + //this.addTexture(textureExtended.Name, textureExtended); + } + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + // Static Functions // + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// + + public static void addTexture(IManifest ModManifest,string managerName, string textureName, Texture2DExtended Texture) + { + Texture.texture.Name = managerName + "." + textureName; + TextureManagers[ModManifest.UniqueID][managerName].addTexture(textureName, Texture); + } + + public static void AddTextureManager(IManifest ModManifest,string Name) + { + if (TextureManager.TextureManagers.ContainsKey(ModManifest.UniqueID)){ + TextureManagers[ModManifest.UniqueID].Add(Name, new TextureManager(Name)); + } + else + { + TextureManager.TextureManagers.Add(ModManifest.UniqueID, new Dictionary()); + TextureManagers[ModManifest.UniqueID].Add(Name, new TextureManager(Name)); + } + + } + + public static TextureManager GetTextureManager(IManifest Manifest,string Name) + { + return TextureManagers[Manifest.UniqueID][Name]; } } diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/Texture2DConverter.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/Texture2DConverter.cs index 5f73bc18..dfaa3dfe 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/Texture2DConverter.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/Texture2DConverter.cs @@ -26,11 +26,11 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters string textureName = reader.Value as string; //ModCore.log(textureName); if (string.IsNullOrEmpty(textureName)) return new Texture2D(Game1.graphics.GraphicsDevice, 2, 2); - string[] names = textureName.Split('.'); + string[] names = textureName.Split('_'); if (names.Length == 0) return null; if (!TextureManager.TextureManagers.ContainsKey(names[0])) return null; - return textureName == null ? null : Revitalize.Framework.Graphics.TextureManager.TextureManagers[names[0]].getTexture(names[1]).texture; + return textureName == null ? null : Revitalize.Framework.Graphics.TextureManager.TextureManagers[names[0]][names[1]].getTexture(names[2]).texture; } public override bool CanConvert(Type objectType) diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index c07594f8..eb71c3f3 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -27,7 +27,7 @@ namespace Revitalize // -load content MUST be enabled for the table to be placed?????? WTF // TODO: // - // -Get way to read in textures at runtime without having to load them in... + // -Add in object pool class to handle the multitudes of objects I'll be making. // -Make this mod able to load content packs for easier future modding // -Make deserialize/serialize look through sub directories instead of just one directory. // @@ -36,7 +36,7 @@ namespace Revitalize // Furniture: // -rugs (done, needs factory info/sprite) // -tables (done) - // -lamps + // -lamps (done) // -chairs (done) // -benches (done but needs factory info/sprite) // -dressers/other storage containers @@ -113,6 +113,7 @@ namespace Revitalize { public static IModHelper ModHelper; public static IMonitor ModMonitor; + public static IManifest Manifest; public static Dictionary customObjects; @@ -128,6 +129,7 @@ namespace Revitalize { ModHelper = helper; ModMonitor = this.Monitor; + Manifest = this.ModManifest; this.createDirectories(); this.initailizeComponents(); @@ -138,10 +140,12 @@ namespace Revitalize ModHelper.Events.GameLoop.ReturnedToTitle += this.GameLoop_ReturnedToTitle; playerInfo = new PlayerInfo(); - Framework.Graphics.TextureManager.TextureManagers.Add("Furniture", new TextureManager()); - TextureManager.addTexture("Furniture","Oak Chair", new Texture2DExtended(this.Helper, this.ModManifest, Path.Combine("Content","Graphics","Furniture", "Chairs", "OakChair.png"))); - TextureManager.addTexture("Furniture", "Oak Table", new Texture2DExtended(this.Helper, this.ModManifest, Path.Combine("Content", "Graphics", "Furniture", "Tables", "OakTable.png"))); - TextureManager.addTexture("Furniture", "Oak Lamp", new Texture2DExtended(this.Helper, this.ModManifest, Path.Combine("Content", "Graphics", "Furniture", "Lamps", "OakLamp.png"))); + Framework.Graphics.TextureManager.AddTextureManager(Manifest,"Furniture"); + TextureManager.GetTextureManager(Manifest,"Furniture").searchForTextures(); + + //TextureManager.addTexture("Furniture","Oak Chair", new Texture2DExtended(this.Helper, this.ModManifest, Path.Combine("Content","Graphics","Furniture", "Chairs", "Oak Chair.png"))); + //TextureManager.addTexture("Furniture", "Oak Table", new Texture2DExtended(this.Helper, this.ModManifest, Path.Combine("Content", "Graphics", "Furniture", "Tables", "Oak Table.png"))); + //TextureManager.addTexture("Furniture", "Oak Lamp", new Texture2DExtended(this.Helper, this.ModManifest, Path.Combine("Content", "Graphics", "Furniture", "Lamps", "Oak Lamp.png"))); customObjects = new Dictionary(); ObjectGroups = new Dictionary(); @@ -163,14 +167,14 @@ namespace Revitalize private void loadContent() { - MultiTiledComponent obj = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest", "YAY FUN!", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 0, 16, 16))), Color.Red, true, null, null)); - MultiTiledComponent obj2 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest2", "SomeFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 16, 16, 16))), Color.Red, false, null, null)); - MultiTiledComponent obj3 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest3", "NoFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 32, 16, 16))), Color.Red, false, null, null)); + MultiTiledComponent obj = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest", "YAY FUN!", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers[Manifest.UniqueID]["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(TextureManager.TextureManagers[Manifest.UniqueID]["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 0, 16, 16))), Color.Red, true, null, null)); + MultiTiledComponent obj2 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest2", "SomeFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers[Manifest.UniqueID]["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(TextureManager.TextureManagers[Manifest.UniqueID]["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 16, 16, 16))), Color.Red, false, null, null)); + MultiTiledComponent obj3 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest3", "NoFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers[Manifest.UniqueID]["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(TextureManager.TextureManagers[Manifest.UniqueID]["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 32, 16, 16))), Color.Red, false, null, null)); obj3.info.lightManager.addLight(new Vector2(Game1.tileSize), new LightSource(4, new Vector2(0, 0), 2.5f, Color.Orange.Invert()), obj3); - MultiTiledObject bigObject = new MultiTiledObject(new BasicItemInformation("MultiTest", "A really big object", "Omegasis.Revitalize.MultiTiledObject", Color.Blue, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.BigTiledTest", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(MultiTiledObject), null, new AnimationManager(), Color.White, false, null, null)); + MultiTiledObject bigObject = new MultiTiledObject(new BasicItemInformation("MultiTest", "A really big object", "Omegasis.Revitalize.MultiTiledObject", Color.Blue, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.BigTiledTest", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", TextureManager.TextureManagers[Manifest.UniqueID]["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(MultiTiledObject), null, new AnimationManager(), Color.White, false, null, null)); bigObject.addComponent(new Vector2(0, 0), obj); bigObject.addComponent(new Vector2(1, 0), obj2); bigObject.addComponent(new Vector2(2, 0), obj3); @@ -183,8 +187,8 @@ namespace Revitalize customObjects.Add("Omegasis.BigTiledTest", bigObject); - Framework.Objects.Furniture.RugTileComponent rug1 = new Framework.Objects.Furniture.RugTileComponent(new BasicItemInformation("BasicRugTile", "A basic rug", "Rug", Color.Brown, -300, 0, false, 100, new Vector2(0, 0), true, true, "Omegasis.Revitalize.Furniture.Basic.Rugs.TestRug", generatePlaceholderString(), TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0,true, typeof(Framework.Objects.Furniture.RugTileComponent), null, new AnimationManager(TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 0, 16, 16))), Color.White, true, null, null)); - Framework.Objects.Furniture.RugMultiTiledObject rug = new Framework.Objects.Furniture.RugMultiTiledObject(new BasicItemInformation("BasicRugTile", "A basic rug", "Rug", Color.Brown, -300, 0, false, 100, new Vector2(0, 0), true, true, "Omegasis.Revitalize.Furniture.Basic.Rugs.TestRug", generatePlaceholderString(), TextureManager.TextureManagers["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(Framework.Objects.Furniture.RugMultiTiledObject), null, new AnimationManager(), Color.White, true, null, null)); + Framework.Objects.Furniture.RugTileComponent rug1 = new Framework.Objects.Furniture.RugTileComponent(new BasicItemInformation("BasicRugTile", "A basic rug", "Rug", Color.Brown, -300, 0, false, 100, new Vector2(0, 0), true, true, "Omegasis.Revitalize.Furniture.Basic.Rugs.TestRug", generatePlaceholderString(), TextureManager.TextureManagers[Manifest.UniqueID]["Furniture"].getTexture("Oak Chair").texture, Color.White, 0,true, typeof(Framework.Objects.Furniture.RugTileComponent), null, new AnimationManager(TextureManager.TextureManagers[Manifest.UniqueID]["Furniture"].getTexture("Oak Chair"), new Animation(new Rectangle(0, 0, 16, 16))), Color.White, true, null, null)); + Framework.Objects.Furniture.RugMultiTiledObject rug = new Framework.Objects.Furniture.RugMultiTiledObject(new BasicItemInformation("BasicRugTile", "A basic rug", "Rug", Color.Brown, -300, 0, false, 100, new Vector2(0, 0), true, true, "Omegasis.Revitalize.Furniture.Basic.Rugs.TestRug", generatePlaceholderString(), TextureManager.TextureManagers[Manifest.UniqueID]["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(Framework.Objects.Furniture.RugMultiTiledObject), null, new AnimationManager(), Color.White, true, null, null)); rug.addComponent(new Vector2(0, 0), rug1); customObjects.Add("Omegasis.Revitalize.Furniture.Rugs.RugTest", rug);