add multiplayer player type to window titles

This commit is contained in:
Jesse Plamondon-Willard 2023-04-22 11:55:39 -04:00
parent 445370b75b
commit 342b91ff80
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
2 changed files with 11 additions and 7 deletions

View File

@ -9,6 +9,7 @@
## Upcoming release
* For players:
* In multiplayer, the game/SMAPI window titles now show whether you're the main player or a farmhand.
* Fixed logged SMAPI errors not having line numbers on Linux/macOS.
## 3.18.3

View File

@ -852,6 +852,9 @@ namespace StardewModdingAPI.Framework
this.Monitor.Log(context);
// add context to window titles
this.UpdateWindowTitles();
// raise events
this.OnLoadStageChanged(LoadStage.Ready);
events.SaveLoaded.RaiseEmpty();
@ -1203,6 +1206,7 @@ namespace StardewModdingAPI.Framework
case LoadStage.None:
this.JustReturnedToTitle = true;
this.UpdateWindowTitles();
break;
case LoadStage.Loaded:
@ -1450,15 +1454,14 @@ namespace StardewModdingAPI.Framework
string consoleTitle = $"SMAPI {Constants.ApiVersion} - running Stardew Valley {Constants.GameVersion}";
string gameTitle = $"Stardew Valley {Constants.GameVersion} - running SMAPI {Constants.ApiVersion}";
string suffix = "";
if (this.ModRegistry.AreAllModsLoaded)
{
int modsLoaded = this.ModRegistry.GetAll().Count();
consoleTitle += $" with {modsLoaded} mods";
gameTitle += $" with {modsLoaded} mods";
}
suffix += $" with {this.ModRegistry.GetAll().Count()} mods";
if (Context.IsMultiplayer)
suffix += $" [{(Context.IsMainPlayer ? "main player" : "farmhand")}]";
this.Game.Window.Title = gameTitle;
this.LogManager.SetConsoleTitle(consoleTitle);
this.Game.Window.Title = gameTitle + suffix;
this.LogManager.SetConsoleTitle(consoleTitle + suffix);
}
/// <summary>Log a warning if software known to cause issues is installed.</summary>