diff --git a/TrainInfo/ModConfig.cs b/TrainInfo/ModConfig.cs index eefc9c9..e22fb03 100644 --- a/TrainInfo/ModConfig.cs +++ b/TrainInfo/ModConfig.cs @@ -3,5 +3,6 @@ internal class ModConfig { public int NotificationTime { get; set; } = 1800; + public bool ShowContent { get; set; } = true; } } diff --git a/TrainInfo/ModEntry.cs b/TrainInfo/ModEntry.cs index 80f29f1..67d2d6f 100644 --- a/TrainInfo/ModEntry.cs +++ b/TrainInfo/ModEntry.cs @@ -80,6 +80,13 @@ private void OnGameLaunched(object sender, GameLaunchedEventArgs e) 100, value => Game1.getTimeOfDayString(value) ); + configMenuApi.AddBoolOption( + ModManifest, + name: () => this.Helper.Translation.Get("config.option.show_content.name"), + tooltip: () => this.Helper.Translation.Get("config.option.show_content.description"), + getValue: () => Config.ShowContent, + setValue: value => Config.ShowContent = value + ); } } @@ -204,14 +211,17 @@ public void HandleTrainContents(Train train) public void DisplayTrainContents(Dictionary trainItems) { - string message = string.Join(Environment.NewLine, trainItems.Select(item => $"{item.Value} {ItemRegistry.Create(item.Key).DisplayName}")); - message = string.IsNullOrEmpty(message) ? this.Helper.Translation.Get("empty_train") : message; - CustomHUDMessage trainContentsMessage = new(message) + if (Config.ShowContent) { - timeLeft = 7000f, - titleText = this.Helper.Translation.Get("list_title") - }; - Game1.addHUDMessage(trainContentsMessage); + string message = string.Join(Environment.NewLine, trainItems.Select(item => $"{item.Value} {ItemRegistry.Create(item.Key).DisplayName}")); + message = string.IsNullOrEmpty(message) ? this.Helper.Translation.Get("empty_train") : message; + CustomHUDMessage trainContentsMessage = new(message) + { + timeLeft = 7000f, + titleText = this.Helper.Translation.Get("list_title") + }; + Game1.addHUDMessage(trainContentsMessage); + } } } -} \ No newline at end of file +} diff --git a/TrainInfo/i18n/default.json b/TrainInfo/i18n/default.json index f60d14d..e6eadbb 100644 --- a/TrainInfo/i18n/default.json +++ b/TrainInfo/i18n/default.json @@ -1,8 +1,10 @@ { "config.option.notification_time.name": "Train tomorrow notification time", "config.option.notification_time.description": "When to display the notification that a train is coming tomorrow", + "config.option.show_content.name": "Display train content", + "config.option.show_content.description": "Set to false, if you don't want to see a message about the content of the coming train", "list_title": "Train Contents", "train_today": "A train will be passing through Stardew Valley today at {{time}}", "train_tomorrow": "A train will be passing through Stardew Valley tomorrow at {{time}}", "empty_train": "None" -} \ No newline at end of file +} diff --git a/TrainInfo/manifest.json b/TrainInfo/manifest.json index 4e004d7..4c134f1 100644 --- a/TrainInfo/manifest.json +++ b/TrainInfo/manifest.json @@ -10,4 +10,4 @@ "Nexus:21883", "CurseForge:1035850" ] -} \ No newline at end of file +}