2017-08-06 03:51:44 +08:00
|
|
|
|
using Omegasis.MuseumRearranger.Framework;
|
2017-07-28 08:28:39 +08:00
|
|
|
|
using StardewModdingAPI;
|
2017-07-30 01:30:04 +08:00
|
|
|
|
using StardewModdingAPI.Events;
|
2017-07-28 08:28:39 +08:00
|
|
|
|
using StardewValley;
|
2017-07-30 01:30:04 +08:00
|
|
|
|
using StardewValley.Locations;
|
2017-07-28 08:28:39 +08:00
|
|
|
|
|
|
|
|
|
namespace Omegasis.MuseumRearranger
|
2016-10-13 15:22:50 +08:00
|
|
|
|
{
|
2017-07-30 01:30:04 +08:00
|
|
|
|
/// <summary>The mod entry point.</summary>
|
|
|
|
|
public class MuseumRearranger : Mod
|
2016-10-13 15:22:50 +08:00
|
|
|
|
{
|
2017-07-30 01:30:04 +08:00
|
|
|
|
/*********
|
|
|
|
|
** Properties
|
|
|
|
|
*********/
|
2017-08-06 03:51:44 +08:00
|
|
|
|
/// <summary>The mod configuration.</summary>
|
|
|
|
|
private ModConfig Config;
|
2017-07-30 01:30:04 +08:00
|
|
|
|
|
|
|
|
|
/// <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>
|
2016-12-09 08:34:28 +08:00
|
|
|
|
public override void Entry(IModHelper helper)
|
2016-10-13 15:22:50 +08:00
|
|
|
|
{
|
2017-08-06 03:51:44 +08:00
|
|
|
|
this.Config = helper.ReadConfig<ModConfig>();
|
|
|
|
|
|
2017-07-30 01:30:04 +08:00
|
|
|
|
ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
|
2016-10-13 15:22:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-30 01:30:04 +08:00
|
|
|
|
|
|
|
|
|
/*********
|
|
|
|
|
** Private methods
|
|
|
|
|
*********/
|
|
|
|
|
/// <summary>The method invoked when the presses a keyboard button.</summary>
|
|
|
|
|
/// <param name="sender">The event sender.</param>
|
|
|
|
|
/// <param name="e">The event data.</param>
|
|
|
|
|
private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e)
|
2016-10-13 15:22:50 +08:00
|
|
|
|
{
|
2017-08-06 03:23:10 +08:00
|
|
|
|
if (!Context.IsWorldReady)
|
2017-07-30 01:30:04 +08:00
|
|
|
|
return;
|
2016-10-13 15:22:50 +08:00
|
|
|
|
|
2017-07-30 01:30:04 +08:00
|
|
|
|
// open menu
|
2017-08-06 03:51:44 +08:00
|
|
|
|
if (e.KeyPressed.ToString() == this.Config.ShowMenuKey)
|
2016-10-13 15:22:50 +08:00
|
|
|
|
{
|
2017-07-30 01:30:04 +08:00
|
|
|
|
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.");
|
2016-10-13 15:22:50 +08:00
|
|
|
|
}
|
2017-07-30 01:30:04 +08:00
|
|
|
|
|
|
|
|
|
// toggle inventory box
|
2017-08-06 03:51:44 +08:00
|
|
|
|
if (e.KeyPressed.ToString() == this.Config.ToggleInventoryKey)
|
2017-07-30 01:30:04 +08:00
|
|
|
|
this.OpenMenu?.ToggleInventory();
|
2016-10-13 15:22:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|