Example #1
0
 public static bool ManorHouse_performAction_Prefix(ManorHouse __instance, string action, Farmer who, ref bool __result)
 {
     try
     {
         if (action != null && who.IsLocalPlayer && Game1.player.isMarried())
         {
             string a = action.Split(new char[]
             {
                 ' '
             })[0];
             if (a == "DivorceBook")
             {
                 string s2 = Game1.content.LoadStringReturnNullIfNotFound("Strings\\Locations:ManorHouse_DivorceBook_Question_" + Game1.player.spouse);
                 if (s2 == null)
                 {
                     s2 = Game1.content.LoadStringReturnNullIfNotFound("Strings\\Locations:ManorHouse_DivorceBook_Question");
                 }
                 List <Response> responses = new List <Response>();
                 responses.Add(new Response("divorce_Yes", Game1.content.LoadString("Strings\\Lexicon:QuestionDialogue_Yes")));
                 responses.Add(new Response("divorce_Complex", ModEntry.PHelper.Translation.Get("divorce_complex")));
                 responses.Add(new Response("divorce_No", Game1.content.LoadString("Strings\\Lexicon:QuestionDialogue_No")));
                 __instance.createQuestionDialogue(s2, responses.ToArray(), ModEntry.AnswerDialogue);
                 __result = true;
                 return(false);
             }
         }
     }
     catch (Exception ex)
     {
         Monitor.Log($"Failed in {nameof(ManorHouse_performAction_Prefix)}:\n{ex}", LogLevel.Error);
     }
     return(true);
 }
 public static bool ManorHouse_performAction_Prefix(ManorHouse __instance, string action, Farmer who, ref bool __result)
 {
     try
     {
         ModEntry.ResetSpouses(who);
         Dictionary <string, NPC> spouses = ModEntry.GetSpouses(who, true);
         if (action != null && who.IsLocalPlayer && !Game1.player.divorceTonight.Value && (Game1.player.isMarried() || spouses.Count > 0))
         {
             string a = action.Split(new char[]
             {
                 ' '
             })[0];
             if (a == "DivorceBook")
             {
                 string          str       = Helper.Translation.Get("divorce_who");
                 List <Response> responses = new List <Response>();
                 foreach (NPC spouse in spouses.Values)
                 {
                     responses.Add(new Response(spouse.Name, spouse.displayName));
                 }
                 responses.Add(new Response("No", Game1.content.LoadString("Strings\\Lexicon:QuestionDialogue_No")));
                 __instance.createQuestionDialogue(str, responses.ToArray(), Divorce.afterDialogueBehavior);
                 //__instance.createQuestionDialogue(s2, responses.ToArray(), "divorce");
                 __result = true;
                 return(false);
             }
         }
     }
     catch (Exception ex)
     {
         Monitor.Log($"Failed in {nameof(ManorHouse_performAction_Prefix)}:\n{ex}", LogLevel.Error);
     }
     return(true);
 }