示例#1
0
        private void InputEvents_ButtonPressed(object sender, EventArgsInput e)
        {
            try
            {
                //If world is ready (save is loaded) and player left clicked on a supported building, harvest and reload items in that building. Make sure menu is not showing.
                if (Context.IsWorldReady && Game1.didPlayerJustLeftClick() && Game1.currentLocation is Farm farm && Game1.activeClickableMenu == null)
                {
                    Common.Utility.Log($"{DateTime.Now} - {Game1.player.Name} left clicked on something on the farm.");

                    if (DidPlayerClickOnASupportedBuilding())
                    {
                        e.SuppressButton();
                        Common.Utility.Log($"{DateTime.Now} - {Game1.player.Name} clicked on a supported building to harvest all supported containers within it.");
                        HarvestAllItemsInBuilding(_currentTileBuilding);
                    }
                }
            }
            catch (Exception ex)
            {
                Common.Utility.Log($"Exception in BitwiseJonMods.OneClickShedReloader mod: {ex.Message}", LogLevel.Error);
            }
        }
示例#2
0
        private void InputEvents_ButtonPressed(object sender, EventArgsInput e)
        {
            //if (!Context.IsWorldReady)
            //    return;

            if (e.Button.TryGetKeyboard(out Keys _))
            {
                if (e.Button == _config.IncreaseZoomKey)
                {
                    IncreaseZoom();
                }
                else if (e.Button == _config.DecreaseZoomKey)
                {
                    DecreaseZoom();
                }
            }
            else if (e.Button.TryGetController(out Buttons _))
            {
                var wasZoom = false;

                if (e.Button == _config.IncreaseZoomButton)
                {
                    IncreaseZoom();
                    wasZoom = true;
                }
                else if (e.Button == _config.DecreaseZoomButton)
                {
                    DecreaseZoom();
                    wasZoom = true;
                }

                if (_config.SuppressControllerButton && wasZoom)
                {
                    e.SuppressButton();
                }
            }
        }
示例#3
0
 private void ButtonPressed(object sender, EventArgsInput e)
 {
     e.SuppressButton();
     if (e.Button == SButton.Space)
     {
         game.Start();
     }
     else if (e.Button == SButton.Escape)
     {
         if (game.HasStarted())
         {
             game.Reset();
         }
         else
         {
             Game1.quit = true;
             Game1.exitActiveMenu();
         }
     }
     else if (e.Button == SButton.P)
     {
         game.TogglePaused();
     }
 }
示例#4
0
        /*********
        ** Private methods
        *********/
        /// <summary>The method invoked when the player presses a controller, keyboard, or mouse button.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event data.</param>
        private void InputEvents_ButtonPressed(object sender, EventArgsInput e)
        {
            if (!e.IsActionButton && !(e.Button == SButton.ControllerA) && !(e.Button == SButton.ControllerX))
            {
                return;
            }
            Mill mill = this.GetBuildingAt(e.Cursor.GrabTile) as Mill;

            if (mill == null)
            {
                return;
            }

            //if(!e.IsSuppressed)
            e.SuppressButton();


            if (Game1.player.CurrentItem is StardewValley.Object currentObj && currentObj.category == -75)
            {
                if (currentObj.parentSheetIndex == 262 && this.Config.ProcessWheat) // Do things for Wheat.
                {
                    Game1.addHUDMessage(new HUDMessage(currentObj.stack + " " + currentObj.displayName + " added to the mill.", 3)
                    {
                        noIcon = true, timeLeft = HUDMessage.defaultTime
                    });
                    Item remaining = mill.input.addItem(currentObj);
                    if (remaining == null)
                    {
                        DeleteHeld();
                    }
                    //this.Helper.Reflection.GetField<bool>(mill, "hasLoadedToday").SetValue(true);
                    Game1.playSound("Ship");
                }
                //else if (currentObj.parentSheetIndex == 262 && !this.Config.ProcessWheat)
                //{
                //    Game1.showRedMessage(Game1.content.LoadString("Strings\\Buildings:CantMill"));
                //}
                if (currentObj.parentSheetIndex == 270 && this.Config.ProcessCorn) // Do things for Corn.
                {
                    Game1.addHUDMessage(new HUDMessage(currentObj.stack + " " + currentObj.displayName + " added to the mill.", 3)
                    {
                        noIcon = true, timeLeft = HUDMessage.defaultTime
                    });
                    Item remaining = mill.input.addItem(currentObj);
                    if (remaining == null)
                    {
                        DeleteHeld();
                    }
                    //this.Helper.Reflection.GetField<bool>(mill, "hasLoadedToday").SetValue(true);
                    Game1.playSound("Ship");
                }
                if (currentObj.parentSheetIndex == 300 && this.Config.ProcessAmaranth) // Do things for Amaranth.
                {
                    Game1.addHUDMessage(new HUDMessage(currentObj.stack + " " + currentObj.displayName + " added to the mill.", 3)
                    {
                        noIcon = true, timeLeft = HUDMessage.defaultTime
                    });
                    Item remaining = mill.input.addItem(currentObj);
                    if (remaining == null)
                    {
                        DeleteHeld();
                    }
                    //this.Helper.Reflection.GetField<bool>(mill, "hasLoadedToday").SetValue(true);
                    Game1.playSound("Ship");
                }
                if (currentObj.parentSheetIndex == 284 && this.Config.ProcessBeet) // Do things for beets.
                {
                    Game1.addHUDMessage(new HUDMessage(currentObj.stack + " " + currentObj.displayName + " added to the mill.", 3)
                    {
                        noIcon = true, timeLeft = HUDMessage.defaultTime
                    });
                    Item remaining = mill.input.addItem(currentObj);
                    if (remaining == null)
                    {
                        DeleteHeld();
                    }
                    //this.Helper.Reflection.GetField<bool>(mill, "hasLoadedToday").SetValue(true);
                    Game1.playSound("Ship");
                }
            }



            //if (Game1.player.CurrentItem is StardewValley.Object currentObj && currentObj.parentSheetIndex == 262 && currentObj.category == -75) { }// wheat
        }
示例#5
0
        private void InputEvents_ButtonPressed(object sender, EventArgsInput e)
        {
            if (Context.IsWorldReady && e.IsActionButton && Game1.currentLocation.name == "Brewery" && Game1.currentLocation.objects.TryGetValue(e.Cursor.GrabTile, out SObject obj) && obj is Cask cask && cask.heldObject == null)
            { // If the player activates an empty cask in the brewery, suppress input and hijack the cask.
                suppressCaskMessage = true;
                e.SuppressButton();
                Item held = Game1.player.CurrentItem;
                if (held != null)
                {
                    if (held.parentSheetIndex == 348 || held.parentSheetIndex == 346 || held.parentSheetIndex == 303 || held.parentSheetIndex == 459 || held.parentSheetIndex == 426 || held.parentSheetIndex == 424)
                    {
                        switch (held.parentSheetIndex)
                        {
                        case 348:
                            SObject wine = new SObject(348, 1)
                            {
                                name     = $"{held.Name}",
                                price    = ((SObject)Game1.player.CurrentItem).price,
                                preserve = SObject.PreserveType.Wine,
                                preservedParentSheetIndex = held.parentSheetIndex,
                                quality = ((SObject)Game1.player.CurrentItem).quality
                            };
                            cask.heldObject = wine;
                            cask.agingRate  = 1;
                            break;

                        case 346:
                            SObject beer = new SObject(346, 1)
                            {
                                price   = ((SObject)Game1.player.CurrentItem).price,
                                quality = ((SObject)Game1.player.CurrentItem).quality
                            };
                            cask.heldObject = beer;
                            cask.agingRate  = 2;
                            break;

                        case 303:
                            SObject paleAle = new SObject(303, 1)
                            {
                                price   = ((SObject)Game1.player.CurrentItem).price,
                                quality = ((SObject)Game1.player.CurrentItem).quality
                            };
                            cask.heldObject = paleAle;
                            cask.agingRate  = 1.66f;
                            break;

                        case 459:
                            SObject mead = new SObject(459, 1)
                            {
                                price   = ((SObject)Game1.player.CurrentItem).price,
                                quality = ((SObject)Game1.player.CurrentItem).quality
                            };
                            cask.heldObject = mead;
                            cask.agingRate  = 2;
                            break;

                        case 426:
                            SObject goatCheese = new SObject(426, 1)
                            {
                                price   = ((SObject)Game1.player.CurrentItem).price,
                                quality = ((SObject)Game1.player.CurrentItem).quality
                            };
                            cask.heldObject = goatCheese;
                            cask.agingRate  = 4;
                            break;

                        case 424:
                            SObject cheese = new SObject(424, 1)
                            {
                                price   = ((SObject)Game1.player.CurrentItem).price,
                                quality = ((SObject)Game1.player.CurrentItem).quality
                            };
                            cask.heldObject = cheese;
                            cask.agingRate  = 4;
                            break;
                        }
                        cask.daysToMature      = 56;
                        cask.minutesUntilReady = 999999;
                        switch (cask.heldObject.quality)
                        {
                        case SObject.medQuality:
                            cask.daysToMature = 42;
                            break;

                        case SObject.highQuality:
                            cask.daysToMature = 28;
                            break;

                        case SObject.bestQuality:
                            cask.daysToMature      = 0;
                            cask.minutesUntilReady = 1;
                            break;
                        }

                        held.Stack--;
                        if (held.Stack <= 0)
                        {
                            Game1.player.items.Remove(held);
                        }

                        Game1.playSound("Ship");
                        Game1.playSound("bubbles");
                        Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(Game1.animations, new Rectangle(256, 1856, 64, 128), 80f, 6, 999999, cask.tileLocation * (float)Game1.tileSize + new Vector2(0.0f, (float)(-Game1.tileSize * 2)), false, false, (float)(((double)cask.tileLocation.Y + 1.0) * (double)Game1.tileSize / 10000.0 + 9.99999974737875E-05), 0.0f, Color.Yellow * 0.75f, 1f, 0.0f, 0.0f, 0.0f, false)
                        {
                            alphaFade = 0.005f
                        });
                        suppressDrink = true;
                    }
                }
            }
        }
示例#6
0
        private void InputEvents_ButtonPressed(object sender, EventArgsInput e)
        {
            if (!Context.IsWorldReady || !Context.IsPlayerFree || Game1.activeClickableMenu != null ||
                !e.IsActionButton && e.Button != SButton.ControllerA)
            {
                return;
            }

            var property = Game1.currentLocation.doesTileHaveProperty((int)e.Cursor.GrabTile.X,
                                                                      (int)e.Cursor.GrabTile.Y, "Action", "Buildings");

            switch (property)
            {
            case "Buy General":
                if (_config.Pierre && (_config.ShopsAlwaysOpen || IsNpcInLocation("Pierre")))
                {
                    e.SuppressButton();
                    Game1.activeClickableMenu =
                        new ShopMenu(((SeedShop)Game1.currentLocation).shopStock(), 0, "Pierre");
                }
                break;

            case "Carpenter":
                if (_config.Carpenter)
                {
                    if (_config.ShopsAlwaysOpen)
                    {
                        Carpenters();
                    }
                    else
                    {
                        NPC robin;
                        if (Game1.currentLocation.characters.Find("Robin") is NPC npc)
                        {
                            robin = npc;
                        }
                        else
                        {
                            break;
                        }
                        var carpenters   = Helper.Reflection.GetMethod(Game1.currentLocation, "carpenters");
                        var tileLocation = robin.getTileLocation();
                        carpenters.Invoke(new Location((int)tileLocation.X, (int)tileLocation.Y));
                    }
                    e.SuppressButton();
                }
                break;

            case "AnimalShop":
                if (_config.Ranch)
                {
                    if (_config.ShopsAlwaysOpen)
                    {
                        AnimalShop();
                    }
                    else
                    {
                        NPC marnie;
                        if (Game1.currentLocation.characters.Find("Marnie") is NPC npc)
                        {
                            marnie = npc;
                        }
                        else
                        {
                            break;
                        }
                        var animalShop   = Helper.Reflection.GetMethod(Game1.currentLocation, "animalShop");
                        var tileLocation = marnie.getTileLocation();
                        animalShop.Invoke(new Location((int)tileLocation.X, (int)tileLocation.Y + 1));
                    }
                    e.SuppressButton();
                }
                break;

            case "Buy Fish":
                if (_config.FishShop &&
                    (_config.ShopsAlwaysOpen || IsNpcInLocation("Willy") || IsNpcInLocation("Willy", "Beach")))
                {
                    e.SuppressButton();
                    Game1.activeClickableMenu = new ShopMenu(Utility.getFishShopStock(Game1.player), 0, "Willy");
                }
                break;

            case "Blacksmith":
                if (_config.Blacksmith)
                {
                    if (_config.ShopsAlwaysOpen)
                    {
                        Blacksmith(Game1.getCharacterFromName("Clint"));
                    }
                    else
                    {
                        NPC clint;
                        if (Game1.currentLocation.characters.Find("Clint") is NPC npc)
                        {
                            clint = npc;
                        }
                        else
                        {
                            break;
                        }
                        Blacksmith(clint);
                    }
                    e.SuppressButton();
                }
                break;

            case "IceCreamStand":
                if (_config.IceCreamStand &&
                    (_config.ShopsAlwaysOpen || _config.IceCreamInAllSeasons || SDate.Now().Season == "summer"))
                {
                    var d = new Dictionary <Item, int[]>
                    {
                        { new Object(233, 1), new[] { 250, int.MaxValue } }
                    };
                    Game1.activeClickableMenu = new ShopMenu(d);
                    e.SuppressButton();
                }
                break;

            default:
                break;
            }
        }
示例#7
0
        private void InputEvents_ButtonPressed(object sender, EventArgsInput e)
        {
            bool   flag   = Context.IsWorldReady;
            string button = e.Button.ToString();

            if (button == RightClickMoveModeOpenButton)
            {
                isRightClickMoveModeOn = !isRightClickMoveModeOn;
            }
            if (button == ExtendedModeOpenButton)
            {
                isExtendedModeOn = !isExtendedModeOn;
            }

            if (isExtendedModeOn)
            {
                if (button == "RightControl")
                {
                    isHoldingRightCtrl = true;
                }
                if (button == "LeftControl")
                {
                    isHoldingLeftCtrl = true;
                }
                if (button == "RightAlt")
                {
                    isHoldingRightAlt = true;
                }

                if (button == "Enter" && isHoldingRightAlt)
                {
                    if (Game1.options.isCurrentlyWindowedBorderless() || Game1.options.isCurrentlyFullscreen())
                    {
                        Game1.options.setWindowedOption("Windowed");
                    }
                    else
                    {
                        Game1.options.setWindowedOption("Windowed Borderless");
                    }
                    Game1.exitActiveMenu();
                }
            }

            if (flag)
            {
                bool flag2 = button == "MouseRight" && isRightClickMoveModeOn && Context.IsPlayerFree;

                if (Game1.player.ActiveObject != null)
                {
                    if (Game1.player.ActiveObject.getCategoryName() == "Furniture")
                    {
                        flag2 = false;
                    }
                }
                if (flag2)
                {
                    currentToolIndex = Game1.player.CurrentToolIndex;

                    ModEntry.isMovingAutomaticaly = true;
                    isHoldingMove        = true;
                    isBeingControl       = false;
                    isMouseOutsiteHitBox = vector_PlayerToMouse.Length().CompareTo(hitboxRadius) > 0;

                    bool flag3 = false;
                    flag3 = flag3 || isMouseOutsiteHitBox;

                    if (flag3)
                    {
                        e.SuppressButton();
                    }
                }
                else
                {
                    if (e.IsUseToolButton)
                    {
                        tickCount = 15;
                    }
                    else
                    {
                        tickCount = 0;
                    }
                    isBeingControl = true;
                }
            }
        }
示例#8
0
        private void InputEvents_ButtonPressed(object sender, EventArgsInput e)
        {
            bool   flag   = Context.IsWorldReady;
            string button = e.Button.ToString();

            if (button == RightClickMoveModeOpenButton)
            {
                isRightClickMoveModeOn = !isRightClickMoveModeOn;
            }
            if (button == ExtendedModeOpenButton)
            {
                isExtendedModeOn = !isExtendedModeOn;
            }

            if (isExtendedModeOn)
            {
                if (button == "RightControl")
                {
                    isHoldingRightCtrl = true;
                }
                if (button == "LeftControl")
                {
                    isHoldingLeftCtrl = true;
                }
                if (button == "RightAlt")
                {
                    isHoldingRightAlt = true;
                }

                if (button == "Enter" && isHoldingRightAlt)
                {
                    if (Game1.options.isCurrentlyWindowedBorderless() || Game1.options.isCurrentlyFullscreen())
                    {
                        Game1.options.setWindowedOption("Windowed");
                    }
                    else
                    {
                        Game1.options.setWindowedOption("Windowed Borderless");
                    }
                    Game1.exitActiveMenu();
                }
            }

            if (flag)
            {
                bool flag2 = button == "MouseRight" && isRightClickMoveModeOn && Context.IsPlayerFree;

                if (Game1.player.ActiveObject != null)
                {
                    if (Game1.player.ActiveObject.getCategoryName() == "Furniture")
                    {
                        flag2 = false;
                    }
                }

                if (!isWeaponsSpecticalInteraction)
                {
                    if (Game1.player.CurrentTool != null && Game1.player.CurrentTool is MeleeWeapon && SpecialCooldown((MeleeWeapon)Game1.player.CurrentTool) <= 0)
                    {
                        flag2 = false;
                    }
                }

                if (flag2)
                {
                    ModEntry.isMovingAutomaticaly = true;
                    isHoldingMove        = true;
                    isBeingControl       = false;
                    isMouseOutsiteHitBox = vector_PlayerToMouse.Length().CompareTo(hitboxRadius) > 0;

                    grabTile = new Vector2((float)(position_MouseOnScreen.X + Game1.viewport.X), (float)(position_MouseOnScreen.Y + Game1.viewport.Y)) / 64f;

                    if (Game1.player.currentLocation.getObjectAtTile((int)grabTile.X, (int)grabTile.Y) != null)
                    {
                        pointedObject = Game1.player.currentLocation.getObjectAtTile((int)grabTile.X, (int)grabTile.Y);
                    }
                    else
                    {
                        pointedObject = null;
                    }

                    bool flag3 = false;
                    flag3 = flag3 || isMouseOutsiteHitBox;

                    if (flag3)
                    {
                        e.SuppressButton();
                    }
                }
                else
                {
                    if (e.IsUseToolButton)
                    {
                        tickCount = 15;
                    }
                    else
                    {
                        tickCount = 0;
                    }
                    isBeingControl = true;
                }
            }
        }
示例#9
0
        private static void onKeyPress(object sender, EventArgsInput args)
        {
            if (args.Button == Config.Key_Cast)
            {
                castPressed = true;
            }

            if (Data == null || Game1.activeClickableMenu != null)
            {
                return;
            }
            if (args.Button == Config.Key_SwapSpells)
            {
                Game1.player.getSpellBook().swapPreparedSet();
            }
            else if (castPressed &&
                     (args.Button == Config.Key_Spell1 || args.Button == Config.Key_Spell2 ||
                      args.Button == Config.Key_Spell3 || args.Button == Config.Key_Spell4))
            {
                int slot = 0;
                if (args.Button == Config.Key_Spell1)
                {
                    slot = 0;
                }
                else if (args.Button == Config.Key_Spell2)
                {
                    slot = 1;
                }
                else if (args.Button == Config.Key_Spell3)
                {
                    slot = 2;
                }
                else if (args.Button == Config.Key_Spell4)
                {
                    slot = 3;
                }

                args.SuppressButton();

                SpellBook       book     = Game1.player.getSpellBook();
                PreparedSpell[] prepared = book.getPreparedSpells();
                if (prepared[slot] == null)
                {
                    return;
                }
                PreparedSpell prep = prepared[slot];

                Spell toCast = SpellBook.get(prep.SpellId);
                if (toCast == null)
                {
                    return;
                }

                //Log.trace("MEOW " + prep.SpellId + " " + prep.Level + " " + Game1.player.canCastSpell(toCast, prep.Level));
                if (Game1.player.canCastSpell(toCast, prep.Level))
                {
                    Log.trace("Casting " + prep.SpellId);
                    Game1.player.castSpell(toCast, prep.Level);
                    Game1.player.addMana(-toCast.getManaCost(Game1.player, prep.Level));
                }
            }
        }