From 9c2931ec2fb9eca5bf223a522605d1550eb54c52 Mon Sep 17 00:00:00 2001 From: Mohammad Shoaib Date: Mon, 16 May 2022 22:01:02 +0530 Subject: [PATCH] Added all keybinds to mod config --- stardew-access/ModConfig.cs | 24 ++++++++++++++++++- .../Patches/BuildingNAnimalMenuPatches.cs | 2 +- stardew-access/Patches/BundleMenuPatches.cs | 10 ++++---- stardew-access/Patches/DonationMenuPatches.cs | 2 +- stardew-access/Patches/GameMenuPatches.cs | 21 ++++++---------- stardew-access/Patches/MenuPatches.cs | 4 ++-- stardew-access/Patches/QuestPatches.cs | 2 +- stardew-access/Patches/TitleMenuPatches.cs | 12 ++-------- 8 files changed, 42 insertions(+), 35 deletions(-) diff --git a/stardew-access/ModConfig.cs b/stardew-access/ModConfig.cs index ecea532..aac7609 100644 --- a/stardew-access/ModConfig.cs +++ b/stardew-access/ModConfig.cs @@ -45,6 +45,28 @@ namespace stardew_access public Boolean RadarStereoSound { get; set; } = true; #endregion + #region Menu Keys + public KeybindList PrimaryInfoKey { get; set; } = KeybindList.Parse("C"); + + // Charachter Creatinon menu (new game menu) keys + public KeybindList CharacterCreationMenuNextKey { get; set; } = KeybindList.Parse("Right"); + public KeybindList CharacterCreationMenuPreviousKey { get; set; } = KeybindList.Parse("Left"); + + // Bundle menu keys + public KeybindList BundleMenuIngredientsKey { get; set; } = KeybindList.Parse("I"); + public KeybindList BundleMenuInventoryItemsKey { get; set; } = KeybindList.Parse("C"); + public KeybindList BundleMenuPurchaseButtonKey { get; set; } = KeybindList.Parse("P"); + public KeybindList BundleMenuIngredientsInputSlotKey { get; set; } = KeybindList.Parse("V"); + public KeybindList BundleMenuBackButtonKey { get; set; } = KeybindList.Parse("Back"); + + // Menus with secondary inventory(shop inventory or chest inventory or crafting recipe list) + public KeybindList SnapToFirstInventorySlotKey { get; set; } = KeybindList.Parse("I"); + public KeybindList SnapToFirstSecondaryInventorySlotKey { get; set; } = KeybindList.Parse("LeftShift + I"); + + // Crafting menu + public KeybindList CraftingMenuCycleThroughRecipiesKey { get; set; } = KeybindList.Parse("C"); + #endregion + #region Others public KeybindList HealthNStaminaKey { get; set; } = KeybindList.Parse("H"); public KeybindList PositionKey { get; set; } = KeybindList.Parse("K"); @@ -58,4 +80,4 @@ namespace stardew_access // TODO Add the exclusion and focus list too // public String ExclusionList { get; set; } = "test"; } -} +} \ No newline at end of file diff --git a/stardew-access/Patches/BuildingNAnimalMenuPatches.cs b/stardew-access/Patches/BuildingNAnimalMenuPatches.cs index 1d71a5d..1ac91d5 100644 --- a/stardew-access/Patches/BuildingNAnimalMenuPatches.cs +++ b/stardew-access/Patches/BuildingNAnimalMenuPatches.cs @@ -125,7 +125,7 @@ namespace stardew_access.Patches return; int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position - bool isCPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.C); + bool isCPressed = MainClass.Config.PrimaryInfoKey.JustPressed(); string ingredients = ""; string name = currentBluprint.displayName; string upgradeName = currentBluprint.nameOfBuildingToUpgrade; diff --git a/stardew-access/Patches/BundleMenuPatches.cs b/stardew-access/Patches/BundleMenuPatches.cs index a1bf47c..2f8aae4 100644 --- a/stardew-access/Patches/BundleMenuPatches.cs +++ b/stardew-access/Patches/BundleMenuPatches.cs @@ -151,11 +151,11 @@ namespace stardew_access.Patches } else { - bool isIPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.I); // For the ingredients - bool isCPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.C); // For the items in inventory - bool isPPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.P); // For the Purchase Button - bool isVPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.V); // For the ingredient input slots - bool isBackPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Back); // For the back button + bool isIPressed = MainClass.Config.BundleMenuIngredientsInputSlotKey.JustPressed(); // For the ingredients + bool isCPressed = MainClass.Config.BundleMenuInventoryItemsKey.JustPressed(); // For the items in inventory + bool isPPressed = MainClass.Config.BundleMenuPurchaseButtonKey.JustPressed(); // For the Purchase Button + bool isVPressed = MainClass.Config.BundleMenuIngredientsInputSlotKey.JustPressed(); // For the ingredient input slots + bool isBackPressed = MainClass.Config.BundleMenuBackButtonKey.JustPressed(); // For the back button bool isLeftShiftPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift); if (isIPressed && !isUsingCustomButtons) diff --git a/stardew-access/Patches/DonationMenuPatches.cs b/stardew-access/Patches/DonationMenuPatches.cs index ce244ac..8f4747b 100644 --- a/stardew-access/Patches/DonationMenuPatches.cs +++ b/stardew-access/Patches/DonationMenuPatches.cs @@ -82,7 +82,7 @@ namespace stardew_access.Patches int i = narrateHoveredItemInInventory(__instance.inventory, __instance.inventory.inventory, __instance.inventory.actualInventory, x, y); if (i != -9999) { - bool isCPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.C); // For donating hovered item + bool isCPressed = MainClass.Config.PrimaryInfoKey.JustPressed(); // For donating hovered item if (isCPressed && __instance.inventory.actualInventory[i] != null) { diff --git a/stardew-access/Patches/GameMenuPatches.cs b/stardew-access/Patches/GameMenuPatches.cs index d3d468a..228dded 100644 --- a/stardew-access/Patches/GameMenuPatches.cs +++ b/stardew-access/Patches/GameMenuPatches.cs @@ -191,15 +191,13 @@ namespace stardew_access.Patches try { int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position - bool isIPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.I); - bool isLeftShiftPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift); - if (isLeftShiftPressed && isIPressed && __instance.inventory.inventory.Count > 0) + if (MainClass.Config.SnapToFirstInventorySlotKey.JustPressed() && __instance.inventory.inventory.Count > 0) { __instance.inventory.inventory[0].snapMouseCursorToCenter(); __instance.setCurrentlySnappedComponentTo(__instance.inventory.inventory[0].myID); } - else if (!isLeftShiftPressed && isIPressed && __instance.forSaleButtons.Count > 0) + else if (MainClass.Config.SnapToFirstSecondaryInventorySlotKey.JustPressed() && __instance.forSaleButtons.Count > 0) { __instance.forSaleButtons[0].snapMouseCursorToCenter(); __instance.setCurrentlySnappedComponentTo(__instance.forSaleButtons[0].myID); @@ -413,15 +411,13 @@ namespace stardew_access.Patches try { int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position - bool isIPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.I); - bool isLeftShiftPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift); - if (isLeftShiftPressed && isIPressed && __instance.inventory.inventory.Count > 0) + if (MainClass.Config.SnapToFirstInventorySlotKey.JustPressed() && __instance.inventory.inventory.Count > 0) { __instance.setCurrentlySnappedComponentTo(__instance.inventory.inventory[0].myID); __instance.inventory.inventory[0].snapMouseCursorToCenter(); } - else if (!isLeftShiftPressed && isIPressed && __instance.ItemsToGrabMenu.inventory.Count > 0 && !__instance.shippingBin) + else if (MainClass.Config.SnapToFirstSecondaryInventorySlotKey.JustPressed() && __instance.ItemsToGrabMenu.inventory.Count > 0 && !__instance.shippingBin) { __instance.setCurrentlySnappedComponentTo(__instance.ItemsToGrabMenu.inventory[0].myID); __instance.ItemsToGrabMenu.inventory[0].snapMouseCursorToCenter(); @@ -677,25 +673,22 @@ namespace stardew_access.Patches try { int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position - bool isIPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.I); - bool isCPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.C); - bool isLeftShiftPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift); - if (isLeftShiftPressed && isIPressed && __instance.inventory.inventory.Count > 0) + if (MainClass.Config.SnapToFirstInventorySlotKey.JustPressed() && __instance.inventory.inventory.Count > 0) { // snap to first inventory slot __instance.setCurrentlySnappedComponentTo(__instance.inventory.inventory[0].myID); __instance.inventory.inventory[0].snapMouseCursorToCenter(); currentSelectedCraftingRecipe = -1; } - else if (!isLeftShiftPressed && isIPressed && __instance.pagesOfCraftingRecipes[___currentCraftingPage].Count > 0) + else if (MainClass.Config.SnapToFirstSecondaryInventorySlotKey.JustPressed() && __instance.pagesOfCraftingRecipes[___currentCraftingPage].Count > 0) { // snap to first crafting recipe __instance.setCurrentlySnappedComponentTo(__instance.pagesOfCraftingRecipes[___currentCraftingPage].ElementAt(0).Key.myID); __instance.pagesOfCraftingRecipes[___currentCraftingPage].ElementAt(0).Key.snapMouseCursorToCenter(); currentSelectedCraftingRecipe = 0; } - else if (isCPressed && !isSelectingRecipe) + else if (MainClass.Config.CraftingMenuCycleThroughRecipiesKey.JustPressed() && !isSelectingRecipe) { isSelectingRecipe = true; CycleThroughRecipies(__instance.pagesOfCraftingRecipes, ___currentCraftingPage, __instance); diff --git a/stardew-access/Patches/MenuPatches.cs b/stardew-access/Patches/MenuPatches.cs index e1abd64..8dc4c92 100644 --- a/stardew-access/Patches/MenuPatches.cs +++ b/stardew-access/Patches/MenuPatches.cs @@ -171,7 +171,7 @@ namespace stardew_access.Patches try { int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position - bool isCPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.C); + bool isCPressed = MainClass.Config.PrimaryInfoKey.JustPressed(); string toSpeak = " ", extra = ""; if (___confirmingEmpty) @@ -355,7 +355,7 @@ namespace stardew_access.Patches try { int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position - bool isCPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.C); // For narrating animal details + bool isCPressed = MainClass.Config.PrimaryInfoKey.JustPressed(); // For narrating animal details bool isEscPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape); // For escaping/unselecting from the animal name text box string toSpeak = " ", details = " "; diff --git a/stardew-access/Patches/QuestPatches.cs b/stardew-access/Patches/QuestPatches.cs index 73e6784..f5f9835 100644 --- a/stardew-access/Patches/QuestPatches.cs +++ b/stardew-access/Patches/QuestPatches.cs @@ -154,7 +154,7 @@ namespace stardew_access.Patches { try { - bool isCPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.C); + bool isCPressed = MainClass.Config.PrimaryInfoKey.JustPressed(); int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position string toSpeak = " ", extra = ""; diff --git a/stardew-access/Patches/TitleMenuPatches.cs b/stardew-access/Patches/TitleMenuPatches.cs index f8f2ec2..8dcb17f 100644 --- a/stardew-access/Patches/TitleMenuPatches.cs +++ b/stardew-access/Patches/TitleMenuPatches.cs @@ -175,21 +175,13 @@ namespace stardew_access.Patches { try { - bool isNextArrowPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right); - bool isPrevArrowPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left); - - if (__instance.backButton.containsPoint != null && __instance.backButton.visible && __instance.backButton.containsPoint((int)Game1.getMouseX(true), (int)Game1.getMouseY(true))) - { - - } - - if (isNextArrowPressed && !isRunning) + if (MainClass.Config.CharacterCreationMenuNextKey.JustPressed() && !isRunning) { isRunning = true; CycleThroughItems(true, __instance, ___skipIntro, ___startingCabinsLabel, ___difficultyModifierLabel); Task.Delay(200).ContinueWith(_ => { isRunning = false; }); } - else if (isPrevArrowPressed && !isRunning) + else if (MainClass.Config.CharacterCreationMenuPreviousKey.JustPressed() && !isRunning) { isRunning = true; CycleThroughItems(false, __instance, ___skipIntro, ___startingCabinsLabel, ___difficultyModifierLabel);