]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add VV button to the solution editor (#38889)
authorslarticodefast <161409025+slarticodefast@users.noreply.github.com>
Thu, 10 Jul 2025 06:31:39 +0000 (08:31 +0200)
committerGitHub <noreply@github.com>
Thu, 10 Jul 2025 06:31:39 +0000 (23:31 -0700)
add vv button to solution editor

Content.Client/Administration/UI/ManageSolutions/EditSolutionsWindow.xaml
Content.Client/Administration/UI/ManageSolutions/EditSolutionsWindow.xaml.cs
Resources/Locale/en-US/administration/ui/manage-solutions/manage-solutions.ftl

index 01259b60f7ab07fb5e2f5d53de4099ae3f07bc45..6146240824f5139a11297c83e12ed30103b4f185 100644 (file)
@@ -8,6 +8,21 @@
             <OptionButton Name="SolutionOption" HorizontalExpand="True"/>
         </BoxContainer>
 
+        <BoxContainer Orientation="Horizontal" HorizontalExpand="True" Margin="0 4">
+            <Button Name="VVButton"
+                    Text="{Loc 'admin-solutions-window-vv-button'}"
+                    ToolTip="{Loc 'admin-solutions-window-vv-button-tooltip'}"
+                    Disabled="True"
+                    HorizontalExpand="True"
+                    StyleClasses="OpenRight"/>
+            <Button Name="SolutionButton"
+                    Text="{Loc 'admin-solutions-window-solution-button'}"
+                    ToolTip="{Loc 'admin-solutions-window-solution-button-tooltip'}"
+                    Disabled="True"
+                    HorizontalExpand="True"
+                    StyleClasses="OpenLeft"/>
+        </BoxContainer>
+
         <!-- The total volume / capacity of the solution -->
         <BoxContainer Name="VolumeBox" Orientation="Vertical" HorizontalExpand="True" Margin="0 4"/>
 
index 812f2de3a0456d38eb90802e6c7233a8edf18a1f..a6b61a4393179ac219fe1fa5b2654c1d543e23f6 100644 (file)
@@ -1,3 +1,4 @@
+using Content.Client.Administration.Managers;
 using Content.Shared.Administration;
 using Content.Shared.Chemistry.Components;
 using Content.Shared.Chemistry.Reagent;
@@ -20,6 +21,7 @@ namespace Content.Client.Administration.UI.ManageSolutions
         [Dependency] private readonly IClientConsoleHost _consoleHost = default!;
         [Dependency] private readonly IEntityManager _entityManager = default!;
         [Dependency] private readonly IClientGameTiming _timing = default!;
+        [Dependency] private readonly IClientAdminManager _admin = default!;
 
         private NetEntity _target = NetEntity.Invalid;
         private string? _selectedSolution;
@@ -34,6 +36,11 @@ namespace Content.Client.Administration.UI.ManageSolutions
 
             SolutionOption.OnItemSelected += SolutionSelected;
             AddButton.OnPressed += OpenAddReagentWindow;
+            VVButton.OnPressed += OpenVVWindow;
+            SolutionButton.OnPressed += OpenSolutionWindow;
+
+            VVButton.Disabled = !_admin.CanViewVar();
+            SolutionButton.Disabled = !_admin.CanViewVar();
         }
 
         public override void Close()
@@ -271,6 +278,32 @@ namespace Content.Client.Administration.UI.ManageSolutions
             _addReagentWindow.OpenCentered();
         }
 
+        /// <summary>
+        ///     Open the corresponding solution entity in a ViewVariables window.
+        /// </summary>
+        private void OpenVVWindow(BaseButton.ButtonEventArgs obj)
+        {
+            if (_solutions == null
+                || _selectedSolution == null
+                || !_solutions.TryGetValue(_selectedSolution, out var uid)
+                || !_entityManager.TryGetNetEntity(uid, out var netEntity))
+                return;
+            _consoleHost.ExecuteCommand($"vv {netEntity}");
+        }
+
+        /// <summary>
+        ///     Open the corresponding Solution instance in a ViewVariables window.
+        /// </summary>
+        private void OpenSolutionWindow(BaseButton.ButtonEventArgs obj)
+        {
+            if (_solutions == null
+                || _selectedSolution == null
+                || !_solutions.TryGetValue(_selectedSolution, out var uid)
+                || !_entityManager.TryGetNetEntity(uid, out var netEntity))
+                return;
+            _consoleHost.ExecuteCommand($"vv /entity/{netEntity}/Solution/Solution");
+        }
+
         /// <summary>
         ///     When a new solution is selected, set _selectedSolution and update the reagent list.
         /// </summary>
index e5c0b33d4ed52a147f85eb86333d9a203975ffac..937464498538d5e50e63afe7ba940b5b435abf79 100644 (file)
@@ -1,5 +1,9 @@
 admin-solutions-window-title = Solution Editor - {$targetName}
 admin-solutions-window-solution-label = Target solution:
+admin-solutions-window-solution-button = Solution
+admin-solutions-window-solution-button-tooltip = Opens the corresponding server-side Solution instance in ViewVariables. Useful for debugging prediction issues.
+admin-solutions-window-vv-button = VV
+admin-solutions-window-vv-button-tooltip = Opens the corresponding solution entity in ViewVariables.
 admin-solutions-window-add-new-button = Add new reagent
 admin-solutions-window-volume-label = Volume {$currentVolume}/{$maxVolume}u
 admin-solutions-window-capacity-label = Capacity (u):
@@ -7,4 +11,4 @@ admin-solutions-window-specific-heat-label = Specific Heat: {$specificHeat} J/(K
 admin-solutions-window-heat-capacity-label = Heat Capacity: {$heatCapacity} J/K
 admin-solutions-window-temperature-label = Temperature (K):
 admin-solutions-window-thermal-energy-label = Thermal Energy (J):
-admin-solutions-window-thermals = Thermals
\ No newline at end of file
+admin-solutions-window-thermals = Thermals