From d8e7fa3ddbb59fbb83a33bcf8f4ad8788552e728 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Tue, 16 Jul 2019 02:09:42 -0700 Subject: [PATCH] MASSIVE rework of Revitalize. Seperated PyTK obj data from Revitalize data, added dependency to Stardust Core and swapped to Stardust's Tetxure2DExtended and TextureManagers. --- .../Graphics/Furniture/Chairs/Oak Chair.png | Bin 0 -> 1105 bytes .../Graphics/Furniture/Lamps/Oak Lamp.png | Bin 0 -> 470 bytes .../Graphics/Furniture/Tables/Oak Table.png | Bin 0 -> 450 bytes .../Factories/Objects/FactoryInfo.cs | 7 + .../Objects/Furniture/ChairFactoryInfo.cs | 6 +- .../Objects/Furniture/FurnitureFactory.cs | 80 ++++-- .../Objects/Furniture/TableFactoryInfo.cs | 6 +- .../Graphics/Animations/Animation.cs | 7 + .../Graphics/Animations/AnimationManager.cs | 1 + .../Framework/Graphics/Texture2DExtended.cs | 112 -------- .../Framework/Graphics/TextureManager.cs | 195 -------------- .../Framework/Menus/SimpleItemGrabMenu.cs | 51 ++++ .../Framework/Objects/BasicItemInformation.cs | 18 +- .../Framework/Objects/CustomObject.cs | 27 +- .../Framework/Objects/Furniture/Bench.cs | 6 +- .../Furniture/ChairMultiTiledObject.cs | 8 +- .../Objects/Furniture/ChairTileComponent.cs | 6 +- .../Objects/Furniture/CustomFurniture.cs | 5 +- .../Furniture/FurnitureTileComponent.cs | 5 +- .../Objects/Furniture/LampMultiTiledObject.cs | 8 +- .../Objects/Furniture/LampTileComponent.cs | 6 +- .../Objects/Furniture/RugMultiTiledObject.cs | 8 +- .../Objects/Furniture/RugTileComponent.cs | 6 +- .../Furniture/TableMultiTiledObject.cs | 8 +- .../Objects/Furniture/TableTileComponent.cs | 6 +- .../Framework/Objects/MultiTiledComponent.cs | 8 +- .../Framework/Objects/MultiTiledObject.cs | 14 +- .../Framework/Utilities/PyTKHelper.cs | 21 ++ .../Converters/Texture2DConverter.cs | 3 +- GeneralMods/Revitalize/ModCore.cs | 48 ++-- GeneralMods/Revitalize/Revitalize.csproj | 19 +- GeneralMods/Revitalize/manifest.json | 5 +- GeneralMods/StardewMods.sln | 3 + .../Framework/V2/MusicPackV2.cs | 8 +- .../StardewSymphony.cs | 16 +- .../StardewSymphonyRemastered/manifest.json | 2 +- GeneralMods/StardustCore/ModCore.cs | 13 +- .../UIUtilities/Texture2DExtended.cs | 119 ++++++-- .../UIUtilities/TextureManager.cs | 254 +++++++++++++++++- GeneralMods/StardustCore/manifest.json | 2 +- 40 files changed, 633 insertions(+), 484 deletions(-) create mode 100644 GeneralMods/Revitalize/Content/Graphics/Furniture/Chairs/Oak Chair.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Furniture/Lamps/Oak Lamp.png create mode 100644 GeneralMods/Revitalize/Content/Graphics/Furniture/Tables/Oak Table.png delete mode 100644 GeneralMods/Revitalize/Framework/Graphics/Texture2DExtended.cs delete mode 100644 GeneralMods/Revitalize/Framework/Graphics/TextureManager.cs create mode 100644 GeneralMods/Revitalize/Framework/Menus/SimpleItemGrabMenu.cs create mode 100644 GeneralMods/Revitalize/Framework/Utilities/PyTKHelper.cs diff --git a/GeneralMods/Revitalize/Content/Graphics/Furniture/Chairs/Oak Chair.png b/GeneralMods/Revitalize/Content/Graphics/Furniture/Chairs/Oak Chair.png new file mode 100644 index 0000000000000000000000000000000000000000..f7ebaa8992ac8e3b0b219aaa45cb968371d34c56 GIT binary patch literal 1105 zcmV-X1g`suP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02p*dSaefwW^{L9 za%BK;VQFr3E^cLXAT%y9E;EfJ{bv9G1Hwr}K~#8N?U>P#)IbbGF9AY;Dykp@eu;n> z_~VBN$bvY?g`gI{VcMtD$ljT;%j4a0SG7ITs%5G7_HOH5EPlNIa;sr3pYiS8r!aq3 zFe@|X@OAM&-#_2}{`#;=YE+MwM&y)F4Nna136lwaalN=iZ-fjW_b3Kv{@DN}et-Q~ zMZ56B8^A@ww-625r!Zg+CUB=nG4MI=(&)U00qAR(%e#QSFn}NH6io0jSgV0s4bWoh zvqoxEpXE(Jr#@*PEu)4$25U8(w-|uNF3x$4wyyVi(lh%h4A4OIg!UZe_Ie((4>tfk zL@TQIT28v$rW$BZXMp-Brnh3?bKI?_1?YA+fb-n25w@4@r#Q;lIJc<=T4qJhd3Cv@ zn6Or(^Bx9p_i>c7ac)x$w2KCCj^cYYocAz5J!~B1Y@FLv11&w!bKd+8=&ZrW)lvhg zSF~)DvoSrm*Agu~&~q*f@aHI}vl?=yDKU3`$=svr?eqO|#8J-1%05~i~ zNrD$@sE4D~Fyz&|h76=0>POzkQO?Ft%hgal(9>uBO!N?~h9R~?-{YwaXlWp#L91cN z*`e?8GzPRb5d8w=)VzjU4B)O9KD+_k)uYA$oyCVYKzgXqCU1^~Ph+eB<8sO#Sr~0(gev|B>dTbhCFTH(N z$wdt65;*s8lG1nc0K4ejyRxYF?;haX`F!%52iQ%o-wWg-26YL_o4%`hSGV5+TlK>Y zpfNul5_kr6V6;B{DJREk)J&;Rzfkw;pl|H4R5x1BnH;ZClhXy(>XJLT>3>&ZEY*$B zTl7EwHXh8diCU_aXlXDS#X>D)5q_k5h?XX!Q7qL$8Ng?|g_i-B0ha;KVSv6H^e}xF zn3{}6u~Z9Lf_Jiqr!XLW8Oex-jF`)X^cA^>NuB2y24>J=d^V&1;8;@Qj7SD3mlxw( zUcsPlya5bj7uPSTC3+*Y*qhI_TU-q4&S8KS(s1@1oNG#Xv`s%V-os9Z4>uQ4Dn?xr|0J)RE*e8pTk@@%Hi$ XlgMcgGfgXp00000NkvXXu0mjfr&0k` literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Furniture/Lamps/Oak Lamp.png b/GeneralMods/Revitalize/Content/Graphics/Furniture/Lamps/Oak Lamp.png new file mode 100644 index 0000000000000000000000000000000000000000..9598a7e40166938560ae03c68b4768c84ea8c61a GIT binary patch literal 470 zcmV;{0V)28P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02p*dSaefwW^{L9 za%BK;VQFr3E^cLXAT%y9E;jv63FrU-0Y^zhK~zXf?Ug-F12Gsx_aY!D=qTwBM}dlF zPmn95K-3f*fD_QC<^t3l0?`GH^}S`V{D%lsJJQHrd*<0mR?4($)v7<%ZaeQwj_tM- z+<)wf?m{TPzdjb-g&Z94vN=v30%+sy`ECJd{&anotT_P9i;#z#%WuJw0V^A|FFAnG z?R!mtPI7=3*&71*m3^%X@KO%oxeCy?s}Q5leJlbbZb8WB8mp(f6p%OPCuz**5$o&r z=pq$m&0~37zXGTr-(Q`kSDEM7Zi^zL&xari=~S+dxk<#@^3(kmu{|ag+_5~ag8=ya z{|itUtIQXOBUTnAPF0zouX`H`1Z4pJ%#EV9Xx1WOPNYCdW9@}X0R0Cj#ECgXR;CIN zonQ^nynzZ1$?YF8dW&Y+A^ff3Rv9f2KyKC}S5<<@6tZHo{6kICCuQ>6EIY{TX#fBK M07*qoM6N<$f>R5?)c^nh literal 0 HcmV?d00001 diff --git a/GeneralMods/Revitalize/Content/Graphics/Furniture/Tables/Oak Table.png b/GeneralMods/Revitalize/Content/Graphics/Furniture/Tables/Oak Table.png new file mode 100644 index 0000000000000000000000000000000000000000..3699c6e27dd838fa78e091b26597d1d46cad2ab7 GIT binary patch literal 450 zcmeAS@N?(olHy`uVBq!ia0vp^3P5bY!3HD?)>PyJDaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(eheoCO|{#S9F5he4R}c>anMprAyFYeY$Kep*R+Vo@qXL1JcJiC$i6iGqoq zp`O`aKh76GLybLM977`9-%j7id&q&u)tFt#Lu5_m;bEoiGO3w= za~5zn_;8#PW)Rt1++|{Pmdzxw?JV0ah7&ChY#1FbS}*rdzMSJAoOT1KkfH5F!$S;F zbnR0t)3-J1Fuav?P-A({$ + /// Revitalize's extra info tacked on. + /// public BasicItemInformation info; + public CustomObjectData PyTkData; public FactoryInfo() { @@ -19,11 +24,13 @@ namespace Revitalize.Framework.Factories.Objects.Furniture public FactoryInfo(MultiTiledObject obj) { this.info = obj.info; + this.PyTkData = obj.data; } public FactoryInfo(MultiTiledComponent component) { this.info = component.info; + this.PyTkData = component.data; } } diff --git a/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/ChairFactoryInfo.cs b/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/ChairFactoryInfo.cs index faba08c2..98808470 100644 --- a/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/ChairFactoryInfo.cs +++ b/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/ChairFactoryInfo.cs @@ -18,16 +18,14 @@ namespace Revitalize.Framework.Factories.Objects.Furniture } - public ChairFactoryInfo(ChairMultiTiledObject chair) + public ChairFactoryInfo(ChairMultiTiledObject chair): base(chair) { this.chairInfo = null; - this.info = chair.info; } - public ChairFactoryInfo(ChairTileComponent chair) + public ChairFactoryInfo(ChairTileComponent chair):base(chair) { this.chairInfo = chair.furnitureInfo; - this.info = chair.info; } } diff --git a/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/FurnitureFactory.cs b/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/FurnitureFactory.cs index 3dcc3cd9..69f79e76 100644 --- a/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/FurnitureFactory.cs +++ b/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/FurnitureFactory.cs @@ -11,15 +11,22 @@ using Revitalize.Framework.Graphics.Animations; using Revitalize.Framework.Illuminate; using Revitalize.Framework.Objects; using Revitalize.Framework.Objects.Furniture; +using Revitalize.Framework.Objects.InformationFiles.Furniture; +using Revitalize.Framework.Utilities; using StardewValley; +using StardustCore.UIUtilities; namespace Revitalize.Framework.Factories.Objects { + //TODO: Add Rugs + //Add Benches + //Add dressers for storage/appearance change (create this) + //Create portable beds??? public class FurnitureFactory { - public static string ChairFolder = Path.Combine("Objects", "Furniture", "Chairs"); - public static string TablesFolder = Path.Combine("Objects", "Furniture", "Tables"); - public static string LampsFolder = Path.Combine("Objects", "Furniture", "Lamps"); + public static string ChairFolder = Path.Combine("Data", "Furniture", "Chairs"); + public static string TablesFolder = Path.Combine("Data", "Furniture", "Tables"); + public static string LampsFolder = Path.Combine("Data", "Furniture", "Lamps"); public static void LoadFurnitureFiles() { @@ -45,16 +52,20 @@ namespace Revitalize.Framework.Factories.Objects SerializeLamps(); DeserializeLamps(); } - + /// + /// Serialize a lamp to a .json file for easier creation of like 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[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())); + LampTileComponent lampTop = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Lamps.OakLamp", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Lamp"), typeof(LampTileComponent), Color.White), new BasicItemInformation("Oak Lamp", "Omegasis.Revitalize.Furniture.Lamps.OakLamp", "A basic wooden light.", "Lamps", Color.Brown, -300, 0, true, 100, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Lamp"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Oak Lamp"), new Animation(new Rectangle(0, 0, 16, 16))), Color.White,true, new InventoryManager(), new LightManager())); + + LampTileComponent lampMiddle = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Lamps.OakLamp", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Lamp"), typeof(LampTileComponent), Color.White), new BasicItemInformation("Oak Lamp", "Omegasis.Revitalize.Furniture.Lamps.OakLamp", "A basic wooden light.", "Lamps", Color.Brown, -300, 0, true, 100, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Lamp"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Oak Lamp"), new Animation(new Rectangle(0, 16, 16, 16))), Color.White, true, new InventoryManager(), new LightManager())); + LampTileComponent lampBottom = new LampTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Lamps.OakLamp", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Lamp"), typeof(LampTileComponent), Color.White), new BasicItemInformation("Oak Lamp", "Omegasis.Revitalize.Furniture.Lamps.OakLamp", "A basic wooden light.", "Lamps", Color.Brown, -300, 0, true, 100, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Lamp"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Oak Lamp"), new Animation(new Rectangle(0, 32, 16, 16))), Color.White, false, new 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[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())); + LampMultiTiledObject lamp = new LampMultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Lamps.OakLamp", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Lamp"), typeof(LampMultiTiledObject), Color.White), new BasicItemInformation("Oak Lamp", "Omegasis.Revitalize.Furniture.Lamps.OakLamp", "A basic wooden light", "Lamps", Color.Brown, -300, 0, true, 300, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Lamp"), new AnimationManager(), Color.White, false, new InventoryManager(), new LightManager())); + lamp.addComponent(new Vector2(0, -2), lampTop); lamp.addComponent(new Vector2(0, -1), lampMiddle); lamp.addComponent(new Vector2(0, 0), lampBottom); @@ -90,7 +101,8 @@ namespace Revitalize.Framework.Factories.Objects if ((Path.GetFileName(file)).Contains("_") == true) continue; else { - objs.Add(Path.GetFileNameWithoutExtension(file), new LampMultiTiledObject(ModCore.Serializer.DeserializeContentFile(file).info)); + FactoryInfo factoryInfo = ModCore.Serializer.DeserializeContentFile(file); + objs.Add(Path.GetFileNameWithoutExtension(file), new LampMultiTiledObject(factoryInfo.PyTkData,factoryInfo.info)); } } //Deseralize components @@ -105,7 +117,7 @@ namespace Revitalize.Framework.Factories.Objects Vector2 offset = new Vector2(Convert.ToInt32(splits[1]), Convert.ToInt32(splits[2])); FactoryInfo info = ModCore.Serializer.DeserializeContentFile(file); - LampTileComponent lampPiece = new LampTileComponent(info.info); + LampTileComponent lampPiece = new LampTileComponent(info.PyTkData,info.info); //Recreate the lights info. if (lampPiece.lights != null) { @@ -130,12 +142,12 @@ namespace Revitalize.Framework.Factories.Objects } - - - + /// + /// Serialize all chair basic information to a file to have as a reference for making other like 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[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>() { + Framework.Objects.Furniture.ChairTileComponent chairTop = new ChairTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Chairs.OakChair", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Chair"), typeof(ChairTileComponent), Color.White), new BasicItemInformation("Oak Chair", "Omegasis.Revitalize.Furniture.Chairs.OakChair", "A basic wooden chair made out of oak.", "Chairs", Color.Brown, -300, 0, false, 250, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Chair"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest,"Furniture","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)) @@ -176,8 +188,10 @@ namespace Revitalize.Framework.Factories.Objects new Animation(new Rectangle(48,0,16,16)) } } - }, "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[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), Color.White, true, null, null),new ChairInformation(false)); + + + Framework.Objects.Furniture.ChairTileComponent chairBottom = new ChairTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Chairs.OakChair", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Chair"), typeof(ChairTileComponent), Color.White), new BasicItemInformation("Oak Chair", "Omegasis.Revitalize.Furniture.Chairs.OakChair", "A basic wooden chair.", "Chairs", Color.Brown, -300, 0, false, 250, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Chair"), 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)) @@ -218,8 +232,10 @@ namespace Revitalize.Framework.Factories.Objects new Animation(new Rectangle(48,16,16,16)) } } - }, "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[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())); + }, "Default_" + (int)Framework.Enums.Direction.Down), Color.White, false, null, null), new ChairInformation(true)); + + Framework.Objects.Furniture.ChairMultiTiledObject oakChair = new ChairMultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Chairs.OakChair", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Chair"), typeof(ChairMultiTiledObject), Color.White), new BasicItemInformation("Oak Chair", "Omegasis.Revitalize.Furniture.Chairs.OakChair", "A basic wooden chair.", "Chairs", Color.White, -300, 0, false, 250, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Chair"), new AnimationManager(), Color.White, false, null, null)); + ChairFactoryInfo top = new ChairFactoryInfo(chairTop); ChairFactoryInfo bottom = new ChairFactoryInfo(chairBottom); @@ -247,7 +263,8 @@ namespace Revitalize.Framework.Factories.Objects if ((Path.GetFileName(file)).Contains("_") == true) continue; else { - chairObjects.Add(Path.GetFileNameWithoutExtension(file), new ChairMultiTiledObject(ModCore.Serializer.DeserializeContentFile(file).info)); + ChairFactoryInfo factoryInfo = ModCore.Serializer.DeserializeContentFile(file); + chairObjects.Add(Path.GetFileNameWithoutExtension(file), new ChairMultiTiledObject(factoryInfo.PyTkData,factoryInfo.info)); } } //Deseralize components @@ -261,7 +278,7 @@ namespace Revitalize.Framework.Factories.Objects string name = splits[0]; Vector2 offset = new Vector2(Convert.ToInt32(splits[1]), Convert.ToInt32(splits[2])); ChairFactoryInfo info = ModCore.Serializer.DeserializeContentFile(file); - chairObjects[name].addComponent(offset, new ChairTileComponent(info.info, info.chairInfo)); + chairObjects[name].addComponent(offset, new ChairTileComponent(info.PyTkData,info.info, info.chairInfo)); } } foreach (var v in chairObjects) @@ -273,14 +290,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[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)); + TableTileComponent upperLeft = new TableTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Tables.OakTable", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Table"), typeof(TableTileComponent), Color.White), new BasicItemInformation("Oak Table", "Omegasis.Revitalize.Furniture.Tables.OakTable", "A simple wooden table to place objects on.", "Tables", Color.Brown, -300, 0, false, 350, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Table"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Oak Table"), new Animation(0, 0, 16, 16)), Color.White, true, null, null), new TableInformation(true)); + TableTileComponent upperRight = new TableTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Tables.OakTable", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Table"), typeof(TableTileComponent), Color.White), new BasicItemInformation("Oak Table", "Omegasis.Revitalize.Furniture.Tables.OakTable", "A simple wooden table to place objects on.", "Tables", Color.Brown, -300, 0, false, 350, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Table"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Oak Table"), new Animation(16, 0, 16, 16)), Color.White, true, null, null), new TableInformation(true)); + TableTileComponent centerLeft = new TableTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Tables.OakTable", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Table"), typeof(TableTileComponent), Color.White), new BasicItemInformation("Oak Table", "Omegasis.Revitalize.Furniture.Tables.OakTable", "A simple wooden table to place objects on.", "Tables", Color.Brown, -300, 0, false, 350, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Table"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Oak Table"), new Animation(0, 16, 16, 16)), Color.White, false, null, null), new TableInformation(true)); + TableTileComponent centerRight = new TableTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Tables.OakTable", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Table"), typeof(TableTileComponent), Color.White), new BasicItemInformation("Oak Table", "Omegasis.Revitalize.Furniture.Tables.OakTable", "A simple wooden table to place objects on.", "Tables", Color.Brown, -300, 0, false, 350, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Table"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Oak Table"), new Animation(16, 16, 16, 16)), Color.White, false, null, null), new TableInformation(true)); + TableTileComponent bottomLeft = new TableTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Tables.OakTable", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Table"), typeof(TableTileComponent), Color.White), new BasicItemInformation("Oak Table", "Omegasis.Revitalize.Furniture.Tables.OakTable", "A simple wooden table to place objects on.", "Tables", Color.Brown, -300, 0, false, 350, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Table"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Oak Table"), new Animation(0, 32, 16, 16)), Color.White, false, null, null), new TableInformation(true)); + TableTileComponent bottomRight = new TableTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Tables.OakTable", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Table"), typeof(TableTileComponent), Color.White), new BasicItemInformation("Oak Table", "Omegasis.Revitalize.Furniture.Tables.OakTable", "A simple wooden table to place objects on.", "Tables", Color.Brown, -300, 0, false, 350, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Table"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Furniture", "Oak Table"), new Animation(16, 32, 16, 16)), Color.White, false, null, null), new 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[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())); + TableMultiTiledObject obj = new TableMultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Tables.OakTable", TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Table"), typeof(TableMultiTiledObject), Color.White), new BasicItemInformation("Oak Table", "Omegasis.Revitalize.Furniture.Tables.OakTable", "A simple oak table to place things on.", "Tables", Color.Brown, -300, 0, false, 350, Vector2.Zero, true, true, TextureManager.GetTexture(ModCore.Manifest, "Furniture", "Oak Table"), new AnimationManager(), Color.White, false, null, null)); TableFactoryInfo uL = new TableFactoryInfo(upperLeft); TableFactoryInfo uR = new TableFactoryInfo(upperRight); @@ -321,7 +338,8 @@ namespace Revitalize.Framework.Factories.Objects if ((Path.GetFileName(file)).Contains("_") == true) continue; else { - chairObjects.Add(Path.GetFileNameWithoutExtension(file), new TableMultiTiledObject(ModCore.Serializer.DeserializeContentFile(file).info)); + TableFactoryInfo factoryInfo = ModCore.Serializer.DeserializeContentFile(file); + chairObjects.Add(Path.GetFileNameWithoutExtension(file), new TableMultiTiledObject(factoryInfo.PyTkData,factoryInfo.info)); } } //Deseralize components @@ -335,7 +353,7 @@ namespace Revitalize.Framework.Factories.Objects string name = splits[0]; Vector2 offset = new Vector2(Convert.ToInt32(splits[1]), Convert.ToInt32(splits[2])); TableFactoryInfo info = ModCore.Serializer.DeserializeContentFile(file); - chairObjects[name].addComponent(offset, new TableTileComponent(info.info, info.tableInfo)); + chairObjects[name].addComponent(offset, new TableTileComponent(info.PyTkData,info.info, info.tableInfo)); } } foreach (var v in chairObjects) @@ -354,6 +372,10 @@ namespace Revitalize.Framework.Factories.Objects { return (TableMultiTiledObject)ModCore.GetObjectFromPool(name); } + public static LampMultiTiledObject GetLamp(string name) + { + return (LampMultiTiledObject)ModCore.GetObjectFromPool(name); + } diff --git a/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/TableFactoryInfo.cs b/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/TableFactoryInfo.cs index f3c06252..7d855ff6 100644 --- a/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/TableFactoryInfo.cs +++ b/GeneralMods/Revitalize/Framework/Factories/Objects/Furniture/TableFactoryInfo.cs @@ -19,15 +19,13 @@ namespace Revitalize.Framework.Factories.Objects.Furniture } - public TableFactoryInfo(TableTileComponent table) + public TableFactoryInfo(TableTileComponent table):base(table) { - this.info= table.info; this.tableInfo = table.furnitureInfo; } - public TableFactoryInfo(TableMultiTiledObject table) + public TableFactoryInfo(TableMultiTiledObject table):base(table) { - this.info = table.info; this.tableInfo = null; } diff --git a/GeneralMods/Revitalize/Framework/Graphics/Animations/Animation.cs b/GeneralMods/Revitalize/Framework/Graphics/Animations/Animation.cs index 9218b13b..eb9341b1 100644 --- a/GeneralMods/Revitalize/Framework/Graphics/Animations/Animation.cs +++ b/GeneralMods/Revitalize/Framework/Graphics/Animations/Animation.cs @@ -26,6 +26,13 @@ namespace Revitalize.Framework.Graphics.Animations this.frameDuration = -1; } + public Animation(int xPos, int yPos, int width, int height) + { + this.sourceRectangle = new Rectangle(xPos, yPos, width, height); + this.frameCountUntilNextAnimation = -1; + this.frameDuration = -1; + } + /// Constructor that causes the animation frame count to be set to -1; This forces it to never change. /// The draw source for this animation. public Animation(Rectangle SourceRectangle) diff --git a/GeneralMods/Revitalize/Framework/Graphics/Animations/AnimationManager.cs b/GeneralMods/Revitalize/Framework/Graphics/Animations/AnimationManager.cs index 566295b2..5402c3a1 100644 --- a/GeneralMods/Revitalize/Framework/Graphics/Animations/AnimationManager.cs +++ b/GeneralMods/Revitalize/Framework/Graphics/Animations/AnimationManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using StardewValley; +using StardustCore.UIUtilities; namespace Revitalize.Framework.Graphics.Animations { diff --git a/GeneralMods/Revitalize/Framework/Graphics/Texture2DExtended.cs b/GeneralMods/Revitalize/Framework/Graphics/Texture2DExtended.cs deleted file mode 100644 index bad8a4e4..00000000 --- a/GeneralMods/Revitalize/Framework/Graphics/Texture2DExtended.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System.IO; -using Microsoft.Xna.Framework.Graphics; -using StardewModdingAPI; -using StardewValley; - -namespace Revitalize.Framework.Graphics -{ - public class Texture2DExtended - { - public string Name; - public Texture2D texture; - public string path; - public string modID; - public ContentSource source; - private readonly IModHelper helper; - private readonly IContentPack content; - - /// Empty/null constructor. - public Texture2DExtended() - { - this.Name = ""; - this.texture = null; - this.path = ""; - this.helper = null; - this.modID = ""; - } - - - /// Construct an instance. - /// The relative path to file on disk. See StardustCore.Utilities.getRelativePath(modname,path); - public Texture2DExtended(IModHelper helper, IManifest manifest, string path, ContentSource contentSource = ContentSource.ModFolder) - { - this.Name = Path.GetFileNameWithoutExtension(path); - this.path = path; - this.texture = helper.Content.Load(path, contentSource); - this.helper = helper; - this.modID = manifest.UniqueID; - this.source = contentSource; - } - - public Texture2DExtended(IModHelper helper, string modID, string path, ContentSource contentSource = ContentSource.ModFolder) - { - this.Name = Path.GetFileNameWithoutExtension(path); - this.path = path; - this.texture = helper.Content.Load(path, contentSource); - this.helper = helper; - this.modID = modID; - this.source = contentSource; - } - - public Texture2DExtended(IContentPack ContentPack, IManifest manifest, string path) - { - this.Name = Path.GetFileNameWithoutExtension(path); - this.path = path; - this.texture = ContentPack.LoadAsset(path); - this.helper = null; - this.modID = manifest.UniqueID; - this.source = ContentSource.ModFolder; - } - public Texture2DExtended(IContentPack ContentPack, string modID, string path) - { - this.Name = Path.GetFileNameWithoutExtension(path); - this.path = path; - this.texture = ContentPack.LoadAsset(path); - this.helper = null; - this.modID = modID; - this.source = ContentSource.ModFolder; - } - - 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() - { - 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() - { - return this.helper; - } - - /// Returns the actual 2D texture held by this wrapper class. - public Texture2D getTexture() - { - return this.texture; - } - - public void setTexure(Texture2D text) - { - this.texture = text; - } - } -} diff --git a/GeneralMods/Revitalize/Framework/Graphics/TextureManager.cs b/GeneralMods/Revitalize/Framework/Graphics/TextureManager.cs deleted file mode 100644 index eb092bea..00000000 --- a/GeneralMods/Revitalize/Framework/Graphics/TextureManager.cs +++ /dev/null @@ -1,195 +0,0 @@ -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 Dictionary textures; - - public string name; - - public TextureManager(string Name) - { - this.name = Name; - this.textures = new Dictionary(); - } - - - public TextureManager(string Name,IContentPack ContentPack) - { - this.name = Name; - this.textures = new Dictionary(); - } - - public void addTexture(string name, Texture2DExtended texture) - { - this.textures.Add(name, texture); - } - - /// Returns a Texture2DExtended held by the manager. - public Texture2DExtended getTexture(string name) - { - foreach (var v in this.textures) - { - if (v.Key == name) - return v.Value.Copy(); - } - throw new Exception("Error, texture name not found!!!"); - } - - - /// - /// Content pack search. - /// - public void searchForTextures(IContentPack content,string RelativePath) - { - if (string.IsNullOrEmpty(RelativePath)) - { - string path = content.DirectoryPath; - this.searchDirectories(path, "", content); - } - else - { - string path =Path.Combine(content.DirectoryPath,RelativePath); - this.searchDirectories(path, RelativePath, content); - } - } - - /// - /// Non-Content pack search. - /// - public void searchForTextures(string RelativePath="") - { - if (string.IsNullOrEmpty(RelativePath)) - { - string path = ModCore.ModHelper.DirectoryPath; - this.searchDirectories(path, "", ModCore.Manifest); - } - else - { - string path = Path.Combine(ModCore.ModHelper.DirectoryPath,RelativePath); - this.searchDirectories(path, RelativePath, 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/Menus/SimpleItemGrabMenu.cs b/GeneralMods/Revitalize/Framework/Menus/SimpleItemGrabMenu.cs new file mode 100644 index 00000000..eab161b4 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Menus/SimpleItemGrabMenu.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using StardewValley; + +namespace Revitalize.Framework.Menus +{ + public class SimpleItemGrabMenu: StardustCore.UIUtilities.IClickableMenuExtended + { + public List stroageInventory; + public List receivingInventory; + public List clickableItems; + public SimpleItemGrabMenu(int xPos,int yPos,int width, int height,bool showCloseButton,List StorageInventory,ListReceivingInventory) : base(xPos, yPos, width, height, showCloseButton) + { + this.stroageInventory = StorageInventory; + this.receivingInventory = ReceivingInventory; + this.clickableItems = new List(); + } + + public override void performHoverAction(int x, int y) + { + + } + + public override void receiveLeftClick(int x, int y, bool playSound = true) + { + + } + + public override void receiveRightClick(int x, int y, bool playSound = true) + { + + } + + public override void update(GameTime time) + { + + } + + public override void draw(SpriteBatch b) + { + this.drawDialogueBoxBackground(); + this.drawMouse(b); + //base.draw(b); + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs index 436cde65..debf067e 100644 --- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -6,12 +6,14 @@ using Revitalize.Framework.Graphics.Animations; using Revitalize.Framework.Illuminate; using Revitalize.Framework.Utilities; using StardewValley; +using StardustCore.UIUtilities; namespace Revitalize.Framework.Objects { - public class BasicItemInformation : CustomObjectData + public class BasicItemInformation { public string name; + public string id; public string description; public string categoryName; public Color categoryColor; @@ -56,12 +58,14 @@ namespace Revitalize.Framework.Objects this.lightManager = new LightManager(); this.facingDirection = Enums.Direction.Down; + this.id = ""; } - public BasicItemInformation(string name, string description, string categoryName, Color categoryColor,int edibility, int fragility, bool isLamp, int price, Vector2 TileLocation, bool canBeSetOutdoors, bool canBeSetIndoors, string id, string data, Texture2D texture, Color color, int tileIndex, bool bigCraftable, Type type, CraftingData craftingData, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights) : base(id, data, texture, color, tileIndex, bigCraftable, type, craftingData) + public BasicItemInformation(string name, string id, string description, string categoryName, Color categoryColor,int edibility, int fragility, bool isLamp, int price, Vector2 TileLocation, bool canBeSetOutdoors, bool canBeSetIndoors, Texture2D texture, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights) { this.name = name; + this.id = id; this.description = description; this.categoryName = categoryName; this.categoryColor = categoryColor; @@ -77,27 +81,19 @@ namespace Revitalize.Framework.Objects this.animationManager = animationManager; if (this.animationManager.IsNull) { - this.animationManager = new AnimationManager(new Graphics.Texture2DExtended(), new Animation(new Rectangle(0, 0, 16, 16)), false); + this.animationManager = new AnimationManager(new Texture2DExtended(), new Animation(new Rectangle(0, 0, 16, 16)), false); this.animationManager.getExtendedTexture().texture = texture; } - else - this.texture = texture; this.drawPosition = Vector2.Zero; this.drawColor = drawColor; this.ignoreBoundingBox = ignoreBoundingBox; - this.recreateDataString(); this.inventory = Inventory ?? new InventoryManager(); this.lightManager = Lights ?? new LightManager(); this.facingDirection = Enums.Direction.Down; } - public void recreateDataString() - { - this.data = $"{this.name}/{this.price}/{this.edibility}/Crafting -9/{this.description}/{this.canBeSetOutdoors}/{this.canBeSetIndoors}/{this.fragility}/{this.isLamp}/{this.name}"; - } - } } diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 19421134..efc14a19 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -64,8 +64,8 @@ namespace Revitalize.Framework.Objects } /// Construct an instance. - public CustomObject(BasicItemInformation info) - : base(info, Vector2.Zero) + public CustomObject(CustomObjectData PyTKData, BasicItemInformation info) + : base(PyTKData, Vector2.Zero) { this.info = info; this.initializeBasics(); @@ -74,8 +74,8 @@ namespace Revitalize.Framework.Objects } /// Construct an instance. - public CustomObject(BasicItemInformation info, Vector2 TileLocation) - : base(info, TileLocation) + public CustomObject(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation) + : base(PyTKData, TileLocation) { this.info = info; this.initializeBasics(); @@ -94,7 +94,7 @@ namespace Revitalize.Framework.Objects this.setOutdoors.Value = true; this.setIndoors.Value = true; this.isLamp.Value = false; - this.fragility.Value = 0; + this.Fragility = 0; this.updateDrawPosition(0, 0); @@ -148,8 +148,15 @@ namespace Revitalize.Framework.Objects public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) { - BasicItemInformation data = (BasicItemInformation)CustomObjectData.collection[additionalSaveData["id"]]; - return new CustomObject(data, (replacement as Chest).TileLocation); + CustomObjectData data = CustomObjectData.collection[additionalSaveData["id"]]; + BasicItemInformation info = Revitalize.ModCore.Serializer.DeserializeFromJSONString(additionalSaveData["ItemInfo"]); + return new CustomObject(data,info,(replacement as Chest).TileLocation); + } + public override Dictionary getAdditionalSaveData() + { + Dictionary serializedInfo = new Dictionary(); + serializedInfo.Add("ItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); + return serializedInfo; } /// What happens when the player right clicks the object. @@ -295,7 +302,7 @@ namespace Revitalize.Framework.Objects /// Gets a clone of the game object. public override Item getOne() { - return new CustomObject((BasicItemInformation)this.data); + return new CustomObject(this.data,this.info); } /// What happens when the object is drawn at a tile location. @@ -435,6 +442,10 @@ namespace Revitalize.Framework.Objects this.info = Revitalize.ModCore.Serializer.DeserializeFromJSONString(syncData["BasicItemInfo"]); } + + + + public string getDisplayNameFromStringsFile(string objectID) { //Load in a file that has all object names referenced here or something. diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/Bench.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/Bench.cs index c8958818..bd230a00 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/Bench.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/Bench.cs @@ -18,13 +18,13 @@ namespace Revitalize.Framework.Objects.Furniture public List playersSittingHere = new List(); - public Bench(BasicItemInformation info, Vector2 TilePosition) : base(info, TilePosition) + public Bench(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TilePosition) : base(PyTKData,info, TilePosition) { } - public Bench(BasicItemInformation info,Vector2 TilePosition, Dictionary Objects) : base(info, TilePosition, Objects) + public Bench(CustomObjectData PyTKData, BasicItemInformation info,Vector2 TilePosition, Dictionary Objects) : base(PyTKData,info, TilePosition, Objects) { } @@ -62,7 +62,7 @@ namespace Revitalize.Framework.Objects.Furniture objs.Add(pair.Key, (MultiTiledComponent)pair.Value); } - return new Bench(this.info, this.TileLocation, objs); + return new Bench(this.data,this.info, this.TileLocation, objs); } diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairMultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairMultiTiledObject.cs index 225d662c..251b6162 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairMultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairMultiTiledObject.cs @@ -22,17 +22,17 @@ namespace Revitalize.Framework.Objects.Furniture } - public ChairMultiTiledObject(BasicItemInformation Info) : base(Info) + public ChairMultiTiledObject(CustomObjectData PyTKData, BasicItemInformation Info) : base(PyTKData,Info) { } - public ChairMultiTiledObject(BasicItemInformation Info, Vector2 TilePosition) : base(Info, TilePosition) + public ChairMultiTiledObject(CustomObjectData PyTKData,BasicItemInformation Info, Vector2 TilePosition) : base(PyTKData,Info, TilePosition) { } - public ChairMultiTiledObject(BasicItemInformation Info,Vector2 TilePosition,Dictionary Objects) : base(Info, TilePosition, Objects) { + public ChairMultiTiledObject(CustomObjectData PyTKData, BasicItemInformation Info,Vector2 TilePosition,Dictionary Objects) : base(PyTKData,Info, TilePosition, Objects) { } @@ -63,7 +63,7 @@ namespace Revitalize.Framework.Objects.Furniture } - return new ChairMultiTiledObject(this.info, this.TileLocation, objs); + return new ChairMultiTiledObject(this.data,this.info, this.TileLocation, objs); } diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs index daba1b42..4864ae68 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/ChairTileComponent.cs @@ -35,12 +35,12 @@ namespace Revitalize.Framework.Objects.Furniture } - public ChairTileComponent(BasicItemInformation Info,ChairInformation FurnitureInfo) : base(Info) + public ChairTileComponent(CustomObjectData PyTKData,BasicItemInformation Info,ChairInformation FurnitureInfo) : base(PyTKData,Info) { this.furnitureInfo = FurnitureInfo; } - public ChairTileComponent(BasicItemInformation Info,Vector2 TileLocation, ChairInformation FurnitureInfo) : base(Info, TileLocation) + public ChairTileComponent(CustomObjectData PyTKData,BasicItemInformation Info,Vector2 TileLocation, ChairInformation FurnitureInfo) : base(PyTKData,Info, TileLocation) { this.furnitureInfo = FurnitureInfo; } @@ -88,7 +88,7 @@ namespace Revitalize.Framework.Objects.Furniture public override Item getOne() { - ChairTileComponent component = new ChairTileComponent(this.info, (ChairInformation)this.furnitureInfo); + ChairTileComponent component = new ChairTileComponent(this.data,this.info, (ChairInformation)this.furnitureInfo); component.containerObject = this.containerObject; component.offsetKey = this.offsetKey; return component; diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/CustomFurniture.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/CustomFurniture.cs index 7ef18e8b..c74b5525 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/CustomFurniture.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/CustomFurniture.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; +using PyTK.CustomElementHandler; using Revitalize.Framework.Objects.InformationFiles.Furniture; namespace Revitalize.Framework.Objects.Furniture @@ -18,12 +19,12 @@ namespace Revitalize.Framework.Objects.Furniture } - public CustomFurniture(BasicItemInformation itemInfo, FurnitureInformation furnitureInfo) : base(itemInfo) + public CustomFurniture(CustomObjectData PyTKData,BasicItemInformation itemInfo, FurnitureInformation furnitureInfo) : base(PyTKData,itemInfo) { this.furnitureInfo = furnitureInfo; } - public CustomFurniture(BasicItemInformation itemInfo, Vector2 TileLocation, FurnitureInformation furnitureInfo) : base(itemInfo, TileLocation) + public CustomFurniture(CustomObjectData PyTKData, BasicItemInformation itemInfo, Vector2 TileLocation, FurnitureInformation furnitureInfo) : base(PyTKData,itemInfo, TileLocation) { this.furnitureInfo = furnitureInfo; } diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/FurnitureTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/FurnitureTileComponent.cs index 7c5661c2..d0cc2786 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/FurnitureTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/FurnitureTileComponent.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; +using PyTK.CustomElementHandler; using Revitalize.Framework.Objects.InformationFiles; using Revitalize.Framework.Objects.InformationFiles.Furniture; @@ -18,11 +19,11 @@ namespace Revitalize.Framework.Objects.Furniture } - public FurnitureTileComponent(BasicItemInformation itemInfo):base(itemInfo) + public FurnitureTileComponent(CustomObjectData PyTKData,BasicItemInformation itemInfo):base(PyTKData,itemInfo) { } - public FurnitureTileComponent(BasicItemInformation itemInfo,Vector2 TileLocation) : base(itemInfo,TileLocation) + public FurnitureTileComponent(CustomObjectData PyTKData, BasicItemInformation itemInfo,Vector2 TileLocation) : base(PyTKData,itemInfo,TileLocation) { } diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/LampMultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/LampMultiTiledObject.cs index df901d38..dfc63cef 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/LampMultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/LampMultiTiledObject.cs @@ -17,17 +17,17 @@ namespace Revitalize.Framework.Objects.Furniture } - public LampMultiTiledObject(BasicItemInformation Info) : base(Info) + public LampMultiTiledObject(CustomObjectData PyTKData, BasicItemInformation Info) : base(PyTKData,Info) { } - public LampMultiTiledObject(BasicItemInformation Info, Vector2 TilePosition) : base(Info, TilePosition) + public LampMultiTiledObject(CustomObjectData PyTKData, BasicItemInformation Info, Vector2 TilePosition) : base(PyTKData,Info, TilePosition) { } - public LampMultiTiledObject(BasicItemInformation Info, Vector2 TilePosition, Dictionary Objects) : base(Info, TilePosition, Objects) + public LampMultiTiledObject(CustomObjectData PyTKData, BasicItemInformation Info, Vector2 TilePosition, Dictionary Objects) : base(PyTKData,Info, TilePosition, Objects) { @@ -47,7 +47,7 @@ namespace Revitalize.Framework.Objects.Furniture } - return new LampMultiTiledObject(this.info, this.TileLocation, objs); + return new LampMultiTiledObject(this.data,this.info, this.TileLocation, objs); } diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs index 6dfd3d8a..b87265cf 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/LampTileComponent.cs @@ -37,12 +37,12 @@ namespace Revitalize.Framework.Objects.Furniture } - public LampTileComponent(BasicItemInformation Info) : base(Info) + public LampTileComponent(CustomObjectData PyTKData,BasicItemInformation Info) : base(PyTKData,Info) { } - public LampTileComponent(BasicItemInformation Info, Vector2 TileLocation) : base(Info, TileLocation) + public LampTileComponent(CustomObjectData PyTKData,BasicItemInformation Info, Vector2 TileLocation) : base(PyTKData,Info, TileLocation) { } @@ -124,7 +124,7 @@ namespace Revitalize.Framework.Objects.Furniture public override Item getOne() { - LampTileComponent component = new LampTileComponent(this.info); + LampTileComponent component = new LampTileComponent(this.data,this.info); component.containerObject = this.containerObject; component.offsetKey = this.offsetKey; return component; diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/RugMultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/RugMultiTiledObject.cs index 257993b0..45ad8bc9 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/RugMultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/RugMultiTiledObject.cs @@ -16,17 +16,17 @@ namespace Revitalize.Framework.Objects.Furniture } - public RugMultiTiledObject(BasicItemInformation Info) : base(Info) + public RugMultiTiledObject(CustomObjectData PyTKData, BasicItemInformation Info) : base(PyTKData,Info) { } - public RugMultiTiledObject(BasicItemInformation Info, Vector2 TilePosition) : base(Info, TilePosition) + public RugMultiTiledObject(CustomObjectData PyTKData, BasicItemInformation Info, Vector2 TilePosition) : base(PyTKData,Info, TilePosition) { } - public RugMultiTiledObject(BasicItemInformation Info, Vector2 TilePosition, Dictionary Objects) : base(Info, TilePosition, Objects) + public RugMultiTiledObject(CustomObjectData PyTKData, BasicItemInformation Info, Vector2 TilePosition, Dictionary Objects) : base(PyTKData,Info, TilePosition, Objects) { @@ -49,7 +49,7 @@ namespace Revitalize.Framework.Objects.Furniture } - return new RugMultiTiledObject(this.info, this.TileLocation, objs); + return new RugMultiTiledObject(this.data,this.info, this.TileLocation, objs); } diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/RugTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/RugTileComponent.cs index a3c57b3e..84fb935f 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/RugTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/RugTileComponent.cs @@ -18,12 +18,12 @@ namespace Revitalize.Framework.Objects.Furniture } - public RugTileComponent(BasicItemInformation Info) : base(Info) + public RugTileComponent(CustomObjectData PyTKData,BasicItemInformation Info) : base(PyTKData,Info) { this.info.ignoreBoundingBox = true; } - public RugTileComponent(BasicItemInformation Info, Vector2 TileLocation) : base(Info, TileLocation) + public RugTileComponent(CustomObjectData PyTKData,BasicItemInformation Info, Vector2 TileLocation) : base(PyTKData,Info, TileLocation) { this.info.ignoreBoundingBox = true; } @@ -44,7 +44,7 @@ namespace Revitalize.Framework.Objects.Furniture public override Item getOne() { - RugTileComponent component = new RugTileComponent(this.info); + RugTileComponent component = new RugTileComponent(this.data,this.info); component.containerObject = this.containerObject; component.offsetKey = this.offsetKey; return component; diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableMultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableMultiTiledObject.cs index a46a3cf1..7920f9f0 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableMultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableMultiTiledObject.cs @@ -17,17 +17,17 @@ namespace Revitalize.Framework.Objects.Furniture } - public TableMultiTiledObject(BasicItemInformation Info) : base(Info) + public TableMultiTiledObject(CustomObjectData PyTKData, BasicItemInformation Info) : base(PyTKData,Info) { } - public TableMultiTiledObject(BasicItemInformation Info, Vector2 TilePosition) : base(Info, TilePosition) + public TableMultiTiledObject(CustomObjectData PyTKData, BasicItemInformation Info, Vector2 TilePosition) : base(PyTKData,Info, TilePosition) { } - public TableMultiTiledObject(BasicItemInformation Info, Vector2 TilePosition, Dictionary Objects) : base(Info, TilePosition, Objects) + public TableMultiTiledObject(CustomObjectData PyTKData, BasicItemInformation Info, Vector2 TilePosition, Dictionary Objects) : base(PyTKData,Info, TilePosition, Objects) { @@ -48,7 +48,7 @@ namespace Revitalize.Framework.Objects.Furniture } - return new TableMultiTiledObject(this.info, this.TileLocation,objs); + return new TableMultiTiledObject(this.data,this.info, this.TileLocation,objs); } diff --git a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs index b081e901..756b47ac 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Furniture/TableTileComponent.cs @@ -38,12 +38,12 @@ namespace Revitalize.Framework.Objects.Furniture } - public TableTileComponent(BasicItemInformation Info, TableInformation FurnitureInfo) : base(Info) + public TableTileComponent(CustomObjectData PyTKData,BasicItemInformation Info, TableInformation FurnitureInfo) : base(PyTKData,Info) { this.furnitureInfo = FurnitureInfo; } - public TableTileComponent(BasicItemInformation Info, Vector2 TileLocation, TableInformation FurnitureInfo) : base(Info, TileLocation) + public TableTileComponent(CustomObjectData PyTKData,BasicItemInformation Info, Vector2 TileLocation, TableInformation FurnitureInfo) : base(PyTKData,Info, TileLocation) { this.furnitureInfo = FurnitureInfo; } @@ -180,7 +180,7 @@ namespace Revitalize.Framework.Objects.Furniture public override Item getOne() { - TableTileComponent component = new TableTileComponent(this.info, (TableInformation)this.furnitureInfo); + TableTileComponent component = new TableTileComponent(this.data,this.info, (TableInformation)this.furnitureInfo); component.containerObject = this.containerObject; component.offsetKey = this.offsetKey; return component; diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index bc66ff15..0c4378f1 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -18,13 +18,13 @@ namespace Revitalize.Framework.Objects public MultiTiledComponent() { } - public MultiTiledComponent(BasicItemInformation info) : base(info) { } + public MultiTiledComponent(CustomObjectData PyTKData,BasicItemInformation info) : base(PyTKData,info) { } - public MultiTiledComponent(BasicItemInformation info, Vector2 TileLocation,MultiTiledObject obj=null) : base(info, TileLocation) { + public MultiTiledComponent(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation,MultiTiledObject obj=null) : base(PyTKData,info, TileLocation) { this.containerObject = obj; } - public MultiTiledComponent(BasicItemInformation info, Vector2 TileLocation,Vector2 offsetKey ,MultiTiledObject obj = null) : base(info, TileLocation) { + public MultiTiledComponent(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation,Vector2 offsetKey ,MultiTiledObject obj = null) : base(PyTKData,info, TileLocation) { this.offsetKey = offsetKey; this.containerObject = obj; } @@ -113,7 +113,7 @@ namespace Revitalize.Framework.Objects public override Item getOne() { - MultiTiledComponent component = new MultiTiledComponent(this.info, this.TileLocation,this.offsetKey,this.containerObject); + MultiTiledComponent component = new MultiTiledComponent(this.data,this.info, this.TileLocation,this.offsetKey,this.containerObject); return component; } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs index 405adcf5..faf5491c 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs @@ -42,24 +42,24 @@ namespace Revitalize.Framework.Objects } - public MultiTiledObject(BasicItemInformation info) - : base(info) + public MultiTiledObject(CustomObjectData PyTKData,BasicItemInformation info) + : base(PyTKData,info) { this.objects = new Dictionary(); this.childrenGuids = new Dictionary(); } - public MultiTiledObject(BasicItemInformation info, Vector2 TileLocation) - : base(info, TileLocation) + public MultiTiledObject(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation) + : base(PyTKData,info, TileLocation) { this.objects = new Dictionary(); this.childrenGuids = new Dictionary(); } - public MultiTiledObject(BasicItemInformation info, Vector2 TileLocation, Dictionary ObjectsList) - : base(info, TileLocation) + public MultiTiledObject(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, Dictionary ObjectsList) + : base(PyTKData,info, TileLocation) { this.objects = new Dictionary(); this.childrenGuids = new Dictionary(); @@ -268,7 +268,7 @@ namespace Revitalize.Framework.Objects { objs.Add(pair.Key, (MultiTiledComponent)pair.Value); } - return new MultiTiledObject(this.info, this.TileLocation, objs); + return new MultiTiledObject(this.data,this.info, this.TileLocation, objs); } public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) diff --git a/GeneralMods/Revitalize/Framework/Utilities/PyTKHelper.cs b/GeneralMods/Revitalize/Framework/Utilities/PyTKHelper.cs new file mode 100644 index 00000000..68be78a0 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Utilities/PyTKHelper.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using PyTK.CustomElementHandler; + +namespace Revitalize.Framework.Utilities +{ + public class PyTKHelper + { + + public static CustomObjectData CreateOBJData(string id, Texture2D Texture, Type type, Color color, bool bigCraftable = true) + { + return new PyTK.CustomElementHandler.CustomObjectData(id, "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Texture, color, 0, bigCraftable, type, null); + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/Texture2DConverter.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/Texture2DConverter.cs index dfaa3dfe..302c3b46 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/Texture2DConverter.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/Texture2DConverter.cs @@ -8,6 +8,7 @@ using Microsoft.Xna.Framework.Graphics; using Newtonsoft.Json; using Revitalize.Framework.Graphics; using StardewValley; +using StardustCore.UIUtilities; namespace Revitalize.Framework.Utilities.Serialization.Converters { @@ -30,7 +31,7 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters 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]][names[1]].getTexture(names[2]).texture; + return textureName == null ? null : 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 de9c3204..a34bc1af 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -18,6 +18,7 @@ using Revitalize.Framework.Utilities; using StardewModdingAPI; using StardewValley; using StardewValley.Objects; +using StardustCore.UIUtilities; namespace Revitalize { @@ -26,7 +27,12 @@ namespace Revitalize // -Chair tops cut off objects // -load content MUST be enabled for the table to be placed?????? WTF // TODO: - // + /* + * + *Menus: + * -Simple Item Grab Menu (to transfer items from one inventory to another) + * -Need to make this. + * // -Add in object pool class to handle the multitudes of objects I'll be making. (WIP) // -Make this mod able to load content packs for easier future modding // @@ -43,6 +49,7 @@ namespace Revitalize // -More crafting tables // -Machines // !=Energy + // -solar // -Furnace // -Seed Maker // -Stone Quarry @@ -52,8 +59,18 @@ namespace Revitalize // -Auto Preserves // -Auto Keg // -Auto Cask + // -Calcinator (oil+stone) // -Materials // -Tin/Bronze/Alluminum/Silver?Platinum/Etc + -titanium + -Alloys! + -Brass + -Electrum + -Liquids + -oil + -water + -coal + -juice??? // -Crafting Menu // -Item Grab Menu (Extendable) // -Yes/No Dialogue Box @@ -69,7 +86,8 @@ namespace Revitalize // -Connected chests much like Project EE2 from MC // // - // -Food? + // -Food? + -multi flavored sodas // -Bigger chests // // Festivals @@ -108,7 +126,7 @@ namespace Revitalize // -boss fights // // More dungeons?? - + */ public class ModCore : Mod { @@ -120,9 +138,6 @@ namespace Revitalize public static DictionaryObjectGroups; - - - public static PlayerInfo playerInfo; public static Serializer Serializer; @@ -144,8 +159,8 @@ namespace Revitalize ModHelper.Events.GameLoop.ReturnedToTitle += this.GameLoop_ReturnedToTitle; playerInfo = new PlayerInfo(); - Framework.Graphics.TextureManager.AddTextureManager(Manifest,"Furniture"); - TextureManager.GetTextureManager(Manifest,"Furniture").searchForTextures(Path.Combine("Content", "Graphics", "Furniture")); + TextureManager.AddTextureManager(Manifest,"Furniture"); + TextureManager.GetTextureManager(Manifest,"Furniture").searchForTextures(ModHelper,this.ModManifest,Path.Combine("Content", "Graphics", "Furniture")); //TextureManager.addTexture("Furniture","Oak Chair", new Texture2DExtended(this.Helper, this.ModManifest, Path.Combine("Content","Graphics","Furniture", "Chairs", "Oak Chair.png"))); @@ -177,15 +192,16 @@ 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[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)); + + MultiTiledComponent obj = new MultiTiledComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.MultiTiledComponent.Test", TextureManager.GetTexture(Manifest,"Furniture","Oak Chair"),typeof(MultiTiledComponent),Color.White), new BasicItemInformation("CoreObjectTest", "Omegasis.TEST1", "YAY FUN!", "Omegasis.Revitalize.MultiTiledComponent.Test", Color.White, -300, 0, false, 300, Vector2.Zero, true, true, TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Furniture", "Oak Chair"), new Animation(new Rectangle(0, 0, 16, 16))), Color.White, false, null, null)); + MultiTiledComponent obj2 = new MultiTiledComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.MultiTiledComponent.Test", TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), typeof(MultiTiledComponent), Color.White), new BasicItemInformation("CoreObjectTest2", "Omegasis.TEST2", "Some fun!", "Omegasis.Revitalize.MultiTiledComponent.Test", Color.White, -300, 0, false, 300, Vector2.Zero, true, true, TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Furniture", "Oak Chair"), new Animation(new Rectangle(0, 16, 16, 16))), Color.White, false, null, null)); + MultiTiledComponent obj3 = new MultiTiledComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.MultiTiledComponent.Test", TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), typeof(MultiTiledComponent), Color.White), new BasicItemInformation("CoreObjectTest3", "Omegasis.TEST3", "NoFun", "Omegasis.Revitalize.MultiTiledComponent.Test", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, TextureManager.GetTexture(Manifest,"Furniture","Oak Chair"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Furniture", "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[Manifest.UniqueID]["Furniture"].getTexture("Oak Chair").texture, Color.White, 0, true, typeof(MultiTiledObject), null, new AnimationManager(), Color.White, false, null, null)); + MultiTiledObject bigObject = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.MultiTiledComponent.Test", TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), typeof(MultiTiledObject), Color.White), new BasicItemInformation("MultiTest", "Omegasis.BigTiledTest", "A really big object", "Omegasis.Revitalize.MultiTiledObject", Color.Blue, -300, 0, false, 500, Vector2.Zero, true, true, TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), 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); @@ -198,8 +214,10 @@ 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[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)); + Framework.Objects.Furniture.RugTileComponent rug1 = new RugTileComponent(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Basic.Rugs.TestRug", TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), typeof(RugTileComponent), Color.White), new BasicItemInformation("Rug Tile", "Omegasis.Revitalize.Furniture.Basic.Rugs.TestRug", "A rug tile", "Rug", Color.Brown, -300, 0, false, 100, Vector2.Zero, true, true, TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Furniture", "Oak Chair"), new Animation(new Rectangle(0, 0, 16, 16))), Color.White, true, null, null)); + + Framework.Objects.Furniture.RugMultiTiledObject rug=new RugMultiTiledObject( PyTKHelper.CreateOBJData("Omegasis.Revitalize.Furniture.Basic.Rugs.TestRug", TextureManager.GetTexture(Manifest, "Furniture", "Oak Chair"),typeof(RugMultiTiledObject),Color.White,false),new BasicItemInformation("Simple Rug Test", "Omegasis.Revitalize.Furniture.Basic.Rugs.TestRug","A simple rug for testing","Rugs",Color.Brown,-300,0,false,500,Vector2.Zero,true,true,TextureManager.GetTexture(Manifest,"Furniture","Oak Chair"),new AnimationManager(),Color.White,true,null,null)); + rug.addComponent(new Vector2(0, 0), rug1); customObjects.Add("Omegasis.Revitalize.Furniture.Rugs.RugTest", rug); diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index a9ed5b0d..83b2a594 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -39,6 +39,9 @@ $(GamePath)\Mods\PyTK\PyTK.dll + + $(GamePath)\Mods\StardustCore\StardustCore.dll + @@ -60,11 +63,10 @@ - - + @@ -90,6 +92,7 @@ + @@ -104,6 +107,16 @@ - + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + \ No newline at end of file diff --git a/GeneralMods/Revitalize/manifest.json b/GeneralMods/Revitalize/manifest.json index 8ce50f03..5c46a2a6 100644 --- a/GeneralMods/Revitalize/manifest.json +++ b/GeneralMods/Revitalize/manifest.json @@ -6,5 +6,8 @@ "UniqueID": "Omegasis.Revitalize", "EntryDll": "Revitalize.dll", "MinimumApiVersion": "2.10.1", - "UpdateKeys": [] + "UpdateKeys": [], + "Dependencies": [ + { "UniqueID": "Omegasis.StardustCore" } + ] } diff --git a/GeneralMods/StardewMods.sln b/GeneralMods/StardewMods.sln index 7e30180b..0a8bcec3 100644 --- a/GeneralMods/StardewMods.sln +++ b/GeneralMods/StardewMods.sln @@ -76,6 +76,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vocalization", "Vocalizatio EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Revitalize", "Revitalize\Revitalize.csproj", "{44EF6CEC-FBF1-4B45-8135-81D4EBE84DDD}" + ProjectSection(ProjectDependencies) = postProject + {0756D36A-95C8-480D-8EA6-4584C03010C6} = {0756D36A-95C8-480D-8EA6-4584C03010C6} + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MapExampleRF1", "MapExampleRF1\MapExampleRF1.csproj", "{696CDAA9-295F-49F0-97F9-334F626EA137}" EndProject diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/V2/MusicPackV2.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/V2/MusicPackV2.cs index 099cc2a2..95719fc4 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/V2/MusicPackV2.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/V2/MusicPackV2.cs @@ -108,11 +108,6 @@ namespace StardewSymphonyRemastered.Framework.V2 //Clear out directory so that changes can be reflected. DirectoryInfo dataFolder = new DirectoryInfo(Path.Combine(this.ContentPack.DirectoryPath, this.DataFolderName)); - StardewSymphony.ModMonitor.Log(dataFolder.FullName); - foreach (FileInfo file in dataFolder.GetFiles()) - { - file.Delete(); - } foreach (var list in this.SongInformation.songs) { @@ -155,8 +150,7 @@ namespace StardewSymphonyRemastered.Framework.V2 { try { - Texture2D texture = this.ContentPack.LoadAsset("icon.png"); - return new Texture2DExtended(texture); + return new Texture2DExtended(this.ContentPack,"icon.png"); } catch (Exception err) { diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs index ea5f3fe0..d125e17d 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs @@ -51,11 +51,9 @@ namespace StardewSymphonyRemastered helper.Events.Display.MenuChanged += this.OnMenuChanged; - helper.Events.GameLoop.GameLaunched += this.OnGameLaunched; - musicManager = new MusicManagerV2(); - textureManager = new TextureManager(); + textureManager = new TextureManager("StardewSymphony"); this.LoadTextures(); menuChangedMusic = false; @@ -95,16 +93,6 @@ namespace StardewSymphonyRemastered musicManager.selectMusic(SongSpecificsV2.getCurrentConditionalString(), true); } - /// Raised after the game is launched, right before the first update tick. This happens once per game session (unrelated to loading saves). All mods are loaded and initialised at this point, so this is a good time to set up mod integrations. - /// The event sender. - /// The event arguments. - private void OnGameLaunched(object sender, GameLaunchedEventArgs e) - { - // Ran once all of the entry methods are ran. This will ensure that all custom music from other mods has been properly loaded in. - - - } - /// Raised after the player loads a save slot and the world is initialised. /// The event sender. /// The event arguments. @@ -222,7 +210,7 @@ namespace StardewSymphonyRemastered { Texture2DExtended LoadTexture(string name) { - return new Texture2DExtended(this.Helper.Content.Load($"assets/{name}")); + return new Texture2DExtended(this.Helper, this.ModManifest, $"assets/{name}"); } textureManager.addTexture("SaveIcon", LoadTexture("SaveIcon.png")); diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json index 6964a140..c60dc83a 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json @@ -1,7 +1,7 @@ { "Name": "Stardew Symphony Remastered", "Author": "Alpha_Omegasis", - "Version": "3.0.0", + "Version": "3.0.1", "Description": "Adding more music to the game one beep at a time. Now with streaming!", "UniqueID": "Omegasis.StardewSymphonyRemastered", "EntryDll": "StardewSymphonyRemastered.dll", diff --git a/GeneralMods/StardustCore/ModCore.cs b/GeneralMods/StardustCore/ModCore.cs index a0598504..72d4496b 100644 --- a/GeneralMods/StardustCore/ModCore.cs +++ b/GeneralMods/StardustCore/ModCore.cs @@ -32,13 +32,18 @@ namespace StardustCore SpriteFonts.initialize(); TextureManagers = new Dictionary(); - TextureManager = new TextureManager(); - TextureManager.addTexture("Test1", new Texture2DExtended(ModCore.ModHelper, Path.Combine("Content", "Graphics", "MultiTest", "Test1.png"))); - TextureManager.addTexture("Test2", new Texture2DExtended(ModCore.ModHelper, Path.Combine("Content", "Graphics", "MultiTest", "Test2.png"))); - TextureManager.addTexture("Test3", new Texture2DExtended(ModCore.ModHelper, Path.Combine("Content", "Graphics", "MultiTest", "Test3.png"))); + TextureManager = new TextureManager("StardustCore"); + TextureManager.addTexture("Test1", new Texture2DExtended(ModCore.ModHelper,Manifest,Path.Combine("Content", "Graphics", "MultiTest", "Test1.png"))); + TextureManager.addTexture("Test2", new Texture2DExtended(ModCore.ModHelper,Manifest, Path.Combine("Content", "Graphics", "MultiTest", "Test2.png"))); + TextureManager.addTexture("Test3", new Texture2DExtended(ModCore.ModHelper, Manifest,Path.Combine("Content", "Graphics", "MultiTest", "Test3.png"))); TextureManagers.Add(this.ModManifest.UniqueID, TextureManager); this.config = ModHelper.ReadConfig(); } + + public static void log(string message) + { + ModMonitor.Log(message); + } } } diff --git a/GeneralMods/StardustCore/UIUtilities/Texture2DExtended.cs b/GeneralMods/StardustCore/UIUtilities/Texture2DExtended.cs index 4e63a612..a9a9ca61 100644 --- a/GeneralMods/StardustCore/UIUtilities/Texture2DExtended.cs +++ b/GeneralMods/StardustCore/UIUtilities/Texture2DExtended.cs @@ -7,53 +7,120 @@ namespace StardustCore.UIUtilities { public class Texture2DExtended { - /********* - ** Accessors - *********/ - /// The underlying texture. - public Texture2D Texture { get; } + public string Name; + public Texture2D texture; + public string path; + public string modID; + public ContentSource source; + private readonly IModHelper helper; + private readonly IContentPack content; + public int Width + { + get + { + return this.texture.Width; + } + } + public int Height + { + get + { + return this.texture.Height; + } + } - /// The texture width. - public int Width => this.Texture.Width; - - /// The texture height. - public int Height => this.Texture.Height; - - - /********* - ** Public methods - *********/ /// Empty/null constructor. public Texture2DExtended() { - this.Texture = null; + this.Name = ""; + this.texture = null; + this.path = ""; + this.helper = null; + this.modID = ""; } + /// Construct an instance. - public Texture2DExtended(Texture2D texture) + /// The relative path to file on disk. See StardustCore.Utilities.getRelativePath(modname,path); + public Texture2DExtended(IModHelper helper, IManifest manifest, string path, ContentSource contentSource = ContentSource.ModFolder) { - this.Texture = texture; + this.Name = Path.GetFileNameWithoutExtension(path); + this.path = path; + this.texture = helper.Content.Load(path, contentSource); + this.helper = helper; + this.modID = manifest.UniqueID; + this.source = contentSource; } - public Texture2DExtended(IModHelper helper, string path, ContentSource contentSource = ContentSource.ModFolder) + public Texture2DExtended(IModHelper helper, string modID, string path, ContentSource contentSource = ContentSource.ModFolder) { - this.Texture = helper.Content.Load(path, contentSource); + this.Name = Path.GetFileNameWithoutExtension(path); + this.path = path; + this.texture = helper.Content.Load(path, contentSource); + this.helper = helper; + this.modID = modID; + this.source = contentSource; + } + + public Texture2DExtended(IContentPack ContentPack, IManifest manifest, string path) + { + this.Name = Path.GetFileNameWithoutExtension(path); + this.path = path; + this.texture = ContentPack.LoadAsset(path); + this.helper = null; + this.modID = manifest.UniqueID; + this.source = ContentSource.ModFolder; + } + public Texture2DExtended(IContentPack ContentPack, string modID, string path) + { + this.Name = Path.GetFileNameWithoutExtension(path); + this.path = path; + this.texture = ContentPack.LoadAsset(path); + this.helper = null; + this.modID = modID; + this.source = ContentSource.ModFolder; + } + + 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() { - Texture2D clone = new Texture2D(this.Texture.GraphicsDevice, this.Texture.Width, this.Texture.Height); - Color[] data = new Color[clone.Width * clone.Height]; - this.Texture.GetData(data); - clone.SetData(data); + 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!!!"); + } + } - return new Texture2DExtended(clone); + public IModHelper getHelper() + { + return this.helper; } /// Returns the actual 2D texture held by this wrapper class. public Texture2D getTexture() { - return this.Texture; + return this.texture; + } + + public void setTexure(Texture2D text) + { + this.texture = text; } } } diff --git a/GeneralMods/StardustCore/UIUtilities/TextureManager.cs b/GeneralMods/StardustCore/UIUtilities/TextureManager.cs index 8293bf81..2d3ec51f 100644 --- a/GeneralMods/StardustCore/UIUtilities/TextureManager.cs +++ b/GeneralMods/StardustCore/UIUtilities/TextureManager.cs @@ -1,14 +1,31 @@ using System; using System.Collections.Generic; +using System.IO; +using System.Linq; +using Microsoft.Xna.Framework.Graphics; +using StardewModdingAPI; namespace StardustCore.UIUtilities { public class TextureManager { + 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(); + } + + + public TextureManager(string Name, IContentPack ContentPack) + { + this.name = Name; this.textures = new Dictionary(); } @@ -25,7 +42,240 @@ namespace StardustCore.UIUtilities if (v.Key == name) return v.Value.Copy(); } - throw new Exception("Error, texture name not found!!! Name: "+name); + throw new Exception("Error, texture name not found!!!"); + } + + + /// + /// Content pack search. + /// + public void searchForTextures(IContentPack content, string RelativePath) + { + if (string.IsNullOrEmpty(RelativePath)) + { + string path = content.DirectoryPath; + this.searchDirectories(path, "", content); + } + else + { + string path = Path.Combine(content.DirectoryPath, RelativePath); + this.searchDirectories(path, RelativePath, content); + } + } + + /// + /// Non-Content pack search. + /// + public void searchForTextures(string RelativePath = "") + { + if (string.IsNullOrEmpty(RelativePath)) + { + string path = ModCore.ModHelper.DirectoryPath; + this.searchDirectories(path, "", ModCore.Manifest); + } + else + { + string path = Path.Combine(ModCore.ModHelper.DirectoryPath, RelativePath); + this.searchDirectories(path, RelativePath, ModCore.Manifest); + } + } + + /// + /// Searches for textures in the given path. Used to search for textures in extended mods. + /// + /// The absolute starting path to start looking + /// + public void searchForTextures(string ABSPath,IModHelper helper,IManifest manifest,string RelativePath = "") + { + if (string.IsNullOrEmpty(RelativePath)) + { + string path = ABSPath; + this.searchDirectories(path, "", manifest); + } + else + { + string path = Path.Combine(ABSPath, RelativePath); + this.searchDirectories(path, RelativePath, manifest); + } + } + /// + /// Used to search through a mod's directories for textures. + /// + /// The mod's SMAPI helper object. + /// The mod's SMAPI manifest object. + /// The relative starting path. + public void searchForTextures(IModHelper helper, IManifest manifest, string RelativePath = "") + { + if (string.IsNullOrEmpty(RelativePath)) + { + string path = helper.DirectoryPath; + this.searchDirectories(path, "",helper,manifest); + } + else + { + string path = Path.Combine(helper.DirectoryPath, RelativePath); + this.searchDirectories(path, RelativePath,helper ,manifest); + } + } + /// + /// Used to search the directories of a mod that has been extended from Stardust Core. + /// + /// The path to the manifest's directory path + /// + /// + /// + private void searchDirectories(string path, string relativePath, IModHelper helper,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, helper,manifest); + } + + foreach (string file in files) + { + if (extensions.Contains(Path.GetExtension(file))) + { + this.processFoundTexture(file, relativePath,helper,manifest); + //StardustCore.ModCore.ModMonitor.Log("Found a texture!: "+Path.GetFileNameWithoutExtension(file)); + } + } + + } + + 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); + //StardustCore.ModCore.ModMonitor.Log("Found a texture!: "+Path.GetFileNameWithoutExtension(file)); + } + } + + } + 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); + //StardustCore.ModCore.ModMonitor.Log("Found a texture!: " + Path.GetFileNameWithoutExtension(file)); + } + } + + } + + 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 ,IModHelper Helper, IManifest Manifest) + { + Texture2DExtended textureExtended = new Texture2DExtended(Helper, Manifest, Path.Combine(relativePath, Path.GetFileName(file))); + + ModCore.log("Found texture: " + textureExtended.Name); + + textureExtended.texture.Name = 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]; + } + + public static Texture2D GetTexture(IManifest Manifest, string ManagerName, string TextureName) + { + return GetTextureManager(Manifest, ManagerName).getTexture(TextureName).texture; + } + public static Texture2DExtended GetExtendedTexture(IManifest Manifest, string ManagerName, string TextureName) + { + return GetTextureManager(Manifest, ManagerName).getTexture(TextureName); } } } diff --git a/GeneralMods/StardustCore/manifest.json b/GeneralMods/StardustCore/manifest.json index 78b5f7a6..901157d5 100644 --- a/GeneralMods/StardustCore/manifest.json +++ b/GeneralMods/StardustCore/manifest.json @@ -1,7 +1,7 @@ { "Name": "StardustCore", "Author": "Alpha_Omegasis", - "Version": "2.2.0", + "Version": "2.2.1", "Description": "A core mod that allows for other mods of mine to be run.", "UniqueID": "Omegasis.StardustCore", "EntryDll": "StardustCore.dll",