2022-01-14 05:23:15 +00:00
using Microsoft.Xna.Framework ;
2022-03-19 09:53:18 +00:00
using Microsoft.Xna.Framework.Input ;
2022-02-13 12:42:19 +00:00
using stardew_access.Features ;
2022-01-14 05:23:15 +00:00
using StardewModdingAPI ;
2021-12-10 15:47:50 +00:00
using StardewValley ;
2022-03-19 10:14:57 +00:00
using StardewValley.Locations ;
2021-12-10 15:47:50 +00:00
using StardewValley.Menus ;
namespace stardew_access.Patches
{
2022-01-04 14:02:44 +00:00
internal class MenuPatches
2021-12-10 15:47:50 +00:00
{
2021-12-30 13:39:05 +00:00
private static string currentLevelUpTitle = " " ;
2022-04-09 09:45:50 +00:00
internal static bool firstTimeInNamingMenu = true ;
2022-04-05 11:51:35 +00:00
private static string animalQueryMenuQuery = " " ;
2022-01-16 11:40:03 +00:00
public static Vector2 ? prevTile = null ;
2021-12-28 15:13:07 +00:00
2022-04-11 18:30:00 +00:00
internal static void TailoringMenuPatch ( TailoringMenu __instance )
{
try
{
int x = Game1 . getMouseX ( true ) , y = Game1 . getMouseY ( true ) ; // Mouse x and y position
string toSpeak = "" ;
if ( __instance . leftIngredientSpot ! = null & & __instance . leftIngredientSpot . containsPoint ( x , y ) )
{
if ( __instance . leftIngredientSpot . item = = null )
{
toSpeak = "Input cloth here" ;
}
else
{
Item item = __instance . leftIngredientSpot . item ;
toSpeak = $"Cloth slot: {item.Stack} {item.DisplayName}" ;
}
}
else if ( __instance . rightIngredientSpot ! = null & & __instance . rightIngredientSpot . containsPoint ( x , y ) )
{
if ( __instance . rightIngredientSpot . item = = null )
{
toSpeak = "Input ingredient here" ;
}
else
{
Item item = __instance . rightIngredientSpot . item ;
toSpeak = $"Ingredient slot: {item.Stack} {item.DisplayName}" ;
}
}
else if ( __instance . startTailoringButton ! = null & & __instance . startTailoringButton . containsPoint ( x , y ) )
{
toSpeak = "Star tailoring button" ;
}
// TODO add other things
if ( toSpeak ! = "" )
MainClass . ScreenReader . SayWithMenuChecker ( toSpeak , true ) ;
}
catch ( System . Exception e )
{
MainClass . ErrorLog ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" ) ;
}
}
2022-04-09 10:54:55 +00:00
internal static void ChooseFromListMenuPatch ( ChooseFromListMenu __instance , List < string > ___options , int ___index , bool ___isJukebox )
{
try
{
int x = Game1 . getMouseX ( true ) , y = Game1 . getMouseY ( true ) ; // Mouse x and y position
string toSpeak = "" ;
if ( __instance . okButton ! = null & & __instance . okButton . containsPoint ( x , y ) )
toSpeak = "Select " + ( ___isJukebox ? Utility . getSongTitleFromCueName ( ___options [ ___index ] ) : ___options [ ___index ] ) + " button" ;
else if ( __instance . cancelButton ! = null & & __instance . cancelButton . containsPoint ( x , y ) )
toSpeak = "Cancel button" ;
else if ( __instance . backButton ! = null & & __instance . backButton . containsPoint ( x , y ) )
toSpeak = "Previous option: " + ( ___isJukebox ? Utility . getSongTitleFromCueName ( ___options [ Math . Max ( 0 , ___index - 1 ) ] ) : ___options [ Math . Max ( 0 , ___index - 1 ) ] ) + " button" ;
else if ( __instance . forwardButton ! = null & & __instance . forwardButton . containsPoint ( x , y ) )
toSpeak = "Next option: " + ( ___isJukebox ? Utility . getSongTitleFromCueName ( ___options [ Math . Min ( ___options . Count , ___index + 1 ) ] ) : ___options [ Math . Min ( ___options . Count , ___index + 1 ) ] ) + " button" ;
MainClass . ScreenReader . SayWithMenuChecker ( toSpeak , true ) ;
}
catch ( System . Exception e )
{
MainClass . ErrorLog ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" ) ;
}
}
2022-04-05 11:51:35 +00:00
internal static void AnimalQueryMenuPatch ( AnimalQueryMenu __instance , bool ___confirmingSell , FarmAnimal ___animal , TextBox ___textBox , string ___parentName )
{
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 isEscPressed = Game1 . input . GetKeyboardState ( ) . IsKeyDown ( Microsoft . Xna . Framework . Input . Keys . Escape ) ; // For escaping/unselecting from the animal name text box
string toSpeak = " " , details = " " ;
if ( ___textBox . Selected )
{
toSpeak = ___textBox . Text ;
if ( isEscPressed )
{
___textBox . Selected = false ;
}
}
else
{
if ( isCPressed )
{
string name = ___animal . displayName ;
string type = ___animal . displayType ;
int age = ( ___animal . GetDaysOwned ( ) + 1 ) / 28 + 1 ;
string ageText = ( age < = 1 ) ? Game1 . content . LoadString ( "Strings\\UI:AnimalQuery_Age1" ) : Game1 . content . LoadString ( "Strings\\UI:AnimalQuery_AgeN" , age ) ;
string parent = "" ;
2022-04-09 10:18:13 +00:00
if ( ( int ) ___animal . age . Value < ( byte ) ___animal . ageWhenMature . Value )
2022-04-05 11:51:35 +00:00
{
ageText + = Game1 . content . LoadString ( "Strings\\UI:AnimalQuery_AgeBaby" ) ;
}
if ( ___parentName ! = null )
{
parent = Game1 . content . LoadString ( "Strings\\UI:AnimalQuery_Parent" , ___parentName ) ;
}
details = $"Name: {name} Type: {type} \n\t Age: {ageText} {parent}" ;
animalQueryMenuQuery = " " ;
}
if ( __instance . okButton ! = null & & __instance . okButton . containsPoint ( x , y ) )
toSpeak = "OK button" ;
else if ( __instance . sellButton ! = null & & __instance . sellButton . containsPoint ( x , y ) )
toSpeak = $"Sell for {___animal.getSellPrice()}g button" ;
else if ( ___confirmingSell & & __instance . yesButton ! = null & & __instance . yesButton . containsPoint ( x , y ) )
toSpeak = "Confirm selling animal" ;
else if ( ___confirmingSell & & __instance . noButton ! = null & & __instance . noButton . containsPoint ( x , y ) )
toSpeak = "Cancel selling animal" ;
else if ( __instance . moveHomeButton ! = null & & __instance . moveHomeButton . containsPoint ( x , y ) )
toSpeak = "Change home building button" ;
else if ( __instance . allowReproductionButton ! = null & & __instance . allowReproductionButton . containsPoint ( x , y ) )
toSpeak = ( ( ___animal . allowReproduction . Value ) ? "Enabled" : "Disabled" ) + " allow reproduction button" ;
else if ( __instance . textBoxCC ! = null & & __instance . textBoxCC . containsPoint ( x , y ) )
toSpeak = "Animal name text box" ;
}
if ( animalQueryMenuQuery ! = toSpeak )
{
animalQueryMenuQuery = toSpeak ;
2022-04-09 10:18:13 +00:00
MainClass . ScreenReader . Say ( $"{details} {toSpeak}" , true ) ;
2022-04-05 11:51:35 +00:00
}
}
catch ( System . Exception e )
{
MainClass . ErrorLog ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" ) ;
}
}
2022-01-14 05:23:15 +00:00
internal static bool PlaySoundPatch ( string cueName )
{
try
{
if ( ! Context . IsPlayerFree )
return true ;
2022-02-01 07:20:40 +00:00
if ( ! Game1 . player . isMoving ( ) )
2022-01-14 05:23:15 +00:00
return true ;
2022-02-01 07:20:40 +00:00
if ( cueName = = "grassyStep" | | cueName = = "sandyStep" | | cueName = = "snowyStep" | | cueName = = "stoneStep" | | cueName = = "thudStep" | | cueName = = "woodyStep" )
2022-01-14 05:23:15 +00:00
{
2022-01-16 11:40:03 +00:00
Vector2 nextTile = CurrentPlayer . getNextTile ( ) ;
2022-01-21 08:51:43 +00:00
if ( ReadTile . isCollidingAtTile ( ( int ) nextTile . X , ( int ) nextTile . Y ) )
2022-01-14 05:23:15 +00:00
{
2022-01-16 11:40:03 +00:00
if ( prevTile ! = nextTile )
{
prevTile = nextTile ;
2022-01-21 08:51:43 +00:00
//Game1.playSound("colliding");
2022-01-16 11:40:03 +00:00
}
2022-01-14 05:23:15 +00:00
return false ;
}
}
}
catch ( Exception e )
{
2022-03-19 07:24:53 +00:00
MainClass . ErrorLog ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" ) ;
2022-01-14 05:23:15 +00:00
}
return true ;
}
2022-01-03 14:25:15 +00:00
internal static void LanguageSelectionMenuPatch ( LanguageSelectionMenu __instance )
{
try
{
2022-03-21 06:42:50 +00:00
int x = Game1 . getMouseX ( true ) , y = Game1 . getMouseY ( true ) ; // Mouse x and y position
2022-01-03 14:25:15 +00:00
2022-02-01 07:20:40 +00:00
if ( __instance . nextPageButton ! = null & & __instance . nextPageButton . containsPoint ( x , y ) )
2022-01-03 14:25:15 +00:00
{
2022-04-09 10:18:13 +00:00
MainClass . ScreenReader . SayWithMenuChecker ( $"Next Page Button" , true ) ;
2022-01-03 14:25:15 +00:00
return ;
}
if ( __instance . previousPageButton ! = null & & __instance . previousPageButton . containsPoint ( x , y ) )
{
2022-04-09 10:18:13 +00:00
MainClass . ScreenReader . SayWithMenuChecker ( $"Previous Page Button" , true ) ;
2022-01-03 14:25:15 +00:00
return ;
}
2022-02-01 07:20:40 +00:00
for ( int i = 0 ; i < __instance . languages . Count ; i + + )
2022-01-03 14:25:15 +00:00
{
2022-02-01 07:20:40 +00:00
if ( __instance . languages [ i ] . containsPoint ( x , y ) )
2022-01-03 14:25:15 +00:00
{
2022-04-09 10:18:13 +00:00
MainClass . ScreenReader . SayWithMenuChecker ( $"{__instance.languageList[i]} Button" , true ) ;
2022-01-03 14:25:15 +00:00
break ;
}
}
}
catch ( Exception e )
{
2022-03-19 07:24:53 +00:00
MainClass . ErrorLog ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" ) ;
2022-01-03 14:25:15 +00:00
}
}
2022-01-03 14:17:58 +00:00
internal static void MineElevatorMenuPatch ( List < ClickableComponent > ___elevators )
{
try
{
2022-03-21 06:42:50 +00:00
int x = Game1 . getMouseX ( true ) , y = Game1 . getMouseY ( true ) ; // Mouse x and y position
2022-02-01 07:20:40 +00:00
for ( int i = 0 ; i < ___elevators . Count ; i + + )
2022-01-03 14:17:58 +00:00
{
2022-02-01 07:20:40 +00:00
if ( ___elevators [ i ] . containsPoint ( x , y ) )
2022-01-03 14:17:58 +00:00
{
2022-04-09 10:18:13 +00:00
MainClass . ScreenReader . SayWithMenuChecker ( $"{___elevators[i].name} level" , true ) ;
2022-01-03 14:17:58 +00:00
break ;
}
}
}
catch ( Exception e )
{
2022-03-19 07:24:53 +00:00
MainClass . ErrorLog ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" ) ;
2022-01-03 14:17:58 +00:00
}
}
2022-04-09 09:45:50 +00:00
internal static void TitleTextInputMenuPatch ( TitleTextInputMenu __instance )
2021-12-31 15:15:52 +00:00
{
try
{
2022-04-09 09:45:50 +00:00
string toSpeak = "" ;
int x = Game1 . getMouseX ( true ) , y = Game1 . getMouseY ( true ) ; // Mouse x and y position
if ( __instance . pasteButton ! = null & & __instance . pasteButton . containsPoint ( x , y ) )
toSpeak = $"Paste button" ;
if ( toSpeak ! = "" )
2022-04-09 10:18:13 +00:00
MainClass . ScreenReader . SayWithChecker ( toSpeak , true ) ;
2022-04-09 09:45:50 +00:00
}
catch ( System . Exception e )
{
MainClass . ErrorLog ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" ) ;
}
}
internal static void NamingMenuPatch ( NamingMenu __instance , TextBox ___textBox , string ___title )
{
try
{
string toSpeak = "" ;
int x = Game1 . getMouseX ( true ) , y = Game1 . getMouseY ( true ) ; // Mouse x and y position
bool isEscPressed = Game1 . input . GetKeyboardState ( ) . IsKeyDown ( Microsoft . Xna . Framework . Input . Keys . Escape ) ; // For escaping/unselecting from the animal name text box
if ( firstTimeInNamingMenu )
{
firstTimeInNamingMenu = false ;
___textBox . Selected = false ;
}
if ( ___textBox . Selected )
{
___textBox . Update ( ) ;
toSpeak = ___textBox . Text ;
if ( isEscPressed )
{
___textBox . Selected = false ;
}
}
else
{
if ( __instance . textBoxCC ! = null & & __instance . textBoxCC . containsPoint ( x , y ) )
toSpeak = $"{___title} text box" ;
else if ( __instance . doneNamingButton ! = null & & __instance . doneNamingButton . containsPoint ( x , y ) )
toSpeak = $"Done naming button" ;
else if ( __instance . randomButton ! = null & & __instance . randomButton . containsPoint ( x , y ) )
toSpeak = $"Random button" ;
}
2021-12-31 15:15:52 +00:00
2022-04-09 09:45:50 +00:00
if ( toSpeak ! = "" )
2022-04-09 10:18:13 +00:00
MainClass . ScreenReader . SayWithChecker ( toSpeak , true ) ;
2021-12-31 15:15:52 +00:00
}
catch ( Exception e )
{
2022-03-19 07:24:53 +00:00
MainClass . ErrorLog ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" ) ;
2021-12-31 15:15:52 +00:00
}
}
2021-12-30 13:55:42 +00:00
internal static void ConfirmationDialogPatch ( ConfirmationDialog __instance , string ___message )
{
try
{
2022-03-21 06:42:50 +00:00
int x = Game1 . getMouseX ( true ) , y = Game1 . getMouseY ( true ) ;
2022-04-09 10:54:55 +00:00
string toSpeak = ___message ;
2021-12-30 13:55:42 +00:00
2022-02-01 07:20:40 +00:00
if ( __instance . okButton . containsPoint ( x , y ) )
2021-12-30 13:55:42 +00:00
{
2022-04-09 10:54:55 +00:00
toSpeak + = "\n\tOk Button" ;
2022-02-01 07:20:40 +00:00
}
else if ( __instance . cancelButton . containsPoint ( x , y ) )
2021-12-30 13:55:42 +00:00
{
2022-04-09 10:54:55 +00:00
toSpeak + = "\n\tCancel Button" ;
2021-12-30 13:55:42 +00:00
}
2022-04-09 10:54:55 +00:00
MainClass . ScreenReader . SayWithMenuChecker ( toSpeak , true ) ;
2021-12-30 13:55:42 +00:00
}
catch ( Exception e )
{
2022-03-19 07:24:53 +00:00
MainClass . ErrorLog ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" ) ;
2021-12-30 13:55:42 +00:00
}
}
2022-02-05 06:05:36 +00:00
internal static void LevelUpMenuPatch ( LevelUpMenu __instance , List < int > ___professionsToChoose , List < string > ___leftProfessionDescription , List < string > ___rightProfessionDescription , List < string > ___extraInfoForLevel , List < CraftingRecipe > ___newCraftingRecipes , string ___title , bool ___isActive , bool ___isProfessionChooser )
2021-12-30 13:39:05 +00:00
{
try
{
2022-03-21 06:42:50 +00:00
int x = Game1 . getMouseX ( true ) , y = Game1 . getMouseY ( true ) ;
2021-12-30 13:39:05 +00:00
string leftProfession = " " , rightProfession = " " , extraInfo = " " , newCraftingRecipe = " " , toSpeak = " " ;
if ( ! __instance . informationUp )
{
return ;
}
if ( __instance . isProfessionChooser )
{
if ( ___professionsToChoose . Count ( ) = = 0 )
{
return ;
}
for ( int j = 0 ; j < ___leftProfessionDescription . Count ; j + + )
{
leftProfession + = ___leftProfessionDescription [ j ] + ", " ;
}
for ( int i = 0 ; i < ___rightProfessionDescription . Count ; i + + )
{
rightProfession + = ___rightProfessionDescription [ i ] + ", " ;
}
if ( __instance . leftProfession . containsPoint ( x , y ) )
2022-02-05 06:05:36 +00:00
{
2022-03-21 06:42:50 +00:00
if ( ( MainClass . Config . LeftClickMainKey . JustPressed ( ) | | MainClass . Config . LeftClickAlternateKey . JustPressed ( ) ) & & __instance . readyToClose ( ) )
2022-02-05 06:05:36 +00:00
{
Game1 . player . professions . Add ( ___professionsToChoose [ 0 ] ) ;
__instance . getImmediateProfessionPerk ( ___professionsToChoose [ 0 ] ) ;
___isActive = false ;
__instance . informationUp = false ;
___isProfessionChooser = false ;
__instance . RemoveLevelFromLevelList ( ) ;
__instance . exitThisMenu ( ) ;
return ;
}
2021-12-30 13:39:05 +00:00
toSpeak = $"Selected: {leftProfession} Left click to choose." ;
2022-02-05 06:05:36 +00:00
}
2021-12-30 13:39:05 +00:00
if ( __instance . rightProfession . containsPoint ( x , y ) )
2022-02-05 06:05:36 +00:00
{
2022-03-21 06:42:50 +00:00
if ( ( MainClass . Config . LeftClickMainKey . JustPressed ( ) | | MainClass . Config . LeftClickAlternateKey . JustPressed ( ) ) & & __instance . readyToClose ( ) )
2022-02-05 06:05:36 +00:00
{
Game1 . player . professions . Add ( ___professionsToChoose [ 1 ] ) ;
__instance . getImmediateProfessionPerk ( ___professionsToChoose [ 1 ] ) ;
___isActive = false ;
__instance . informationUp = false ;
___isProfessionChooser = false ;
__instance . RemoveLevelFromLevelList ( ) ;
__instance . exitThisMenu ( ) ;
return ;
}
2021-12-30 13:39:05 +00:00
toSpeak = $"Selected: {rightProfession} Left click to choose." ;
2022-02-05 06:05:36 +00:00
}
2021-12-30 13:39:05 +00:00
}
else
{
foreach ( string s2 in ___extraInfoForLevel )
{
extraInfo + = s2 + ", " ;
}
foreach ( CraftingRecipe s in ___newCraftingRecipes )
{
string cookingOrCrafting = Game1 . content . LoadString ( "Strings\\UI:LearnedRecipe_" + ( s . isCookingRecipe ? "cooking" : "crafting" ) ) ;
string message = Game1 . content . LoadString ( "Strings\\UI:LevelUp_NewRecipe" , cookingOrCrafting , s . DisplayName ) ;
newCraftingRecipe + = $"{message}, " ;
}
2022-02-05 06:05:36 +00:00
}
2021-12-30 13:39:05 +00:00
2022-02-05 06:05:36 +00:00
if ( __instance . okButton . containsPoint ( x , y ) )
{
2022-03-21 06:42:50 +00:00
if ( MainClass . Config . LeftClickMainKey . JustPressed ( ) | | MainClass . Config . LeftClickAlternateKey . JustPressed ( ) )
2022-02-05 06:05:36 +00:00
__instance . okButtonClicked ( ) ;
toSpeak = $"{___title} {extraInfo} {newCraftingRecipe}. Left click to close." ;
2021-12-30 13:39:05 +00:00
}
if ( toSpeak ! = " " )
2022-04-09 10:18:13 +00:00
MainClass . ScreenReader . SayWithMenuChecker ( toSpeak , true ) ;
2021-12-30 13:39:05 +00:00
else if ( __instance . isProfessionChooser & & currentLevelUpTitle ! = $"{___title}. Select a new profession." )
{
2022-04-09 10:18:13 +00:00
MainClass . ScreenReader . SayWithMenuChecker ( $"{___title}. Select a new profession." , true ) ;
2021-12-30 13:39:05 +00:00
currentLevelUpTitle = $"{___title}. Select a new profession." ;
}
}
catch ( Exception e )
{
2022-03-19 07:24:53 +00:00
MainClass . ErrorLog ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" ) ;
2021-12-30 13:39:05 +00:00
}
}
2021-12-27 14:39:45 +00:00
internal static void ShippingMenuPatch ( ShippingMenu __instance , List < int > ___categoryTotals )
{
2021-12-28 15:13:07 +00:00
try
2021-12-27 14:39:45 +00:00
{
2022-02-05 06:05:36 +00:00
2021-12-28 15:13:07 +00:00
if ( __instance . currentPage = = - 1 )
2021-12-27 14:39:45 +00:00
{
2021-12-28 15:13:07 +00:00
int total = ___categoryTotals [ 5 ] ;
string toSpeak ;
2022-03-21 06:42:50 +00:00
if ( __instance . okButton . containsPoint ( Game1 . getMouseX ( true ) , Game1 . getMouseY ( true ) ) )
2021-12-27 14:39:45 +00:00
{
2022-02-05 06:05:36 +00:00
// Perform Left Click
2022-03-21 06:42:50 +00:00
if ( MainClass . Config . LeftClickMainKey . JustPressed ( ) | | MainClass . Config . LeftClickAlternateKey . JustPressed ( ) )
2022-02-05 06:05:36 +00:00
{
Game1 . activeClickableMenu . receiveLeftClick ( Game1 . getMouseX ( true ) , Game1 . getMouseY ( true ) ) ;
}
2021-12-28 15:13:07 +00:00
toSpeak = $"{total}g in total. Press left mouse button to save." ;
2022-04-09 10:18:13 +00:00
MainClass . ScreenReader . SayWithChecker ( toSpeak , true ) ;
2021-12-27 14:39:45 +00:00
}
2021-12-28 15:13:07 +00:00
for ( int i = 0 ; i < __instance . categories . Count ; i + + )
{
2022-03-21 06:42:50 +00:00
if ( __instance . categories [ i ] . containsPoint ( Game1 . getMouseX ( true ) , Game1 . getMouseY ( true ) ) )
2021-12-28 15:13:07 +00:00
{
toSpeak = $"Money recieved from {__instance.getCategoryName(i)}: {___categoryTotals[i]}g." ;
2022-04-09 10:18:13 +00:00
MainClass . ScreenReader . SayWithChecker ( toSpeak , true ) ;
2021-12-28 15:13:07 +00:00
}
}
2021-12-27 14:39:45 +00:00
}
}
2021-12-28 15:13:07 +00:00
catch ( Exception e )
{
2022-03-19 07:24:53 +00:00
MainClass . ErrorLog ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" ) ;
2021-12-28 15:13:07 +00:00
}
2021-12-27 14:39:45 +00:00
}
2022-03-29 14:27:38 +00:00
#region Cleanup on exitting a menu
2022-01-07 10:34:37 +00:00
internal static void Game1ExitActiveMenuPatch ( )
2022-01-06 13:22:23 +00:00
{
try
{
2022-03-29 14:27:38 +00:00
Cleanup ( Game1 . activeClickableMenu ) ;
2022-01-07 10:34:37 +00:00
}
catch ( Exception e )
{
2022-03-19 07:24:53 +00:00
MainClass . ErrorLog ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" ) ;
2022-01-07 10:34:37 +00:00
}
}
2022-01-07 09:27:57 +00:00
2022-01-07 10:34:37 +00:00
internal static void IClickableMenuOnExitPatch ( IClickableMenu __instance )
{
try
{
2022-03-29 14:27:38 +00:00
Cleanup ( __instance ) ;
}
catch ( Exception e )
{
MainClass . ErrorLog ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" ) ;
}
}
2022-01-07 08:34:58 +00:00
2022-03-29 14:27:38 +00:00
private static void Cleanup ( IClickableMenu menu )
{
2022-04-05 06:47:28 +00:00
if ( menu is LetterViewerMenu )
{
DialoguePatches . currentLetterText = " " ;
}
if ( menu is LevelUpMenu )
{
currentLevelUpTitle = " " ;
}
if ( menu is Billboard )
{
QuestPatches . currentDailyQuestText = " " ;
}
2022-03-29 14:27:38 +00:00
if ( menu is GameMenu )
{
GameMenuPatches . gameMenuQueryKey = "" ;
GameMenuPatches . craftingPageQueryKey = "" ;
GameMenuPatches . inventoryPageQueryKey = "" ;
GameMenuPatches . exitPageQueryKey = "" ;
GameMenuPatches . optionsPageQueryKey = "" ;
GameMenuPatches . socialPageQuery = "" ;
GameMenuPatches . currentSelectedCraftingRecipe = - 1 ;
GameMenuPatches . isSelectingRecipe = false ;
}
2022-01-07 08:34:58 +00:00
2022-03-29 14:27:38 +00:00
if ( menu is JunimoNoteMenu )
{
2022-04-11 17:18:56 +00:00
BundleMenuPatches . currentIngredientListItem = - 1 ;
BundleMenuPatches . currentIngredientInputSlot = - 1 ;
BundleMenuPatches . currentInventorySlot = - 1 ;
BundleMenuPatches . junimoNoteMenuQuery = "" ;
2022-03-29 14:27:38 +00:00
}
2022-01-07 11:13:44 +00:00
2022-03-29 14:27:38 +00:00
if ( menu is ShopMenu )
{
GameMenuPatches . shopMenuQueryKey = "" ;
}
2022-02-03 10:39:30 +00:00
2022-03-29 14:27:38 +00:00
if ( menu is ItemGrabMenu )
{
GameMenuPatches . itemGrabMenuQueryKey = "" ;
}
2022-02-04 08:45:24 +00:00
2022-03-29 14:27:38 +00:00
if ( menu is GeodeMenu )
{
GameMenuPatches . geodeMenuQueryKey = "" ;
}
2022-02-13 14:26:09 +00:00
2022-03-29 14:27:38 +00:00
if ( menu is CarpenterMenu )
{
BuildingNAnimalMenuPatches . carpenterMenuQuery = "" ;
BuildingNAnimalMenuPatches . isUpgrading = false ;
BuildingNAnimalMenuPatches . isDemolishing = false ;
BuildingNAnimalMenuPatches . isPainting = false ;
BuildingNAnimalMenuPatches . isMoving = false ;
BuildingNAnimalMenuPatches . isConstructing = false ;
BuildingNAnimalMenuPatches . carpenterMenu = null ;
2022-01-06 13:22:23 +00:00
}
2022-03-29 14:27:38 +00:00
if ( menu is PurchaseAnimalsMenu )
2022-01-06 13:22:23 +00:00
{
2022-03-29 14:27:38 +00:00
BuildingNAnimalMenuPatches . purchaseAnimalMenuQuery = "" ;
BuildingNAnimalMenuPatches . firstTimeInNamingMenu = true ;
BuildingNAnimalMenuPatches . purchaseAnimalsMenu = null ;
}
if ( menu is DialogueBox )
{
DialoguePatches . isDialogueAppearingFirstTime = true ;
DialoguePatches . currentDialogue = " " ;
2022-01-06 13:22:23 +00:00
}
2022-03-29 14:27:38 +00:00
2022-04-11 18:18:20 +00:00
if ( menu is JojaCDMenu )
{
BundleMenuPatches . jojaCDMenuQuery = "" ;
}
if ( menu is QuestLog )
{
QuestPatches . questLogQuery = " " ;
}
2022-03-29 14:27:38 +00:00
GameMenuPatches . hoveredItemQueryKey = "" ;
2022-01-06 13:22:23 +00:00
}
2022-03-29 14:27:38 +00:00
# endregion
2022-01-06 13:22:23 +00:00
2022-01-30 16:55:02 +00:00
internal static void ExitEventPatch ( )
{
2022-04-09 10:18:13 +00:00
if ( MainClass . ScreenReader ! = null )
MainClass . ScreenReader . CloseScreenReader ( ) ;
2022-01-30 16:55:02 +00:00
}
2021-12-10 15:47:50 +00:00
}
}