2021-12-11 18:10:31 +05:30
using Microsoft.Xna.Framework ;
2021-12-14 19:06:06 +05:30
using Microsoft.Xna.Framework.Graphics ;
2021-12-11 18:10:31 +05:30
using StardewModdingAPI ;
2021-12-10 21:17:50 +05:30
using StardewValley ;
using StardewValley.Menus ;
2021-12-13 21:00:07 +05:30
using StardewValley.Quests ;
2021-12-28 20:43:07 +05:30
using static StardewValley . Menus . LoadGameMenu ;
2021-12-10 21:17:50 +05:30
namespace stardew_access.Patches
{
internal class MenuPatch
{
2021-12-29 19:43:32 +05:30
private static int saveGameIndex = - 1 , currentChatMessageIndex = 0 ;
private static bool isRunning = false , isChatRunning = false ;
2021-12-13 19:59:17 +05:30
private static string currentLetterText = " " ;
2021-12-14 19:06:06 +05:30
private static string currentDailyQuestText = " " ;
2021-12-30 19:09:05 +05:30
private static string currentLevelUpTitle = " " ;
2021-12-31 20:16:43 +05:30
private const int MAX_COMPONENTS = 20 ;
2021-12-28 20:43:07 +05:30
2021-12-30 19:25:42 +05:30
internal static void ConfirmationDialogPatch ( ConfirmationDialog __instance , string ___message )
{
try
{
int x = Game1 . getMousePosition ( true ) . X , y = Game1 . getMousePosition ( true ) . Y ;
2021-12-30 20:23:10 +05:30
ScreenReader . sayWithMenuChecker ( ___message , true ) ;
2021-12-30 19:25:42 +05:30
if ( __instance . okButton . containsPoint ( x , y ) )
{
ScreenReader . sayWithMenuChecker ( "Ok Button" , false ) ;
} else if ( __instance . cancelButton . containsPoint ( x , y ) )
{
ScreenReader . sayWithMenuChecker ( "Cancel Button" , false ) ;
}
}
catch ( Exception e )
{
MainClass . monitor . Log ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" , LogLevel . Error ) ;
}
}
2021-12-29 18:43:56 +05:30
internal static void ChatBoxPatch ( ChatBox __instance , List < ChatMessage > ___messages )
{
try
{
2021-12-29 19:43:32 +05:30
string toSpeak = " " ;
2021-12-29 18:43:56 +05:30
2021-12-29 19:43:32 +05:30
if ( __instance . chatBox . Selected )
2021-12-29 18:43:56 +05:30
{
2021-12-29 19:43:32 +05:30
bool isPrevArrowPressed = Game1 . input . GetKeyboardState ( ) . IsKeyDown ( Microsoft . Xna . Framework . Input . Keys . PageUp ) ;
bool isNextArrowPressed = Game1 . input . GetKeyboardState ( ) . IsKeyDown ( Microsoft . Xna . Framework . Input . Keys . PageDown ) ;
if ( ___messages . Count > 0 )
{
#region To narrate previous and next chat messages
if ( isNextArrowPressed & & ! isChatRunning )
{
_ = CycleThroughChatMessages ( true , ___messages ) ;
}
else if ( isPrevArrowPressed & & ! isChatRunning )
{
_ = CycleThroughChatMessages ( false , ___messages ) ;
}
#endregion
}
}
else if ( ___messages . Count > 0 )
{
#region To narrate latest chat message
___messages [ ___messages . Count - 1 ] . message . ForEach ( message = >
{
toSpeak + = $"{message.message}, " ;
} ) ;
if ( toSpeak ! = " " )
ScreenReader . sayWithChatChecker ( toSpeak , false ) ;
#endregion
}
2021-12-29 18:43:56 +05:30
}
catch ( Exception e )
{
MainClass . monitor . Log ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" , LogLevel . Error ) ;
}
}
2021-12-29 19:43:32 +05:30
private static async Task CycleThroughChatMessages ( bool increase , List < ChatMessage > ___messages )
{
isChatRunning = true ;
await Task . Delay ( 200 ) ;
string toSpeak = " " ;
if ( increase )
{
+ + currentChatMessageIndex ;
if ( currentChatMessageIndex > ___messages . Count - 1 )
{
currentChatMessageIndex = ___messages . Count - 1 ;
}
}
else
{
- - currentChatMessageIndex ;
if ( currentChatMessageIndex < 0 )
{
currentChatMessageIndex = 0 ;
}
}
___messages [ currentChatMessageIndex ] . message . ForEach ( message = >
{
toSpeak + = $"{message.message}, " ;
} ) ;
ScreenReader . say ( toSpeak , true ) ;
isChatRunning = false ;
}
2021-12-28 20:43:07 +05:30
internal static void CoopMenuPatch ( CoopMenu __instance , CoopMenu . Tab ___currentTab )
{
try
{
int x = Game1 . getMousePosition ( true ) . X , y = Game1 . getMousePosition ( true ) . Y ;
string toSpeak = " " ;
#region Join / Host Button ( Important ! This should be checked before checking other buttons )
if ( __instance . slotButtons [ 0 ] . containsPoint ( x , y ) )
{
if ( ___currentTab = = CoopMenu . Tab . JOIN_TAB )
toSpeak = "Join lan game" ;
if ( ___currentTab = = CoopMenu . Tab . HOST_TAB )
toSpeak = "Host new farm" ;
}
#endregion
#region Other Buttons
if ( __instance . joinTab . containsPoint ( x , y ) )
{
toSpeak = "Join Tab Button" ;
}
else if ( __instance . hostTab . containsPoint ( x , y ) )
{
toSpeak = "Host Tab Button" ;
}
else if ( __instance . refreshButton . containsPoint ( x , y ) )
{
toSpeak = "Refresh Button" ;
}
#endregion
if ( toSpeak ! = " " )
ScreenReader . sayWithChecker ( toSpeak , true ) ;
}
catch ( Exception e )
{
2021-12-28 20:44:59 +05:30
MainClass . monitor . Log ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" , LogLevel . Error ) ;
2021-12-28 20:43:07 +05:30
}
}
2021-12-14 19:06:06 +05:30
2021-12-28 18:45:22 +05:30
internal static void OptionsPagePatch ( OptionsPage __instance )
{
2021-12-28 20:43:07 +05:30
try
2021-12-28 18:45:22 +05:30
{
2021-12-28 20:43:07 +05:30
int currentItemIndex = Math . Max ( 0 , Math . Min ( __instance . options . Count - 7 , __instance . currentItemIndex ) ) ;
int x = Game1 . getMousePosition ( true ) . X , y = Game1 . getMousePosition ( true ) . Y ;
for ( int i = 0 ; i < __instance . optionSlots . Count ; i + + )
2021-12-28 18:45:22 +05:30
{
2021-12-28 20:43:07 +05:30
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 ) )
2021-12-28 19:00:51 +05:30
{
2021-12-28 20:43:07 +05:30
OptionsElement optionsElement = __instance . options [ currentItemIndex + i ] ;
string toSpeak = optionsElement . label ;
if ( optionsElement is OptionsButton )
toSpeak = $" {toSpeak} Button" ;
else if ( optionsElement is OptionsCheckbox )
toSpeak = ( ( optionsElement as OptionsCheckbox ) . isChecked ? "Enabled" : "Disabled" ) + $" {toSpeak} Checkbox" ;
else if ( optionsElement is OptionsDropDown )
toSpeak = $"{toSpeak} Dropdown, option {(optionsElement as OptionsDropDown).dropDownDisplayOptions[(optionsElement as OptionsDropDown).selectedOption]} selected" ;
else if ( optionsElement is OptionsSlider )
toSpeak = $"{(optionsElement as OptionsSlider).value}% {toSpeak} Slider" ;
else if ( optionsElement is OptionsPlusMinus )
toSpeak = $"{(optionsElement as OptionsPlusMinus).displayOptions[(optionsElement as OptionsPlusMinus).selected]} selected of {toSpeak}" ;
else if ( optionsElement is OptionsInputListener )
{
string buttons = "" ;
( optionsElement as OptionsInputListener ) . buttonNames . ForEach ( name = > { buttons + = $", {name}" ; } ) ;
toSpeak = $"{toSpeak} is bound to {buttons}. Left click to change." ;
}
else
{
if ( toSpeak . Contains ( ":" ) )
toSpeak = toSpeak . Replace ( ":" , "" ) ;
2021-12-28 18:45:22 +05:30
2021-12-28 20:43:07 +05:30
toSpeak = $"{toSpeak} Options:" ;
}
2021-12-28 19:00:51 +05:30
2021-12-28 20:43:07 +05:30
ScreenReader . sayWithChecker ( toSpeak , true ) ;
break ;
}
2021-12-28 18:45:22 +05:30
}
}
2021-12-28 20:43:07 +05:30
catch ( Exception e )
{
2021-12-28 20:44:59 +05:30
MainClass . monitor . Log ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" , LogLevel . Error ) ;
2021-12-28 20:43:07 +05:30
}
2021-12-28 18:45:22 +05:30
}
2021-12-30 19:09:05 +05:30
internal static void LevelUpMenuPatch ( LevelUpMenu __instance , List < int > ___professionsToChoose , List < string > ___leftProfessionDescription , List < string > ___rightProfessionDescription , List < string > ___extraInfoForLevel , List < CraftingRecipe > ___newCraftingRecipes , string ___title )
{
try
{
int x = Game1 . getMousePosition ( true ) . X , y = Game1 . getMousePosition ( true ) . Y ;
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 ) )
toSpeak = $"Selected: {leftProfession} Left click to choose." ;
if ( __instance . rightProfession . containsPoint ( x , y ) )
toSpeak = $"Selected: {rightProfession} Left click to choose." ;
}
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}, " ;
}
if ( __instance . okButton . containsPoint ( x , y ) )
{
toSpeak = $"{___title} {extraInfo} {newCraftingRecipe}. Left click to close." ;
}
}
if ( toSpeak ! = " " )
ScreenReader . sayWithMenuChecker ( toSpeak , true ) ;
else if ( __instance . isProfessionChooser & & currentLevelUpTitle ! = $"{___title}. Select a new profession." )
{
ScreenReader . sayWithMenuChecker ( $"{___title}. Select a new profession." , true ) ;
currentLevelUpTitle = $"{___title}. Select a new profession." ;
}
}
catch ( Exception e )
{
MainClass . monitor . Log ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" , LogLevel . Error ) ;
}
}
2021-12-27 20:09:45 +05:30
internal static void ShippingMenuPatch ( ShippingMenu __instance , List < int > ___categoryTotals )
{
2021-12-28 20:43:07 +05:30
try
2021-12-27 20:09:45 +05:30
{
2021-12-28 20:43:07 +05:30
if ( __instance . currentPage = = - 1 )
2021-12-27 20:09:45 +05:30
{
2021-12-28 20:43:07 +05:30
int total = ___categoryTotals [ 5 ] ;
string toSpeak ;
if ( __instance . okButton . containsPoint ( Game1 . getMousePosition ( true ) . X , Game1 . getMousePosition ( true ) . Y ) )
2021-12-27 20:09:45 +05:30
{
2021-12-28 20:43:07 +05:30
toSpeak = $"{total}g in total. Press left mouse button to save." ;
2021-12-27 20:09:45 +05:30
ScreenReader . sayWithChecker ( toSpeak , true ) ;
}
2021-12-28 20:43:07 +05:30
for ( int i = 0 ; i < __instance . categories . Count ; i + + )
{
if ( __instance . categories [ i ] . containsPoint ( Game1 . getMousePosition ( true ) . X , Game1 . getMousePosition ( true ) . Y ) )
{
toSpeak = $"Money recieved from {__instance.getCategoryName(i)}: {___categoryTotals[i]}g." ;
ScreenReader . sayWithChecker ( toSpeak , true ) ;
}
}
2021-12-27 20:09:45 +05:30
}
}
2021-12-28 20:43:07 +05:30
catch ( Exception e )
{
2021-12-28 20:44:59 +05:30
MainClass . monitor . Log ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" , LogLevel . Error ) ;
2021-12-28 20:43:07 +05:30
}
2021-12-27 20:09:45 +05:30
}
2021-12-14 19:06:06 +05:30
internal static void BillboardPatch ( Billboard __instance , bool ___dailyQuestBoard )
{
2021-12-28 20:44:59 +05:30
try
2021-12-14 19:06:06 +05:30
{
2021-12-28 20:44:59 +05:30
if ( ! ___dailyQuestBoard )
2021-12-27 19:37:41 +05:30
{
2021-12-28 20:44:59 +05:30
#region Callender
for ( int i = 0 ; i < __instance . calendarDays . Count ; i + + )
2021-12-27 19:37:41 +05:30
{
2021-12-28 20:44:59 +05:30
if ( __instance . calendarDays [ i ] . containsPoint ( Game1 . getMousePosition ( true ) . X , Game1 . getMousePosition ( true ) . Y ) )
2021-12-27 19:37:41 +05:30
{
2021-12-28 20:44:59 +05:30
string toSpeak = $"Day {i + 1}" ;
2021-12-27 19:37:41 +05:30
2021-12-28 20:44:59 +05:30
if ( __instance . calendarDays [ i ] . name . Length > 0 )
{
toSpeak + = $", {__instance.calendarDays[i].name}" ;
}
if ( __instance . calendarDays [ i ] . hoverText . Length > 0 )
{
toSpeak + = $", {__instance.calendarDays[i].hoverText}" ;
}
2021-12-27 19:37:41 +05:30
2021-12-28 20:44:59 +05:30
if ( Game1 . dayOfMonth = = i + 1 )
toSpeak + = $", Current" ;
ScreenReader . sayWithChecker ( toSpeak , true ) ;
}
2021-12-27 19:37:41 +05:30
}
2021-12-28 20:44:59 +05:30
#endregion
2021-12-27 19:37:41 +05:30
}
2021-12-28 20:44:59 +05:30
else
2021-12-14 19:06:06 +05:30
{
2021-12-28 20:44:59 +05:30
#region Daily Quest Board
if ( Game1 . questOfTheDay = = null | | Game1 . questOfTheDay . currentObjective = = null | | Game1 . questOfTheDay . currentObjective . Length = = 0 )
2021-12-14 19:06:06 +05:30
{
2021-12-28 20:44:59 +05:30
// No quests
string toSpeak = "No quests for today!" ;
if ( currentDailyQuestText ! = toSpeak )
{
currentDailyQuestText = toSpeak ;
ScreenReader . say ( toSpeak , true ) ;
}
2021-12-14 19:06:06 +05:30
}
2021-12-28 20:44:59 +05:30
else
2021-12-14 19:06:06 +05:30
{
2021-12-28 20:44:59 +05:30
SpriteFont font = ( ( LocalizedContentManager . CurrentLanguageCode = = LocalizedContentManager . LanguageCode . ko ) ? Game1 . smallFont : Game1 . dialogueFont ) ;
string description = Game1 . parseText ( Game1 . questOfTheDay . questDescription , font , 640 ) ;
string toSpeak = description ;
2021-12-14 19:06:06 +05:30
2021-12-28 20:44:59 +05:30
if ( currentDailyQuestText ! = toSpeak )
2021-12-14 19:13:34 +05:30
{
2021-12-28 20:44:59 +05:30
currentDailyQuestText = toSpeak ;
// Snap to accept quest button
if ( __instance . acceptQuestButton . visible )
{
toSpeak + = "\t\n Left click to accept quest." ;
__instance . acceptQuestButton . snapMouseCursorToCenter ( ) ;
}
2021-12-14 19:06:06 +05:30
2021-12-28 20:44:59 +05:30
ScreenReader . say ( toSpeak , true ) ;
}
2021-12-14 19:06:06 +05:30
}
2021-12-28 20:44:59 +05:30
#endregion
}
}
catch ( Exception e )
{
MainClass . monitor . Log ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" , LogLevel . Error ) ;
2021-12-14 19:06:06 +05:30
}
}
2021-12-13 19:59:17 +05:30
2021-12-13 21:00:07 +05:30
internal static void QuestLogPatch ( QuestLog __instance , int ___questPage , List < List < IQuest > > ___pages , int ___currentPage , IQuest ____shownQuest , List < string > ____objectiveText )
{
try
{
2021-12-14 19:06:06 +05:30
bool snapMouseToRewardBox = false ;
2021-12-13 21:00:07 +05:30
if ( ___questPage = = - 1 )
{
#region Quest Lists
for ( int i = 0 ; i < __instance . questLogButtons . Count ; i + + )
{
if ( ___pages . Count ( ) > 0 & & ___pages [ ___currentPage ] . Count ( ) > i )
{
string name = ___pages [ ___currentPage ] [ i ] . GetName ( ) ;
int daysLeft = ___pages [ ___currentPage ] [ i ] . GetDaysLeft ( ) ;
2021-12-14 19:13:34 +05:30
string toSpeak = $"{name} quest" ;
2021-12-14 19:06:06 +05:30
if ( daysLeft > 0 & & ___pages [ ___currentPage ] [ i ] . ShouldDisplayAsComplete ( ) )
2021-12-13 21:00:07 +05:30
toSpeak + = $"\t\n {daysLeft} days left" ;
2021-12-14 19:06:06 +05:30
toSpeak + = ___pages [ ___currentPage ] [ i ] . ShouldDisplayAsComplete ( ) ? " completed!" : "" ;
2021-12-13 21:00:07 +05:30
if ( __instance . questLogButtons [ i ] . containsPoint ( Game1 . getOldMouseX ( ) , Game1 . getOldMouseY ( ) ) )
{
ScreenReader . sayWithChecker ( toSpeak , true ) ;
}
}
}
#endregion
}
else
{
#region Individual quest
string description = Game1 . parseText ( ____shownQuest . GetDescription ( ) , Game1 . dialogueFont , __instance . width - 128 ) ;
string title = ____shownQuest . GetName ( ) ;
string toSpeak = " " ;
if ( ____shownQuest . ShouldDisplayAsComplete ( ) )
{
#region Quest completed menu
2021-12-14 19:06:06 +05:30
toSpeak = $"Quest: {title} Completed!" ;
if ( __instance . HasReward ( ) )
2021-12-13 21:00:07 +05:30
{
2021-12-14 19:06:06 +05:30
snapMouseToRewardBox = true ;
if ( __instance . HasMoneyReward ( ) )
{
toSpeak + = $"you recieved {____shownQuest.GetMoneyReward()}g" ;
}
toSpeak + = "... left click to collect reward" ;
2021-12-13 21:00:07 +05:30
}
2021-12-14 19:06:06 +05:30
2021-12-13 21:00:07 +05:30
#endregion
}
else
{
#region Quest in - complete menu
toSpeak = $"Title: {title}. \t\n Description: {description}" ;
for ( int j = 0 ; j < ____objectiveText . Count ; j + + )
{
if ( ____shownQuest ! = null )
{
_ = ____shownQuest is SpecialOrder ;
}
string parsed_text = Game1 . parseText ( ____objectiveText [ j ] , width : __instance . width - 192 , whichFont : Game1 . dialogueFont ) ;
toSpeak + = $"\t\nOrder {j + 1}: {parsed_text} \t\n" ;
}
int daysLeft = ____shownQuest . GetDaysLeft ( ) ;
if ( daysLeft > 0 )
toSpeak + = $"\t\n{daysLeft} days left." ;
#endregion
}
2021-12-14 19:06:06 +05:30
// Move mouse to reward button
if ( snapMouseToRewardBox )
__instance . rewardBox . snapMouseCursorToCenter ( ) ;
ScreenReader . sayWithChecker ( toSpeak , true ) ;
2021-12-13 21:00:07 +05:30
#endregion
}
}
catch ( Exception e )
{
MainClass . monitor . Log ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" , LogLevel . Error ) ;
}
}
2021-12-13 19:59:17 +05:30
internal static void LetterViewerMenuPatch ( LetterViewerMenu __instance )
{
try
{
if ( ! __instance . IsActive ( ) )
return ;
#region Texts in the letter
string title = __instance . mailTitle ;
string message = __instance . mailMessage [ __instance . page ] ;
string toSpeak = $"{title} \t\n\t {message}." ;
if ( __instance . ShouldShowInteractable ( ) )
{
if ( __instance . moneyIncluded > 0 )
{
string moneyText = Game1 . content . LoadString ( "Strings\\UI:LetterViewer_MoneyIncluded" , __instance . moneyIncluded ) ;
toSpeak + = $"\t\n\t ,Included money: {moneyText}" ;
}
else if ( __instance . learnedRecipe ! = null & & __instance . learnedRecipe . Length > 0 )
{
string recipeText = Game1 . content . LoadString ( "Strings\\UI:LetterViewer_LearnedRecipe" , __instance . cookingOrCrafting ) ;
toSpeak + = $"\t\n\t ,Learned Recipe: {recipeText}" ;
}
}
if ( currentLetterText ! = toSpeak )
{
currentLetterText = toSpeak ;
2021-12-14 19:13:34 +05:30
// snap mouse to accept quest button
if ( __instance . acceptQuestButton . visible )
{
toSpeak + = "\t\n Left click to accept quest." ;
__instance . acceptQuestButton . snapMouseCursorToCenter ( ) ;
}
2021-12-13 19:59:17 +05:30
ScreenReader . say ( toSpeak , false ) ;
}
#endregion
#region Narrate items given in the mail
if ( __instance . ShouldShowInteractable ( ) )
{
foreach ( ClickableComponent c in __instance . itemsToGrab )
{
string name = c . name ;
string label = c . label ;
if ( c . containsPoint ( Game1 . getMousePosition ( ) . X , Game1 . getMousePosition ( ) . Y ) )
ScreenReader . sayWithChecker ( $"Grab: {name} \t\n {label}" , false ) ;
}
2021-12-14 19:06:06 +05:30
}
2021-12-13 19:59:17 +05:30
#endregion
}
catch ( Exception e )
{
MainClass . monitor . Log ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" , LogLevel . Error ) ;
}
}
2021-12-10 21:17:50 +05:30
2021-12-28 20:43:07 +05:30
internal static void TitleMenuPatch ( TitleMenu __instance , bool ___isTransitioningButtons )
2021-12-10 21:17:50 +05:30
{
try
{
2021-12-28 20:43:07 +05:30
if ( ___isTransitioningButtons )
return ;
2021-12-10 21:17:50 +05:30
string toSpeak = "" ;
__instance . buttons . ForEach ( component = >
{
if ( component . containsPoint ( Game1 . getMousePosition ( true ) . X , Game1 . getMousePosition ( true ) . Y ) )
{
string name = component . name ;
string label = component . label ;
toSpeak = $"{name} {label} Button" ;
}
} ) ;
2021-12-14 19:06:06 +05:30
if ( __instance . muteMusicButton . containsPoint ( Game1 . getMousePosition ( true ) . X , Game1 . getMousePosition ( true ) . Y ) )
2021-12-10 21:17:50 +05:30
{
toSpeak = "Mute Music Button" ;
}
if ( __instance . aboutButton . containsPoint ( Game1 . getMousePosition ( true ) . X , Game1 . getMousePosition ( true ) . Y ) )
{
toSpeak = "About Button" ;
}
if ( __instance . languageButton . containsPoint ( Game1 . getMousePosition ( true ) . X , Game1 . getMousePosition ( true ) . Y ) )
{
toSpeak = "Language Button" ;
}
if ( __instance . windowedButton . containsPoint ( Game1 . getMousePosition ( true ) . X , Game1 . getMousePosition ( true ) . Y ) )
{
toSpeak = "Fullscreen toggle Button" ;
}
if ( TitleMenu . subMenu ! = null & & __instance . backButton . containsPoint ( Game1 . getMousePosition ( true ) . X , Game1 . getMousePosition ( true ) . Y ) )
{
string text = "Back Button" ;
ScreenReader . sayWithChecker ( text , true ) ;
}
if ( TitleMenu . subMenu = = null & & toSpeak ! = "" )
ScreenReader . sayWithChecker ( toSpeak , true ) ;
}
catch ( Exception e )
{
MainClass . monitor . Log ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" , LogLevel . Error ) ;
}
}
2021-12-28 20:43:07 +05:30
internal static void LoadGameMenuPatch ( SaveFileSlot __instance , LoadGameMenu ___menu , int i )
2021-12-10 21:17:50 +05:30
{
try
{
2021-12-30 19:46:07 +05:30
int x = Game1 . getMousePosition ( true ) . X , y = Game1 . getMousePosition ( true ) . Y ;
if ( ___menu . slotButtons [ i ] . containsPoint ( x , y ) )
2021-12-10 21:17:50 +05:30
{
2021-12-28 20:43:07 +05:30
if ( __instance . Farmer ! = null )
2021-12-10 22:26:53 +05:30
{
2021-12-28 20:43:07 +05:30
#region Farms
2021-12-30 19:46:07 +05:30
if ( ___menu . deleteButtons . Count > 0 & & ___menu . deleteButtons [ i ] . containsPoint ( x , y ) )
2021-12-28 20:43:07 +05:30
{
ScreenReader . sayWithChecker ( $"Delete {__instance.Farmer.farmName} Farm" , true ) ;
return ;
}
2021-12-10 22:26:53 +05:30
2021-12-30 19:46:07 +05:30
if ( ___menu . deleteConfirmationScreen )
{
// Used diff. functions to narrate to prevent it from speaking the message again on selecting another button.
string message = "Really delete farm?" ;
ScreenReader . sayWithChecker ( message , true ) ;
if ( ___menu . okDeleteButton . containsPoint ( x , y ) )
{
ScreenReader . sayWithMenuChecker ( "Ok Button" , false ) ;
}
else if ( ___menu . cancelDeleteButton . containsPoint ( x , y ) )
{
ScreenReader . sayWithMenuChecker ( "Cancel Button" , false ) ;
}
return ;
}
2021-12-28 20:43:07 +05:30
String farmerName = __instance . Farmer . displayName ;
String farmName = __instance . Farmer . farmName ;
String money = __instance . Farmer . Money . ToString ( ) ;
String hoursPlayed = Utility . getHoursMinutesStringFromMilliseconds ( __instance . Farmer . millisecondsPlayed ) ;
string dateStringForSaveGame = ( ( ! __instance . Farmer . dayOfMonthForSaveGame . HasValue | |
! __instance . Farmer . seasonForSaveGame . HasValue | |
! __instance . Farmer . yearForSaveGame . HasValue ) ? __instance . Farmer . dateStringForSaveGame : Utility . getDateStringFor ( __instance . Farmer . dayOfMonthForSaveGame . Value , __instance . Farmer . seasonForSaveGame . Value , __instance . Farmer . yearForSaveGame . Value ) ) ;
2021-12-10 21:17:50 +05:30
2021-12-28 20:43:07 +05:30
string toSpeak = $"{farmName} Farm Selected, \t\n Farmer:{farmerName}, \t\nMoney:{money}, \t\nHours Played:{hoursPlayed}, \t\nDate:{dateStringForSaveGame}" ;
2021-12-10 21:17:50 +05:30
2021-12-28 20:43:07 +05:30
ScreenReader . sayWithChecker ( toSpeak , true ) ;
#endregion
}
2021-12-10 21:17:50 +05:30
}
}
catch ( Exception e )
{
MainClass . monitor . Log ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" , LogLevel . Error ) ;
}
}
2021-12-10 22:26:53 +05:30
2021-12-31 19:03:33 +05:30
internal static void NewGameMenuPatch ( CharacterCustomization __instance , TextBox ___nameBox , TextBox ___farmnameBox ,
TextBox ___favThingBox , ClickableTextureComponent ___skipIntroButton , ClickableTextureComponent ___okButton ,
ClickableComponent ___backButton , ClickableTextureComponent ___randomButton , List < ClickableComponent > ___genderButtons ,
2021-12-31 20:16:43 +05:30
List < ClickableTextureComponent > ___farmTypeButtons , ClickableTextureComponent ___farmTypeNextPageButton , ClickableTextureComponent ___farmTypePreviousPageButton ,
List < ClickableTextureComponent > ___cabinLayoutButtons )
2021-12-11 18:10:31 +05:30
{
try
{
2021-12-31 19:03:33 +05:30
if ( __instance . source ! = CharacterCustomization . Source . NewGame & & __instance . source ! = CharacterCustomization . Source . HostNewFarm )
2021-12-11 18:10:31 +05:30
return ;
bool isNextArrowPressed = Game1 . input . GetKeyboardState ( ) . IsKeyDown ( Microsoft . Xna . Framework . Input . Keys . Right ) ;
bool isPrevArrowPressed = Game1 . input . GetKeyboardState ( ) . IsKeyDown ( Microsoft . Xna . Framework . Input . Keys . Left ) ;
2021-12-14 22:51:38 +05:30
2021-12-16 19:00:51 +05:30
if ( isNextArrowPressed & & ! isRunning )
2021-12-11 18:10:31 +05:30
{
2021-12-31 19:03:33 +05:30
_ = CycleThroughItems ( true , ___nameBox , ___farmnameBox , ___favThingBox ,
___skipIntroButton , ___okButton , ___backButton ,
___randomButton , ___genderButtons , ___farmTypeButtons ,
2021-12-31 20:16:43 +05:30
___farmTypeNextPageButton , ___farmTypePreviousPageButton , ___cabinLayoutButtons ) ;
2021-12-11 18:10:31 +05:30
}
2021-12-16 19:00:51 +05:30
else if ( isPrevArrowPressed & & ! isRunning )
2021-12-11 18:10:31 +05:30
{
2021-12-31 19:03:33 +05:30
_ = CycleThroughItems ( false , ___nameBox , ___farmnameBox , ___favThingBox ,
___skipIntroButton , ___okButton , ___backButton , ___randomButton ,
___genderButtons , ___farmTypeButtons ,
2021-12-31 20:16:43 +05:30
___farmTypeNextPageButton , ___farmTypePreviousPageButton , ___cabinLayoutButtons ) ;
2021-12-11 18:10:31 +05:30
}
}
catch ( Exception e )
{
MainClass . monitor . Log ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" , LogLevel . Error ) ;
}
}
2021-12-31 19:03:33 +05:30
private static async Task CycleThroughItems ( bool increase , TextBox ___nameBox , TextBox ___farmnameBox ,
TextBox ___favThingBox , ClickableTextureComponent ___skipIntroButton , ClickableTextureComponent ___okButton ,
ClickableComponent ___backButton , ClickableTextureComponent ___randomButton , List < ClickableComponent > ___genderButtons ,
2021-12-31 20:16:43 +05:30
List < ClickableTextureComponent > ___farmTypeButtons , ClickableTextureComponent ___farmTypeNextPageButton , ClickableTextureComponent ___farmTypePreviousPageButton ,
List < ClickableTextureComponent > ___cabinLayoutButtons )
2021-12-11 18:10:31 +05:30
{
isRunning = true ;
if ( increase )
{
saveGameIndex + + ;
2021-12-31 19:03:33 +05:30
if ( saveGameIndex > MAX_COMPONENTS )
2021-12-14 19:06:06 +05:30
saveGameIndex = 0 ;
}
else
2021-12-11 18:10:31 +05:30
{
saveGameIndex - - ;
if ( saveGameIndex < 0 )
2021-12-31 19:03:33 +05:30
saveGameIndex = MAX_COMPONENTS ;
2021-12-11 18:10:31 +05:30
}
await Task . Delay ( 200 ) ;
switch ( saveGameIndex )
{
case 0 :
{
Rectangle bounds = new Rectangle ( ___nameBox . X , ___nameBox . Y , ___nameBox . Width , ___nameBox . Height ) ;
Game1 . input . SetMousePosition ( bounds . Center . X , bounds . Center . Y ) ;
2021-12-31 19:03:33 +05:30
ScreenReader . say ( "Enter Farmer's Name" , false ) ;
2021-12-11 18:10:31 +05:30
}
break ;
case 1 :
{
Rectangle bounds = new Rectangle ( ___farmnameBox . X , ___farmnameBox . Y , ___farmnameBox . Width , ___farmnameBox . Height ) ;
Game1 . input . SetMousePosition ( bounds . Center . X , bounds . Center . Y ) ;
2021-12-31 19:03:33 +05:30
ScreenReader . say ( "Enter Farm's Name" , false ) ;
2021-12-11 18:10:31 +05:30
}
break ;
case 3 :
{
Rectangle bounds = new Rectangle ( ___favThingBox . X , ___favThingBox . Y , ___favThingBox . Width , ___favThingBox . Height ) ;
Game1 . input . SetMousePosition ( bounds . Center . X , bounds . Center . Y ) ;
2021-12-31 19:03:33 +05:30
ScreenReader . say ( "Enter Favourite Thing" , false ) ;
2021-12-11 18:10:31 +05:30
}
break ;
case 4 :
{
___skipIntroButton . snapMouseCursor ( ) ;
2021-12-31 19:03:33 +05:30
ScreenReader . say ( "Skip Intro Button" , false ) ;
2021-12-11 18:10:31 +05:30
}
break ;
case 5 :
2021-12-31 19:03:33 +05:30
{
___randomButton . snapMouseCursor ( ) ;
ScreenReader . say ( "Random Skin Button" , false ) ;
break ;
}
case 6 :
{
___genderButtons [ 0 ] . snapMouseCursor ( ) ;
ScreenReader . say ( "Gender Male Button" , false ) ;
break ;
}
case 7 :
{
___genderButtons [ 1 ] . snapMouseCursor ( ) ;
ScreenReader . say ( "Gender Female Button" , false ) ;
break ;
}
case 8 :
{
___farmTypeButtons [ 0 ] . snapMouseCursor ( ) ;
ScreenReader . say ( getFarmHoverText ( ___farmTypeButtons [ 0 ] ) , false ) ;
break ;
}
case 9 :
{
___farmTypeButtons [ 1 ] . snapMouseCursor ( ) ;
ScreenReader . say ( getFarmHoverText ( ___farmTypeButtons [ 1 ] ) , false ) ;
break ;
}
case 10 :
{
___farmTypeButtons [ 2 ] . snapMouseCursor ( ) ;
ScreenReader . say ( getFarmHoverText ( ___farmTypeButtons [ 2 ] ) , false ) ;
break ;
}
case 11 :
{
___farmTypeButtons [ 3 ] . snapMouseCursor ( ) ;
ScreenReader . say ( getFarmHoverText ( ___farmTypeButtons [ 3 ] ) , false ) ;
break ;
}
case 12 :
{
___farmTypeButtons [ 4 ] . snapMouseCursor ( ) ;
ScreenReader . say ( getFarmHoverText ( ___farmTypeButtons [ 4 ] ) , false ) ;
break ;
}
case 13 :
{
___farmTypeButtons [ 5 ] . snapMouseCursor ( ) ;
ScreenReader . say ( getFarmHoverText ( ___farmTypeButtons [ 5 ] ) , false ) ;
break ;
}
case 14 :
{
___farmTypeButtons [ 6 ] . snapMouseCursor ( ) ;
ScreenReader . say ( getFarmHoverText ( ___farmTypeButtons [ 6 ] ) , false ) ;
break ;
}
case 15 :
{
if ( ___farmTypeNextPageButton = = null )
{
if ( increase )
{
+ + saveGameIndex ;
goto case 16 ;
}
else
{
- - saveGameIndex ;
goto case 14 ;
}
}
___farmTypeNextPageButton . snapMouseCursor ( ) ;
ScreenReader . say ( "Next Farm Type Page Button" , false ) ;
break ;
}
case 16 :
{
if ( ___farmTypePreviousPageButton = = null )
{
if ( increase )
{
+ + saveGameIndex ;
goto case 17 ;
}
else
{
- - saveGameIndex ;
goto case 15 ;
}
}
___farmTypePreviousPageButton . snapMouseCursor ( ) ;
ScreenReader . say ( "Previous Farm Type Page Button" , false ) ;
break ;
}
case 17 :
2021-12-31 20:16:43 +05:30
{
if ( ___cabinLayoutButtons . Count < = 0 )
{
if ( increase )
{
+ + saveGameIndex ;
goto case 18 ;
}
else
{
- - saveGameIndex ;
goto case 16 ;
}
}
___cabinLayoutButtons [ 0 ] . snapMouseCursor ( ) ;
ScreenReader . say ( "Cabin layout nearby" , false ) ;
break ;
}
case 18 :
{
if ( ___cabinLayoutButtons . Count < = 0 )
{
if ( increase )
{
+ + saveGameIndex ;
goto case 19 ;
}
else
{
- - saveGameIndex ;
goto case 17 ;
}
}
___cabinLayoutButtons [ 1 ] . snapMouseCursor ( ) ;
ScreenReader . say ( "Cabin layout separate" , false ) ;
break ;
}
case 19 :
2021-12-11 18:10:31 +05:30
{
___okButton . snapMouseCursor ( ) ;
2021-12-31 19:03:33 +05:30
ScreenReader . say ( "Ok Button" , false ) ;
2021-12-11 18:10:31 +05:30
}
break ;
2021-12-31 20:16:43 +05:30
case 20 :
2021-12-11 18:10:31 +05:30
{
___backButton . snapMouseCursor ( ) ;
2021-12-31 19:03:33 +05:30
ScreenReader . say ( "Back Button" , false ) ;
2021-12-11 18:10:31 +05:30
}
break ;
}
isRunning = false ;
}
2021-12-31 19:03:33 +05:30
private static string getFarmHoverText ( ClickableTextureComponent farm )
{
string hoverTitle = " " , hoverText = " " ;
if ( ! farm . name . Contains ( "Gray" ) )
{
if ( farm . hoverText . Contains ( '_' ) )
{
hoverTitle = farm . hoverText . Split ( '_' ) [ 0 ] ;
hoverText = farm . hoverText . Split ( '_' ) [ 1 ] ;
}
else
{
hoverTitle = null ;
hoverText = farm . hoverText ;
}
}
else
{
if ( farm . name . Contains ( "Gray" ) )
{
hoverText = "Reach level 10 " + Game1 . content . LoadString ( "Strings\\UI:Character_" + farm . name . Split ( '_' ) [ 1 ] ) + " to unlock." ;
}
}
return $"{hoverTitle}: {hoverText}" ;
}
2021-12-10 22:26:53 +05:30
internal static void ExitPagePatch ( ExitPage __instance )
{
2021-12-10 23:35:04 +05:30
try
2021-12-10 22:26:53 +05:30
{
2021-12-10 23:35:04 +05:30
if ( __instance . exitToTitle . visible & &
__instance . exitToTitle . containsPoint ( Game1 . getMousePosition ( true ) . X , Game1 . getMousePosition ( true ) . Y ) )
{
ScreenReader . sayWithChecker ( "Exit to Title Button" , true ) ;
}
if ( __instance . exitToDesktop . visible & &
__instance . exitToDesktop . containsPoint ( Game1 . getMousePosition ( true ) . X , Game1 . getMousePosition ( true ) . Y ) )
{
ScreenReader . sayWithChecker ( "Exit to Desktop Button" , true ) ;
}
2021-12-10 22:26:53 +05:30
}
2021-12-10 23:35:04 +05:30
catch ( Exception e )
2021-12-10 22:26:53 +05:30
{
2021-12-10 23:35:04 +05:30
MainClass . monitor . Log ( $"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}" , LogLevel . Error ) ;
2021-12-10 22:26:53 +05:30
}
}
2021-12-14 19:06:06 +05:30
internal static void resetGlobalVars ( )
{
currentLetterText = " " ;
currentDailyQuestText = " " ;
2021-12-30 19:09:05 +05:30
currentLevelUpTitle = " " ;
2021-12-14 19:06:06 +05:30
}
2021-12-10 21:17:50 +05:30
}
}