From 010e705b6a2a9dddafb4456ae60993942fdc4aeb Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Tue, 3 Sep 2019 15:12:34 -0700 Subject: [PATCH] Got crafting recipes page to sort itself. --- .../Framework/Menus/CraftingMenuV1.cs | 20 ++++++++++++++ GeneralMods/Revitalize/ModCore.cs | 27 ++++++++++--------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs index e312a96b..5b466029 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs @@ -17,6 +17,9 @@ namespace Revitalize.Framework.Menus /// /// All the different pages for crafting. + /// + /// Sort recipes by recipe name. + /// Add in search box /// public Dictionary CraftingTabs; @@ -138,6 +141,23 @@ namespace Revitalize.Framework.Menus this.rightButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Right Button", new Vector2(this.xPositionOnScreen + this.width, this.yPositionOnScreen), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "NextPageButton"), new StardustCore.Animations.Animation(0, 0, 32, 32)), Color.White), new Rectangle(0, 0, 32, 32), 2f); } + public void sortRecipes() + { + foreach(KeyValuePair> pair in this.craftingItemsToDisplay) + { + List copy = pair.Value.ToList(); + pair.Value.Clear(); + + copy=copy.OrderBy(x => x.displayItem.item.DisplayName).ToList(); + foreach(CraftingRecipeButton b in copy) + { + this.addInCraftingRecipe(b, pair.Key); + } + } + + + } + public void addInCraftingPageTab(string name, AnimatedButton Button) { int count = this.CraftingTabs.Count; diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 5c0b67b4..3587ebd7 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -335,7 +335,12 @@ namespace Revitalize { //Inputs here {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, - }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0,0,16,16), 4f, true, Color.White),"Default"); + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.Wool, 1), 1)), null, new Vector2(), new Rectangle(0,0,16,16), 4f, true, Color.White),"Default"); + menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() + { + //Inputs here + {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.FairyRose, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() { //Inputs here @@ -345,45 +350,41 @@ namespace Revitalize { //Inputs here {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, - }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.OakResin, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() { //Inputs here {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, - }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.ChocolateCake, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() { //Inputs here {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, - }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.QualitySprinkler, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() { //Inputs here {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, - }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.JackOLantern, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() { //Inputs here {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, - }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.WildPlum, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() { //Inputs here {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, - }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.Egg, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() { //Inputs here {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, - }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); - menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() - { - //Inputs here - {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, - }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.BakedFish, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default"); menu.currentTab = "Default"; + menu.sortRecipes(); if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = menu; }