diff --git a/Content.Client/Changelog/ChangelogManager.cs b/Content.Client/Changelog/ChangelogManager.cs
index 4383f46617..657d0cb3ac 100644
--- a/Content.Client/Changelog/ChangelogManager.cs
+++ b/Content.Client/Changelog/ChangelogManager.cs
@@ -1,6 +1,7 @@
using System.Linq;
using System.Threading.Tasks;
using Content.Shared.CCVar;
+using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.ContentPack;
using Robust.Shared.Serialization.Manager;
@@ -125,6 +126,27 @@ namespace Content.Client.Changelog
_sawmill = _logManager.GetSawmill(SawmillName);
}
+ ///
+ /// Tries to return a human-readable version number from the build.json file
+ ///
+ public string GetClientVersion()
+ {
+ var fork = _configManager.GetCVar(CVars.BuildForkId);
+ var version = _configManager.GetCVar(CVars.BuildVersion);
+
+ // This trimming might become annoying if down the line some codebases want to switch to a real
+ // version format like "104.11.3" while others are still using the git hashes
+ if (version.Length > 7)
+ version = version[..7];
+
+ if (string.IsNullOrEmpty(version) || string.IsNullOrEmpty(fork))
+ return Loc.GetString("changelog-version-unknown");
+
+ return Loc.GetString("changelog-version-tag",
+ ("fork", fork),
+ ("version", version));
+ }
+
[DataDefinition]
public sealed partial class Changelog
{
diff --git a/Content.Client/Changelog/ChangelogWindow.xaml.cs b/Content.Client/Changelog/ChangelogWindow.xaml.cs
index cb07e16a9c..0b1afcbb0a 100644
--- a/Content.Client/Changelog/ChangelogWindow.xaml.cs
+++ b/Content.Client/Changelog/ChangelogWindow.xaml.cs
@@ -70,22 +70,7 @@ namespace Content.Client.Changelog
Tabs.SetTabTitle(i++, Loc.GetString($"changelog-tab-title-{changelog.Name}"));
}
- // Try to get the current version from the build.json file
- var version = _cfg.GetCVar(CVars.BuildVersion);
- var forkId = _cfg.GetCVar(CVars.BuildForkId);
-
- var versionText = Loc.GetString("changelog-version-unknown");
-
- // Make sure these aren't empty, like in a dev env
- if (!string.IsNullOrEmpty(version) && !string.IsNullOrEmpty(forkId))
- {
- versionText = Loc.GetString("changelog-version-tag",
- ("fork", forkId),
- ("version", version[..7])); // Only show the first 7 characters
- }
-
- // if else statements are ugly, shut up
- VersionLabel.Text = versionText;
+ VersionLabel.Text = _changelog.GetClientVersion();
TabsUpdated();
}
diff --git a/Content.Client/Gameplay/GameplayState.cs b/Content.Client/Gameplay/GameplayState.cs
index 1efee978f3..427dd5c071 100644
--- a/Content.Client/Gameplay/GameplayState.cs
+++ b/Content.Client/Gameplay/GameplayState.cs
@@ -1,3 +1,5 @@
+using System.Numerics;
+using Content.Client.Changelog;
using Content.Client.Hands;
using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Screens;
@@ -7,6 +9,7 @@ using Content.Shared.CCVar;
using Robust.Client.Graphics;
using Robust.Client.Input;
using Robust.Client.UserInterface;
+using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Configuration;
using Robust.Shared.Timing;
@@ -20,9 +23,11 @@ namespace Content.Client.Gameplay
[Dependency] private readonly IOverlayManager _overlayManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IUserInterfaceManager _uiManager = default!;
+ [Dependency] private readonly ChangelogManager _changelog = default!;
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
private FpsCounter _fpsCounter = default!;
+ private Label _version = default!;
public MainViewport Viewport => _uiManager.ActiveScreen!.GetWidget()!;
@@ -40,6 +45,7 @@ namespace Content.Client.Gameplay
base.Startup();
LoadMainScreen();
+ _configurationManager.OnValueChanged(CCVars.UILayout, ReloadMainScreenValueChange);
// Add the hand-item overlay.
_overlayManager.AddOverlay(new ShowHandItemOverlay());
@@ -50,7 +56,24 @@ namespace Content.Client.Gameplay
UserInterfaceManager.PopupRoot.AddChild(_fpsCounter);
_fpsCounter.Visible = _configurationManager.GetCVar(CCVars.HudFpsCounterVisible);
_configurationManager.OnValueChanged(CCVars.HudFpsCounterVisible, (show) => { _fpsCounter.Visible = show; });
- _configurationManager.OnValueChanged(CCVars.UILayout, ReloadMainScreenValueChange);
+
+ // Version number watermark.
+ _version = new Label();
+ _version.Text = _changelog.GetClientVersion();
+ _version.Visible = VersionVisible();
+ UserInterfaceManager.PopupRoot.AddChild(_version);
+ _configurationManager.OnValueChanged(CCVars.HudVersionWatermark, (show) => { _version.Visible = VersionVisible(); });
+ _configurationManager.OnValueChanged(CCVars.ForceClientHudVersionWatermark, (show) => { _version.Visible = VersionVisible(); });
+ // TODO make this centered or something
+ LayoutContainer.SetPosition(_version, new Vector2(800, 0));
+ }
+
+ // This allows servers to force the watermark on clients
+ private bool VersionVisible()
+ {
+ var client = _configurationManager.GetCVar(CCVars.HudVersionWatermark);
+ var server = _configurationManager.GetCVar(CCVars.ForceClientHudVersionWatermark);
+ return client || server;
}
protected override void Shutdown()
diff --git a/Content.Shared/CCVar/CCVars.Hud.cs b/Content.Shared/CCVar/CCVars.Hud.cs
index f96924b349..c435f07cbe 100644
--- a/Content.Shared/CCVar/CCVars.Hud.cs
+++ b/Content.Shared/CCVar/CCVars.Hud.cs
@@ -19,6 +19,15 @@ public sealed partial class CCVars
public static readonly CVarDef HudHeldItemOffset =
CVarDef.Create("hud.held_item_offset", 28f, CVar.ARCHIVE | CVar.CLIENTONLY);
+ ///
+ /// Displays framerate counter
+ ///
public static readonly CVarDef HudFpsCounterVisible =
CVarDef.Create("hud.fps_counter_visible", false, CVar.CLIENTONLY | CVar.ARCHIVE);
+
+ ///
+ /// Displays the fork ID and version number
+ ///
+ public static readonly CVarDef HudVersionWatermark =
+ CVarDef.Create("hud.version_watermark", false, CVar.CLIENTONLY | CVar.ARCHIVE);
}
diff --git a/Content.Shared/CCVar/CCVars.Server.cs b/Content.Shared/CCVar/CCVars.Server.cs
index 88e7b251ba..aad6d0a808 100644
--- a/Content.Shared/CCVar/CCVars.Server.cs
+++ b/Content.Shared/CCVar/CCVars.Server.cs
@@ -53,4 +53,10 @@ public sealed partial class CCVars
///
public static readonly CVarDef ServerLobbyRightPanelWidth =
CVarDef.Create("server.lobby_right_panel_width", 650, CVar.REPLICATED | CVar.SERVER);
+
+ ///
+ /// Forces clients to display version watermark, as if HudVersionWatermark was true
+ ///
+ public static readonly CVarDef ForceClientHudVersionWatermark =
+ CVarDef.Create("server.force_client_hud_version_watermark", false, CVar.REPLICATED | CVar.SERVER);
}
diff --git a/Resources/ConfigPresets/WizardsDen/vulture.toml b/Resources/ConfigPresets/WizardsDen/vulture.toml
index ab1d8459f3..8eccfa48e1 100644
--- a/Resources/ConfigPresets/WizardsDen/vulture.toml
+++ b/Resources/ConfigPresets/WizardsDen/vulture.toml
@@ -10,6 +10,7 @@ tags = "lang:en,region:am_n_e,rp:low"
[server]
# This needs to be specified even though it's identical to the hostname, because fallback lobby name is "Lobby " which would be too long and go out of bounds
lobby_name = "[EN][Testing] Wizard's Den Vulture [US East 2]"
+force_client_hud_version_watermark = true
[chat]
-motd = "\n########################################################\n\n[font size=17]This is a test server. You can play with the newest changes to the game, but these [color=red]changes may not be final or stable[/color], and may be reverted. Please report bugs via our GitHub, forum, or community Discord.[/font]\n\n########################################################\n"
\ No newline at end of file
+motd = "\n########################################################\n\n[font size=17]This is a test server. You can play with the newest changes to the game, but these [color=red]changes may not be final or stable[/color], and may be reverted. Please report bugs via our GitHub, forum, or community Discord.[/font]\n\n########################################################\n"