Added mod config with keybindings

This commit is contained in:
Mohammad Shoaib
2022-03-21 12:12:50 +05:30
parent 9607a008e0
commit fb087476d2
10 changed files with 131 additions and 98 deletions

View File

@@ -24,7 +24,7 @@ namespace stardew_access.Patches
{
try
{
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
purchaseAnimalsMenu = __instance;
isOnFarm = ___onFarm;
@@ -125,7 +125,7 @@ namespace stardew_access.Patches
if (currentBluprint == null)
return;
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
bool isBPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.B);
string ingredients = "";
string name = currentBluprint.displayName;

View File

@@ -29,7 +29,7 @@ namespace stardew_access.Patches
{
try
{
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
if (!___specificBundlePage)
{
currentIngredientListItem = -1;
@@ -300,7 +300,7 @@ namespace stardew_access.Patches
{
try
{
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
for (int i = ___slotPosition; i < ___slotPosition + 5; i++)
{
if (i < ___sprites.Count)
@@ -308,7 +308,7 @@ namespace stardew_access.Patches
if (__instance.names[i] is string)
{
#region For NPCs
if (__instance.characterSlots[i].bounds.Contains(Game1.getMouseX(), Game1.getMouseY()))
if (__instance.characterSlots[i].bounds.Contains(Game1.getMouseX(true), Game1.getMouseY(true)))
{
string name = $"{__instance.names[i] as string}";
int heartLevel = Game1.player.getFriendshipHeartLevelForNPC(name);
@@ -448,7 +448,7 @@ namespace stardew_access.Patches
{
try
{
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
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);
@@ -560,7 +560,7 @@ namespace stardew_access.Patches
if (__instance.currentTab != 0 && __instance.currentTab != 4 && __instance.currentTab != 6 && __instance.currentTab != 7)
return;
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
for (int i = 0; i < __instance.tabs.Count; i++)
{
@@ -586,7 +586,7 @@ namespace stardew_access.Patches
{
try
{
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
#region Narrate the treasure recieved on breaking the geode
if (__instance.geodeTreasure != null)
@@ -670,7 +670,7 @@ namespace stardew_access.Patches
{
try
{
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
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);
@@ -934,7 +934,7 @@ namespace stardew_access.Patches
{
try
{
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
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);
@@ -1138,7 +1138,7 @@ namespace stardew_access.Patches
{
try
{
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
#region Narrate buttons in the menu
if (__instance.inventory.dropItemInvisibleButton != null && __instance.inventory.dropItemInvisibleButton.containsPoint(x, y))
@@ -1326,7 +1326,7 @@ namespace stardew_access.Patches
try
{
int currentItemIndex = Math.Max(0, Math.Min(__instance.options.Count - 7, __instance.currentItemIndex));
int x = Game1.getMouseX(), y = Game1.getMouseY();
int x = Game1.getMouseX(true), y = Game1.getMouseY(true);
for (int i = 0; i < __instance.optionSlots.Count; i++)
{
if (__instance.optionSlots[i].bounds.Contains(x, y) && currentItemIndex + i < __instance.options.Count && __instance.options[currentItemIndex + i].bounds.Contains(x - __instance.optionSlots[i].bounds.X, y - __instance.optionSlots[i].bounds.Y))
@@ -1379,7 +1379,7 @@ namespace stardew_access.Patches
try
{
if (__instance.exitToTitle.visible &&
__instance.exitToTitle.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
__instance.exitToTitle.containsPoint(Game1.getMouseX(true), Game1.getMouseY(true)))
{
string toSpeak = "Exit to Title Button";
if (exitPageQueryKey != toSpeak)
@@ -1391,7 +1391,7 @@ namespace stardew_access.Patches
return;
}
if (__instance.exitToDesktop.visible &&
__instance.exitToDesktop.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
__instance.exitToDesktop.containsPoint(Game1.getMouseX(true), Game1.getMouseY(true)))
{
string toSpeak = "Exit to Desktop Button";
if (exitPageQueryKey != toSpeak)

View File

@@ -43,7 +43,7 @@ namespace stardew_access.Patches
{
try
{
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
if (__instance.heldItem != null)
{
@@ -188,7 +188,7 @@ namespace stardew_access.Patches
{
try
{
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
if (__instance.nextPageButton != null && __instance.nextPageButton.containsPoint(x, y))
{
@@ -221,7 +221,7 @@ namespace stardew_access.Patches
{
try
{
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
for (int i = 0; i < ___elevators.Count; i++)
{
if (___elevators[i].containsPoint(x, y))
@@ -257,7 +257,7 @@ namespace stardew_access.Patches
{
try
{
int x = Game1.getMouseX(), y = Game1.getMouseY();
int x = Game1.getMouseX(true), y = Game1.getMouseY(true);
MainClass.GetScreenReader().SayWithMenuChecker(___message, true);
if (__instance.okButton.containsPoint(x, y))
@@ -279,13 +279,9 @@ namespace stardew_access.Patches
{
try
{
int x = Game1.getMouseX(), y = Game1.getMouseY();
int x = Game1.getMouseX(true), y = Game1.getMouseY(true);
string leftProfession = " ", rightProfession = " ", extraInfo = " ", newCraftingRecipe = " ", toSpeak = " ";
bool isOpenBracketPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.OemOpenBrackets); // for left click
bool isLeftCtrlPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftControl);
bool isEnterPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Enter);
if (!__instance.informationUp)
{
return;
@@ -307,7 +303,7 @@ namespace stardew_access.Patches
if (__instance.leftProfession.containsPoint(x, y))
{
if (isOpenBracketPressed || (isLeftCtrlPressed && isEnterPressed && __instance.readyToClose()))
if ((MainClass.Config.LeftClickMainKey.JustPressed() || MainClass.Config.LeftClickAlternateKey.JustPressed()) && __instance.readyToClose())
{
Game1.player.professions.Add(___professionsToChoose[0]);
__instance.getImmediateProfessionPerk(___professionsToChoose[0]);
@@ -324,7 +320,7 @@ namespace stardew_access.Patches
if (__instance.rightProfession.containsPoint(x, y))
{
if (isOpenBracketPressed || (isLeftCtrlPressed && isEnterPressed && __instance.readyToClose()))
if ((MainClass.Config.LeftClickMainKey.JustPressed() || MainClass.Config.LeftClickAlternateKey.JustPressed()) && __instance.readyToClose())
{
Game1.player.professions.Add(___professionsToChoose[1]);
__instance.getImmediateProfessionPerk(___professionsToChoose[1]);
@@ -356,7 +352,7 @@ namespace stardew_access.Patches
if (__instance.okButton.containsPoint(x, y))
{
if (isOpenBracketPressed || (isLeftCtrlPressed && isEnterPressed))
if (MainClass.Config.LeftClickMainKey.JustPressed() || MainClass.Config.LeftClickAlternateKey.JustPressed())
__instance.okButtonClicked();
toSpeak = $"{___title} {extraInfo} {newCraftingRecipe}. Left click to close.";
@@ -380,18 +376,15 @@ namespace stardew_access.Patches
{
try
{
bool isLeftControlPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftControl);
bool isOpenBracketPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.OemOpenBrackets); // for left click
bool isEnterPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Enter);
if (__instance.currentPage == -1)
{
int total = ___categoryTotals[5];
string toSpeak;
if (__instance.okButton.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
if (__instance.okButton.containsPoint(Game1.getMouseX(true), Game1.getMouseY(true)))
{
// Perform Left Click
if (isOpenBracketPressed || (isLeftControlPressed && isEnterPressed))
if (MainClass.Config.LeftClickMainKey.JustPressed() || MainClass.Config.LeftClickAlternateKey.JustPressed())
{
Game1.activeClickableMenu.receiveLeftClick(Game1.getMouseX(true), Game1.getMouseY(true));
}
@@ -400,7 +393,7 @@ namespace stardew_access.Patches
}
for (int i = 0; i < __instance.categories.Count; i++)
{
if (__instance.categories[i].containsPoint(Game1.getMouseX(), Game1.getMouseY()))
if (__instance.categories[i].containsPoint(Game1.getMouseX(true), Game1.getMouseY(true)))
{
toSpeak = $"Money recieved from {__instance.getCategoryName(i)}: {___categoryTotals[i]}g.";
MainClass.GetScreenReader().SayWithChecker(toSpeak, true);

View File

@@ -15,7 +15,7 @@ namespace stardew_access.Patches
{
try
{
int x = Game1.getMouseX(), y = Game1.getMouseY(); // Mouse x and y position
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
if (__instance.acceptLeftQuestButton.visible && __instance.acceptLeftQuestButton.containsPoint(x, y))
{
@@ -83,7 +83,7 @@ namespace stardew_access.Patches
#region Callender
for (int i = 0; i < __instance.calendarDays.Count; i++)
{
if (__instance.calendarDays[i].containsPoint(Game1.getMouseX(), Game1.getMouseY()))
if (__instance.calendarDays[i].containsPoint(Game1.getMouseX(true), Game1.getMouseY(true)))
{
string toSpeak = $"Day {i + 1}";

View File

@@ -1,6 +1,4 @@
using Microsoft.Xna.Framework;
using StardewModdingAPI;
using StardewValley;
using StardewValley;
using StardewValley.Menus;
using static StardewValley.Menus.LoadGameMenu;
@@ -16,7 +14,7 @@ namespace stardew_access.Patches
{
try
{
int x = Game1.getMouseX(), y = Game1.getMouseY();
int x = Game1.getMouseX(true), y = Game1.getMouseY(true);
string toSpeak = " ";
#region Join/Host Button (Important! This should be checked before checking other buttons)
@@ -64,7 +62,7 @@ namespace stardew_access.Patches
__instance.buttons.ForEach(component =>
{
if (component.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
if (component.containsPoint(Game1.getMouseX(true), Game1.getMouseY(true)))
{
string name = component.name;
string label = component.label;
@@ -72,27 +70,27 @@ namespace stardew_access.Patches
}
});
if (__instance.muteMusicButton.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
if (__instance.muteMusicButton.containsPoint(Game1.getMouseX(true), Game1.getMouseY(true)))
{
toSpeak = "Mute Music Button";
}
if (__instance.aboutButton.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
if (__instance.aboutButton.containsPoint(Game1.getMouseX(true), Game1.getMouseY(true)))
{
toSpeak = "About Button";
}
if (__instance.languageButton.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
if (__instance.languageButton.containsPoint(Game1.getMouseX(true), Game1.getMouseY(true)))
{
toSpeak = "Language Button";
}
if (__instance.windowedButton.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
if (__instance.windowedButton.containsPoint(Game1.getMouseX(true), Game1.getMouseY(true)))
{
toSpeak = "Fullscreen toggle Button";
}
if (TitleMenu.subMenu != null && __instance.backButton.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
if (TitleMenu.subMenu != null && __instance.backButton.containsPoint(Game1.getMouseX(true), Game1.getMouseY(true)))
{
string text = "Back Button";
MainClass.GetScreenReader().SayWithChecker(text, true);
@@ -111,7 +109,7 @@ namespace stardew_access.Patches
{
try
{
int x = Game1.getMouseX(), y = Game1.getMouseY();
int x = Game1.getMouseX(true), y = Game1.getMouseY(true);
if (___menu.slotButtons[i].containsPoint(x, y))
{
if (__instance.Farmer != null)
@@ -161,13 +159,22 @@ namespace stardew_access.Patches
}
}
internal static void NewGameMenuPatch(CharacterCustomization __instance, bool ___skipIntro)
internal static void CharacterCustomizationMenuPatch(CharacterCustomization __instance, bool ___skipIntro)
{
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)))
{
// Perform Left Click
if (MainClass.Config.LeftClickMainKey.JustPressed() || MainClass.Config.LeftClickAlternateKey.JustPressed())
{
Game1.activeClickableMenu.receiveLeftClick(Game1.getMouseX(true), Game1.getMouseY(true));
}
}
if (isNextArrowPressed && !isRunning)
{
_ = CycleThroughItems(true, __instance, ___skipIntro);
@@ -289,7 +296,7 @@ namespace stardew_access.Patches
}
#endregion
__instance.skipIntroButton.snapMouseCursor();
__instance.skipIntroButton.snapMouseCursorToCenter();
toSpeak = (___skipIntro ? "Enabled" : "Disabled") + " Skip Intro Button";
}
break;
@@ -311,7 +318,7 @@ namespace stardew_access.Patches
}
#endregion
__instance.randomButton.snapMouseCursor();
__instance.randomButton.snapMouseCursorToCenter();
toSpeak = "Random Skin Button";
break;
}
@@ -333,7 +340,7 @@ namespace stardew_access.Patches
}
#endregion
__instance.genderButtons[0].snapMouseCursor();
__instance.genderButtons[0].snapMouseCursorToCenter();
toSpeak = "Gender Male Button";
break;
}
@@ -355,7 +362,7 @@ namespace stardew_access.Patches
}
#endregion
__instance.genderButtons[1].snapMouseCursor();
__instance.genderButtons[1].snapMouseCursorToCenter();
toSpeak = "Gender Female Button";
break;
}
@@ -377,7 +384,7 @@ namespace stardew_access.Patches
}
#endregion
__instance.farmTypeButtons[0].snapMouseCursor();
__instance.farmTypeButtons[0].snapMouseCursorToCenter();
toSpeak = getFarmHoverText(__instance.farmTypeButtons[0]);
break;
}
@@ -399,7 +406,7 @@ namespace stardew_access.Patches
}
#endregion
__instance.farmTypeButtons[1].snapMouseCursor();
__instance.farmTypeButtons[1].snapMouseCursorToCenter();
toSpeak = getFarmHoverText(__instance.farmTypeButtons[1]);
break;
}
@@ -421,7 +428,7 @@ namespace stardew_access.Patches
}
#endregion
__instance.farmTypeButtons[2].snapMouseCursor();
__instance.farmTypeButtons[2].snapMouseCursorToCenter();
toSpeak = getFarmHoverText(__instance.farmTypeButtons[2]);
break;
}
@@ -443,7 +450,7 @@ namespace stardew_access.Patches
}
#endregion
__instance.farmTypeButtons[3].snapMouseCursor();
__instance.farmTypeButtons[3].snapMouseCursorToCenter();
toSpeak = getFarmHoverText(__instance.farmTypeButtons[3]);
break;
}
@@ -465,7 +472,7 @@ namespace stardew_access.Patches
}
#endregion
__instance.farmTypeButtons[4].snapMouseCursor();
__instance.farmTypeButtons[4].snapMouseCursorToCenter();
toSpeak = getFarmHoverText(__instance.farmTypeButtons[4]);
break;
}
@@ -487,7 +494,7 @@ namespace stardew_access.Patches
}
#endregion
__instance.farmTypeButtons[5].snapMouseCursor();
__instance.farmTypeButtons[5].snapMouseCursorToCenter();
toSpeak = getFarmHoverText(__instance.farmTypeButtons[5]);
break;
}
@@ -509,7 +516,7 @@ namespace stardew_access.Patches
}
#endregion
__instance.farmTypeButtons[6].snapMouseCursor();
__instance.farmTypeButtons[6].snapMouseCursorToCenter();
toSpeak = getFarmHoverText(__instance.farmTypeButtons[6]);
break;
}
@@ -531,7 +538,7 @@ namespace stardew_access.Patches
}
#endregion
__instance.farmTypeNextPageButton.snapMouseCursor();
__instance.farmTypeNextPageButton.snapMouseCursorToCenter();
toSpeak = "Next Farm Type Page Button";
break;
}
@@ -553,7 +560,7 @@ namespace stardew_access.Patches
}
#endregion
__instance.farmTypePreviousPageButton.snapMouseCursor();
__instance.farmTypePreviousPageButton.snapMouseCursorToCenter();
toSpeak = "Previous Farm Type Page Button";
break;
}
@@ -575,7 +582,7 @@ namespace stardew_access.Patches
}
#endregion
__instance.cabinLayoutButtons[0].snapMouseCursor();
__instance.cabinLayoutButtons[0].snapMouseCursorToCenter();
toSpeak = "Cabin layout nearby";
break;
}
@@ -597,7 +604,7 @@ namespace stardew_access.Patches
}
#endregion
__instance.cabinLayoutButtons[1].snapMouseCursor();
__instance.cabinLayoutButtons[1].snapMouseCursorToCenter();
toSpeak = "Cabin layout separate";
break;
}
@@ -619,7 +626,7 @@ namespace stardew_access.Patches
}
#endregion
__instance.okButton.snapMouseCursor();
__instance.okButton.snapMouseCursorToCenter();
toSpeak = "Ok Button";
}
break;
@@ -632,7 +639,7 @@ namespace stardew_access.Patches
}
#endregion
__instance.backButton.snapMouseCursor();
__instance.backButton.snapMouseCursorToCenter();
toSpeak = "Back Button";
}
break;