using Omegasis.MuseumRearranger.Framework;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley;
using StardewValley.Locations;
namespace Omegasis.MuseumRearranger
{
/// The mod entry point.
public class MuseumRearranger : Mod
{
/*********
** Properties
*********/
/// The mod configuration.
private ModConfig Config;
/// The open museum menu (if any).
private NewMuseumMenu OpenMenu;
/*********
** Public methods
*********/
/// The mod entry point, called after the mod is first loaded.
/// Provides simplified APIs for writing mods.
public override void Entry(IModHelper helper)
{
this.Config = helper.ReadConfig();
ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
}
/*********
** Private methods
*********/
/// The method invoked when the presses a keyboard button.
/// The event sender.
/// The event data.
private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e)
{
if (!Context.IsWorldReady)
return;
// open menu
if (e.KeyPressed.ToString() == this.Config.ShowMenuKey)
{
if (Game1.activeClickableMenu != null)
return;
if (Game1.player.currentLocation is LibraryMuseum)
Game1.activeClickableMenu = this.OpenMenu = new NewMuseumMenu(this.Helper.Reflection);
else
this.Monitor.Log("You can't rearrange the museum here.");
}
// toggle inventory box
if (e.KeyPressed.ToString() == this.Config.ToggleInventoryKey)
this.OpenMenu?.ToggleInventory();
}
}
}