Stardew_Valley_Mods/GeneralMods/MuseumRearranger/MuseumRearranger.cs

63 lines
2.0 KiB
C#
Raw Normal View History

using Omegasis.MuseumRearranger.Framework;
2017-07-28 08:28:39 +08:00
using StardewModdingAPI;
using StardewModdingAPI.Events;
2017-07-28 08:28:39 +08:00
using StardewValley;
using StardewValley.Locations;
2017-07-28 08:28:39 +08:00
namespace Omegasis.MuseumRearranger
{
/// <summary>The mod entry point.</summary>
public class MuseumRearranger : Mod
{
/*********
2019-01-06 15:23:07 +08:00
** Fields
*********/
/// <summary>The mod configuration.</summary>
private ModConfig Config;
/// <summary>The open museum menu (if any).</summary>
private NewMuseumMenu OpenMenu;
/*********
** Public methods
*********/
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
/// <param name="helper">Provides simplified APIs for writing mods.</param>
public override void Entry(IModHelper helper)
{
this.Config = helper.ReadConfig<ModConfig>();
2019-01-06 15:21:06 +08:00
helper.Events.Input.ButtonPressed += this.OnButtonPressed;
}
/*********
** Private methods
*********/
2019-01-06 15:21:06 +08:00
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
/// <param name="sender">The event sender.</param>
2019-01-06 15:21:06 +08:00
/// <param name="e">The event arguments.</param>
private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
{
if (!Context.IsWorldReady)
return;
// open menu
2019-01-06 15:21:06 +08:00
if (e.Button == 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
2019-01-06 15:21:06 +08:00
if (e.Button == this.Config.ToggleInventoryKey)
this.OpenMenu?.ToggleInventory();
}
}
}