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;
_sawmill = _logManager.GetSawmill(SawmillName);
}
+ /// <summary>
+ /// Tries to return a human-readable version number from the build.json file
+ /// </summary>
+ 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
{
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();
}
+using System.Numerics;
+using Content.Client.Changelog;
using Content.Client.Hands;
using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Screens;
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;
[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<MainViewport>()!;
base.Startup();
LoadMainScreen();
+ _configurationManager.OnValueChanged(CCVars.UILayout, ReloadMainScreenValueChange);
// Add the hand-item overlay.
_overlayManager.AddOverlay(new ShowHandItemOverlay());
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()
public static readonly CVarDef<float> HudHeldItemOffset =
CVarDef.Create("hud.held_item_offset", 28f, CVar.ARCHIVE | CVar.CLIENTONLY);
+ /// <summary>
+ /// Displays framerate counter
+ /// </summary>
public static readonly CVarDef<bool> HudFpsCounterVisible =
CVarDef.Create("hud.fps_counter_visible", false, CVar.CLIENTONLY | CVar.ARCHIVE);
+
+ /// <summary>
+ /// Displays the fork ID and version number
+ /// </summary>
+ public static readonly CVarDef<bool> HudVersionWatermark =
+ CVarDef.Create("hud.version_watermark", false, CVar.CLIENTONLY | CVar.ARCHIVE);
}
/// </summary>
public static readonly CVarDef<int> ServerLobbyRightPanelWidth =
CVarDef.Create("server.lobby_right_panel_width", 650, CVar.REPLICATED | CVar.SERVER);
+
+ /// <summary>
+ /// Forces clients to display version watermark, as if HudVersionWatermark was true
+ /// </summary>
+ public static readonly CVarDef<bool> ForceClientHudVersionWatermark =
+ CVarDef.Create("server.force_client_hud_version_watermark", false, CVar.REPLICATED | CVar.SERVER);
}
[server]
# This needs to be specified even though it's identical to the hostname, because fallback lobby name is "Lobby <hostname>" 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"