From 7f81d7277115bdb63d533eaaf1b242c13c36b941 Mon Sep 17 00:00:00 2001 From: Mohammad Shoaib Date: Sun, 15 May 2022 15:00:08 +0530 Subject: [PATCH] added more scenes to grandpa story --- stardew-access/ModEntry.cs | 31 +++++++ stardew-access/Patches/MiniGamesPatches.cs | 97 ++++++++++------------ stardew-access/i18n/default.json | 7 +- 3 files changed, 82 insertions(+), 53 deletions(-) diff --git a/stardew-access/ModEntry.cs b/stardew-access/ModEntry.cs index 4579a36..8412b81 100644 --- a/stardew-access/ModEntry.cs +++ b/stardew-access/ModEntry.cs @@ -194,6 +194,7 @@ namespace stardew_access 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); @@ -223,6 +224,36 @@ namespace stardew_access #endregion } + 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()) + { + Game1.currentMinigame.receiveLeftClick(Game1.getMouseX(true), Game1.getMouseY(true)); + } + if (isLeftShiftPressed && Config.RightClickMainKey.JustPressed()) + { + Game1.currentMinigame.receiveRightClick(Game1.getMouseX(true), Game1.getMouseY(true)); + } + + // Alternate Keybinds + if (Config.LeftClickAlternateKey.JustPressed()) + { + Game1.currentMinigame.receiveLeftClick(Game1.getMouseX(true), Game1.getMouseY(true)); + } + if (Config.RightClickAlternateKey.JustPressed()) + { + Game1.currentMinigame.receiveRightClick(Game1.getMouseX(true), Game1.getMouseY(true)); + } + #endregion + } + #endregion + if (!Context.IsPlayerFree) return; diff --git a/stardew-access/Patches/MiniGamesPatches.cs b/stardew-access/Patches/MiniGamesPatches.cs index 938b98b..ec3985d 100644 --- a/stardew-access/Patches/MiniGamesPatches.cs +++ b/stardew-access/Patches/MiniGamesPatches.cs @@ -7,31 +7,27 @@ namespace stardew_access.Patches public class MiniGamesPatches { public static string grandpaStoryQuery = " "; + public static string introQuery = " "; internal static void IntroPatch(Intro __instance, int ___currentState) { try { - MainClass.DebugLog(___currentState + "\t intro"); + string toSpeak = " "; if (___currentState == 3) { - string text = "Travelling to Stardew Valley bus stop"; - if (grandpaStoryQuery != text) - { - grandpaStoryQuery = text; - MainClass.ScreenReader.Say(text, true); - return; - } + toSpeak = "Travelling to Stardew Valley bus stop"; } if (___currentState == 4) { - string text = "Stardew valley 0.5 miles away"; - if (grandpaStoryQuery != text) - { - grandpaStoryQuery = text; - MainClass.ScreenReader.Say(text, true); - return; - } + toSpeak = "Stardew valley 0.5 miles away"; + } + + if (toSpeak != " " && introQuery != toSpeak) + { + introQuery = toSpeak; + MainClass.ScreenReader.Say(toSpeak, false); + return; } } catch (System.Exception e) @@ -45,46 +41,42 @@ namespace stardew_access.Patches try { int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position + string toSpeak = " "; + MainClass.DebugLog("" + ___scene); - // TODO add scene 0 explaination - // if(___scene == 0) - // { - // - // } + if (___letterView != null) + { + DialoguePatches.NarrateLetterContent(___letterView); + } + + if (MainClass.ModHelper == null) + return; + + if (___scene == 0) + { + toSpeak = MainClass.ModHelper.Translation.Get("grandpastory.scene0"); + } if (___drawGrandpa) { if (___grandpaSpeech.Count > 0 && ___grandpaSpeechTimer > 3000) { - string text = ___grandpaSpeech.Peek(); - if (grandpaStoryQuery != text) - { - grandpaStoryQuery = text; - MainClass.ScreenReader.Say(text, true); - return; - } + toSpeak = ___grandpaSpeech.Peek(); } } if (___scene == 3) { - string text = Game1.content.LoadString("Strings\\StringsFromCSFiles:GrandpaStory.cs.12059"); - if (grandpaStoryQuery != text) - { - grandpaStoryQuery = text; - MainClass.ScreenReader.Say(text, true); - return; - } + toSpeak = Game1.content.LoadString("Strings\\StringsFromCSFiles:GrandpaStory.cs.12059"); } - // TODO add scene 4 & 5 explaination - // if(___scene == 4) - // { - // - // } - // if(___scene == 5) - // { - // - // } + if (___scene == 4) + { + toSpeak = MainClass.ModHelper.Translation.Get("grandpastory.scene4"); + } + if (___scene == 5) + { + toSpeak = MainClass.ModHelper.Translation.Get("grandpastory.scene5"); + } if (___scene == 6) { @@ -92,13 +84,7 @@ namespace stardew_access.Patches { if (clickableGrandpaLetterRect(___parallaxPan, ___grandpaSpeechTimer).Contains(x, y)) { - string text = "Left click to open grandpa's letter"; - if (grandpaStoryQuery != text) - { - grandpaStoryQuery = text; - MainClass.ScreenReader.Say(text, true); - return; - } + toSpeak = MainClass.ModHelper.Translation.Get("grandpastory.letteropen"); } else if (___letterView == null) { @@ -107,10 +93,16 @@ namespace stardew_access.Patches return; } } + else + { + toSpeak = MainClass.ModHelper.Translation.Get("grandpastory.scene6"); + } } - if (___letterView != null) + + if (toSpeak != " " && grandpaStoryQuery != toSpeak) { - DialoguePatches.NarrateLetterContent(___letterView); + grandpaStoryQuery = toSpeak; + MainClass.ScreenReader.Say(toSpeak, false); } } catch (System.Exception e) @@ -119,6 +111,7 @@ namespace stardew_access.Patches } } + // This method is taken from the game's source code private static Rectangle clickableGrandpaLetterRect(int ___parallaxPan, int ___grandpaSpeechTimer) { return new Rectangle((int)Utility.getTopLeftPositionForCenteringOnScreen(Game1.viewport, 1294, 730).X + (286 - ___parallaxPan) * 4, (int)Utility.getTopLeftPositionForCenteringOnScreen(Game1.viewport, 1294, 730).Y + 218 + Math.Max(0, Math.Min(60, (___grandpaSpeechTimer - 5000) / 8)), 524, 344); diff --git a/stardew-access/i18n/default.json b/stardew-access/i18n/default.json index 071bf62..893d9b2 100644 --- a/stardew-access/i18n/default.json +++ b/stardew-access/i18n/default.json @@ -1,5 +1,10 @@ { "warnings.health": "Warning! Health is at {{value}} percent!", "warnings.stamina": "Warning! Stamina is at {{value}} percent!", - "warnings.time": "Warning! Time is {{value}}" + "warnings.time": "Warning! Time is {{value}}", + "grandpastory.scene0":"Grandpa, on his deathbed.", + "grandpastory.scene4":"Employees working in JoJa corp.", + "grandpastory.scene5":"Employees in their cubicals, some of them look exhausted including yourself.", + "grandpastory.scene6":"You reach your desk finding grandpa's letter.", + "grandpastory.letteropen":"Left click to open grandpa's letter" } \ No newline at end of file