using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using StardewModdingAPI; using StardewValley; using StardewValley.Locations; using StardewValley.Menus; namespace Omegasis.MuseumRearranger.Framework { /// A subclass of which adds support for toggling the inventory box. internal class NewMuseumMenu : MuseumMenu { /********* ** Fields *********/ /// Whether to show the inventory screen. private bool ShowInventory = true; /// A reference to a private field for use in the overridden draw code. private readonly IReflectedField HoldingMuseumPiece; /********* ** Public methods *********/ /// Construct an instance. /// Simplifies access to private game code. public NewMuseumMenu(IReflectionHelper reflection) { this.HoldingMuseumPiece = reflection.GetField(this, "holdingMuseumPiece"); } /// Toggle the inventory box. public void ToggleInventory() { this.ShowInventory = !this.ShowInventory; } /// Draw the menu to the screen. /// The sprite batch being drawn. public override void draw(SpriteBatch b) { if ((this.fadeTimer <= 0 || !this.fadeIntoBlack) && this.state != 3) { if (this.heldItem != null) { for (int i = Game1.viewport.Y / Game1.tileSize - 1; i < (Game1.viewport.Y + Game1.viewport.Height) / Game1.tileSize + 2; i++) { for (int j = Game1.viewport.X / Game1.tileSize - 1; j < (Game1.viewport.X + Game1.viewport.Width) / Game1.tileSize + 1; j++) { if (((LibraryMuseum)Game1.currentLocation).isTileSuitableForMuseumPiece(j, i)) b.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2(j, i) * Game1.tileSize), Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 29), Color.LightGreen); } } } if (!this.HoldingMuseumPiece.GetValue() && this.ShowInventory) base.draw(b, false, false); if (!this.hoverText.Equals("")) IClickableMenu.drawHoverText(b, this.hoverText, Game1.smallFont); this.heldItem?.drawInMenu(b, new Vector2(Game1.getOldMouseX() + 8, Game1.getOldMouseY() + 8), 1f); base.drawMouse(b); this.sparkleText?.draw(b, Game1.GlobalToLocal(Game1.viewport, this.globalLocationOfSparklingArtifact)); } b.Draw(Game1.fadeToBlackRect, new Rectangle(0, 0, Game1.viewport.Width, Game1.viewport.Height), Color.Black * this.blackFadeAlpha); } } }