From ff27555b475af9214b9a5dbccbfd05f22db23d96 Mon Sep 17 00:00:00 2001 From: Milon Date: Sat, 25 Jan 2025 12:21:52 +0100 Subject: [PATCH] display the current version in the changelog window (#34556) * just works first try * introduce more magic numbers into the codebase * idiot doesnt know the difference between AND/OR --- .../Changelog/ChangelogWindow.xaml.cs | 23 ++++++++++++++++--- .../en-US/changelog/changelog-window.ftl | 3 ++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Content.Client/Changelog/ChangelogWindow.xaml.cs b/Content.Client/Changelog/ChangelogWindow.xaml.cs index 9b7fd75436..cb07e16a9c 100644 --- a/Content.Client/Changelog/ChangelogWindow.xaml.cs +++ b/Content.Client/Changelog/ChangelogWindow.xaml.cs @@ -8,6 +8,8 @@ using JetBrains.Annotations; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface; using Robust.Client.UserInterface.XAML; +using Robust.Shared; +using Robust.Shared.Configuration; using Robust.Shared.Console; namespace Content.Client.Changelog @@ -15,8 +17,9 @@ namespace Content.Client.Changelog [GenerateTypedNameReferences] public sealed partial class ChangelogWindow : FancyWindow { - [Dependency] private readonly IClientAdminManager _adminManager = default!; [Dependency] private readonly ChangelogManager _changelog = default!; + [Dependency] private readonly IClientAdminManager _adminManager = default!; + [Dependency] private readonly IConfigurationManager _cfg = default!; public ChangelogWindow() { @@ -67,8 +70,22 @@ namespace Content.Client.Changelog Tabs.SetTabTitle(i++, Loc.GetString($"changelog-tab-title-{changelog.Name}")); } - var version = typeof(ChangelogWindow).Assembly.GetName().Version ?? new Version(1, 0); - VersionLabel.Text = Loc.GetString("changelog-version-tag", ("version", version.ToString())); + // 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; TabsUpdated(); } diff --git a/Resources/Locale/en-US/changelog/changelog-window.ftl b/Resources/Locale/en-US/changelog/changelog-window.ftl index b7f5d6a2fa..9d17dea629 100644 --- a/Resources/Locale/en-US/changelog/changelog-window.ftl +++ b/Resources/Locale/en-US/changelog/changelog-window.ftl @@ -5,7 +5,8 @@ changelog-author-changed = [color=#EEE]{ $author }[/color] changed: changelog-today = Today changelog-yesterday = Yesterday changelog-new-changes = new changes -changelog-version-tag = version v{ $version } +changelog-version-unknown = Unknown Version +changelog-version-tag = { $fork }/{ $version } changelog-button = Changelog changelog-button-new-entries = Changelog (new!)