/// <inheritdoc /> public void Suppress(SButton button) { this.InputState.OverrideButton(button, setDown: false); }
public static bool IsTTSTimeButton(SButton b) => ModEntry.GetConfig().key_tts_time.Contains(b);
public static bool IsGameMenuInventoryButton(SButton b) => ModEntry.GetConfig().key_gamemenu_inv.Contains(b);
public static bool IsTTSMapCheckUnderneathButton(SButton b, System.Func <SButton, bool> extra) => IsTTSMapCheckButton(b) && (extra(SButton.LeftShift) || extra(SButton.RightShift));
public static bool IsTTSRepeatButton(SButton b) => ModEntry.GetConfig().key_tts_repeat.Contains(b);
public static bool IsMenuDeleteButton(SButton b) => ModEntry.GetConfig().key_menu_delete.Contains(b);
public static bool IsMenuTitleMuteButton(SButton b) => ModEntry.GetConfig().key_menu_title_mute.Contains(b);
public void AddKey(SButton key, string description) { var component = new ClickableTextureComponent("", Rectangle.Empty, null, description, Game1.mouseCursors, new Rectangle(473, 36, 24, 24), 2.5f, false); this.Keys.Add(key, component); }
/// <summary>Raise a <see cref="ButtonReleased"/> event.</summary> /// <param name="monitor">Encapsulates monitoring and logging.</param> /// <param name="button">The button on the controller, keyboard, or mouse.</param> /// <param name="cursor">The cursor position.</param> /// <param name="isActionButton">Whether the input should trigger actions on the affected tile.</param> /// <param name="isUseToolButton">Whether the input should use tools on the affected tile.</param> internal static void InvokeButtonReleased(IMonitor monitor, SButton button, ICursorPosition cursor, bool isActionButton, bool isUseToolButton) { monitor.SafelyRaiseGenericEvent($"{nameof(InputEvents)}.{nameof(InputEvents.ButtonReleased)}", InputEvents.ButtonReleased?.GetInvocationList(), null, new EventArgsInput(button, cursor, isActionButton, isUseToolButton)); }
/// <summary>Get the state of a button.</summary> /// <param name="button">The button to check.</param> public SButtonState GetState(SButton button) { return(this.InputState.GetState(button)); }
/// <summary>Whether we should consume the input, preventing it from reaching the game.</summary> /// <param name="keyPressed">The key that was pressed.</param> /// <returns>True if it should be consumed, false otherwise.</returns> protected virtual bool ShouldConsumeKeyboardInput(SButton keyPressed) { return(this.SplitMenu != null); }
/// <summary>Prevent the game from handling a button press. This doesn't prevent other mods from receiving the event.</summary> /// <param name="button">The button to suppress.</param> public void Suppress(SButton button) { this.InputState.SuppressButtons.Add(button); }
/// <summary>Get the status of a button.</summary> /// <param name="button">The button to check.</param> public InputStatus GetStatus(SButton button) { return(this.GetStatus(this.ActiveButtons, button)); }
private void OverrideRanching(GameLocation currentLocation, int x, int y, Farmer who, SButton button, string toolName) { AnimalBeingRanched = null; FarmAnimal animal = null; string ranchAction = string.Empty; string ranchProduct = string.Empty; if (toolName == null) { return; } switch (toolName) { case GameConstants.Tools.MilkPail: ranchAction = "Milking"; ranchProduct = "milk"; break; case GameConstants.Tools.Shears: ranchAction = "Shearing"; ranchProduct = "wool"; break; } var rectangle = new Rectangle(x - (Game1.tileSize / 2), y - (Game1.tileSize / 2), Game1.tileSize, Game1.tileSize); if (currentLocation is AnimalHouse animalHouse) { animal = animalHouse.GetSelectedAnimal(rectangle); } else if (currentLocation.IsFarm && currentLocation.IsOutdoors) { animal = ((Farm)currentLocation).GetSelectedAnimal(rectangle); } if (animal == null) { this.Helper.Input.OverwriteState(button, $"{ranchAction} Failed"); return; } if (animal.CanBeRanched(toolName)) { if (who.couldInventoryAcceptThisObject(animal.currentProduce.Value, 1, 0)) { AnimalBeingRanched = animal; return; } else { this.Helper.Input.OverwriteState(button, "Inventory Full"); } } else if (animal?.isBaby() == true && animal.toolUsedForHarvest.Equals(toolName)) { this.Helper.Input.OverwriteState(button); DelayedAction.showDialogueAfterDelay($"Baby {animal.Name} will produce {ranchProduct} in {animal.ageWhenMature.Value - animal.age.Value} days.", 0); } else { this.Helper.Input.OverwriteState(button, $"{ranchAction} Failed"); } }
public static bool IsMenuPrevButton(SButton b) => ModEntry.GetConfig().key_menu_prev.Contains(b);
/// <summary>Get whether a given button was pressed or held.</summary> /// <param name="button">The button to check.</param> public bool IsDown(SButton button) { return(this.GetStatus(this.ActiveButtons, button).IsDown()); }
public static bool IsMenuActivateButton(SButton b) => ModEntry.GetConfig().key_menu_activate.Contains(b) || b.IsActionButton();
/// <summary>Get the status of a button.</summary> /// <param name="activeButtons">The current button states to check.</param> /// <param name="button">The button to check.</param> private InputStatus GetStatus(IDictionary <SButton, InputStatus> activeButtons, SButton button) { return(activeButtons.TryGetValue(button, out InputStatus status) ? status : InputStatus.None); }
public static bool IsMenuEscapeButton(SButton b) => ModEntry.GetConfig().key_menu_escape.Contains(b);
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="button">The button on the controller, keyboard, or mouse.</param> /// <param name="cursor">The cursor position.</param> /// <param name="inputState">The game's current input state.</param> internal ButtonPressedEventArgs(SButton button, ICursorPosition cursor, SInputState inputState) { this.Button = button; this.Cursor = cursor; this.InputState = inputState; }
public static bool IsTTSMapCheckButton(SButton b) => ModEntry.GetConfig().key_tts_map_check.Contains(b);
/// <summary>Whether a mod has indicated the key was already handled, so the game should handle it.</summary> /// <param name="button">The button to check.</param> public bool IsSuppressed(SButton button) { return(this.InputState.SuppressButtons.Contains(button)); }
public static bool IsTTSInfoButton(SButton b) => ModEntry.GetConfig().key_tts_info.Contains(b);
/// <summary>Get whether a given button was pressed or held.</summary> /// <param name="button">The button to check.</param> public bool IsDown(SButton button) { return(this.InputState.IsDown(button)); }
public static bool IsTTSStopButton(SButton b) => ModEntry.GetConfig().key_tts_stop.Contains(b);
public static string constructCmdKey(SButton modifyKey, SButton key) { return(modifyKey + "+" + key); }
public static bool IsTTSHealthButton(SButton b) => ModEntry.GetConfig().key_tts_health.Contains(b);
public static bool IsMenuNextButton(SButton b) => ModEntry.GetConfig().key_menu_next.Contains(b);
public static bool IsGameMenuSkillsButton(SButton b) => ModEntry.GetConfig().key_gamemenu_skills.Contains(b);
/// <inheritdoc /> public bool IsSuppressed(SButton button) { return(this.InputState.IsSuppressed(button)); }