Skip to content

Commit

Permalink
Display the Current Version in the Changelog Window (#34556) (#1678)
Browse files Browse the repository at this point in the history
ver 0.1 no longer

Co-authored-by: Milon <milonpl.git@proton.me>
  • Loading branch information
sleepyyapril and MilonPL authored Jan 28, 2025
1 parent 2b6f898 commit 7d345cf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
23 changes: 20 additions & 3 deletions Content.Client/Changelog/ChangelogWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@
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
{
[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()
{
Expand Down Expand Up @@ -67,8 +70,22 @@ private async void PopulateChangelog()
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();
}
Expand Down
3 changes: 2 additions & 1 deletion Resources/Locale/en-US/changelog/changelog-window.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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!)
Expand Down

0 comments on commit 7d345cf

Please sign in to comment.