1212using Object = StardewValley . Object ;
1313using AnimalSitter . Integrations . GenericModConfigMenu ;
1414using Microsoft . Xna . Framework . Input ;
15+ using System . Reflection ;
1516
1617namespace AnimalSitter
1718{
@@ -65,10 +66,12 @@ public class AnimalSitter : Mod
6566
6667 private ModConfig Config ;
6768
68- private DialogueManager DialogueManager ;
69+ // private DialogueManager DialogueManager;
6970
7071 private ChestManager ChestManager ;
7172
73+ private readonly Random RandomDialogue = new Random ( ) ;
74+
7275
7376 /*********
7477 ** Public methods
@@ -78,7 +81,7 @@ public class AnimalSitter : Mod
7881 public override void Entry ( IModHelper helper )
7982 {
8083 this . Config = this . Helper . ReadConfig < ModConfig > ( ) ;
81- this . DialogueManager = new DialogueManager ( this . Config , helper . ModContent , this . Monitor ) ;
84+ // this.DialogueManager = new DialogueManager(this.Config, helper.ModContent, this.Monitor);
8285 this . ChestManager = new ChestManager ( this . Monitor ) ;
8386 I18n . Init ( helper . Translation ) ;
8487
@@ -202,7 +205,7 @@ private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
202205 this . ChestManager . SetDefault ( this . ChestCoords ) ;
203206
204207 // Read in dialogue
205- this . DialogueManager . ReadInMessages ( ) ;
208+ // this.DialogueManager.ReadInMessages();
206209
207210 this . Monitor . Log ( I18n . Log_ChestCoords ( x : this . ChestCoords . X , y : this . ChestCoords . Y ) , LogLevel . Trace ) ;
208211 }
@@ -551,28 +554,34 @@ private void ShowMessage(int numActions, int totalCost, bool doesPlayerHaveEnoug
551554 {
552555 if ( Game1 . player . isMarriedOrRoommates ( ) )
553556 {
554- message += this . DialogueManager . PerformReplacement ( this . DialogueManager . GetMessageAt ( 1 , "Xdialog" ) , stats , this . Config ) ;
557+ string spouse = Game1 . player . isMarriedOrRoommates ( ) ? Game1 . player . getSpouse ( ) . getName ( ) : this . Checker ;
558+ // message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(1, "Xdialog"), stats, this.Config);
559+ message += I18n . Dialog_Xdialog1 ( spouse : spouse ) ;
555560 }
556561 else
557562 {
558- message += this . DialogueManager . PerformReplacement ( this . DialogueManager . GetMessageAt ( 2 , "Xdialog" ) , stats , this . Config ) ;
563+ // message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(2, "Xdialog"), stats, this.Config);
564+ message += I18n . Dialog_Xdialog2 ( num_actions : stats . NumActions ) ;
559565 }
560566
561567 if ( totalCost > 0 && this . CostPerAnimal > 0 )
562568 {
563- message += this . DialogueManager . PerformReplacement ( this . DialogueManager . GetMessageAt ( 3 , "Xdialog" ) , stats , this . Config ) ;
569+ // message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(3, "Xdialog"), stats, this.Config);
570+ message += I18n . Dialog_Xdialog3 ( total_cost : stats . TotalCost ) ;
564571 }
565572
566573 HUDMessage msg = new HUDMessage ( message ) ;
567574 Game1 . addHUDMessage ( msg ) ;
568575 }
569576 else if ( gatheringOnly )
570577 {
571- message += this . DialogueManager . PerformReplacement ( this . DialogueManager . GetMessageAt ( 4 , "Xdialog" ) , stats , this . Config ) ;
578+ // message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(4, "Xdialog"), stats, this.Config);
579+ message += I18n . Dialog_Xdialog4 ( checker : this . Checker ) ;
572580
573581 if ( totalCost > 0 && this . CostPerAnimal > 0 )
574582 {
575- message += this . DialogueManager . PerformReplacement ( this . DialogueManager . GetMessageAt ( 3 , "Xdialog" ) , stats , this . Config ) ;
583+ // message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(3, "Xdialog"), stats, this.Config);
584+ message += I18n . Dialog_Xdialog3 ( total_cost : stats . TotalCost ) ;
576585 }
577586
578587 HUDMessage msg = new HUDMessage ( message ) ;
@@ -590,18 +599,22 @@ private void ShowMessage(int numActions, int totalCost, bool doesPlayerHaveEnoug
590599 portrait = "$8" ;
591600 }
592601
593- message += this . DialogueManager . PerformReplacement ( this . DialogueManager . GetRandomMessage ( "greeting" ) , stats , this . Config ) ;
594- message += this . DialogueManager . PerformReplacement ( this . DialogueManager . GetMessageAt ( 5 , "Xdialog" ) , stats , this . Config ) ;
602+ // message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetRandomMessage("greeting"), stats, this.Config);
603+ // message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(5, "Xdialog"), stats, this.Config);
604+ message += I18n . Dialog_Greeting1 ( name : Game1 . player . Name ) ;
605+ message += I18n . Dialog_Xdialog5 ( ) ;
595606
596607 if ( this . CostPerAnimal > 0 )
597608 {
598609 if ( doesPlayerHaveEnoughCash )
599610 {
600- message += this . DialogueManager . PerformReplacement ( this . DialogueManager . GetMessageAt ( 6 , "Xdialog" ) , stats , this . Config ) ;
611+ // message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(6, "Xdialog"), stats, this.Config);
612+ message += I18n . Dialog_Xdialog6 ( total_cost : stats . TotalCost ) ;
601613 }
602614 else
603615 {
604- message += this . DialogueManager . PerformReplacement ( this . DialogueManager . GetRandomMessage ( "unfinishedmoney" ) , stats , this . Config ) ;
616+ // message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetRandomMessage("unfinishedmoney"), stats, this.Config);
617+ message += this . GetRandomMessage ( messageStoreName : "unfinishedmoney" , low : 1 , high : 8 ) ;
605618 }
606619 }
607620 else
@@ -610,7 +623,8 @@ private void ShowMessage(int numActions, int totalCost, bool doesPlayerHaveEnoug
610623 //message += portrait + "#$e#";
611624 }
612625
613- message += this . DialogueManager . PerformReplacement ( this . DialogueManager . GetRandomMessage ( "smalltalk" ) , stats , this . Config ) ;
626+ // message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetRandomMessage("smalltalk"), stats, this.Config);
627+ message += this . GetRandomMessage ( messageStoreName : "smalltalk" , low : 1 , high : 14 ) ;
614628 message += portrait + "#$e#" ;
615629
616630 character . CurrentDialogue . Push ( new Dialogue ( character , message ) ) ;
@@ -619,7 +633,8 @@ private void ShowMessage(int numActions, int totalCost, bool doesPlayerHaveEnoug
619633 else
620634 {
621635 //message += checker + " has performed " + numActions + " for your animals.";
622- message += this . DialogueManager . PerformReplacement ( this . DialogueManager . GetMessageAt ( 7 , "Xdialog" ) , stats , this . Config ) ;
636+ // message += this.DialogueManager.PerformReplacement(this.DialogueManager.GetMessageAt(7, "Xdialog"), stats, this.Config);
637+ message += I18n . Dialog_Xdialog7 ( checker : this . Checker , num_actions : stats . NumActions ) ;
623638 HUDMessage msg = new HUDMessage ( message ) ;
624639 Game1 . addHUDMessage ( msg ) ;
625640 }
@@ -639,5 +654,77 @@ private List<FarmAnimal> GetAnimals()
639654 return animals ;
640655 }
641656
657+ private string GetRandomMessage ( string messageStoreName , int low = 1 , int high = 4 )
658+ {
659+ var rand = RandomDialogue . Next ( low , high + 1 ) ;
660+
661+ if ( messageStoreName == "greeting" )
662+ {
663+ return rand switch
664+ {
665+ 1 => I18n . Dialog_Greeting1 ( name : Game1 . player . Name ) ,
666+ 2 => I18n . Dialog_Greeting2 ( name : Game1 . player . Name ) ,
667+ 3 => I18n . Dialog_Greeting3 ( name : Game1 . player . Name ) ,
668+ 4 => I18n . Dialog_Greeting4 ( name : Game1 . player . Name ) ,
669+ 5 => I18n . Dialog_Greeting5 ( name : Game1 . player . Name ) ,
670+ 6 => I18n . Dialog_Greeting6 ( name : Game1 . player . Name ) ,
671+ 7 => I18n . Dialog_Greeting7 ( name : Game1 . player . Name ) ,
672+ _ => I18n . Dialog_Greeting1 ( name : Game1 . player . Name ) ,
673+ } ;
674+ }
675+ else if ( messageStoreName == "unfinishedmoney" )
676+ {
677+ return rand switch
678+ {
679+ 1 => I18n . Dialog_Unfinishedmoney1 ( ) ,
680+ 2 => I18n . Dialog_Unfinishedmoney2 ( ) ,
681+ 3 => I18n . Dialog_Unfinishedmoney3 ( ) ,
682+ 4 => I18n . Dialog_Unfinishedmoney4 ( ) ,
683+ 5 => I18n . Dialog_Unfinishedmoney5 ( ) ,
684+ 6 => I18n . Dialog_Unfinishedmoney6 ( ) ,
685+ 7 => I18n . Dialog_Unfinishedmoney7 ( ) ,
686+ 8 => I18n . Dialog_Unfinishedmoney8 ( ) ,
687+ _ => I18n . Dialog_Unfinishedmoney1 ( ) ,
688+ } ;
689+ }
690+ else if ( messageStoreName == "unfinishedinventory" )
691+ {
692+ return rand switch
693+ {
694+ 1 => I18n . Dialog_Unfinishedinventory1 ( ) ,
695+ 2 => I18n . Dialog_Unfinishedinventory2 ( ) ,
696+ 3 => I18n . Dialog_Unfinishedinventory3 ( ) ,
697+ 4 => I18n . Dialog_Unfinishedinventory4 ( ) ,
698+ _ => I18n . Dialog_Unfinishedinventory1 ( ) ,
699+ } ;
700+ }
701+ else if ( messageStoreName == "smalltalk" )
702+ {
703+ return rand switch
704+ {
705+ 1 => I18n . Dialog_Smalltalk1 ( ) ,
706+ 2 => I18n . Dialog_Smalltalk2 ( ) ,
707+ 3 => I18n . Dialog_Smalltalk3 ( ) ,
708+ 4 => I18n . Dialog_Smalltalk4 ( ) ,
709+ 5 => I18n . Dialog_Smalltalk5 ( ) ,
710+ 6 => I18n . Dialog_Smalltalk6 ( ) ,
711+ 7 => I18n . Dialog_Smalltalk7 ( ) ,
712+ 8 => I18n . Dialog_Smalltalk8 ( ) ,
713+ 9 => I18n . Dialog_Smalltalk9 ( ) ,
714+ 10 => I18n . Dialog_Smalltalk10 ( ) ,
715+ 11 => I18n . Dialog_Smalltalk11 ( ) ,
716+ 12 => I18n . Dialog_Smalltalk12 ( ) ,
717+ 13 => I18n . Dialog_Smalltalk13 ( ) ,
718+ 14 => I18n . Dialog_Smalltalk14 ( ) ,
719+ _ => I18n . Dialog_Smalltalk1 ( ) ,
720+ } ;
721+ }
722+ else
723+ {
724+ return "...$h#$e#" ;
725+ }
726+
727+ }
728+
642729 }
643730}
0 commit comments