Refactored code
This commit is contained in:
@@ -48,7 +48,7 @@ namespace stardew_access
|
||||
|
||||
harmony.Patch(
|
||||
original: AccessTools.Method(typeof(CharacterCustomization), nameof(CharacterCustomization.draw), new Type[] { typeof(SpriteBatch) }),
|
||||
postfix: new HarmonyMethod(typeof(CharacterCustomizationPatches), nameof(CharacterCustomizationPatches.CharacterCustomizationMenuPatch))
|
||||
postfix: new HarmonyMethod(typeof(CharacterCustomizationMenuPatch), nameof(CharacterCustomizationMenuPatch.DrawPatch))
|
||||
);
|
||||
|
||||
harmony.Patch(
|
||||
|
@@ -1,8 +1,10 @@
|
||||
using StardewValley;
|
||||
using StardewValley.Menus;
|
||||
|
||||
namespace stardew_access.Patches {
|
||||
internal class CharacterCustomizationPatches {
|
||||
namespace stardew_access.Patches
|
||||
{
|
||||
internal class CharacterCustomizationMenuPatch
|
||||
{
|
||||
private static bool isRunning = false;
|
||||
private static int saveGameIndex = -1;
|
||||
public static string characterCreationMenuQueryKey = " ";
|
||||
@@ -28,7 +30,7 @@ namespace stardew_access.Patches {
|
||||
public static bool characterDesignToggleShouldSpeak = true;
|
||||
public static ClickableComponent? currentComponent = null;
|
||||
|
||||
internal static void CharacterCustomizationMenuPatch(CharacterCustomization __instance, bool ___skipIntro,
|
||||
internal static void DrawPatch(CharacterCustomization __instance, bool ___skipIntro,
|
||||
ClickableComponent ___startingCabinsLabel, ClickableComponent ___difficultyModifierLabel, TextBox ___nameBox,
|
||||
TextBox ___farmnameBox, TextBox ___favThingBox)
|
||||
{
|
||||
@@ -97,7 +99,9 @@ namespace stardew_access.Patches {
|
||||
if (characterDesignToggle)
|
||||
{
|
||||
displayState = "shown";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
displayState = "hidden";
|
||||
}
|
||||
toSpeak = $"Character design controls {displayState}. \n {toSpeak}";
|
||||
@@ -185,7 +189,9 @@ namespace stardew_access.Patches {
|
||||
prevEyeColorHue = currentEyeColorHue;
|
||||
if (currentEyeColorHue != "")
|
||||
toSpeak = $"{toSpeak} \n Hue: {currentEyeColorHue}";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
prevEyeColorHue = "";
|
||||
}
|
||||
}
|
||||
@@ -197,7 +203,9 @@ namespace stardew_access.Patches {
|
||||
prevEyeColorSaturation = currentEyeColorSaturation;
|
||||
if (currentEyeColorSaturation != "")
|
||||
toSpeak = $"{toSpeak} \n Saturation: {currentEyeColorSaturation}";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
prevEyeColorSaturation = "";
|
||||
}
|
||||
}
|
||||
@@ -209,7 +217,9 @@ namespace stardew_access.Patches {
|
||||
prevEyeColorValue = currentEyeColorValue;
|
||||
if (currentEyeColorValue != "")
|
||||
toSpeak = $"{toSpeak} \n Value: {currentEyeColorValue}";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
prevEyeColorValue = "";
|
||||
}
|
||||
}
|
||||
@@ -231,7 +241,9 @@ namespace stardew_access.Patches {
|
||||
prevHairColorHue = currentHairColorHue;
|
||||
if (currentHairColorHue != "")
|
||||
toSpeak = $"{toSpeak} \n Hue: {currentHairColorHue}";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
prevHairColorHue = "";
|
||||
}
|
||||
}
|
||||
@@ -243,7 +255,9 @@ namespace stardew_access.Patches {
|
||||
prevHairColorSaturation = currentHairColorSaturation;
|
||||
if (currentHairColorSaturation != "")
|
||||
toSpeak = $"{toSpeak} \n Saturation: {currentHairColorSaturation}";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
prevHairColorSaturation = "";
|
||||
}
|
||||
}
|
||||
@@ -255,7 +269,9 @@ namespace stardew_access.Patches {
|
||||
prevHairColorValue = currentHairColorValue;
|
||||
if (currentHairColorValue != "")
|
||||
toSpeak = $"{toSpeak} \n Value: {currentHairColorValue}";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
prevHairColorValue = "";
|
||||
}
|
||||
}
|
||||
@@ -277,7 +293,9 @@ namespace stardew_access.Patches {
|
||||
prevPantsColorHue = currentPantsColorHue;
|
||||
if (currentPantsColorHue != "")
|
||||
toSpeak = $"{toSpeak} \n Hue: {currentPantsColorHue}";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
prevPantsColorHue = "";
|
||||
}
|
||||
}
|
||||
@@ -289,7 +307,9 @@ namespace stardew_access.Patches {
|
||||
prevPantsColorSaturation = currentPantsColorSaturation;
|
||||
if (currentPantsColorSaturation != "")
|
||||
toSpeak = $"{toSpeak} \n Saturation: {currentPantsColorSaturation}";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
prevPantsColorSaturation = "";
|
||||
}
|
||||
}
|
||||
@@ -301,7 +321,9 @@ namespace stardew_access.Patches {
|
||||
prevPantsColorValue = currentPantsColorValue;
|
||||
if (currentPantsColorValue != "")
|
||||
toSpeak = $"{toSpeak} \n Value: {currentPantsColorValue}";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
prevPantsColorValue = "";
|
||||
}
|
||||
}
|
||||
@@ -326,7 +348,6 @@ namespace stardew_access.Patches {
|
||||
return toSpeak.Trim();
|
||||
}
|
||||
|
||||
|
||||
private static string CycleThroughItems(bool increase, CharacterCustomization __instance, bool ___skipIntro,
|
||||
ClickableComponent ___startingCabinsLabel, ClickableComponent ___difficultyModifierLabel, TextBox ___nameBox,
|
||||
TextBox ___farmnameBox, TextBox ___favThingBox)
|
||||
@@ -344,7 +365,9 @@ namespace stardew_access.Patches {
|
||||
if (___nameBox.Text != "")
|
||||
{
|
||||
postText = $": {___nameBox.Text}";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
postText = " Text Box";
|
||||
}
|
||||
buttons.Add(__instance.nameBoxCC, $"Farmer's Name{postText}");
|
||||
@@ -355,7 +378,9 @@ namespace stardew_access.Patches {
|
||||
if (___farmnameBox.Text != "")
|
||||
{
|
||||
postText = $": {___farmnameBox.Text}";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
postText = " Text Box";
|
||||
}
|
||||
buttons.Add(__instance.farmnameBoxCC, $"Farm's Name{postText}");
|
||||
@@ -366,7 +391,9 @@ namespace stardew_access.Patches {
|
||||
if (___favThingBox.Text != "")
|
||||
{
|
||||
postText = $": {___favThingBox.Text}";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
postText = " Text Box";
|
||||
}
|
||||
buttons.Add(__instance.favThingBoxCC, $"Favourite Thing{postText}");
|
||||
@@ -630,7 +657,9 @@ namespace stardew_access.Patches {
|
||||
break;
|
||||
}
|
||||
return sb;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -650,7 +679,9 @@ namespace stardew_access.Patches {
|
||||
{
|
||||
value = Math.Min(value + amount, 99d);
|
||||
x = Math.Min(Math.Ceiling((value * step)), (double)sb.bounds.Width);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Math.Max(value - amount, 0d);
|
||||
x = Math.Max(Math.Ceiling((value * step)), 0d);
|
||||
}
|
||||
@@ -796,7 +827,9 @@ namespace stardew_access.Patches {
|
||||
if (currentComponent != null && currentComponent.name == "Pet")
|
||||
{
|
||||
return ((Game1.player.catPerson) ? "Cat" : "Dog") + " Breed: " + Game1.player.whichPetBreed;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user