diff --git a/Content.Client/Entry/EntryPoint.cs b/Content.Client/Entry/EntryPoint.cs index cd73d3397dfe4b..5c1f94f3332911 100644 --- a/Content.Client/Entry/EntryPoint.cs +++ b/Content.Client/Entry/EntryPoint.cs @@ -4,6 +4,7 @@ using Content.Client.DebugMon; using Content.Client.Eui; using Content.Client.Fullscreen; +using Content.Client.GameTicking.Managers; using Content.Client.GhostKick; using Content.Client.Guidebook; using Content.Client.Input; @@ -70,6 +71,7 @@ public sealed class EntryPoint : GameClient [Dependency] private readonly IReplayLoadManager _replayLoad = default!; [Dependency] private readonly ILogManager _logManager = default!; [Dependency] private readonly DebugMonitorManager _debugMonitorManager = default!; + [Dependency] private readonly TitleWindowManager _titleWindowManager = default!; public override void Init() { @@ -139,6 +141,12 @@ public override void Init() _configManager.SetCVar("interface.resolutionAutoScaleMinimum", 0.5f); } + public override void Shutdown() + { + base.Shutdown(); + _titleWindowManager.Shutdown(); + } + public override void PostInit() { base.PostInit(); @@ -159,6 +167,7 @@ public override void PostInit() _userInterfaceManager.SetDefaultTheme("SS14DefaultTheme"); _userInterfaceManager.SetActiveTheme(_configManager.GetCVar(CVars.InterfaceTheme)); _documentParsingManager.Initialize(); + _titleWindowManager.Initialize(); _baseClient.RunLevelChanged += (_, args) => { diff --git a/Content.Client/GameTicking/Managers/TitleWindowManager.cs b/Content.Client/GameTicking/Managers/TitleWindowManager.cs new file mode 100644 index 00000000000000..6686d9fd3c7c77 --- /dev/null +++ b/Content.Client/GameTicking/Managers/TitleWindowManager.cs @@ -0,0 +1,46 @@ +using Content.Shared.CCVar; +using Robust.Client; +using Robust.Client.Graphics; +using Robust.Shared; +using Robust.Shared.Configuration; + +namespace Content.Client.GameTicking.Managers; + +public sealed class TitleWindowManager +{ + [Dependency] private readonly IClyde _clyde = default!; + [Dependency] private readonly IConfigurationManager _cfg = default!; + [Dependency] private readonly IGameController _gameController = default!; + + public void Initialize() + { + _cfg.OnValueChanged(CVars.GameHostName, OnHostnameChange, true); + _cfg.OnValueChanged(CCVars.HostnameInTitlebar, OnHostnameTitleChange, true); + } + + public void Shutdown() + { + _cfg.UnsubValueChanged(CVars.GameHostName, OnHostnameChange); + } + + // This may use the last joined server temporarily until the CCVars of the joining server are received. + private void OnHostnameChange(string hostname) + { + var defaultWindowTitle = _gameController.GameTitle(); + + if (_cfg.GetCVar(CCVars.HostnameInTitlebar)) + // If you really dislike the dash I guess change it here + _clyde.SetWindowTitle(hostname + " - " + defaultWindowTitle); + else + _clyde.SetWindowTitle(defaultWindowTitle); + } + + // Clients by default assume game.hostname_in_titlebar is true (and also that the server hostname is MyServer) + // but we need to clear it as soon as we join and actually receive the CCVar. + // This will ensure we rerun OnHostnameChange and set the correct title bar name. + // We could also initialize this later but uhh I was told to make this a manager and put it into entrypoint. + private void OnHostnameTitleChange(bool colonthree) + { + OnHostnameChange(_cfg.GetCVar(CVars.GameHostName)); + } +} diff --git a/Content.Client/IoC/ClientContentIoC.cs b/Content.Client/IoC/ClientContentIoC.cs index e643552f70b3b1..370188e3c61de2 100644 --- a/Content.Client/IoC/ClientContentIoC.cs +++ b/Content.Client/IoC/ClientContentIoC.cs @@ -5,6 +5,7 @@ using Content.Client.DebugMon; using Content.Client.Eui; using Content.Client.Fullscreen; +using Content.Client.GameTicking.Managers; using Content.Client.GhostKick; using Content.Client.Guidebook; using Content.Client.Launcher; @@ -57,6 +58,7 @@ public static void Register() collection.Register(); collection.Register(); collection.Register(); + collection.Register(); } } } diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index a4f315d62c567f..4d45ce8d44aa6c 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -436,6 +436,12 @@ public static readonly CVarDef public static readonly CVarDef GameEntityMenuLookup = CVarDef.Create("game.entity_menu_lookup", 0.25f, CVar.CLIENTONLY | CVar.ARCHIVE); + /// + /// Size of the lookup area for adding entities to the context menu + /// + public static readonly CVarDef HostnameInTitlebar = + CVarDef.Create("game.hostname_in_titlebar", true, CVar.SERVER | CVar.REPLICATED); + /* * Discord */