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 ## Upcoming release
* For players: * 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. * Fixed logged SMAPI errors not having line numbers on Linux/macOS.
## 3.18.3 ## 3.18.3

View File

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