From 0aa1a8eb87fa641687304c20424d208c49b51c8a Mon Sep 17 00:00:00 2001 From: lilazero Date: Mon, 20 Jan 2025 19:33:10 +0100 Subject: [PATCH] Created Debug Version Panel and Version Info Printer similar to DebugSystemPanel --- .../DebugMonitorControls/DebugMonitors.cs | 1 + .../DebugMonitorControls/DebugVersionPanel.cs | 38 +++++++++++++++++++ Robust.Client/UserInterface/IDebugMonitors.cs | 4 +- .../Utility/VersionInformationPrinter.cs | 17 +++++++++ 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 Robust.Client/UserInterface/CustomControls/DebugMonitorControls/DebugVersionPanel.cs create mode 100644 Robust.Shared/Utility/VersionInformationPrinter.cs diff --git a/Robust.Client/UserInterface/CustomControls/DebugMonitorControls/DebugMonitors.cs b/Robust.Client/UserInterface/CustomControls/DebugMonitorControls/DebugMonitors.cs index ef70099b7f1..e54dde8f718 100644 --- a/Robust.Client/UserInterface/CustomControls/DebugMonitorControls/DebugMonitors.cs +++ b/Robust.Client/UserInterface/CustomControls/DebugMonitorControls/DebugMonitors.cs @@ -39,6 +39,7 @@ public DebugMonitors(IClientGameTiming gameTiming, IPlayerManager playerManager, Add(DebugMonitor.System, new DebugSystemPanel { HorizontalAlignment = HAlignment.Left }); Add(DebugMonitor.Input, new DebugInputPanel { HorizontalAlignment = HAlignment.Left }); Add(DebugMonitor.Prof, new LiveProfileViewControl()); + Add(DebugMonitor.Version, new DebugVersionPanel(IoCManager.Resolve()) { HorizontalAlignment = HAlignment.Left }); void Add(DebugMonitor monitor, Control instance) { diff --git a/Robust.Client/UserInterface/CustomControls/DebugMonitorControls/DebugVersionPanel.cs b/Robust.Client/UserInterface/CustomControls/DebugMonitorControls/DebugVersionPanel.cs new file mode 100644 index 00000000000..c96544cc75e --- /dev/null +++ b/Robust.Client/UserInterface/CustomControls/DebugMonitorControls/DebugVersionPanel.cs @@ -0,0 +1,38 @@ +using Robust.Client.Graphics; +using Robust.Client.UserInterface.Controls; +using Robust.Shared.Configuration; +using Robust.Shared.Maths; +using Robust.Shared.Utility; + +namespace Robust.Client.UserInterface.CustomControls.DebugMonitorControls +{ + internal sealed class DebugVersionPanel : PanelContainer + { + public DebugVersionPanel(IConfigurationManager cfg) + { + var contents = new Label + { + FontColorShadowOverride = Color.Black, + }; + AddChild(contents); + + PanelOverride = new StyleBoxFlat + { + BackgroundColor = new Color(35, 134, 37, 138), + ContentMarginLeftOverride = 5, + ContentMarginRightOverride = 5, + ContentMarginTopOverride = 5, + ContentMarginBottomOverride = 5, + }; + + MouseFilter = contents.MouseFilter = MouseFilterMode.Ignore; + + // Set visible explicitly + Visible = true; + HorizontalAlignment = HAlignment.Left; + VerticalAlignment = VAlignment.Top; + + contents.Text = string.Join('\n', VersionInformationPrinter.GetInformationDump(cfg)); + } + } +} diff --git a/Robust.Client/UserInterface/IDebugMonitors.cs b/Robust.Client/UserInterface/IDebugMonitors.cs index da7b87adc13..21600d65b31 100644 --- a/Robust.Client/UserInterface/IDebugMonitors.cs +++ b/Robust.Client/UserInterface/IDebugMonitors.cs @@ -36,5 +36,7 @@ public enum DebugMonitor Input, Bandwidth, Prof, - System + System, + + Version } diff --git a/Robust.Shared/Utility/VersionInformationPrinter.cs b/Robust.Shared/Utility/VersionInformationPrinter.cs new file mode 100644 index 00000000000..05c723814d0 --- /dev/null +++ b/Robust.Shared/Utility/VersionInformationPrinter.cs @@ -0,0 +1,17 @@ +using Robust.Shared.Configuration; + +namespace Robust.Shared.Utility; + +internal static class VersionInformationPrinter +{ + public static string[] GetInformationDump(IConfigurationManager cfg) + { + var buildInfo = GameBuildInformation.GetBuildInfoFromConfig(cfg); + + return new[] + { + $"Fork ID: {buildInfo.ForkId}", + $"Version: {buildInfo.Version}", + }; + } +}