Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions TrainInfo/ModConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
internal class ModConfig
{
public int NotificationTime { get; set; } = 1800;
public bool ShowContent { get; set; } = true;
}
}
26 changes: 18 additions & 8 deletions TrainInfo/ModEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}

Expand Down Expand Up @@ -204,14 +211,17 @@ public void HandleTrainContents(Train train)

public void DisplayTrainContents(Dictionary<string, int> 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);
}
}
}
}
}
4 changes: 3 additions & 1 deletion TrainInfo/i18n/default.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
2 changes: 1 addition & 1 deletion TrainInfo/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
"Nexus:21883",
"CurseForge:1035850"
]
}
}