Moved social page patch
parent
2a5baa6770
commit
9d7c2c36ec
|
@ -105,7 +105,7 @@ namespace stardew_access
|
||||||
|
|
||||||
harmony.Patch(
|
harmony.Patch(
|
||||||
original: AccessTools.Method(typeof(SocialPage), nameof(SocialPage.draw), new Type[] { typeof(SpriteBatch) }),
|
original: AccessTools.Method(typeof(SocialPage), nameof(SocialPage.draw), new Type[] { typeof(SpriteBatch) }),
|
||||||
postfix: new HarmonyMethod(typeof(GameMenuPatches), nameof(GameMenuPatches.SocialPagePatch))
|
postfix: new HarmonyMethod(typeof(SocialPagePatch), nameof(SocialPagePatch.DrawPatch))
|
||||||
);
|
);
|
||||||
|
|
||||||
harmony.Patch(
|
harmony.Patch(
|
||||||
|
|
|
@ -13,160 +13,10 @@ namespace stardew_access.Patches
|
||||||
internal static string inventoryPageQueryKey = "";
|
internal static string inventoryPageQueryKey = "";
|
||||||
internal static string exitPageQueryKey = "";
|
internal static string exitPageQueryKey = "";
|
||||||
internal static string optionsPageQueryKey = "";
|
internal static string optionsPageQueryKey = "";
|
||||||
internal static string socialPageQuery = "";
|
|
||||||
internal static string profilePageQuery = "";
|
internal static string profilePageQuery = "";
|
||||||
internal static int currentSelectedCraftingRecipe = -1;
|
internal static int currentSelectedCraftingRecipe = -1;
|
||||||
internal static bool isSelectingRecipe = false;
|
internal static bool isSelectingRecipe = false;
|
||||||
|
|
||||||
|
|
||||||
internal static void SocialPagePatch(SocialPage __instance, List<ClickableTextureComponent> ___sprites, int ___slotPosition, List<string> ___kidsNames)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
|
|
||||||
for (int i = ___slotPosition; i < ___slotPosition + 5; i++)
|
|
||||||
{
|
|
||||||
if (i < ___sprites.Count)
|
|
||||||
{
|
|
||||||
if (__instance.names[i] is string)
|
|
||||||
{
|
|
||||||
#region For NPCs
|
|
||||||
if (__instance.characterSlots[i].bounds.Contains(Game1.getMouseX(true), Game1.getMouseY(true)))
|
|
||||||
{
|
|
||||||
string name = $"{__instance.names[i] as string}";
|
|
||||||
int heartLevel = Game1.player.getFriendshipHeartLevelForNPC(name);
|
|
||||||
bool datable = SocialPage.isDatable(name);
|
|
||||||
Friendship friendship = __instance.getFriendship(name);
|
|
||||||
int giftsThisWeek = friendship.GiftsThisWeek;
|
|
||||||
bool hasTalked = Game1.player.hasPlayerTalkedToNPC(name);
|
|
||||||
bool spouse = friendship.IsMarried();
|
|
||||||
bool housemate = spouse && SocialPage.isRoommateOfAnyone(name);
|
|
||||||
___kidsNames.Add("Robin");
|
|
||||||
___kidsNames.Add("Pierre");
|
|
||||||
___kidsNames.Add("Caroline");
|
|
||||||
___kidsNames.Add("Jodi");
|
|
||||||
___kidsNames.Add("Kent");
|
|
||||||
___kidsNames.Add("George");
|
|
||||||
___kidsNames.Add("Evelyn");
|
|
||||||
___kidsNames.Add("Demetrius");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
string toSpeak = $"{name}";
|
|
||||||
|
|
||||||
if (!hasTalked)
|
|
||||||
{
|
|
||||||
toSpeak = $"{toSpeak}, not talked yet";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (datable | housemate)
|
|
||||||
{
|
|
||||||
string text2 = (LocalizedContentManager.CurrentLanguageCode != LocalizedContentManager.LanguageCode.pt) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635") : ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').First() : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').Last());
|
|
||||||
if (housemate)
|
|
||||||
{
|
|
||||||
text2 = Game1.content.LoadString("Strings\\StringsFromCSFiles:Housemate");
|
|
||||||
}
|
|
||||||
else if (spouse)
|
|
||||||
{
|
|
||||||
text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11636") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11637"));
|
|
||||||
}
|
|
||||||
else if (__instance.isMarriedToAnyone(name))
|
|
||||||
{
|
|
||||||
text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_MaleNPC") : Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_FemaleNPC"));
|
|
||||||
}
|
|
||||||
else if (!Game1.player.isMarried() && friendship.IsDating())
|
|
||||||
{
|
|
||||||
text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11639") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11640"));
|
|
||||||
}
|
|
||||||
else if (__instance.getFriendship(name).IsDivorced())
|
|
||||||
{
|
|
||||||
text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11642") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11643"));
|
|
||||||
}
|
|
||||||
|
|
||||||
toSpeak = $"{toSpeak}, {text2}";
|
|
||||||
}
|
|
||||||
if (!__instance.getFriendship(name).IsMarried() && ___kidsNames.Contains(name))
|
|
||||||
{
|
|
||||||
toSpeak = $"{toSpeak}, married";
|
|
||||||
}
|
|
||||||
if (spouse)
|
|
||||||
{
|
|
||||||
toSpeak = $"{toSpeak}, spouse";
|
|
||||||
}
|
|
||||||
else if (friendship.IsDating())
|
|
||||||
{
|
|
||||||
toSpeak = $"{toSpeak}, dating";
|
|
||||||
}
|
|
||||||
|
|
||||||
toSpeak = $"{toSpeak}, {heartLevel} hearts, {giftsThisWeek} gifts given this week.";
|
|
||||||
|
|
||||||
|
|
||||||
if (socialPageQuery != toSpeak)
|
|
||||||
{
|
|
||||||
socialPageQuery = toSpeak;
|
|
||||||
MainClass.ScreenReader.Say(toSpeak, true);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
else if (__instance.names[i] is long)
|
|
||||||
{
|
|
||||||
#region For Farmers
|
|
||||||
|
|
||||||
long farmerID = (long)__instance.names[i];
|
|
||||||
Farmer farmer = Game1.getFarmerMaybeOffline(farmerID);
|
|
||||||
if (farmer != null)
|
|
||||||
{
|
|
||||||
int gender = (!farmer.IsMale) ? 1 : 0;
|
|
||||||
ClickableTextureComponent clickableTextureComponent = ___sprites[i];
|
|
||||||
if (clickableTextureComponent.containsPoint(x, y))
|
|
||||||
{
|
|
||||||
Friendship friendship = Game1.player.team.GetFriendship(Game1.player.UniqueMultiplayerID, farmerID);
|
|
||||||
bool spouse = friendship.IsMarried();
|
|
||||||
string toSpeak = "";
|
|
||||||
|
|
||||||
string text2 = (LocalizedContentManager.CurrentLanguageCode != LocalizedContentManager.LanguageCode.pt) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635") : ((gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').First() : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').Last());
|
|
||||||
if (spouse)
|
|
||||||
{
|
|
||||||
text2 = ((gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11636") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11637"));
|
|
||||||
}
|
|
||||||
else if (farmer.isMarried() && !farmer.hasRoommate())
|
|
||||||
{
|
|
||||||
text2 = ((gender == 0) ? Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_MaleNPC") : Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_FemaleNPC"));
|
|
||||||
}
|
|
||||||
else if (!Game1.player.isMarried() && friendship.IsDating())
|
|
||||||
{
|
|
||||||
text2 = ((gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11639") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11640"));
|
|
||||||
}
|
|
||||||
else if (friendship.IsDivorced())
|
|
||||||
{
|
|
||||||
text2 = ((gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11642") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11643"));
|
|
||||||
}
|
|
||||||
|
|
||||||
toSpeak = $"{farmer.displayName}, {text2}";
|
|
||||||
|
|
||||||
if (socialPageQuery != toSpeak)
|
|
||||||
{
|
|
||||||
socialPageQuery = toSpeak;
|
|
||||||
MainClass.ScreenReader.Say(toSpeak, true);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void GameMenuPatch(GameMenu __instance)
|
internal static void GameMenuPatch(GameMenu __instance)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -0,0 +1,163 @@
|
||||||
|
using StardewValley;
|
||||||
|
using StardewValley.Menus;
|
||||||
|
|
||||||
|
namespace stardew_access.Patches
|
||||||
|
{
|
||||||
|
internal class SocialPagePatch
|
||||||
|
{
|
||||||
|
internal static string socialPageQuery = "";
|
||||||
|
|
||||||
|
internal static void DrawPatch(SocialPage __instance, List<ClickableTextureComponent> ___sprites, int ___slotPosition, List<string> ___kidsNames)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int x = Game1.getMouseX(true), y = Game1.getMouseY(true); // Mouse x and y position
|
||||||
|
for (int i = ___slotPosition; i < ___slotPosition + 5; i++)
|
||||||
|
{
|
||||||
|
if (i < ___sprites.Count)
|
||||||
|
{
|
||||||
|
if (__instance.names[i] is string)
|
||||||
|
{
|
||||||
|
#region For NPCs
|
||||||
|
if (__instance.characterSlots[i].bounds.Contains(Game1.getMouseX(true), Game1.getMouseY(true)))
|
||||||
|
{
|
||||||
|
string name = $"{__instance.names[i] as string}";
|
||||||
|
int heartLevel = Game1.player.getFriendshipHeartLevelForNPC(name);
|
||||||
|
bool datable = SocialPage.isDatable(name);
|
||||||
|
Friendship friendship = __instance.getFriendship(name);
|
||||||
|
int giftsThisWeek = friendship.GiftsThisWeek;
|
||||||
|
bool hasTalked = Game1.player.hasPlayerTalkedToNPC(name);
|
||||||
|
bool spouse = friendship.IsMarried();
|
||||||
|
bool housemate = spouse && SocialPage.isRoommateOfAnyone(name);
|
||||||
|
___kidsNames.Add("Robin");
|
||||||
|
___kidsNames.Add("Pierre");
|
||||||
|
___kidsNames.Add("Caroline");
|
||||||
|
___kidsNames.Add("Jodi");
|
||||||
|
___kidsNames.Add("Kent");
|
||||||
|
___kidsNames.Add("George");
|
||||||
|
___kidsNames.Add("Evelyn");
|
||||||
|
___kidsNames.Add("Demetrius");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
string toSpeak = $"{name}";
|
||||||
|
|
||||||
|
if (!hasTalked)
|
||||||
|
{
|
||||||
|
toSpeak = $"{toSpeak}, not talked yet";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (datable | housemate)
|
||||||
|
{
|
||||||
|
string text2 = (LocalizedContentManager.CurrentLanguageCode != LocalizedContentManager.LanguageCode.pt) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635") : ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').First() : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').Last());
|
||||||
|
if (housemate)
|
||||||
|
{
|
||||||
|
text2 = Game1.content.LoadString("Strings\\StringsFromCSFiles:Housemate");
|
||||||
|
}
|
||||||
|
else if (spouse)
|
||||||
|
{
|
||||||
|
text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11636") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11637"));
|
||||||
|
}
|
||||||
|
else if (__instance.isMarriedToAnyone(name))
|
||||||
|
{
|
||||||
|
text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_MaleNPC") : Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_FemaleNPC"));
|
||||||
|
}
|
||||||
|
else if (!Game1.player.isMarried() && friendship.IsDating())
|
||||||
|
{
|
||||||
|
text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11639") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11640"));
|
||||||
|
}
|
||||||
|
else if (__instance.getFriendship(name).IsDivorced())
|
||||||
|
{
|
||||||
|
text2 = ((__instance.getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11642") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11643"));
|
||||||
|
}
|
||||||
|
|
||||||
|
toSpeak = $"{toSpeak}, {text2}";
|
||||||
|
}
|
||||||
|
if (!__instance.getFriendship(name).IsMarried() && ___kidsNames.Contains(name))
|
||||||
|
{
|
||||||
|
toSpeak = $"{toSpeak}, married";
|
||||||
|
}
|
||||||
|
if (spouse)
|
||||||
|
{
|
||||||
|
toSpeak = $"{toSpeak}, spouse";
|
||||||
|
}
|
||||||
|
else if (friendship.IsDating())
|
||||||
|
{
|
||||||
|
toSpeak = $"{toSpeak}, dating";
|
||||||
|
}
|
||||||
|
|
||||||
|
toSpeak = $"{toSpeak}, {heartLevel} hearts, {giftsThisWeek} gifts given this week.";
|
||||||
|
|
||||||
|
|
||||||
|
if (socialPageQuery != toSpeak)
|
||||||
|
{
|
||||||
|
socialPageQuery = toSpeak;
|
||||||
|
MainClass.ScreenReader.Say(toSpeak, true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
else if (__instance.names[i] is long)
|
||||||
|
{
|
||||||
|
#region For Farmers
|
||||||
|
|
||||||
|
long farmerID = (long)__instance.names[i];
|
||||||
|
Farmer farmer = Game1.getFarmerMaybeOffline(farmerID);
|
||||||
|
if (farmer != null)
|
||||||
|
{
|
||||||
|
int gender = (!farmer.IsMale) ? 1 : 0;
|
||||||
|
ClickableTextureComponent clickableTextureComponent = ___sprites[i];
|
||||||
|
if (clickableTextureComponent.containsPoint(x, y))
|
||||||
|
{
|
||||||
|
Friendship friendship = Game1.player.team.GetFriendship(Game1.player.UniqueMultiplayerID, farmerID);
|
||||||
|
bool spouse = friendship.IsMarried();
|
||||||
|
string toSpeak = "";
|
||||||
|
|
||||||
|
string text2 = (LocalizedContentManager.CurrentLanguageCode != LocalizedContentManager.LanguageCode.pt) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635") : ((gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').First() : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').Last());
|
||||||
|
if (spouse)
|
||||||
|
{
|
||||||
|
text2 = ((gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11636") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11637"));
|
||||||
|
}
|
||||||
|
else if (farmer.isMarried() && !farmer.hasRoommate())
|
||||||
|
{
|
||||||
|
text2 = ((gender == 0) ? Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_MaleNPC") : Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_FemaleNPC"));
|
||||||
|
}
|
||||||
|
else if (!Game1.player.isMarried() && friendship.IsDating())
|
||||||
|
{
|
||||||
|
text2 = ((gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11639") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11640"));
|
||||||
|
}
|
||||||
|
else if (friendship.IsDivorced())
|
||||||
|
{
|
||||||
|
text2 = ((gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11642") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11643"));
|
||||||
|
}
|
||||||
|
|
||||||
|
toSpeak = $"{farmer.displayName}, {text2}";
|
||||||
|
|
||||||
|
if (socialPageQuery != toSpeak)
|
||||||
|
{
|
||||||
|
socialPageQuery = toSpeak;
|
||||||
|
MainClass.ScreenReader.Say(toSpeak, true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void Cleanup()
|
||||||
|
{
|
||||||
|
socialPageQuery = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -38,7 +38,7 @@ namespace stardew_access.Patches
|
||||||
GameMenuPatches.inventoryPageQueryKey = "";
|
GameMenuPatches.inventoryPageQueryKey = "";
|
||||||
GameMenuPatches.exitPageQueryKey = "";
|
GameMenuPatches.exitPageQueryKey = "";
|
||||||
GameMenuPatches.optionsPageQueryKey = "";
|
GameMenuPatches.optionsPageQueryKey = "";
|
||||||
GameMenuPatches.socialPageQuery = "";
|
SocialPagePatch.Cleanup();
|
||||||
GameMenuPatches.currentSelectedCraftingRecipe = -1;
|
GameMenuPatches.currentSelectedCraftingRecipe = -1;
|
||||||
GameMenuPatches.isSelectingRecipe = false;
|
GameMenuPatches.isSelectingRecipe = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue