diff --git a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs index c6903062..271d3e6d 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/CraftingRecipeBook.cs @@ -6,6 +6,7 @@ using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; using Revitalize.Framework.Menus; +using Revitalize.Framework.Objects; using Revitalize.Framework.Objects.Machines; using Revitalize.Framework.Utilities; using StardewValley; @@ -257,6 +258,43 @@ namespace Revitalize.Framework.Crafting } InitializeRecipeBooks(); + + + for(int bookIndex=0;bookIndex pair = CraftingRecipesByGroup.ElementAt(bookIndex); + for(int recipeIndex=0;recipeIndex recipe = pair.Value.craftingRecipes.ElementAt(recipeIndex); + for (int i = 0; i < recipe.Value.recipe.ingredients.Count; i++) + { + if (recipe.Value.recipe.ingredients[i].item is MultiTiledObject) + { + ModCore.log("Found a multi tiled object as an output!"); + //ModCore.log("Found a multi tiled object!"); + Type t = recipe.Value.recipe.ingredients[i].item.GetType(); + string id = (recipe.Value.recipe.ingredients[i].item as MultiTiledObject).info.id; + recipe.Value.recipe.ingredients[i].item = ModCore.ObjectManager.getItemByIDAndType(id, t); + } + } + for (int i = 0; i < recipe.Value.recipe.outputs.Count; i++) + { + if (recipe.Value.recipe.outputs[i].item is MultiTiledObject) + { + ModCore.log("Found a multi tiled object as an output!"); + //ModCore.log("Found a multi tiled object!"); + Type t = recipe.Value.recipe.outputs[i].item.GetType(); + string id = (recipe.Value.recipe.outputs[i].item as MultiTiledObject).info.id; + recipe.Value.recipe.outputs[i].item = ModCore.ObjectManager.getItemByIDAndType(id, t); + + ModCore.log("Components are: "+(recipe.Value.recipe.outputs[i].item as MultiTiledObject).objects.Count); + } + } + } + } + + } private static void InitializeRecipeBooks() diff --git a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs index 475019e5..af8db6e5 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs @@ -19,15 +19,10 @@ namespace Revitalize.Framework.Crafting /// public List outputs; - /// - /// The item that is displayed for the crafting recipe. - /// - private Item displayItem; public Item DisplayItem { - get => this.displayItem ?? this.outputs.ElementAt(0).item; - set => this.displayItem = value; + get => this.outputs.ElementAt(0).item; } /// @@ -57,7 +52,6 @@ namespace Revitalize.Framework.Crafting public Recipe(List inputs, CraftingRecipeComponent output, StatCost StatCost = null,int TimeToCraft=0) { this.ingredients = inputs; - this.DisplayItem = output.item; this.outputDescription = output.item.getDescription(); this.outputName = output.item.DisplayName; this.outputs = new List() @@ -74,7 +68,6 @@ namespace Revitalize.Framework.Crafting this.outputs = outputs; this.outputName = OutputName; this.outputDescription = OutputDescription; - this.DisplayItem = DisplayItem; this.statCost = StatCost ?? new StatCost(); this.timeToCraft = TimeToCraft; } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs index afc140fa..f081be7a 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs @@ -213,7 +213,10 @@ namespace Revitalize.Framework.Objects { this.updateInfo(); foreach (KeyValuePair pair in this.objects) - pair.Value.drawInMenu(spriteBatch, location + (pair.Key * 16)+new Vector2(32,32), 1.0f, transparency, layerDepth, drawStackNumber, c, drawShadow); + { + //ModCore.log(location + (pair.Key * 16) + new Vector2(32, 32)); + pair.Value.drawInMenu(spriteBatch, location + (pair.Key * 16) + new Vector2(32, 32), 1.0f, transparency, layerDepth, drawStackNumber, c, drawShadow); + } //base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, c, drawShadow); } @@ -366,7 +369,7 @@ namespace Revitalize.Framework.Objects Dictionary objs = new Dictionary(); foreach (var pair in this.objects) { - objs.Add(pair.Key, (MultiTiledComponent)pair.Value); + objs.Add(pair.Key, (MultiTiledComponent)pair.Value.getOne()); } return new MultiTiledObject(this.data, this.info.Copy(), this.TileLocation, objs); } diff --git a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs index fd630ab9..902b8cba 100644 --- a/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs +++ b/GeneralMods/Revitalize/Framework/Objects/ObjectManager.cs @@ -356,13 +356,13 @@ namespace Revitalize.Framework.Objects /// /// /// - public CustomObject GetItem(string Key,int Stack=1) + public Item GetItem(string Key,int Stack=1) { if (this.ItemsByName.ContainsKey(Key)) { Item I= this.ItemsByName[Key].getOne(); I.Stack = Stack; - return (CustomObject)I; + return I; } else { diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index b8d69715..195560b2 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -330,20 +330,16 @@ namespace Revitalize */ if (e.Button == SButton.U) { - MultiTiledObject test =(MultiTiledObject) ObjectManager.GetItem("SandBox"); - test.EnergyManager.maxEnergy = 100; - test.EnergyManager.produceEnergy(100); - MachineSummaryMenu m= new Framework.Menus.Machines.MachineSummaryMenu((Game1.viewport.Width/2)-400, 48, 800, 600,Color.White,test); - InventoryTransferMenu transferMenu = new InventoryTransferMenu(100, 150, 500, 600, test.info.inventory.items, 36); - MachineMenu machineMenu = new MachineMenu((Game1.viewport.Width / 2) - 400, 0, 800, 600); - CraftingMenuV1 craftingMenu= new Framework.Menus.CraftingMenuV1(100, 100, 400, 700, Color.White, Game1.player.Items); - - machineMenu.addInMenuTab("Summary",new AnimatedButton(new StardustCore.Animations.AnimatedSprite("SummaryTab",new Vector2(),new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest,"Menus","MenuTab"),new Animation(0,0,24,24)),Color.White),new Rectangle(0,0,24,24),2f),m,true); - machineMenu.addInMenuTab("Inventory", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Inventory Tab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), transferMenu, true); - machineMenu.addInMenuTab("Crafting", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Crafting Tab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), craftingMenu, true); - - - if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = machineMenu; + CraftingMenuV1 craft = new CraftingMenuV1(100, 100, 600, 800, Color.White, Game1.player.Items); + craft.addInCraftingPageTab("Default", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f)); + craft.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new List() + { + //Inputs here + new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot"),20) + }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Anvil"), 1)),null,new Vector2(),new Rectangle(0,0,32,32),1f,false,Color.White),"Default"); + craft.currentTab = "Default"; + craft.sortRecipes(); + Game1.activeClickableMenu = craft; } /* if (e.Button == SButton.Y) diff --git a/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs b/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs index 6780eac0..729e823f 100644 --- a/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs +++ b/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs @@ -108,7 +108,7 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons { //this.background.draw(b); //if(this.item!=null)this.item.drawInMenu(b, this.position, this.scale); - this.draw(b, 1f, Alpha, false); + this.draw(b, 0f, Alpha, false); } @@ -122,11 +122,10 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons public void draw(SpriteBatch b,float Depth, float Alpha,bool DrawShadow) { if(this.background!=null)this.background.draw(b, this.scale, Depth,Alpha); - if (this.item == null) + if (this.item != null) { - ModCore.log("ITEM IS NULL!!!!"); + this.item.drawInMenu(b, this.position, 1f, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow); } - if(this.item!=null)this.item.drawInMenu(b, this.position, 1f,Alpha,Depth,this.drawStackNumber,this.drawColor,DrawShadow); } /// @@ -140,10 +139,9 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons public void draw(SpriteBatch b,Vector2 Position ,float Depth, float Alpha, bool DrawShadow) { if (this.background != null) this.background.draw(b,Position,this.scale, Depth, Alpha); - if (this.item != null) this.item.drawInMenu(b, Position, 1f, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow); - if (this.item == null) + if (this.item != null) { - ModCore.log("ITEM IS NULL!!!!"); + this.item.drawInMenu(b, Position, 1f, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow); } } @@ -151,10 +149,6 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons { this.background.draw(b, this.scale, Depth, Alpha); if (this.item != null) this.item.drawInMenu(b, this.position, ItemScale, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow); - if (this.item == null) - { - ModCore.log("ITEM IS NULL!!!!"); - } } /// @@ -167,10 +161,6 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons /// Should the shadow be drawn for the item? public void drawJustItem(SpriteBatch b,float Scale,float Depth, float Alpha, bool DrawShadow) { - if (this.item == null) - { - ModCore.log("ITEM IS NULL!!!!"); - } if (this.item != null) this.item.drawInMenu(b, this.position, Scale, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow); }