Organized charcter customization patch

master
shoaib11120 2022-01-03 20:36:57 +05:30
parent 1084ef8dd8
commit 43a94b7f72
2 changed files with 316 additions and 76 deletions

View File

@ -14,7 +14,6 @@ namespace stardew_access.Patches
internal static void CoopMenuPatch(CoopMenu __instance, CoopMenu.Tab ___currentTab) internal static void CoopMenuPatch(CoopMenu __instance, CoopMenu.Tab ___currentTab)
{ {
try try
{ {
int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y; int x = Game1.getMousePosition(true).X, y = Game1.getMousePosition(true).Y;
@ -162,34 +161,20 @@ namespace stardew_access.Patches
} }
} }
internal static void NewGameMenuPatch(CharacterCustomization __instance, TextBox ___nameBox, TextBox ___farmnameBox, internal static void NewGameMenuPatch(CharacterCustomization __instance, bool ___skipIntro)
TextBox ___favThingBox, ClickableTextureComponent ___skipIntroButton, ClickableTextureComponent ___okButton,
ClickableComponent ___backButton, ClickableTextureComponent ___randomButton, List<ClickableComponent> ___genderButtons,
List<ClickableTextureComponent> ___farmTypeButtons, ClickableTextureComponent ___farmTypeNextPageButton, ClickableTextureComponent ___farmTypePreviousPageButton,
List<ClickableTextureComponent> ___cabinLayoutButtons)
{ {
try try
{ {
if (__instance.source != CharacterCustomization.Source.NewGame && __instance.source != CharacterCustomization.Source.HostNewFarm)
return;
bool isNextArrowPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right); bool isNextArrowPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right);
bool isPrevArrowPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left); bool isPrevArrowPressed = Game1.input.GetKeyboardState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left);
if (isNextArrowPressed && !isRunning) if (isNextArrowPressed && !isRunning)
{ {
_ = CycleThroughItems(true, ___nameBox, ___farmnameBox, ___favThingBox, _ = CycleThroughItems(true, __instance, ___skipIntro);
___skipIntroButton, ___okButton, ___backButton,
___randomButton, ___genderButtons, ___farmTypeButtons,
___farmTypeNextPageButton, ___farmTypePreviousPageButton, ___cabinLayoutButtons);
} }
else if (isPrevArrowPressed && !isRunning) else if (isPrevArrowPressed && !isRunning)
{ {
_ = CycleThroughItems(false, ___nameBox, ___farmnameBox, ___favThingBox, _ = CycleThroughItems(false, __instance, ___skipIntro);
___skipIntroButton, ___okButton, ___backButton, ___randomButton,
___genderButtons, ___farmTypeButtons,
___farmTypeNextPageButton, ___farmTypePreviousPageButton, ___cabinLayoutButtons);
} }
} }
catch (Exception e) catch (Exception e)
@ -198,121 +183,340 @@ namespace stardew_access.Patches
} }
} }
private static async Task CycleThroughItems(bool increase, TextBox ___nameBox, TextBox ___farmnameBox, private static async Task CycleThroughItems(bool increase, CharacterCustomization __instance, bool ___skipIntro)
TextBox ___favThingBox, ClickableTextureComponent ___skipIntroButton, ClickableTextureComponent ___okButton,
ClickableComponent ___backButton, ClickableTextureComponent ___randomButton, List<ClickableComponent> ___genderButtons,
List<ClickableTextureComponent> ___farmTypeButtons, ClickableTextureComponent ___farmTypeNextPageButton, ClickableTextureComponent ___farmTypePreviousPageButton,
List<ClickableTextureComponent> ___cabinLayoutButtons)
{ {
isRunning = true; isRunning = true;
string toSpeak = " ";
if (increase) if (increase)
{ {
saveGameIndex++; saveGameIndex++;
if (saveGameIndex > MAX_COMPONENTS) if (saveGameIndex > MAX_COMPONENTS)
saveGameIndex = 0; saveGameIndex = 1;
} }
else else
{ {
saveGameIndex--; saveGameIndex--;
if (saveGameIndex < 0) if (saveGameIndex < 1)
saveGameIndex = MAX_COMPONENTS; saveGameIndex = MAX_COMPONENTS;
} }
await Task.Delay(200);
switch (saveGameIndex) switch (saveGameIndex)
{ {
case 0: case 1:
{ {
Rectangle bounds = new Rectangle(___nameBox.X, ___nameBox.Y, ___nameBox.Width, ___nameBox.Height); #region Skip if button is not available
Game1.input.SetMousePosition(bounds.Center.X, bounds.Center.Y); if (!__instance.nameBoxCC.visible)
ScreenReader.say("Enter Farmer's Name", false); {
if (increase)
{
++saveGameIndex;
goto case 2;
}
else
{
--saveGameIndex;
goto case MAX_COMPONENTS;
}
}
#endregion
__instance.nameBoxCC.snapMouseCursorToCenter();
toSpeak = "Enter Farmer's Name";
} }
break; break;
case 1: case 2:
{ {
Rectangle bounds = new Rectangle(___farmnameBox.X, ___farmnameBox.Y, ___farmnameBox.Width, ___farmnameBox.Height); #region Skip if button is not available
Game1.input.SetMousePosition(bounds.Center.X, bounds.Center.Y); if (!__instance.farmnameBoxCC.visible)
ScreenReader.say("Enter Farm's Name", false); {
if (increase)
{
++saveGameIndex;
goto case 3;
}
else
{
--saveGameIndex;
goto case 1;
}
}
#endregion
__instance.farmnameBoxCC.snapMouseCursorToCenter();
toSpeak = "Enter Farm's Name";
} }
break; break;
case 3: case 3:
{ {
Rectangle bounds = new Rectangle(___favThingBox.X, ___favThingBox.Y, ___favThingBox.Width, ___favThingBox.Height); #region Skip if button is not available
Game1.input.SetMousePosition(bounds.Center.X, bounds.Center.Y); if (!__instance.favThingBoxCC.visible)
ScreenReader.say("Enter Favourite Thing", false); {
if (increase)
{
++saveGameIndex;
goto case 4;
}
else
{
--saveGameIndex;
goto case 2;
}
}
#endregion
__instance.favThingBoxCC.snapMouseCursorToCenter();
toSpeak = "Enter Favourite Thing";
} }
break; break;
case 4: case 4:
{ {
___skipIntroButton.snapMouseCursor(); #region Skip if button is not available
ScreenReader.say("Skip Intro Button", false); if (!__instance.skipIntroButton.visible)
{
if (increase)
{
++saveGameIndex;
goto case 5;
}
else
{
--saveGameIndex;
goto case 3;
}
}
#endregion
__instance.skipIntroButton.snapMouseCursor();
toSpeak = (___skipIntro?"Enabled":"Disabled") + " Skip Intro Button";
} }
break; break;
case 5: case 5:
{ {
___randomButton.snapMouseCursor(); #region Skip if button is not available
ScreenReader.say("Random Skin Button", false); if (!__instance.randomButton.visible)
{
if (increase)
{
++saveGameIndex;
goto case 6;
}
else
{
--saveGameIndex;
goto case 5;
}
}
#endregion
__instance.randomButton.snapMouseCursor();
toSpeak = "Random Skin Button";
break; break;
} }
case 6: case 6:
{ {
___genderButtons[0].snapMouseCursor(); #region Skip if button is not available
ScreenReader.say("Gender Male Button", false); if (__instance.genderButtons.Count <= 0)
{
if (increase)
{
++saveGameIndex;
goto case 8;
}
else
{
--saveGameIndex;
goto case 6;
}
}
#endregion
__instance.genderButtons[0].snapMouseCursor();
toSpeak = "Gender Male Button";
break; break;
} }
case 7: case 7:
{ {
___genderButtons[1].snapMouseCursor(); #region Skip if button is not available
ScreenReader.say("Gender Female Button", false); if (__instance.genderButtons.Count <= 0)
{
if (increase)
{
++saveGameIndex;
goto case 8;
}
else
{
--saveGameIndex;
goto case 6;
}
}
#endregion
__instance.genderButtons[1].snapMouseCursor();
toSpeak = "Gender Female Button";
break; break;
} }
case 8: case 8:
{ {
___farmTypeButtons[0].snapMouseCursor(); #region Skip if button is not available
ScreenReader.say(getFarmHoverText(___farmTypeButtons[0]), false); if (__instance.farmTypeButtons.Count <= 0)
{
if (increase)
{
++saveGameIndex;
goto case 9;
}
else
{
--saveGameIndex;
goto case 7;
}
}
#endregion
__instance.farmTypeButtons[0].snapMouseCursor();
toSpeak = getFarmHoverText(__instance.farmTypeButtons[0]);
break; break;
} }
case 9: case 9:
{ {
___farmTypeButtons[1].snapMouseCursor(); #region Skip if button is not available
ScreenReader.say(getFarmHoverText(___farmTypeButtons[1]), false); if (__instance.farmTypeButtons.Count <= 0)
{
if (increase)
{
++saveGameIndex;
goto case 10;
}
else
{
--saveGameIndex;
goto case 8;
}
}
#endregion
__instance.farmTypeButtons[1].snapMouseCursor();
toSpeak = getFarmHoverText(__instance.farmTypeButtons[1]);
break; break;
} }
case 10: case 10:
{ {
___farmTypeButtons[2].snapMouseCursor(); #region Skip if button is not available
ScreenReader.say(getFarmHoverText(___farmTypeButtons[2]), false); if (__instance.farmTypeButtons.Count <= 0)
{
if (increase)
{
++saveGameIndex;
goto case 11;
}
else
{
--saveGameIndex;
goto case 9;
}
}
#endregion
__instance.farmTypeButtons[2].snapMouseCursor();
toSpeak = getFarmHoverText(__instance.farmTypeButtons[2]);
break; break;
} }
case 11: case 11:
{ {
___farmTypeButtons[3].snapMouseCursor(); #region Skip if button is not available
ScreenReader.say(getFarmHoverText(___farmTypeButtons[3]), false); if (__instance.farmTypeButtons.Count <= 0)
{
if (increase)
{
++saveGameIndex;
goto case 12;
}
else
{
--saveGameIndex;
goto case 10;
}
}
#endregion
__instance.farmTypeButtons[3].snapMouseCursor();
toSpeak = getFarmHoverText(__instance.farmTypeButtons[3]);
break; break;
} }
case 12: case 12:
{ {
___farmTypeButtons[4].snapMouseCursor(); #region Skip if button is not available
ScreenReader.say(getFarmHoverText(___farmTypeButtons[4]), false); if (__instance.farmTypeButtons.Count <= 0)
{
if (increase)
{
++saveGameIndex;
goto case 13;
}
else
{
--saveGameIndex;
goto case 11;
}
}
#endregion
__instance.farmTypeButtons[4].snapMouseCursor();
toSpeak = getFarmHoverText(__instance.farmTypeButtons[4]);
break; break;
} }
case 13: case 13:
{ {
___farmTypeButtons[5].snapMouseCursor(); #region Skip if button is not available
ScreenReader.say(getFarmHoverText(___farmTypeButtons[5]), false); if (__instance.farmTypeButtons.Count <= 0)
{
if (increase)
{
++saveGameIndex;
goto case 14;
}
else
{
--saveGameIndex;
goto case 12;
}
}
#endregion
__instance.farmTypeButtons[5].snapMouseCursor();
toSpeak = getFarmHoverText(__instance.farmTypeButtons[5]);
break; break;
} }
case 14: case 14:
{ {
___farmTypeButtons[6].snapMouseCursor(); #region Skip if button is not available
ScreenReader.say(getFarmHoverText(___farmTypeButtons[6]), false); if (__instance.farmTypeButtons.Count <= 0)
{
if (increase)
{
++saveGameIndex;
goto case 15;
}
else
{
--saveGameIndex;
goto case 13;
}
}
#endregion
__instance.farmTypeButtons[6].snapMouseCursor();
toSpeak = getFarmHoverText(__instance.farmTypeButtons[6]);
break; break;
} }
case 15: case 15:
{ {
if (___farmTypeNextPageButton == null) #region Skip if button is not available
if (__instance.farmTypeNextPageButton == null)
{ {
if (increase) if (increase)
{ {
@ -325,14 +529,16 @@ namespace stardew_access.Patches
goto case 14; goto case 14;
} }
} }
#endregion
___farmTypeNextPageButton.snapMouseCursor(); __instance.farmTypeNextPageButton.snapMouseCursor();
ScreenReader.say("Next Farm Type Page Button", false); toSpeak = "Next Farm Type Page Button";
break; break;
} }
case 16: case 16:
{ {
if (___farmTypePreviousPageButton == null) #region Skip if button is not available
if (__instance.farmTypePreviousPageButton == null)
{ {
if (increase) if (increase)
{ {
@ -345,14 +551,16 @@ namespace stardew_access.Patches
goto case 15; goto case 15;
} }
} }
#endregion
___farmTypePreviousPageButton.snapMouseCursor(); __instance.farmTypePreviousPageButton.snapMouseCursor();
ScreenReader.say("Previous Farm Type Page Button", false); toSpeak = "Previous Farm Type Page Button";
break; break;
} }
case 17: case 17:
{ {
if (___cabinLayoutButtons.Count <= 0) #region Skip if button is not available
if (__instance.cabinLayoutButtons.Count <= 0)
{ {
if (increase) if (increase)
{ {
@ -365,14 +573,16 @@ namespace stardew_access.Patches
goto case 16; goto case 16;
} }
} }
#endregion
___cabinLayoutButtons[0].snapMouseCursor(); __instance.cabinLayoutButtons[0].snapMouseCursor();
ScreenReader.say("Cabin layout nearby", false); toSpeak = "Cabin layout nearby";
break; break;
} }
case 18: case 18:
{ {
if (___cabinLayoutButtons.Count <= 0) #region Skip if button is not available
if (__instance.cabinLayoutButtons.Count <= 0)
{ {
if (increase) if (increase)
{ {
@ -385,25 +595,55 @@ namespace stardew_access.Patches
goto case 17; goto case 17;
} }
} }
#endregion
___cabinLayoutButtons[1].snapMouseCursor(); __instance.cabinLayoutButtons[1].snapMouseCursor();
ScreenReader.say("Cabin layout separate", false); toSpeak = "Cabin layout separate";
break; break;
} }
case 19: case 19:
{ {
___okButton.snapMouseCursor(); #region Skip if button is not available
ScreenReader.say("Ok Button", false); if (!__instance.okButton.visible)
{
if (increase)
{
++saveGameIndex;
goto case 18;
}
else
{
--saveGameIndex;
goto case 20;
}
}
#endregion
__instance.okButton.snapMouseCursor();
toSpeak = "Ok Button";
} }
break; break;
case 20: case 20:
{ {
___backButton.snapMouseCursor(); #region Exit if button is not available
ScreenReader.say("Back Button", false); if (!__instance.backButton.visible)
{
break;
}
#endregion
__instance.backButton.snapMouseCursor();
toSpeak = "Back Button";
} }
break; break;
} }
if(toSpeak!=" ")
{
ScreenReader.say(toSpeak, true);
}
await Task.Delay(200);
isRunning = false; isRunning = false;
} }

View File

@ -1,7 +1,7 @@
{ {
"Name": "Stardew Access", "Name": "Stardew Access",
"Author": "Mohammad Shoaib", "Author": "Mohammad Shoaib",
"Version": "1.0.11-beta", "Version": "1.0.12-beta",
"Description": "An accessibility mod with screen reader support!", "Description": "An accessibility mod with screen reader support!",
"UniqueID": "shoaib.stardewaccess", "UniqueID": "shoaib.stardewaccess",
"EntryDll": "stardew-access.dll", "EntryDll": "stardew-access.dll",