2018-12-30 18:00:05 +08:00
|
|
|
using Microsoft.Xna.Framework;
|
2016-10-13 15:22:50 +08:00
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
2017-07-30 01:30:04 +08:00
|
|
|
using StardewModdingAPI;
|
2017-07-28 08:28:39 +08:00
|
|
|
using StardewValley;
|
2016-10-13 15:22:50 +08:00
|
|
|
using StardewValley.Locations;
|
2017-07-28 08:28:39 +08:00
|
|
|
using StardewValley.Menus;
|
2016-10-13 15:22:50 +08:00
|
|
|
|
2017-07-31 11:07:07 +08:00
|
|
|
namespace Omegasis.MuseumRearranger.Framework
|
2016-10-13 15:22:50 +08:00
|
|
|
{
|
2017-07-30 01:30:04 +08:00
|
|
|
/// <summary>A subclass of <see cref="MuseumMenu"/> which adds support for toggling the inventory box.</summary>
|
2017-07-31 11:07:07 +08:00
|
|
|
internal class NewMuseumMenu : MuseumMenu
|
2016-10-13 15:22:50 +08:00
|
|
|
{
|
2017-07-30 01:30:04 +08:00
|
|
|
/*********
|
|
|
|
** Properties
|
|
|
|
*********/
|
|
|
|
/// <summary>Whether to show the inventory screen.</summary>
|
|
|
|
private bool ShowInventory = true;
|
|
|
|
|
|
|
|
/// <summary>A reference to a private <see cref="MuseumMenu"/> field for use in the overridden draw code.</summary>
|
2018-01-11 13:50:16 +08:00
|
|
|
private readonly IReflectedField<bool> HoldingMuseumPiece;
|
2017-07-30 01:30:04 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*********
|
|
|
|
** Public methods
|
|
|
|
*********/
|
|
|
|
/// <summary>Construct an instance.</summary>
|
|
|
|
/// <param name="reflection">Simplifies access to private game code.</param>
|
|
|
|
public NewMuseumMenu(IReflectionHelper reflection)
|
2016-10-13 15:22:50 +08:00
|
|
|
{
|
2018-01-11 13:50:16 +08:00
|
|
|
this.HoldingMuseumPiece = reflection.GetField<bool>(this, "holdingMuseumPiece");
|
2016-10-13 15:22:50 +08:00
|
|
|
}
|
|
|
|
|
2017-07-30 01:30:04 +08:00
|
|
|
/// <summary>Toggle the inventory box.</summary>
|
|
|
|
public void ToggleInventory()
|
2016-10-13 15:22:50 +08:00
|
|
|
{
|
2017-07-30 01:30:04 +08:00
|
|
|
this.ShowInventory = !this.ShowInventory;
|
2016-10-13 15:22:50 +08:00
|
|
|
}
|
|
|
|
|
2017-07-30 01:30:04 +08:00
|
|
|
/// <summary>Draw the menu to the screen.</summary>
|
|
|
|
/// <param name="b">The sprite batch being drawn.</param>
|
2016-10-13 15:22:50 +08:00
|
|
|
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++)
|
|
|
|
{
|
2017-07-30 01:30:04 +08:00
|
|
|
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);
|
2016-10-13 15:22:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-07-30 01:30:04 +08:00
|
|
|
if (!this.HoldingMuseumPiece.GetValue() && this.ShowInventory)
|
2016-10-13 15:22:50 +08:00
|
|
|
base.draw(b, false, false);
|
|
|
|
if (!this.hoverText.Equals(""))
|
2017-07-30 01:30:04 +08:00
|
|
|
IClickableMenu.drawHoverText(b, this.hoverText, Game1.smallFont);
|
|
|
|
this.heldItem?.drawInMenu(b, new Vector2(Game1.getOldMouseX() + 8, Game1.getOldMouseY() + 8), 1f);
|
2016-10-13 15:22:50 +08:00
|
|
|
base.drawMouse(b);
|
2017-07-30 01:30:04 +08:00
|
|
|
this.sparkleText?.draw(b, Game1.GlobalToLocal(Game1.viewport, this.globalLocationOfSparklingArtifact));
|
2016-10-13 15:22:50 +08:00
|
|
|
}
|
2017-07-30 01:30:04 +08:00
|
|
|
b.Draw(Game1.fadeToBlackRect, new Rectangle(0, 0, Game1.viewport.Width, Game1.viewport.Height), Color.Black * this.blackFadeAlpha);
|
2016-10-13 15:22:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|