Added chat menu keys to mod config

master
Mohammad Shoaib 2022-05-16 21:34:19 +05:30
parent f85192178f
commit b1056a6cd1
4 changed files with 44 additions and 49 deletions

View File

@ -133,7 +133,7 @@ namespace stardew_access.Features
{
this.cursorMoveInput(new Vector2(-Game1.tileSize, 0));
}
else if (MainClass.Config.AutoWalkToTile.JustPressed() && StardewModdingAPI.Context.IsPlayerFree)
else if (MainClass.Config.AutoWalkToTileKey.JustPressed() && StardewModdingAPI.Context.IsPlayerFree)
{
this.startAutoWalking();
}

View File

@ -4,31 +4,28 @@ namespace stardew_access
{
internal class ModConfig
{
public Boolean VerboseCoordinates { get; set; } = true;
public Boolean ReadTile { get; set; } = true;
public Boolean SnapMouse { get; set; } = true;
public Boolean Radar { get; set; } = false;
public Boolean RadarStereoSound { get; set; } = true;
public Boolean ReadFlooring { get; set; } = false;
#region KeyBinds
// https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Input#SButton button key codes
#region Simulate mouse clicks
public KeybindList LeftClickMainKey { get; set; } = KeybindList.Parse("LeftControl + Enter");
public KeybindList RightClickMainKey { get; set; } = KeybindList.Parse("LeftShift + Enter");
public KeybindList LeftClickAlternateKey { get; set; } = KeybindList.Parse("OemOpenBrackets");
public KeybindList RightClickAlternateKey { get; set; } = KeybindList.Parse("OemCloseBrackets");
public KeybindList HealthNStaminaKey { get; set; } = KeybindList.Parse("H");
public KeybindList PositionKey { get; set; } = KeybindList.Parse("K");
public KeybindList LocationKey { get; set; } = KeybindList.Parse("LeftAlt + K");
public KeybindList MoneyKey { get; set; } = KeybindList.Parse("R");
public KeybindList TimeNSeasonKey { get; set; } = KeybindList.Parse("Q");
#endregion
#region Chat menu
public KeybindList ChatMenuNextKey { get; set; } = KeybindList.Parse("PageUp");
public KeybindList ChatMenuPreviousKey { get; set; } = KeybindList.Parse("PageDown");
#endregion
#region Read tile
public Boolean ReadTile { get; set; } = true;
public KeybindList ReadTileKey { get; set; } = KeybindList.Parse("J");
public KeybindList ReadStandingTileKey { get; set; } = KeybindList.Parse("LeftAlt + J");
public bool LimitTileCursorToScreen { get; set; } = false;
public int TileCursorPreciseMovementDistance { get; set; } = 8;
public Boolean ReadFlooring { get; set; } = false;
#endregion
//Tile viewer keys
#region Tile viewer
public KeybindList TileCursorUpKey { get; set; } = KeybindList.Parse("Up");
public KeybindList TileCursorRightKey { get; set; } = KeybindList.Parse("Right");
public KeybindList TileCursorDownKey { get; set; } = KeybindList.Parse("Down");
@ -38,7 +35,24 @@ namespace stardew_access
public KeybindList TileCursorPreciseDownKey { get; set; } = KeybindList.Parse("LeftShift + Down");
public KeybindList TileCursorPreciseLeftKey { get; set; } = KeybindList.Parse("LeftShift + Left");
public KeybindList ToggleRelativeCursorLockKey { get; set; } = KeybindList.Parse("L");
public KeybindList AutoWalkToTile { get; set; } = KeybindList.Parse("LeftControl + Enter");
public KeybindList AutoWalkToTileKey { get; set; } = KeybindList.Parse("LeftControl + Enter");
public bool LimitTileCursorToScreen { get; set; } = false;
public int TileCursorPreciseMovementDistance { get; set; } = 8;
#endregion
#region Radar
public Boolean Radar { get; set; } = false;
public Boolean RadarStereoSound { get; set; } = true;
#endregion
#region Others
public KeybindList HealthNStaminaKey { get; set; } = KeybindList.Parse("H");
public KeybindList PositionKey { get; set; } = KeybindList.Parse("K");
public KeybindList LocationKey { get; set; } = KeybindList.Parse("LeftAlt + K");
public KeybindList MoneyKey { get; set; } = KeybindList.Parse("R");
public KeybindList TimeNSeasonKey { get; set; } = KeybindList.Parse("Q");
public Boolean VerboseCoordinates { get; set; } = true;
public Boolean SnapMouse { get; set; } = true;
#endregion
// TODO Add the exclusion and focus list too

View File

@ -192,22 +192,18 @@ namespace stardew_access
if (e == null)
return;
bool isLeftAltPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftAlt);
#region Simulate left and right clicks
if (Game1.activeClickableMenu != null)
{
bool isLeftShiftPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift);
bool isLeftControlPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftControl);
bool isCustomizingChrachter = Game1.activeClickableMenu is CharacterCustomization || (TitleMenu.subMenu != null && TitleMenu.subMenu is CharacterCustomization);
#region Mouse Click Simulation
// Main Keybinds
if (isLeftControlPressed && Config.LeftClickMainKey.JustPressed())
if (Config.LeftClickMainKey.JustPressed())
{
Game1.activeClickableMenu.receiveLeftClick(Game1.getMouseX(true), Game1.getMouseY(true));
}
if (isLeftShiftPressed && Config.RightClickMainKey.JustPressed())
if (Config.RightClickMainKey.JustPressed())
{
Game1.activeClickableMenu.receiveRightClick(Game1.getMouseX(true), Game1.getMouseY(true));
}
@ -226,17 +222,15 @@ namespace stardew_access
if (Game1.currentMinigame != null)
{
bool isLeftShiftPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift);
bool isLeftControlPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftControl);
bool isCustomizingChrachter = Game1.activeClickableMenu is CharacterCustomization || (TitleMenu.subMenu != null && TitleMenu.subMenu is CharacterCustomization);
#region Mouse Click Simulation
// Main Keybinds
if (isLeftControlPressed && Config.LeftClickMainKey.JustPressed())
if (Config.LeftClickMainKey.JustPressed())
{
Game1.currentMinigame.receiveLeftClick(Game1.getMouseX(true), Game1.getMouseY(true));
}
if (isLeftShiftPressed && Config.RightClickMainKey.JustPressed())
if (Config.RightClickMainKey.JustPressed())
{
Game1.currentMinigame.receiveRightClick(Game1.getMouseX(true), Game1.getMouseY(true));
}

View File

@ -16,19 +16,19 @@ namespace stardew_access.Patches
if (__instance.chatBox.Selected)
{
bool isPrevArrowPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.PageUp);
bool isNextArrowPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.PageDown);
bool isPrevButtonPressed = MainClass.Config.ChatMenuNextKey.JustPressed();
bool isNextButtonPressed = MainClass.Config.ChatMenuPreviousKey.JustPressed();
if (___messages.Count > 0)
{
#region To narrate previous and next chat messages
if (isNextArrowPressed && !isChatRunning)
if (isNextButtonPressed && !isChatRunning)
{
isChatRunning = true;
CycleThroughChatMessages(true, ___messages);
Task.Delay(200).ContinueWith(_ => { isChatRunning = false; });
}
else if (isPrevArrowPressed && !isChatRunning)
else if (isPrevButtonPressed && !isChatRunning)
{
isChatRunning = true;
CycleThroughChatMessages(false, ___messages);
@ -58,22 +58,9 @@ namespace stardew_access.Patches
private static void CycleThroughChatMessages(bool increase, List<ChatMessage> ___messages)
{
string toSpeak = " ";
if (increase)
{
++currentChatMessageIndex;
if (currentChatMessageIndex > ___messages.Count - 1)
{
currentChatMessageIndex = ___messages.Count - 1;
}
}
else
{
--currentChatMessageIndex;
if (currentChatMessageIndex < 0)
{
currentChatMessageIndex = 0;
}
}
currentChatMessageIndex = (increase) ? (Math.Min(currentChatMessageIndex + 1, ___messages.Count - 1)) : (currentChatMessageIndex = Math.Max(currentChatMessageIndex - 1, 0));
___messages[currentChatMessageIndex].message.ForEach(message =>
{
toSpeak += $"{message.message}, ";