Ejemplo n.º 1
0
        /// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.
        /// This method implements...
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void Input_ButtonPressed(object sender, ButtonPressedEventArgs e)
        {
            Farmer who = Game1.player;
            bool   useToolButtonPressed = SButtonExtensions.IsUseToolButton(e.Button);
            bool   actionButtonPressed  = SButtonExtensions.IsActionButton(e.Button);

            if (
                (useToolButtonPressed || actionButtonPressed) &&
                (who.CurrentTool != null) &&
                Context.IsPlayerFree
                )
            {
            }
        }
Ejemplo n.º 2
0
        private void Input_ButtonPressed(object sender, ButtonPressedEventArgs e)
        {
#if NEVER //DEBUG
            //  Testing the Scarecrow transpiler harmony patch
            if (e.Button == SButton.R && Game1.activeClickableMenu == null && Game1.player.currentLocation is Farm farm)
            {
                farm.addCrows();
            }
#endif

            if (IsCombineKeyHeld(Helper.Input))
            {
                if (Game1.activeClickableMenu is GameMenu GM && GM.currentTab == GameMenu.inventoryTab && TryGetClickedInventoryItem(GM, e, out Item ClickedItem, out int ClickedItemIndex))
                {
                    //  Detect when player clicks on a machine in their inventory while another machine of the same type is selected
                    if (SButtonExtensions.IsUseToolButton(e.Button) /*e.Button == SButton.MouseLeft*/ && Game1.player.CursorSlotItem is SObject SourceObj && ClickedItem is SObject TargetObj && CanCombine(SourceObj, TargetObj))
                    {
                        if (!SourceObj.TryGetCombinedQuantity(out int SourceQuantity))
                        {
                            SourceQuantity = SourceObj.Stack;
                        }
                        if (!TargetObj.TryGetCombinedQuantity(out int TargetQuantity))
                        {
                            TargetQuantity = TargetObj.Stack;
                        }

                        TargetObj.SetCombinedQuantity(SourceQuantity + TargetQuantity);
                        Game1.player.CursorSlotItem = null;

                        //  Clicking an item will make the game set it to the new CursorSlotItem, but since we just combined them, we want the CursorSlotItem to be empty
                        DelayHelpers.InvokeLater(1, () =>
                        {
                            if (Game1.player.CursorSlotItem != null && Game1.player.Items[ClickedItemIndex] == null)
                            {
                                Game1.player.Items[ClickedItemIndex] = Game1.player.CursorSlotItem;
                                Game1.player.CursorSlotItem          = null;
                            }
                        });
                    }
                    //  Right-clicking a combined machine splits it to its un-combined state
                    else if (SButtonExtensions.IsActionButton(e.Button) /*e.Button == SButton.MouseRight*/ && Game1.player.CursorSlotItem == null && ClickedItem is SObject ClickedObject &&
                             ClickedObject.IsCombinedMachine() && ClickedObject.TryGetCombinedQuantity(out int CombinedQuantity) && CombinedQuantity > 1)
                    {
                        ClickedObject.modData.Remove(ModDataQuantityKey);
                        ClickedObject.Stack += CombinedQuantity - 1;
                        Logger.Log(string.Format("De-combined {0} (Stack={1})", ClickedObject.DisplayName, CombinedQuantity), InfoLogLevel);
                    }
                }
Ejemplo n.º 3
0
        private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
        {
            Farmer player = Game1.player;

            if (
                Context.IsWorldReady &&
                (Game1.activeClickableMenu == null) &&
                player.IsLocalPlayer &&
                (player.CurrentTool is Wand) &&
                !player.isRidingHorse() &&
                !player.bathingClothes.Value &&
                SButtonExtensions.IsUseToolButton(e.Button) &&
                !InOnScreenMenu(e.Cursor)
                )
            {
                ChooseWarpLocation();
            }
        }
Ejemplo n.º 4
0
 /// <summary>Raised after the player releases a button on the keyboard, controller, or mouse.</summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event arguments.</param>
 private void Input_ButtonReleased(object sender, ButtonReleasedEventArgs e)
 {
     if (SButtonExtensions.IsUseToolButton(e.Button))
     {
     }
 }