Got crafting recipes page to sort itself.

This commit is contained in:
JoshuaNavarro 2019-09-03 15:12:34 -07:00
parent cbf2efc690
commit 010e705b6a
2 changed files with 34 additions and 13 deletions

View File

@ -17,6 +17,9 @@ namespace Revitalize.Framework.Menus
/// <summary> /// <summary>
/// All the different pages for crafting. /// All the different pages for crafting.
///
/// Sort recipes by recipe name.
/// Add in search box
/// </summary> /// </summary>
public Dictionary<string, AnimatedButton> CraftingTabs; public Dictionary<string, AnimatedButton> 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); 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<string,List<CraftingRecipeButton>> pair in this.craftingItemsToDisplay)
{
List<CraftingRecipeButton> 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) public void addInCraftingPageTab(string name, AnimatedButton Button)
{ {
int count = this.CraftingTabs.Count; int count = this.CraftingTabs.Count;

View File

@ -335,7 +335,12 @@ namespace Revitalize
{ {
//Inputs here //Inputs here
{new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 },
}, new KeyValuePair<Item, int>(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<Item, int>(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<Item, int>()
{
//Inputs here
{new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 },
}, new KeyValuePair<Item, int>(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<Item, int>() menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary<Item, int>()
{ {
//Inputs here //Inputs here
@ -345,45 +350,41 @@ namespace Revitalize
{ {
//Inputs here //Inputs here
{new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 },
}, new KeyValuePair<Item, int>(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<Item, int>(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<Item, int>() menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary<Item, int>()
{ {
//Inputs here //Inputs here
{new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 },
}, new KeyValuePair<Item, int>(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<Item, int>(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<Item, int>() menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary<Item, int>()
{ {
//Inputs here //Inputs here
{new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 },
}, new KeyValuePair<Item, int>(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<Item, int>(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<Item, int>() menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary<Item, int>()
{ {
//Inputs here //Inputs here
{new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 },
}, new KeyValuePair<Item, int>(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<Item, int>(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<Item, int>() menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary<Item, int>()
{ {
//Inputs here //Inputs here
{new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 },
}, new KeyValuePair<Item, int>(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<Item, int>(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<Item, int>() menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary<Item, int>()
{ {
//Inputs here //Inputs here
{new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 },
}, new KeyValuePair<Item, int>(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<Item, int>(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<Item, int>() menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary<Item, int>()
{ {
//Inputs here //Inputs here
{new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 },
}, new KeyValuePair<Item, int>(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<Item, int>(new StardewValley.Object((int)Enums.SDVObject.BakedFish, 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<Item, int>()
{
//Inputs here
{new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 },
}, new KeyValuePair<Item, int>(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 1), 1)), null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), "Default");
menu.currentTab = "Default"; menu.currentTab = "Default";
menu.sortRecipes();
if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = menu; if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = menu;
} }