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(); helper.Events.Input.ButtonPressed += this.OnButtonPressed; } /********* ** Private methods *********/ /// Raised after the player presses a button on the keyboard, controller, or mouse. /// The event sender. /// The event arguments. private void OnButtonPressed(object sender, ButtonPressedEventArgs e) { if (!Context.IsWorldReady) return; // open menu 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 if (e.Button == this.Config.ToggleInventoryKey) this.OpenMenu?.ToggleInventory(); } } }