Added left and right buttons to the crafting menu. Also centered item name text.
This commit is contained in:
parent
85592f1b53
commit
dd4b4a0ee3
|
@ -32,6 +32,8 @@ namespace Revitalize.Framework.Menus
|
||||||
|
|
||||||
public AnimatedButton craftingButton;
|
public AnimatedButton craftingButton;
|
||||||
|
|
||||||
|
public bool isPlayerInventory;
|
||||||
|
|
||||||
public Item actualItem
|
public Item actualItem
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -45,12 +47,13 @@ namespace Revitalize.Framework.Menus
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CraftingInformationPage(int x, int y, int width, int height,Color BackgroundColor,CraftingRecipeButton ItemToDisplay,ref IList<Item> Inventory) : base(x, y, width, height, false)
|
public CraftingInformationPage(int x, int y, int width, int height,Color BackgroundColor,CraftingRecipeButton ItemToDisplay,ref IList<Item> Inventory,bool IsPlayerInventory) : base(x, y, width, height, false)
|
||||||
{
|
{
|
||||||
this.backgroundColor = BackgroundColor;
|
this.backgroundColor = BackgroundColor;
|
||||||
this.infoButton = ItemToDisplay;
|
this.infoButton = ItemToDisplay;
|
||||||
this.itemDisplayLocation = new Vector2(this.xPositionOnScreen + (this.width / 2) - 32, this.yPositionOnScreen + (128));
|
this.itemDisplayLocation = new Vector2(this.xPositionOnScreen + (this.width / 2) - 32, this.yPositionOnScreen + (128));
|
||||||
this.inventory = Inventory;
|
this.inventory = Inventory;
|
||||||
|
this.isPlayerInventory = IsPlayerInventory;
|
||||||
|
|
||||||
this.requiredItems = new Dictionary<ItemDisplayButton, int>();
|
this.requiredItems = new Dictionary<ItemDisplayButton, int>();
|
||||||
for (int i = 0; i < this.infoButton.recipe.ingredients.Count; i++)
|
for (int i = 0; i < this.infoButton.recipe.ingredients.Count; i++)
|
||||||
|
@ -69,6 +72,11 @@ namespace Revitalize.Framework.Menus
|
||||||
{
|
{
|
||||||
Game1.soundBank.PlayCue("coin");
|
Game1.soundBank.PlayCue("coin");
|
||||||
this.infoButton.craftItem();
|
this.infoButton.craftItem();
|
||||||
|
|
||||||
|
if (this.isPlayerInventory)
|
||||||
|
{
|
||||||
|
this.inventory = Game1.player.Items;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +86,7 @@ namespace Revitalize.Framework.Menus
|
||||||
this.drawDialogueBoxBackground(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, this.backgroundColor);
|
this.drawDialogueBoxBackground(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, this.backgroundColor);
|
||||||
this.infoButton.draw(b,this.itemDisplayLocation);
|
this.infoButton.draw(b,this.itemDisplayLocation);
|
||||||
|
|
||||||
b.DrawString(Game1.dialogueFont, this.actualItem.DisplayName, this.itemDisplayLocation + this.getHeightOffsetFromItem()-this.getItemNameOffset(), this.getNameColor());
|
b.DrawString(Game1.dialogueFont, this.actualItem.DisplayName,new Vector2(this.xPositionOnScreen+ (this.width/2),this.itemDisplayLocation.Y)+ this.getHeightOffsetFromItem()-this.getItemNameOffset(), this.getNameColor());
|
||||||
|
|
||||||
b.DrawString(Game1.smallFont, Game1.parseText(this.actualItem.getDescription(), Game1.smallFont, this.width),new Vector2(this.xPositionOnScreen+64,this.getItemDescriptionOffset().Y), Color.Black);
|
b.DrawString(Game1.smallFont, Game1.parseText(this.actualItem.getDescription(), Game1.smallFont, this.width),new Vector2(this.xPositionOnScreen+64,this.getItemDescriptionOffset().Y), Color.Black);
|
||||||
|
|
||||||
|
@ -150,7 +158,7 @@ namespace Revitalize.Framework.Menus
|
||||||
private Vector2 getItemNameOffset()
|
private Vector2 getItemNameOffset()
|
||||||
{
|
{
|
||||||
Vector2 length = Game1.dialogueFont.MeasureString(this.actualItem.DisplayName);
|
Vector2 length = Game1.dialogueFont.MeasureString(this.actualItem.DisplayName);
|
||||||
length.X = length.X / 4;
|
length.X = length.X / 2;
|
||||||
length.Y = 0;
|
length.Y = 0;
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ namespace Revitalize.Framework.Menus
|
||||||
|
|
||||||
public int currentPageIndex;
|
public int currentPageIndex;
|
||||||
public string currentTab;
|
public string currentTab;
|
||||||
public int currentScrollIndex;
|
|
||||||
|
|
||||||
public Color backgroundColor;
|
public Color backgroundColor;
|
||||||
|
|
||||||
|
@ -37,17 +36,39 @@ 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 = 4;
|
public int amountOfRecipesToShow = 6;
|
||||||
|
|
||||||
public bool playerInventory;
|
public bool playerInventory;
|
||||||
|
|
||||||
public CraftingInformationPage craftingInfo;
|
public CraftingInformationPage craftingInfo;
|
||||||
|
|
||||||
|
public AnimatedButton leftButton;
|
||||||
|
public AnimatedButton rightButton;
|
||||||
|
|
||||||
|
|
||||||
|
private int maxPages
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(this.currentTab)) return 0;
|
||||||
|
return (this.craftingItemsToDisplay[this.currentTab].Count / this.amountOfRecipesToShow) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public CraftingMenuV1() : base()
|
public CraftingMenuV1() : base()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor to be used when the inventory is the player's
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="X"></param>
|
||||||
|
/// <param name="Y"></param>
|
||||||
|
/// <param name="Width"></param>
|
||||||
|
/// <param name="Height"></param>
|
||||||
|
/// <param name="BackgroundColor"></param>
|
||||||
|
/// <param name="Inventory"></param>
|
||||||
public CraftingMenuV1(int X, int Y, int Width, int Height, Color BackgroundColor, IList<Item> Inventory) : base(X, Y, Width, Height, false)
|
public CraftingMenuV1(int X, int Y, int Width, int Height, Color BackgroundColor, IList<Item> Inventory) : base(X, Y, Width, Height, false)
|
||||||
{
|
{
|
||||||
this.backgroundColor = BackgroundColor;
|
this.backgroundColor = BackgroundColor;
|
||||||
|
@ -57,8 +78,18 @@ namespace Revitalize.Framework.Menus
|
||||||
this.fromInventory = Inventory;
|
this.fromInventory = Inventory;
|
||||||
this.toInventory = Inventory;
|
this.toInventory = Inventory;
|
||||||
this.playerInventory = true;
|
this.playerInventory = true;
|
||||||
|
this.initializeButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor to be used when inventory destination is the same and not the player.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="X"></param>
|
||||||
|
/// <param name="Y"></param>
|
||||||
|
/// <param name="Width"></param>
|
||||||
|
/// <param name="Height"></param>
|
||||||
|
/// <param name="BackgroundColor"></param>
|
||||||
|
/// <param name="Inventory"></param>
|
||||||
public CraftingMenuV1(int X, int Y, int Width, int Height, Color BackgroundColor, ref IList<Item> Inventory) : base(X, Y, Width, Height, false)
|
public CraftingMenuV1(int X, int Y, int Width, int Height, Color BackgroundColor, ref IList<Item> Inventory) : base(X, Y, Width, Height, false)
|
||||||
{
|
{
|
||||||
this.backgroundColor = BackgroundColor;
|
this.backgroundColor = BackgroundColor;
|
||||||
|
@ -67,8 +98,19 @@ namespace Revitalize.Framework.Menus
|
||||||
this.currentPageIndex = 0;
|
this.currentPageIndex = 0;
|
||||||
this.fromInventory = Inventory;
|
this.fromInventory = Inventory;
|
||||||
this.toInventory = Inventory;
|
this.toInventory = Inventory;
|
||||||
|
this.initializeButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Inventory constructor to be used when the input and output inventories are different.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="X"></param>
|
||||||
|
/// <param name="Y"></param>
|
||||||
|
/// <param name="Width"></param>
|
||||||
|
/// <param name="Height"></param>
|
||||||
|
/// <param name="BackgroundColor"></param>
|
||||||
|
/// <param name="FromInventory"></param>
|
||||||
|
/// <param name="ToInventory"></param>
|
||||||
public CraftingMenuV1(int X, int Y, int Width, int Height, Color BackgroundColor, ref IList<Item> FromInventory, ref IList<Item> ToInventory) : base(X, Y, Width, Height, false)
|
public CraftingMenuV1(int X, int Y, int Width, int Height, Color BackgroundColor, ref IList<Item> FromInventory, ref IList<Item> ToInventory) : base(X, Y, Width, Height, false)
|
||||||
{
|
{
|
||||||
this.backgroundColor = BackgroundColor;
|
this.backgroundColor = BackgroundColor;
|
||||||
|
@ -77,6 +119,23 @@ namespace Revitalize.Framework.Menus
|
||||||
this.currentPageIndex = 0;
|
this.currentPageIndex = 0;
|
||||||
this.fromInventory = FromInventory;
|
this.fromInventory = FromInventory;
|
||||||
this.toInventory = ToInventory;
|
this.toInventory = ToInventory;
|
||||||
|
this.initializeButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void gameWindowSizeChanged(Rectangle oldBounds, Rectangle newBounds)
|
||||||
|
{
|
||||||
|
base.gameWindowSizeChanged(oldBounds, newBounds);
|
||||||
|
if (this.craftingInfo != null)
|
||||||
|
{
|
||||||
|
this.craftingInfo.gameWindowSizeChanged(oldBounds, newBounds);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeButtons()
|
||||||
|
{
|
||||||
|
this.leftButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Left Button", new Vector2(this.xPositionOnScreen, this.yPositionOnScreen), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "PreviousPageButton"), 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 addInCraftingPageTab(string name, AnimatedButton Button)
|
public void addInCraftingPageTab(string name, AnimatedButton Button)
|
||||||
|
@ -89,7 +148,7 @@ namespace Revitalize.Framework.Menus
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Vector2 newPos = new Vector2(100 + (48) * (count + 1), 100 + (24 * 4) * (count + 1));
|
Vector2 newPos = new Vector2(100 + (48) * (count + 1), this.yPositionOnScreen + (24 * 4) * (count + 1));
|
||||||
Button.Position = newPos;
|
Button.Position = newPos;
|
||||||
this.CraftingTabs.Add(name, Button);
|
this.CraftingTabs.Add(name, Button);
|
||||||
this.craftingItemsToDisplay.Add(name, new List<CraftingRecipeButton>());
|
this.craftingItemsToDisplay.Add(name, new List<CraftingRecipeButton>());
|
||||||
|
@ -102,7 +161,7 @@ namespace Revitalize.Framework.Menus
|
||||||
if (this.craftingItemsToDisplay.ContainsKey(WhichTab))
|
if (this.craftingItemsToDisplay.ContainsKey(WhichTab))
|
||||||
{
|
{
|
||||||
int count = this.craftingItemsToDisplay.Count;
|
int count = this.craftingItemsToDisplay.Count;
|
||||||
Vector2 newPos = new Vector2(100 + (64) * (count + 1), 100 + (16 * 4) * (count + 1));
|
Vector2 newPos = new Vector2(this.xPositionOnScreen + (64) * (count + 1), this.yPositionOnScreen + (16 * 4) * (count + 1));
|
||||||
Button.displayItem.Position = newPos;
|
Button.displayItem.Position = newPos;
|
||||||
this.craftingItemsToDisplay[WhichTab].Add(Button);
|
this.craftingItemsToDisplay[WhichTab].Add(Button);
|
||||||
}
|
}
|
||||||
|
@ -155,11 +214,28 @@ namespace Revitalize.Framework.Menus
|
||||||
|
|
||||||
public override void receiveLeftClick(int x, int y, bool playSound = true)
|
public override void receiveLeftClick(int x, int y, bool playSound = true)
|
||||||
{
|
{
|
||||||
|
if (this.leftButton.containsPoint(x, y))
|
||||||
|
{
|
||||||
|
if (this.currentPageIndex <= 0) this.currentPageIndex = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.currentPageIndex--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.rightButton.containsPoint(x, y))
|
||||||
|
{
|
||||||
|
if (this.currentPageIndex+1 < this.maxPages)
|
||||||
|
{
|
||||||
|
this.currentPageIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach (KeyValuePair<string, AnimatedButton> pair in this.CraftingTabs)
|
foreach (KeyValuePair<string, AnimatedButton> pair in this.CraftingTabs)
|
||||||
{
|
{
|
||||||
if (pair.Value.containsPoint(x, y))
|
if (pair.Value.containsPoint(x, y))
|
||||||
{
|
{
|
||||||
this.currentTab = pair.Key;
|
this.currentTab = pair.Key;
|
||||||
|
this.currentPageIndex = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,7 +250,7 @@ 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);
|
||||||
this.craftingInfo = new CraftingInformationPage(this.xPositionOnScreen + this.width+this.xOffset, this.yPositionOnScreen, 400, this.height, this.backgroundColor, button,ref this.fromInventory);
|
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)
|
||||||
{
|
{
|
||||||
|
@ -198,6 +274,13 @@ namespace Revitalize.Framework.Menus
|
||||||
public override void draw(SpriteBatch b)
|
public override void draw(SpriteBatch b)
|
||||||
{
|
{
|
||||||
this.drawDialogueBoxBackground(this.xPositionOnScreen + this.xOffset, this.yPositionOnScreen, this.width, this.height, this.backgroundColor);
|
this.drawDialogueBoxBackground(this.xPositionOnScreen + this.xOffset, this.yPositionOnScreen, this.width, this.height, this.backgroundColor);
|
||||||
|
|
||||||
|
this.leftButton.draw(b);
|
||||||
|
//Draw page numbers here.
|
||||||
|
//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);
|
||||||
|
this.rightButton.draw(b);
|
||||||
|
|
||||||
//this.drawDialogueBoxBackground();
|
//this.drawDialogueBoxBackground();
|
||||||
foreach (KeyValuePair<string, AnimatedButton> pair in this.CraftingTabs)
|
foreach (KeyValuePair<string, AnimatedButton> pair in this.CraftingTabs)
|
||||||
{
|
{
|
||||||
|
@ -250,7 +333,7 @@ namespace Revitalize.Framework.Menus
|
||||||
|
|
||||||
public List<CraftingRecipeButton> getRecipeButtonsToDisplay()
|
public List<CraftingRecipeButton> getRecipeButtonsToDisplay()
|
||||||
{
|
{
|
||||||
List<CraftingRecipeButton> buttonsToDraw = this.craftingItemsToDisplay[this.currentTab].GetRange(this.currentScrollIndex, Math.Min(this.craftingItemsToDisplay[this.currentTab].Count, this.amountOfRecipesToShow));
|
List<CraftingRecipeButton> buttonsToDraw = this.craftingItemsToDisplay[this.currentTab].GetRange(this.currentPageIndex* this.amountOfRecipesToShow, Math.Min(this.craftingItemsToDisplay[this.currentTab].Count, this.amountOfRecipesToShow));
|
||||||
return buttonsToDraw;
|
return buttonsToDraw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -199,6 +199,8 @@ namespace Revitalize
|
||||||
-Earings
|
-Earings
|
||||||
-Pendants
|
-Pendants
|
||||||
|
|
||||||
|
|
||||||
|
make chat notification when people are sleeping
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ModCore : Mod
|
public class ModCore : Mod
|
||||||
|
@ -326,7 +328,7 @@ namespace Revitalize
|
||||||
if (e.Button == SButton.U)
|
if (e.Button == SButton.U)
|
||||||
{
|
{
|
||||||
|
|
||||||
CraftingMenuV1 menu= new Framework.Menus.CraftingMenuV1(100, 0, 400, 800, Color.White, Game1.player.Items);
|
CraftingMenuV1 menu= new Framework.Menus.CraftingMenuV1(100, 100, 400, 700, Color.White, Game1.player.Items);
|
||||||
menu.addInCraftingPageTab("Default",new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f));
|
menu.addInCraftingPageTab("Default",new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f));
|
||||||
|
|
||||||
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>()
|
||||||
|
|
Loading…
Reference in New Issue