Fixed paging issue for crafting menu not going to the right page.
This commit is contained in:
parent
dd4b4a0ee3
commit
cbf2efc690
|
@ -36,7 +36,7 @@ namespace Revitalize.Framework.Menus
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// How many crafting recipes to display at a time.
|
/// How many crafting recipes to display at a time.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int amountOfRecipesToShow = 6;
|
public int amountOfRecipesToShow = 9;
|
||||||
|
|
||||||
public bool playerInventory;
|
public bool playerInventory;
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ namespace Revitalize.Framework.Menus
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(this.currentTab)) return 0;
|
if (string.IsNullOrEmpty(this.currentTab)) return 0;
|
||||||
return (this.craftingItemsToDisplay[this.currentTab].Count / this.amountOfRecipesToShow) + 1;
|
return (int)(Math.Ceiling((double)(this.craftingItemsToDisplay[this.currentTab].Count / this.amountOfRecipesToShow)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,8 +160,8 @@ namespace Revitalize.Framework.Menus
|
||||||
{
|
{
|
||||||
if (this.craftingItemsToDisplay.ContainsKey(WhichTab))
|
if (this.craftingItemsToDisplay.ContainsKey(WhichTab))
|
||||||
{
|
{
|
||||||
int count = this.craftingItemsToDisplay.Count;
|
int count = this.craftingItemsToDisplay[WhichTab].Count % this.amountOfRecipesToShow;
|
||||||
Vector2 newPos = new Vector2(this.xPositionOnScreen + (64) * (count + 1), this.yPositionOnScreen + (16 * 4) * (count + 1));
|
Vector2 newPos = new Vector2(this.xPositionOnScreen + (128), (this.yPositionOnScreen + 64) + (64 * (count + 1)));
|
||||||
Button.displayItem.Position = newPos;
|
Button.displayItem.Position = newPos;
|
||||||
this.craftingItemsToDisplay[WhichTab].Add(Button);
|
this.craftingItemsToDisplay[WhichTab].Add(Button);
|
||||||
}
|
}
|
||||||
|
@ -171,14 +171,8 @@ namespace Revitalize.Framework.Menus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void receiveScrollWheelAction(int direction)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void performHoverAction(int x, int y)
|
public override void performHoverAction(int x, int y)
|
||||||
{
|
{
|
||||||
|
|
||||||
bool hovered = false;
|
bool hovered = false;
|
||||||
foreach (KeyValuePair<string, AnimatedButton> pair in this.CraftingTabs)
|
foreach (KeyValuePair<string, AnimatedButton> pair in this.CraftingTabs)
|
||||||
{
|
{
|
||||||
|
@ -203,13 +197,10 @@ namespace Revitalize.Framework.Menus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (hovered == false)
|
if (hovered == false)
|
||||||
{
|
{
|
||||||
this.hoverText = "";
|
this.hoverText = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void receiveLeftClick(int x, int y, bool playSound = true)
|
public override void receiveLeftClick(int x, int y, bool playSound = true)
|
||||||
|
@ -220,13 +211,15 @@ namespace Revitalize.Framework.Menus
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.currentPageIndex--;
|
this.currentPageIndex--;
|
||||||
|
Game1.playSound("shwip");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.rightButton.containsPoint(x, y))
|
if (this.rightButton.containsPoint(x, y))
|
||||||
{
|
{
|
||||||
if (this.currentPageIndex+1 < this.maxPages)
|
if (this.currentPageIndex < this.maxPages)
|
||||||
{
|
{
|
||||||
this.currentPageIndex++;
|
this.currentPageIndex++;
|
||||||
|
Game1.playSound("shwip");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,6 +243,12 @@ namespace Revitalize.Framework.Menus
|
||||||
if (button.containsPoint(x, y))
|
if (button.containsPoint(x, y))
|
||||||
{
|
{
|
||||||
//button.craftItem(this.fromInventory, this.toInventory);
|
//button.craftItem(this.fromInventory, this.toInventory);
|
||||||
|
|
||||||
|
if (this.playerInventory)
|
||||||
|
{
|
||||||
|
this.fromInventory = Game1.player.Items;
|
||||||
|
}
|
||||||
|
|
||||||
this.craftingInfo = new CraftingInformationPage(this.xPositionOnScreen + this.width + this.xOffset, this.yPositionOnScreen, 400, this.height, this.backgroundColor, button, ref this.fromInventory, this.playerInventory);
|
this.craftingInfo = new CraftingInformationPage(this.xPositionOnScreen + this.width + this.xOffset, this.yPositionOnScreen, 400, this.height, this.backgroundColor, button, ref this.fromInventory, this.playerInventory);
|
||||||
Game1.soundBank.PlayCue("coin");
|
Game1.soundBank.PlayCue("coin");
|
||||||
if (this.playerInventory)
|
if (this.playerInventory)
|
||||||
|
@ -278,7 +277,7 @@ namespace Revitalize.Framework.Menus
|
||||||
this.leftButton.draw(b);
|
this.leftButton.draw(b);
|
||||||
//Draw page numbers here.
|
//Draw page numbers here.
|
||||||
//b.DrawString(Game1.smallFont,"Page: "+this.currentPageIndex.ToString()/)
|
//b.DrawString(Game1.smallFont,"Page: "+this.currentPageIndex.ToString()/)
|
||||||
b.DrawString(Game1.dialogueFont, ("Page: " + (this.currentPageIndex + 1) + " / " + this.maxPages).ToString(), new Vector2(this.xPositionOnScreen+128, this.yPositionOnScreen), Color.White);
|
b.DrawString(Game1.dialogueFont, ("Page: " + (this.currentPageIndex + 1) + " / " + (this.maxPages+1)).ToString(), new Vector2(this.xPositionOnScreen + 128, this.yPositionOnScreen), Color.White);
|
||||||
this.rightButton.draw(b);
|
this.rightButton.draw(b);
|
||||||
|
|
||||||
//this.drawDialogueBoxBackground();
|
//this.drawDialogueBoxBackground();
|
||||||
|
@ -333,7 +332,10 @@ namespace Revitalize.Framework.Menus
|
||||||
|
|
||||||
public List<CraftingRecipeButton> getRecipeButtonsToDisplay()
|
public List<CraftingRecipeButton> getRecipeButtonsToDisplay()
|
||||||
{
|
{
|
||||||
List<CraftingRecipeButton> buttonsToDraw = this.craftingItemsToDisplay[this.currentTab].GetRange(this.currentPageIndex* this.amountOfRecipesToShow, Math.Min(this.craftingItemsToDisplay[this.currentTab].Count, this.amountOfRecipesToShow));
|
|
||||||
|
int amount = this.craftingItemsToDisplay[this.currentTab].Count / this.amountOfRecipesToShow;
|
||||||
|
int min = this.currentPageIndex == amount ? this.craftingItemsToDisplay[this.currentTab].Count % this.amountOfRecipesToShow : this.amountOfRecipesToShow;
|
||||||
|
List<CraftingRecipeButton> buttonsToDraw = this.craftingItemsToDisplay[this.currentTab].GetRange(this.currentPageIndex * this.amountOfRecipesToShow, min);
|
||||||
return buttonsToDraw;
|
return buttonsToDraw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -336,6 +336,53 @@ 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.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<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.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.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.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.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.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.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.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.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";
|
||||||
|
|
||||||
if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = menu;
|
if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = menu;
|
||||||
|
|
Loading…
Reference in New Issue