Ejemplo n.º 1
0
        /// <summary>The method invoked when the player presses a button.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void InputEvents_ButtonPressed(object sender, EventArgsInput e)
        {
            try
            {
                var controls = this.Config.Controls;

                // open menu
                if (controls.Toggle.Contains(e.Button))
                {
                    // open if no conflict
                    if (Game1.activeClickableMenu == null)
                    {
                        this.OpenMenu();
                    }

                    // open from inventory if it's safe to close the inventory screen
                    else if (Game1.activeClickableMenu is GameMenu gameMenu && gameMenu.currentTab == GameMenu.inventoryTab)
                    {
                        IClickableMenu inventoryPage = this.Helper.Reflection.GetField <List <IClickableMenu> >(gameMenu, "pages").GetValue()[GameMenu.inventoryTab];
                        if (inventoryPage.readyToClose())
                        {
                            this.OpenMenu();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.HandleError(ex, "handling key input");
            }
        }
Ejemplo n.º 2
0
        /// <summary>The method invoked when the player presses a button.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
        {
            try
            {
                ModConfigKeys keys = this.Keys;

                // open menu
                if (keys.Toggle.Contains(e.Button))
                {
                    // open if no conflict
                    if (Game1.activeClickableMenu == null)
                    {
                        this.OpenMenu();
                    }

                    // open from inventory if it's safe to close the inventory screen
                    else if (Game1.activeClickableMenu is GameMenu gameMenu && gameMenu.currentTab == GameMenu.inventoryTab)
                    {
                        IClickableMenu inventoryPage = gameMenu.pages[GameMenu.inventoryTab];
                        if (inventoryPage.readyToClose())
                        {
                            this.OpenMenu();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.HandleError(ex, "handling key input");
            }
        }
Ejemplo n.º 3
0
 private void handleSwapFarmAction()
 {
     if (TreeTransplantMenu.readyToClose())
     {
         Game1.globalFadeToBlack(new Game1.afterFadeFunction(swapFarm));
     }
     else
     {
         framework.helper.Reflection.GetMethod(TreeTransplantMenu, "handleCancelAction").Invoke();
     }
 }
 private static void base_receiveLeftClick(IClickableMenu __instance, int x, int y, bool playSound)
 {
     if (__instance.upperRightCloseButton == null || !__instance.readyToClose() || !__instance.upperRightCloseButton.containsPoint(x, y))
     {
         return;
     }
     if (playSound)
     {
         Game1.playSound("bigDeSelect");
     }
     __instance.exitThisMenu(true);
 }
Ejemplo n.º 5
0
        /// <summary>The method invoked when the player presses a button.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }

            try
            {
                ModConfigKeys keys = this.Keys;

                // open menu
                if (keys.Toggle.JustPressedUnique())
                {
                    // open if no conflict
                    if (Game1.activeClickableMenu == null)
                    {
                        if (Context.IsPlayerFree && !Game1.player.UsingTool && !Game1.player.isEating)
                        {
                            this.OpenMenu();
                        }
                    }

                    // open from inventory if it's safe to close the inventory screen
                    else if (Game1.activeClickableMenu is GameMenu gameMenu && gameMenu.currentTab == GameMenu.inventoryTab)
                    {
                        IClickableMenu inventoryPage = gameMenu.pages[GameMenu.inventoryTab];
                        if (inventoryPage.readyToClose())
                        {
                            this.OpenMenu();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.HandleError(ex, "handling key input");
            }
        }