private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (Context.CanPlayerMove && Config.CheckDonationCollection == e.Button) { Game1.activeClickableMenu = new AquariumCollectionMenu(Helper.Translation.Get("CollectionsMenu")); } }
private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { // Detect when the player uses an Axe or Pickaxe while standing next to an augmented, indestructible machine (such as an Incubator). // This will remove the augmentors from the machine. // (Destructible machines are handled by AugmentedTile.Update, which checks for when a machine is un-placed) if (Context.IsGameLaunched && Context.IsWorldReady && (!Context.IsMultiplayer || Context.IsMainPlayer) && e.Button.IsUseToolButton() && PlacedAugmentorsManager.Instance != null) { Farmer Player = Game1.MasterPlayer; if (Player.CurrentTool != null && (Player.CurrentTool is Pickaxe || Player.CurrentTool is Axe)) { Vector2 ToolTile = Player.GetToolLocation() / Game1.tileSize; GameLocation Location = Player.currentLocation; if (PlacedAugmentorsManager.Instance.Locations.TryGetValue(Location.NameOrUniqueName, out AugmentedLocation AugLoc)) { if (AugLoc.Tiles.TryGetValue(AugmentedLocation.EncodeTileToString(ToolTile), out AugmentedTile AugTile)) { if (!MachineInfo.IsDestructible(AugTile.Machine)) { AugLoc.OnMachineRemoved(AugTile); } } } } } }
static void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (!StardewModdingAPI.Context.IsWorldReady) { return; } //xTile.Dimensions.Location location = new xTile.Dimensions.Location((int)Game1.player.Position.X + Game1.tileSize / 2, (int)Game1.player.Position.Y + Game1.tileSize / 2); //ShowTileInfo(location); SetFacingDir(); if (Game1.activeClickableMenu == null) { if (Inputs.IsTTSMapCheckUnderneathButton(e.Button, e.IsDown)) { SpeakUnderneathDescription(); } else if (Inputs.IsTTSMapCheckButton(e.Button)) { //ModEntry.Log($"dir: {Game1.player.getDirection()}, fdir: {Game1.player.getFacingDirection()}"); string descr = FindBarrierDescription(); if (descr.Length > 0) { TextToSpeech.Speak("You feel a " + descr); } } else if (false && Inputs.IsGameMenuButton(e.Button)) { Game1.activeClickableMenu = new StardewValley.Menus.GameMenu(true); Menus.AccessMenu menu = ModEntry.GetInstance().SelectMenu(Game1.activeClickableMenu); (menu as Menus.AccessGameMenu).ButtonPressed(e.Button); } } }
/******************** ** Input detection ** *********************/ private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (!Context.CanPlayerMove) { return; } if (Constants.TargetPlatform == GamePlatform.Android) { if (e.Button != SButton.MouseLeft) { return; } if (e.Cursor.GrabTile != e.Cursor.Tile) { return; } } else if (!e.Button.IsActionButton()) { return; } Vector2 grabTile = e.Cursor.GrabTile; string tileProperty = Game1.currentLocation.doesTileHaveProperty((int)grabTile.X, (int)grabTile.Y, "Action", "Buildings"); if (tileProperty != "TrainStation") { return; } VanillaPreconditionsMethod = Helper.Reflection.GetMethod(Game1.currentLocation, "checkEventPrecondition"); OpenTrainMenu(); }
private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (Context.IsWorldReady && e.Button == SButton.Escape && Game1.activeClickableMenu is CabinQuestionsBox) { Game1.playSound("smallSelect"); helper.Input.Suppress(e.Button); Game1.activeClickableMenu = null; } if (!Context.CanPlayerMove) { return; } if (!e.Button.IsActionButton()) { return; } if (Game1.currentLocation.Name != "ScienceHouse") { return; } if (helper.Input.GetCursorPosition().GrabTile != new Microsoft.Xna.Framework.Vector2(6, 19)) { return; } AskForUpgrade(); }
private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (!clickedOnQuote) { clickedOnQuote = true; } }
public void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (e.Button == Config.ReloadButton) { LoadAdvancedMeleeWeapons(); } }
private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (e.Button == SButton.MouseRight && Context.IsWorldReady && Context.CanPlayerMove && (Game1.player.CurrentTool is FishingRod)) { if (hereFishying) { if (canPerfect) { perfect = true; sparklingText = new SparklingText(Game1.dialogueFont, Game1.content.LoadString("Strings\\UI:BobberBar_Perfect"), Color.Yellow, Color.White, false, 0.1, 1500, -1, 500, 1f); Game1.playSound("jingle1"); } return; } try { Vector2 mousePos = Game1.currentCursorTile; if (Game1.player.currentLocation.waterTiles != null && Game1.player.currentLocation.waterTiles[(int)mousePos.X, (int)mousePos.Y]) { context.Monitor.Log($"here fishy fishy {mousePos.X},{mousePos.Y}"); HereFishyFishy(Game1.player, (int)mousePos.X * 64, (int)mousePos.Y * 64); } } catch { context.Monitor.Log($"error getting water tile"); } } }
private void InputEvents_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if ((Keys)e.Button == menuKey && Game1.activeClickableMenu == null) { Game1.activeClickableMenu = new Menu.InputDeviceMenu(kbManager, miceManager); } }
private static void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (Game1.activeClickableMenu != null && Game1.player.currentLocation is MineShaft && Game1.player.currentLocation.lastQuestionKey == "UndergroundSecrets_Question") { IClickableMenu menu = Game1.activeClickableMenu; if (menu == null || menu.GetType() != typeof(DialogueBox)) { return; } DialogueBox db = menu as DialogueBox; int resp = db.selectedResponse; List <Response> resps = db.responses; if (resp < 0 || resps == null || resp >= resps.Count || resps[resp] == null) { return; } Game1.player.currentLocation.lastQuestionKey = ""; helper.Events.Input.ButtonPressed -= Input_ButtonPressed; AnswerResult(resps[resp].responseKey); return; } }
private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (e.Button.Equals(config.ShortcutKey) && Game1.activeClickableMenu is GameMenu menu && Game1.player.CursorSlotItem is StardewValley.Object obj && obj.canBeShipped()) { ShipObject(obj); } }
private void Input_ButtonPressed(object?sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (!Context.IsWorldReady) { return; } if (e.Button == config.VotePauseHotkey) { votePauseToggle(); } else if (e.Button == config.PauseOverrideHotkey && Context.IsMainPlayer && config.EnablePauseOverride) { pauseOverride = !pauseOverride; if (!config.DisplayVotePauseMessages) { return; } if (pauseOverride) { this.Helper.Multiplayer.SendMessage <string>("The host has paused via override.", "info", new[] { this.ModManifest.UniqueID }); Game1.chatBox.addInfoMessage("The host has paused via override."); } else { this.Helper.Multiplayer.SendMessage <string>("The host has unpaused their override.", "info", new[] { this.ModManifest.UniqueID }); Game1.chatBox.addInfoMessage("The host has unpaused their override."); } } }
private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (Game1.activeClickableMenu == null || !(Game1.activeClickableMenu is DialogueBox) || !Helper.Reflection.GetField <bool>(Game1.activeClickableMenu, "isQuestion").GetValue()) { return; } if (e.Button == Config.SelectFirstResponseKey && Helper.Reflection.GetField <List <Response> >(Game1.activeClickableMenu, "responses").GetValue().Count == 2) { Monitor.Log("Pressed selectFirstResponse button key on question dialogue"); Helper.Reflection.GetField <int>(Game1.activeClickableMenu, "selectedResponse").SetValue(0); Game1.activeClickableMenu.receiveLeftClick(0, 0, true); Helper.Input.Suppress(e.Button); return; } List <SButton> sbs = new List <SButton> { SButton.D1, SButton.D2, SButton.D3, SButton.D4, SButton.D5, SButton.D6, SButton.D7, SButton.D8, SButton.D9, SButton.D0 }; if (sbs.Contains(e.Button) && sbs.IndexOf(e.Button) < Helper.Reflection.GetField <List <Response> >(Game1.activeClickableMenu, "responses").GetValue().Count) { Monitor.Log($"Pressed {e.Button} key on question dialogue"); Helper.Reflection.GetField <int>(Game1.activeClickableMenu, "selectedResponse").SetValue(sbs.IndexOf(e.Button)); Game1.activeClickableMenu.receiveLeftClick(0, 0, true); Helper.Input.Suppress(e.Button); return; } }
private void OnButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (GetClicked(e.Button)) { OnAction(); } }
private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (e.Button == Config.ToggleModKey) { Config.EnableMod = !Config.EnableMod; Helper.WriteConfig(Config); } }
/// <summary> /// Event handler for sorting the inventory when the organise button is clicked. /// </summary> /// <param name="sender">The object from which the event originated.</param> /// <param name="e">These are the arguments sent along with the event from SMAPI, used here to get cursor position.</param> private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (e.Button == SButton.MouseLeft && this.organiseButton.containsPoint((int)e.Cursor.ScreenPixels.X, (int)e.Cursor.ScreenPixels.Y)) { CustomOrganise((IList <Item>)Game1.player.items); Game1.playSound("Ship"); } }
/// <summary> /// Event handler for clicking the button. /// The button is clicked if it is the left mouse button that is pressed, the cursor is within the button bounds /// and the mod option for toolbar toggle is enabled. /// </summary> /// <param name="sender">The object from which the event originated.</param> /// <param name="e">These are the arguments sent along with the event from SMAPI, contains which button was pressed and cursor position.</param> private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (e.Button == SButton.MouseLeft && this.ToolbarOption.IsActive && this.Bounds.Contains((int)e.Cursor.ScreenPixels.X, (int)e.Cursor.ScreenPixels.Y)) { this.ToolbarPositionFlag = !ToolbarPositionFlag; } }
private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (e.Button == Config.FireButton) { Monitor.Log($"Begin fire breath, skill level {Game1.player.getEffectiveSkillLevel(4)}"); firing = true; } }
private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (Context.IsWorldReady && e.Button == Config.LightningButton) { Monitor.Log("Lightning strike!"); Utility.performLightningUpdate(Game1.timeOfDay); } }
private static void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (e.Button == SButton.Escape && cycles != 0) { cycles = 2001; Helper.Events.Input.ButtonPressed -= Input_ButtonPressed; } }
private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (e.Button == Config.ToggleButton && !Config.RequireButtonDown) { Config.MakeTransparent = !Config.MakeTransparent; Helper.WriteConfig(Config); Monitor.Log($"Toggled transparency to {Config.MakeTransparent}"); } }
private void OnButtonPressed(object?sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (e.Button is SButton.J) { Monitor.Log("Player pressed J, opening the Bundle Menu", LogLevel.Info); Game1.activeClickableMenu = new EndgameBundleMenu(Helper, Monitor, bundleSets); } }
private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (!Context.CanPlayerMove) { return; } if (Constants.TargetPlatform == GamePlatform.Android) { if (e.Button != SButton.MouseLeft) { return; } if (e.Cursor.GrabTile != e.Cursor.Tile) { return; } } else if (!e.Button.IsActionButton()) { return; } if (!Game1.MasterPlayer.mailReceived.Contains("ccPantry")) { return; } Vector2 grabTile = e.Cursor.GrabTile; if (Game1.currentLocation.Name == "JojaMart" && State.IsJojaRoute) { if (grabTile != State.Config.JojaMartUpgradeCoordinates) { return; } new UpgradeMenu(_helper, _monitor, true); } else if (Game1.currentLocation.Name == "CommunityCenter" && !State.IsJojaRoute) { if (grabTile != State.Config.CommunityCenterUpgradeCoordinates) { return; } if (Game1.player.ActiveObject != null) { //donate object } else { new UpgradeMenu(_helper, _monitor, false); } } }
private static void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (e.Button == SButton.MouseLeft) { leftMouse = true; } else if (e.Button == SButton.MouseRight) { rightMouse = true; } }
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">Event arguments.</param> private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (!Context.IsWorldReady) { return; } if (e.Button.IsActionButton()) { this.TryHurtBecauseCactus(Game1.currentLocation, e.Cursor.GrabTile, Game1.player, true); } }
private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (!Context.CanPlayerMove) { return; } if (Constants.TargetPlatform == GamePlatform.Android) { if (e.Button != SButton.MouseLeft) { return; } if (e.Cursor.GrabTile != e.Cursor.Tile) { return; } } else if (!e.Button.IsActionButton()) { return; } Vector2 grabTile = e.Cursor.GrabTile; string tileProperty = Game1.currentLocation.doesTileHaveProperty((int)grabTile.X, (int)grabTile.Y, "Action", "Buildings"); if (tileProperty == null) { return; } if (tileProperty == "AquariumDonationMenu") { _monitor.Log("AquariumDonationMenu tile detected, opening donation menu..."); TryToOpenDonationMenu(); } else if (tileProperty == "AquariumCollectionMenu") { _monitor.Log("AquariumCollectionMenu tile detected, opening collections menu..."); Game1.activeClickableMenu = new AquariumCollectionMenu(_helper.Translation.Get("CollectionsMenu")); } else if (tileProperty.StartsWith("AquariumSign")) { new AquariumMessage(tileProperty.Split(' ')); } else if (tileProperty.StartsWith("AquariumString")) { string strKey = tileProperty.Split(' ')[1]; Game1.drawObjectDialogue(_helper.Translation.Get(strKey)); } }
private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (e.Button == Config.ToggleModKey) { Config.EnableMod = !Config.EnableMod; Helper.WriteConfig(Config); Monitor.Log($"Mod Enabled: {Config.EnableMod}"); if (Config.ShowMessage) { Game1.addHUDMessage(new HUDMessage(string.Format(Helper.Translation.Get("mod-enabled-x"), Config.EnableMod), 1)); } } }
private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (Config.EnableMod && Game1.activeClickableMenu is CraftingPage && AccessTools.FieldRefAccess <CraftingPage, bool>(Game1.activeClickableMenu as CraftingPage, "cooking")) { for (int i = 0; i < oldIngredients.Length; i++) { if (ingredients[i] is null != oldIngredients is null || ingredients[i]?.Stack != oldIngredients[i]?.Stack || ingredients[i]?.ParentSheetIndex != oldIngredients[i]?.ParentSheetIndex) { UpdateCurrentCookables(); } } } }
private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (!Config.EnableMod) { return; } if (e.Button == Config.BuildKey && Helper.Input.IsDown(Config.ModKey) && Context.CanPlayerMove) { isBuilding = true; buildingRect = new Rectangle(Utility.Vector2ToPoint(Game1.lastCursorTile), new Point(1, 1)); Helper.Input.Suppress(Config.BuildKey); } }
/// <summary> /// Resets tool colors when left click is used for normal tools. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public static void ResetNormalToolsColorOnLeftClick(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { if (e.Button == SButton.MouseLeft) { if (Game1.player.CurrentTool != null) { if (ObjectUtilities.IsSameType(Game1.player.CurrentTool.GetType(), typeof(Pickaxe)) || ObjectUtilities.IsSameType(Game1.player.CurrentTool.GetType(), typeof(Axe)) || ObjectUtilities.IsSameType(Game1.player.CurrentTool.GetType(), typeof(Hoe)) || ObjectUtilities.IsSameType(Game1.player.CurrentTool.GetType(), typeof(WateringCan))) { ColorChanger.ResetToolColorSwaps(); } } } }