Updated the custom game menu so now more tabs and pages can be added! This will allow me to do a whole lot more with modded menus!

This commit is contained in:
2017-06-05 23:33:43 -07:00
parent 47beace46f
commit dbd11117b9
7 changed files with 421 additions and 132 deletions

View File

@ -312,7 +312,7 @@ namespace Revitalize
{ {
// System.Threading.Thread.Sleep(1); // System.Threading.Thread.Sleep(1);
// Game1.activeClickableMenu = new Revitalize.Menus.GameMenu(); Game1.activeClickableMenu = new Revitalize.Menus.GameMenu();
} }
gametick = false; gametick = false;

View File

@ -81,6 +81,8 @@ namespace Revitalize.Menus
private string hoverText = ""; private string hoverText = "";
bool flipFlop;
public BluePrint CurrentBlueprint public BluePrint CurrentBlueprint
{ {
get get
@ -302,7 +304,7 @@ namespace Revitalize.Menus
this.hoverText = Game1.content.LoadString("Strings\\UI:Carpenter_MoveBuildings", new object[0]); this.hoverText = Game1.content.LoadString("Strings\\UI:Carpenter_MoveBuildings", new object[0]);
return; return;
} }
if (this.okButton.containsPoint(x, y) && this.CurrentBlueprint.doesFarmerHaveEnoughResourcesToBuild()) if (this.okButton.containsPoint(x, y) )
{ {
this.hoverText = Game1.content.LoadString("Strings\\UI:Carpenter_Build", new object[0]); this.hoverText = Game1.content.LoadString("Strings\\UI:Carpenter_Build", new object[0]);
return; return;
@ -338,6 +340,20 @@ namespace Revitalize.Menus
public override void receiveKeyPress(Keys key) public override void receiveKeyPress(Keys key)
{ {
KeyboardState newState = Keyboard.GetState();
// Is the SPACE key down?
if (newState.IsKeyDown(Keys.T))
{
if (flipFlop == false)
{
if (this.drawBG) this.drawBG = false;
else this.drawBG = true;
flipFlop = true;
}
}
if (this.freeze) if (this.freeze)
{ {
return; return;
@ -381,6 +397,12 @@ namespace Revitalize.Menus
public override void update(GameTime time) public override void update(GameTime time)
{ {
base.update(time); base.update(time);
KeyboardState newState = Keyboard.GetState();
if (flipFlop == true && newState.IsKeyUp(Keys.T))
{
flipFlop = false;
}
if (this.onFarm && !Game1.globalFade) if (this.onFarm && !Game1.globalFade)
{ {
int num = Game1.getOldMouseX() + Game1.viewport.X; int num = Game1.getOldMouseX() + Game1.viewport.X;
@ -410,6 +432,8 @@ namespace Revitalize.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.freeze) if (this.freeze)
@ -472,7 +496,7 @@ namespace Revitalize.Menus
this.onFarm = true; this.onFarm = true;
this.moving = true; this.moving = true;
} }
if (this.okButton.containsPoint(x, y) && !this.onFarm && Game1.player.money >= this.price && this.blueprints[this.currentBlueprintIndex].doesFarmerHaveEnoughResourcesToBuild()) if (this.okButton.containsPoint(x, y) && !this.onFarm && Game1.player.money >= this.price )
{ {
Game1.globalFadeToBlack(new Game1.afterFadeFunction(this.setUpForBuildingPlacement), 0.02f); Game1.globalFadeToBlack(new Game1.afterFadeFunction(this.setUpForBuildingPlacement), 0.02f);
Game1.playSound("smallSelect"); Game1.playSound("smallSelect");
@ -511,7 +535,7 @@ namespace Revitalize.Menus
Building buildingAt2 = ((Farm)Game1.getLocationFromName("Farm")).getBuildingAt(new Vector2((float)((Game1.viewport.X + Game1.getOldMouseX()) / Game1.tileSize), (float)((Game1.viewport.Y + Game1.getOldMouseY()) / Game1.tileSize))); Building buildingAt2 = ((Farm)Game1.getLocationFromName("Farm")).getBuildingAt(new Vector2((float)((Game1.viewport.X + Game1.getOldMouseX()) / Game1.tileSize), (float)((Game1.viewport.Y + Game1.getOldMouseY()) / Game1.tileSize)));
if (buildingAt2 != null && this.CurrentBlueprint.name != null && buildingAt2.buildingType.Equals(this.CurrentBlueprint.nameOfBuildingToUpgrade)) if (buildingAt2 != null && this.CurrentBlueprint.name != null && buildingAt2.buildingType.Equals(this.CurrentBlueprint.nameOfBuildingToUpgrade))
{ {
this.CurrentBlueprint.consumeResources();
buildingAt2.daysUntilUpgrade = 2; buildingAt2.daysUntilUpgrade = 2;
buildingAt2.showUpgradeAnimation(Game1.getFarm()); buildingAt2.showUpgradeAnimation(Game1.getFarm());
Game1.playSound("axe"); Game1.playSound("axe");
@ -565,6 +589,7 @@ namespace Revitalize.Menus
} }
*/ */
Game1.addHUDMessage(new HUDMessage(Game1.currentCursorTile.ToString(), Color.Red, 3500f)); Game1.addHUDMessage(new HUDMessage(Game1.currentCursorTile.ToString(), Color.Red, 3500f));
Game1.currentLocation.removeObject(Game1.currentCursorTile, false);
//Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\UI:Carpenter_CantBuild", new object[0]), Color.Red, 3500f)); //Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\UI:Carpenter_CantBuild", new object[0]), Color.Red, 3500f));
} }
} }
@ -647,7 +672,7 @@ namespace Revitalize.Menus
{ {
Game1.currentLocation.cleanupBeforePlayerExit(); Game1.currentLocation.cleanupBeforePlayerExit();
this.hoverText = ""; this.hoverText = "";
Game1.currentLocation = Game1.getLocationFromName("Town"); Game1.currentLocation = Game1.getLocationFromName("Farm");
Game1.currentLocation.resetForPlayerEntry(); Game1.currentLocation.resetForPlayerEntry();
Game1.globalFadeToClear(null, 0.02f); Game1.globalFadeToClear(null, 0.02f);
this.onFarm = true; this.onFarm = true;
@ -673,7 +698,7 @@ namespace Revitalize.Menus
public override void draw(SpriteBatch b) public override void draw(SpriteBatch b)
{ {
if (this.drawBG) if (this.drawBG)
{ {
b.Draw(Game1.fadeToBlackRect, Game1.graphics.GraphicsDevice.Viewport.Bounds, Color.Black * 0.5f); b.Draw(Game1.fadeToBlackRect, Game1.graphics.GraphicsDevice.Viewport.Bounds, Color.Black * 0.5f);
} }
@ -732,7 +757,7 @@ namespace Revitalize.Menus
} }
this.backButton.draw(b); this.backButton.draw(b);
this.forwardButton.draw(b); this.forwardButton.draw(b);
this.okButton.draw(b, this.blueprints[this.currentBlueprintIndex].doesFarmerHaveEnoughResourcesToBuild() ? Color.White : (Color.Gray * 0.8f), 0.88f); this.okButton.draw(b, Color.White , 0.88f);
this.demolishButton.draw(b); this.demolishButton.draw(b);
this.moveButton.draw(b); this.moveButton.draw(b);
} }
@ -788,6 +813,163 @@ namespace Revitalize.Menus
public override void receiveRightClick(int x, int y, bool playSound = true) public override void receiveRightClick(int x, int y, bool playSound = true)
{ {
if (this.freeze)
{
return;
}
if (!this.onFarm)
{
base.receiveLeftClick(x, y, playSound);
}
if (this.cancelButton.containsPoint(x, y))
{
if (!this.onFarm)
{
base.exitThisMenu(true);
Game1.player.forceCanMove();
Game1.playSound("bigDeSelect");
}
else
{
if (this.moving && this.buildingToMove != null)
{
Game1.playSound("cancel");
return;
}
Game1.globalFadeToBlack(new Game1.afterFadeFunction(this.returnToCarpentryMenu), 0.02f);
Game1.playSound("smallSelect");
return;
}
}
if (!this.onFarm && this.backButton.containsPoint(x, y))
{
this.currentBlueprintIndex--;
if (this.currentBlueprintIndex < 0)
{
this.currentBlueprintIndex = this.blueprints.Count - 1;
}
this.setNewActiveBlueprint();
Game1.playSound("shwip");
this.backButton.scale = this.backButton.baseScale;
}
if (!this.onFarm && this.forwardButton.containsPoint(x, y))
{
this.currentBlueprintIndex = (this.currentBlueprintIndex + 1) % this.blueprints.Count;
this.setNewActiveBlueprint();
this.backButton.scale = this.backButton.baseScale;
Game1.playSound("shwip");
}
if (!this.onFarm && this.demolishButton.containsPoint(x, y))
{
Game1.globalFadeToBlack(new Game1.afterFadeFunction(this.setUpForBuildingPlacement), 0.02f);
Game1.playSound("smallSelect");
this.onFarm = true;
this.demolishing = true;
}
if (!this.onFarm && this.moveButton.containsPoint(x, y))
{
Game1.globalFadeToBlack(new Game1.afterFadeFunction(this.setUpForBuildingPlacement), 0.02f);
Game1.playSound("smallSelect");
this.onFarm = true;
this.moving = true;
}
if (this.okButton.containsPoint(x, y) && !this.onFarm && Game1.player.money >= this.price )
{
Game1.globalFadeToBlack(new Game1.afterFadeFunction(this.setUpForBuildingPlacement), 0.02f);
Game1.playSound("smallSelect");
this.onFarm = true;
}
if (this.onFarm && !this.freeze && !Game1.globalFade)
{
if (this.demolishing)
{
Building buildingAt = ((Farm)Game1.getLocationFromName("Farm")).getBuildingAt(new Vector2((float)((Game1.viewport.X + Game1.getOldMouseX()) / Game1.tileSize), (float)((Game1.viewport.Y + Game1.getOldMouseY()) / Game1.tileSize)));
if (buildingAt != null && (buildingAt.daysOfConstructionLeft > 0 || buildingAt.daysUntilUpgrade > 0))
{
Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\UI:Carpenter_CantDemolish_DuringConstruction", new object[0]), Color.Red, 3500f));
return;
}
if (buildingAt != null && buildingAt.indoors != null && buildingAt.indoors is AnimalHouse && (buildingAt.indoors as AnimalHouse).animalsThatLiveHere.Count > 0)
{
Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\UI:Carpenter_CantDemolish_AnimalsHere", new object[0]), Color.Red, 3500f));
return;
}
if (buildingAt != null && ((Farm)Game1.getLocationFromName("Farm")).destroyStructure(buildingAt))
{
int arg_366_0 = buildingAt.tileY;
int arg_36D_0 = buildingAt.tilesHigh;
Game1.flashAlpha = 1f;
buildingAt.showDestroyedAnimation(Game1.getFarm());
Game1.playSound("explosion");
Utility.spreadAnimalsAround(buildingAt, (Farm)Game1.getLocationFromName("Farm"));
DelayedAction.fadeAfterDelay(new Game1.afterFadeFunction(this.returnToCarpentryMenu), 1500);
this.freeze = true;
}
return;
}
else if (this.upgrading)
{
Building buildingAt2 = ((Farm)Game1.getLocationFromName("Farm")).getBuildingAt(new Vector2((float)((Game1.viewport.X + Game1.getOldMouseX()) / Game1.tileSize), (float)((Game1.viewport.Y + Game1.getOldMouseY()) / Game1.tileSize)));
if (buildingAt2 != null && this.CurrentBlueprint.name != null && buildingAt2.buildingType.Equals(this.CurrentBlueprint.nameOfBuildingToUpgrade))
{
buildingAt2.daysUntilUpgrade = 2;
buildingAt2.showUpgradeAnimation(Game1.getFarm());
Game1.playSound("axe");
DelayedAction.fadeAfterDelay(new Game1.afterFadeFunction(this.returnToCarpentryMenuAfterSuccessfulBuild), 1500);
this.freeze = true;
return;
}
if (buildingAt2 != null)
{
Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\UI:Carpenter_CantUpgrade_BuildingType", new object[0]), Color.Red, 3500f));
}
return;
}
else if (this.moving)
{
if (this.buildingToMove == null)
{
this.buildingToMove = ((Farm)Game1.getLocationFromName("Farm")).getBuildingAt(new Vector2((float)((Game1.viewport.X + Game1.getMouseX()) / Game1.tileSize), (float)((Game1.viewport.Y + Game1.getMouseY()) / Game1.tileSize)));
if (this.buildingToMove != null)
{
if (this.buildingToMove.daysOfConstructionLeft > 0)
{
this.buildingToMove = null;
return;
}
((Farm)Game1.getLocationFromName("Farm")).buildings.Remove(this.buildingToMove);
Game1.playSound("axchop");
}
return;
}
if (((Farm)Game1.getLocationFromName("Farm")).buildStructure(this.buildingToMove, new Vector2((float)((Game1.viewport.X + Game1.getMouseX()) / Game1.tileSize), (float)((Game1.viewport.Y + Game1.getMouseY()) / Game1.tileSize)), false, Game1.player))
{
this.buildingToMove = null;
Game1.playSound("axchop");
DelayedAction.playSoundAfterDelay("dirtyHit", 50);
DelayedAction.playSoundAfterDelay("dirtyHit", 150);
return;
}
Game1.playSound("cancel");
return;
}
else
{
/*
if (this.tryToBuild())
{
this.CurrentBlueprint.consumeResources();
DelayedAction.fadeAfterDelay(new Game1.afterFadeFunction(this.returnToCarpentryMenuAfterSuccessfulBuild), 2000);
this.freeze = true;
return;
}
*/
Game1.addHUDMessage(new HUDMessage(Game1.currentCursorTile.ToString(), Color.Red, 3500f));
Game1.currentLocation.removeObject(Game1.currentCursorTile, false);
//Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\UI:Carpenter_CantBuild", new object[0]), Color.Red, 3500f));
}
}
} }
} }
} }

View File

@ -1,6 +1,9 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Input;
using Revitalize.Menus.MenuComponents;
using Revitalize.Resources;
using Revitalize.Resources.DataNodes;
using StardewValley; using StardewValley;
using StardewValley.Menus; using StardewValley.Menus;
using System; using System;
@ -35,37 +38,58 @@ namespace Revitalize.Menus
private string descriptionText = ""; private string descriptionText = "";
private List<ClickableComponent> tabs = new List<ClickableComponent>(); public const int maxTabsPerPage = 11;
public int currentMenuPage;
public int currentMenuPageMax;
private List<ClickableComponentExtended> tabs = new List<ClickableComponentExtended>();
private List<IClickableMenu> pages = new List<IClickableMenu>(); private List<IClickableMenu> pages = new List<IClickableMenu>();
private List<Texture2D> pageTextureSheets = new List<Texture2D>();
public bool invisible; public bool invisible;
public static bool forcePreventClose; public static bool forcePreventClose;
private ClickableTextureComponent junimoNoteIcon; private ClickableTextureComponent junimoNoteIcon;
public ClickableTextureComponent LeftButton;
public ClickableTextureComponent RightButton;
public GameMenu() : base(Game1.viewport.Width / 2 - (800 + IClickableMenu.borderWidth * 2) / 2, Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2, 800 + IClickableMenu.borderWidth * 2, 600 + IClickableMenu.borderWidth * 2, true) public GameMenu() : base(Game1.viewport.Width / 2 - (800 + IClickableMenu.borderWidth * 2) / 2, Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2, 800 + IClickableMenu.borderWidth * 2, 600 + IClickableMenu.borderWidth * 2, true)
{ {
this.tabs.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "inventory", Game1.content.LoadString("Strings\\UI:GameMenu_Inventory", new object[0]))); //can only hold about 12 tabs per menu page
this.pages.Add(new Revitalize.Menus.InventoryPage(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height)); this.tabs.Add(new ClickableComponentExtended(new Rectangle(this.xPositionOnScreen + Game1.tileSize, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "inventory", Game1.content.LoadString("Strings\\UI:GameMenu_Inventory", new object[0]),0));
this.pages.Add(new Revitalize.Menus.InventoryPage(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height));
this.tabs.Add(new ClickableComponentExtended(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 2, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "skills", Game1.content.LoadString("Strings\\UI:GameMenu_Skills", new object[0]),1));
this.tabs.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 2, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "skills", Game1.content.LoadString("Strings\\UI:GameMenu_Skills", new object[0])));
this.pages.Add(new SkillsPage(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height)); this.pages.Add(new SkillsPage(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height));
this.tabs.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 3, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "social", Game1.content.LoadString("Strings\\UI:GameMenu_Social", new object[0]))); this.tabs.Add(new ClickableComponentExtended(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 3, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "social", Game1.content.LoadString("Strings\\UI:GameMenu_Social", new object[0]),2));
this.pages.Add(new SocialPage(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height)); this.pages.Add(new SocialPage(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height));
this.tabs.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 4, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "map", Game1.content.LoadString("Strings\\UI:GameMenu_Map", new object[0]))); this.tabs.Add(new ClickableComponentExtended(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 4, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "map", Game1.content.LoadString("Strings\\UI:GameMenu_Map", new object[0]),3));
this.pages.Add(new MapPage(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height)); this.pages.Add(new MapPage(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height));
this.tabs.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 5, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "crafting", Game1.content.LoadString("Strings\\UI:GameMenu_Crafting", new object[0]))); this.tabs.Add(new ClickableComponentExtended(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 5, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "crafting", Game1.content.LoadString("Strings\\UI:GameMenu_Crafting", new object[0]),4));
this.pages.Add(new CraftingPage(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, false)); this.pages.Add(new CraftingPage(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, false));
this.tabs.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 6, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "collections", Game1.content.LoadString("Strings\\UI:GameMenu_Collections", new object[0]))); this.tabs.Add(new ClickableComponentExtended(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 6, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "collections", Game1.content.LoadString("Strings\\UI:GameMenu_Collections", new object[0]),5));
this.pages.Add(new CollectionsPage(this.xPositionOnScreen, this.yPositionOnScreen, this.width - Game1.tileSize - Game1.tileSize / 4, this.height)); this.pages.Add(new CollectionsPage(this.xPositionOnScreen, this.yPositionOnScreen, this.width - Game1.tileSize - Game1.tileSize / 4, this.height));
this.tabs.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 7, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "options", Game1.content.LoadString("Strings\\UI:GameMenu_Options", new object[0]))); this.tabs.Add(new ClickableComponentExtended(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 7, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "options", Game1.content.LoadString("Strings\\UI:GameMenu_Options", new object[0]),6));
this.pages.Add(new OptionsPage(this.xPositionOnScreen, this.yPositionOnScreen, this.width - Game1.tileSize - Game1.tileSize / 4, this.height)); this.pages.Add(new OptionsPage(this.xPositionOnScreen, this.yPositionOnScreen, this.width - Game1.tileSize - Game1.tileSize / 4, this.height));
this.tabs.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 8, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "exit", Game1.content.LoadString("Strings\\UI:GameMenu_Exit", new object[0]))); this.tabs.Add(new ClickableComponentExtended(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 8, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "exit", Game1.content.LoadString("Strings\\UI:GameMenu_Exit", new object[0]),7));
this.pages.Add(new ExitPage(this.xPositionOnScreen, this.yPositionOnScreen, this.width - Game1.tileSize - Game1.tileSize / 4, this.height)); this.pages.Add(new ExitPage(this.xPositionOnScreen, this.yPositionOnScreen, this.width - Game1.tileSize - Game1.tileSize / 4, this.height));
this.tabs.Add(new ClickableComponentExtended(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 9, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "bungalo", "8", 8));
this.pages.Add(new ExitPage(this.xPositionOnScreen, this.yPositionOnScreen, this.width - Game1.tileSize - Game1.tileSize / 4, this.height));
this.tabs.Add(new ClickableComponentExtended(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 10, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "bungalo", "9", 9));
this.pages.Add(new ExitPage(this.xPositionOnScreen, this.yPositionOnScreen, this.width - Game1.tileSize - Game1.tileSize / 4, this.height));
this.tabs.Add(new ClickableComponentExtended(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 11, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "bungalo", "10", 10));
this.pages.Add(new ExitPage(this.xPositionOnScreen, this.yPositionOnScreen, this.width - Game1.tileSize - Game1.tileSize / 4, this.height));
this.tabs.Add(new ClickableComponentExtended(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 12, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "bungalo", "11", 11));
this.pages.Add(new ExitPage(this.xPositionOnScreen, this.yPositionOnScreen, this.width - Game1.tileSize - Game1.tileSize / 4, this.height));
this.tabs.Add(new ClickableComponentExtended(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 1, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "bungalo", "12", 12));
this.pages.Add(new ExitPage(this.xPositionOnScreen, this.yPositionOnScreen, this.width - Game1.tileSize - Game1.tileSize / 4, this.height));
pageTextureSheets.Add(Game1.mouseCursors);
pageTextureSheets.Add(Game1.mouseCursors);
currentMenuPage = 0;
if (Game1.activeClickableMenu == null) if (Game1.activeClickableMenu == null)
{ {
Game1.playSound("bigSelect"); Game1.playSound("bigSelect");
@ -79,6 +103,54 @@ namespace Revitalize.Menus
{ {
this.setUpForGamePadMode(); this.setUpForGamePadMode();
} }
currentMenuPageMax =(int)(Math.Floor(Convert.ToDouble(this.tabs.Count / 13)));
TextureDataNode d;
Dictionaries.spriteFontList.TryGetValue("leftArrow", out d);
TextureDataNode f;
Dictionaries.spriteFontList.TryGetValue("rightArrow", out f);
this.LeftButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen - (Game1.tileSize * 3), this.yPositionOnScreen / 4, Game1.tileSize, Game1.tileSize), d.texture, new Rectangle(0, 0, 16, 16), 4f, false);
this.RightButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen - Game1.tileSize, this.yPositionOnScreen / 4, Game1.tileSize, Game1.tileSize), f.texture, new Rectangle(0, 0, 16, 16), 4f, false);
}
public GameMenu(List<ClickableComponentExtended> tabsToAdd, List<IClickableMenu> pagesToAdd, List<Texture2D> pageTexturesToAdd) : base(Game1.viewport.Width / 2 - (800 + IClickableMenu.borderWidth * 2) / 2, Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2, 800 + IClickableMenu.borderWidth * 2, 600 + IClickableMenu.borderWidth * 2, true)
{
//can only hold about 12 tabs per menu page
foreach(var v in tabsToAdd)
{
tabs.Add(v);
}
foreach(var v in pagesToAdd)
{
pages.Add(v);
}
foreach(var v in pageTexturesToAdd)
{
pageTextureSheets.Add(v);
}
currentMenuPage = 0;
if (Game1.activeClickableMenu == null)
{
Game1.playSound("bigSelect");
}
if (Game1.player.hasOrWillReceiveMail("canReadJunimoText") && !Game1.player.hasOrWillReceiveMail("JojaMember") && !Game1.player.hasCompletedCommunityCenter())
{
this.junimoNoteIcon = new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen + this.width, this.yPositionOnScreen + Game1.tileSize * 3 / 2, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:GameMenu_JunimoNote_Hover", new object[0]), Game1.mouseCursors, new Rectangle(331, 374, 15, 14), (float)Game1.pixelZoom, false);
}
GameMenu.forcePreventClose = false;
if (Game1.options.gamepadControls && Game1.isAnyGamePadButtonBeingPressed())
{
this.setUpForGamePadMode();
}
currentMenuPageMax = (int)(Math.Floor(Convert.ToDouble(this.tabs.Count / 13)));
TextureDataNode d;
Dictionaries.spriteFontList.TryGetValue("leftArrow", out d);
TextureDataNode f;
Dictionaries.spriteFontList.TryGetValue("rightArrow", out f);
this.LeftButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen - (Game1.tileSize * 3), this.yPositionOnScreen / 4, Game1.tileSize, Game1.tileSize), d.texture, new Rectangle(0, 0, 16, 16), 4f, false);
this.RightButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen - Game1.tileSize, this.yPositionOnScreen / 4, Game1.tileSize, Game1.tileSize), f.texture, new Rectangle(0, 0, 16, 16), 4f, false);
} }
public GameMenu(int startingTab, int extra = -1) : this() public GameMenu(int startingTab, int extra = -1) : this()
@ -133,13 +205,25 @@ namespace Revitalize.Menus
public override void receiveLeftClick(int x, int y, bool playSound = true) public override void receiveLeftClick(int x, int y, bool playSound = true)
{ {
base.receiveLeftClick(x, y, playSound); base.receiveLeftClick(x, y, playSound);
if (this.LeftButton.containsPoint(x, y))
{
if (this.currentMenuPage > 0) this.currentMenuPage--;
}
if (this.RightButton.containsPoint(x, y))
{
if (this.currentMenuPage < currentMenuPageMax) this.currentMenuPage++;
}
if (!this.invisible && !GameMenu.forcePreventClose) if (!this.invisible && !GameMenu.forcePreventClose)
{ {
for (int i = 0; i < this.tabs.Count; i++) foreach (var current in this.tabs)
{ {
if (this.tabs[i].containsPoint(x, y) && this.currentTab != i && this.pages[this.currentTab].readyToClose()) if (current.value > (11 + (12 * currentMenuPage))) continue;
{ if (current.value < (0 + (12 * currentMenuPage))) continue;
this.changeTab(this.getTabNumberFromName(this.tabs[i].name)); if (current.containsPoint(x, y) && this.currentTab != current.value && this.pages[this.currentTab].readyToClose())
{
this.changeTab(current.value);
return; return;
} }
} }
@ -192,8 +276,10 @@ namespace Revitalize.Menus
base.performHoverAction(x, y); base.performHoverAction(x, y);
this.hoverText = ""; this.hoverText = "";
this.pages[this.currentTab].performHoverAction(x, y); this.pages[this.currentTab].performHoverAction(x, y);
foreach (ClickableComponent current in this.tabs) foreach (var current in this.tabs)
{ {
if (current.value > (11 + (12 * currentMenuPage))) continue;
if (current.value < (0 + (12 * currentMenuPage))) continue;
if (current.containsPoint(x, y)) if (current.containsPoint(x, y))
{ {
this.hoverText = current.label; this.hoverText = current.label;
@ -208,58 +294,11 @@ namespace Revitalize.Menus
this.hoverText = this.junimoNoteIcon.hoverText; this.hoverText = this.junimoNoteIcon.hoverText;
} }
} }
if (LeftButton.containsPoint(Game1.getMousePosition().X, Game1.getMousePosition().Y) && this.currentMenuPage!=0) this.hoverText = "Previous Page";
if (RightButton.containsPoint(Game1.getMousePosition().X, Game1.getMousePosition().Y)&& this.currentMenuPage!=this.currentMenuPageMax) this.hoverText = "Next Page";
} }
public int getTabNumberFromName(string name)
{
int result = -1;
if (name == "social")
{
result = 2;
}
if (name == "skills")
{
result = 1;
}
if (name == "exit")
{
result = 7;
}
if (name == "crafting")
{
result = 4;
}
if (name == "collections")
{
result = 5;
}
if (name == "map")
{
result = 3;
}
if (name == "inventory")
{
result = 0;
}
if (name == "options")
{
result = 6;
}
return result;
}
public override void releaseLeftClick(int x, int y) public override void releaseLeftClick(int x, int y)
{ {
@ -292,7 +331,7 @@ namespace Revitalize.Menus
ClickableTextureComponent expr_AA_cp_0_cp_0 = this.junimoNoteIcon; ClickableTextureComponent expr_AA_cp_0_cp_0 = this.junimoNoteIcon;
expr_AA_cp_0_cp_0.bounds.X = expr_AA_cp_0_cp_0.bounds.X + Game1.tileSize; expr_AA_cp_0_cp_0.bounds.X = expr_AA_cp_0_cp_0.bounds.X + Game1.tileSize;
} }
this.currentTab = this.getTabNumberFromName(this.tabs[whichTab].name); this.currentTab = this.tabs[whichTab].value;
if (this.currentTab == 3) if (this.currentTab == 3)
{ {
this.invisible = true; this.invisible = true;
@ -322,67 +361,23 @@ namespace Revitalize.Menus
b.Begin(SpriteSortMode.FrontToBack, BlendState.NonPremultiplied, SamplerState.PointClamp, null, null); b.Begin(SpriteSortMode.FrontToBack, BlendState.NonPremultiplied, SamplerState.PointClamp, null, null);
if (!GameMenu.forcePreventClose) if (!GameMenu.forcePreventClose)
{ {
foreach (ClickableComponent current in this.tabs) //foreach (ClickableComponentExtended current in this.tabs)
//{
foreach(var current in this.tabs)
{ {
int num = 0; if (current.value > (11+(12 * currentMenuPage))) continue;
if (current.value < (0 + (12 * currentMenuPage))) continue;
int num = current.value;
string name = current.name; string name = current.name;
//!!!!!BINGO! HERE ARE THE TEXTURES
b.Draw(pageTextureSheets[currentMenuPage], new Vector2((float)current.bounds.X, (float)(current.bounds.Y + ((this.currentTab == current.value) ? 8 : 0))), new Rectangle?(new Rectangle(num * 16, 368, 16, 16)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 0.0001f);
if (name == "catalogue")
{
num = 7;
}
if (name == "skills")
{
num = 1;
}
if (name == "crafting")
{
num = 4;
}
if (name == "social")
{
num = 2;
}
if (name == "map")
{
num = 3;
}
if (name == "exit")
{
num = 7;
}
if (name == "inventory")
{
num = 0;
}
if (name == "options")
{
num = 6;
}
else if (name == "collections")
{
num = 5;
}
b.Draw(Game1.mouseCursors, new Vector2((float)current.bounds.X, (float)(current.bounds.Y + ((this.currentTab == this.getTabNumberFromName(current.name)) ? 8 : 0))), new Rectangle?(new Rectangle(num * 16, 368, 16, 16)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 0.0001f);
if (current.name.Equals("skills")) if (current.name.Equals("skills"))
{ {
Game1.player.FarmerRenderer.drawMiniPortrat(b, new Vector2((float)(current.bounds.X + 8), (float)(current.bounds.Y + 12 + ((this.currentTab == this.getTabNumberFromName(current.name)) ? 8 : 0))), 0.00011f, 3f, 2, Game1.player); Game1.player.FarmerRenderer.drawMiniPortrat(b, new Vector2((float)(current.bounds.X + 8), (float)(current.bounds.Y + 12 + ((this.currentTab == current.value) ? 8 : 0))), 0.00011f, 3f, 2, Game1.player);
} }
} //end for each }
//} //end for each
b.End(); b.End();
b.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); b.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
if (this.junimoNoteIcon != null) if (this.junimoNoteIcon != null)
@ -399,6 +394,8 @@ namespace Revitalize.Menus
{ {
this.pages[this.currentTab].draw(b); this.pages[this.currentTab].draw(b);
} }
if(this.currentMenuPage!=0) LeftButton.draw(b);
if(this.currentMenuPage!=currentMenuPageMax) RightButton.draw(b);
if (!GameMenu.forcePreventClose) if (!GameMenu.forcePreventClose)
{ {
base.draw(b); base.draw(b);

View File

@ -0,0 +1,109 @@
using Microsoft.Xna.Framework;
using StardewValley;
using StardewValley.Menus;
using System;
namespace Revitalize.Menus.MenuComponents
{
public class ClickableComponentExtended :ClickableComponent
{
public const int ID_ignore = -500;
public const int CUSTOM_SNAP_BEHAVIOR = -7777;
public const int SNAP_TO_DEFAULT = -99999;
public Rectangle bounds;
public string name;
public string label;
public float scale = 1f;
public Item item;
public bool visible = true;
public bool leftNeighborImmutable;
public bool rightNeighborImmutable;
public bool upNeighborImmutable;
public bool downNeighborImmutable;
public bool tryDefaultIfNoDownNeighborExists;
public bool tryDefaultIfNoRightNeighborExists;
public bool fullyImmutable;
public int myID = -500;
public int leftNeighborID = -1;
public int rightNeighborID = -1;
public int upNeighborID = -1;
public int downNeighborID = -1;
public int myAlternateID = -500;
public int value;
public int region;
public ClickableComponentExtended(Rectangle bounds, string name) : base(bounds,name)
{
this.bounds = bounds;
this.name = name;
}
public ClickableComponentExtended(Rectangle bounds, string name, string label) : base(bounds,name,label)
{
this.bounds = bounds;
this.name = name;
this.label = label;
}
public ClickableComponentExtended(Rectangle bounds, string name, string label, int value) : base(bounds, name, label)
{
this.bounds = bounds;
this.name = name;
this.label = label;
this.value = value;
}
public ClickableComponentExtended(Rectangle bounds, Item item) : base(bounds,item)
{
this.bounds = bounds;
this.item = item;
}
public override bool containsPoint(int x, int y)
{
if (!this.visible)
{
return false;
}
if (this.bounds.Contains(x, y))
{
Game1.SetFreeCursorDrag();
return true;
}
return false;
}
public override void snapMouseCursor()
{
Game1.setMousePosition(this.bounds.Right - this.bounds.Width / 8, this.bounds.Bottom - this.bounds.Height / 8);
}
public new void snapMouseCursorToCenter()
{
Game1.setMousePosition(this.bounds.Center.X, this.bounds.Center.Y);
}
}
}

View File

@ -56,6 +56,7 @@
<Compile Include="Aesthetics\WeatherDebris\WeatherDebrisPlus.cs" /> <Compile Include="Aesthetics\WeatherDebris\WeatherDebrisPlus.cs" />
<Compile Include="Aesthetics\WeatherDebris\WeatherDebrisSystem.cs" /> <Compile Include="Aesthetics\WeatherDebris\WeatherDebrisSystem.cs" />
<Compile Include="Menus\CarpenterMenu.cs" /> <Compile Include="Menus\CarpenterMenu.cs" />
<Compile Include="Menus\MenuComponents\ClickableComponentsExtended.cs" />
<Compile Include="Utilities\MapUtilities.cs" /> <Compile Include="Utilities\MapUtilities.cs" />
<Compile Include="Magic\Alchemy\Menus\ExpandableItemGrabMenu.cs" /> <Compile Include="Magic\Alchemy\Menus\ExpandableItemGrabMenu.cs" />
<Compile Include="Magic\Alchemy\Objects\BagofHolding.cs" /> <Compile Include="Magic\Alchemy\Objects\BagofHolding.cs" />