]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Hop console grant all and revoke all access buttons (#39375)
authorqwerltaz <69696513+qwerltaz@users.noreply.github.com>
Sat, 11 Oct 2025 00:41:22 +0000 (02:41 +0200)
committerGitHub <noreply@github.com>
Sat, 11 Oct 2025 00:41:22 +0000 (00:41 +0000)
* add hop console select and deselect all access buttons

* align the buttons right

* document code

Content.Client/Access/UI/IdCardConsoleWindow.xaml
Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs
Resources/Locale/en-US/access/components/id-card-console-component.ftl

index a2f5f3382bbcadcd667f089c2480e44874d24279..0a695a3dcee864bb9775fd88608b5ec695e75c05 100644 (file)
@@ -1,6 +1,7 @@
 <DefaultWindow xmlns="https://spacestation14.io"
             MinSize="650 290">
     <BoxContainer Orientation="Vertical">
+        <!-- Privileged and target IDs, crew manifest button. -->
         <GridContainer Columns="2">
             <GridContainer Columns="3" HorizontalExpand="True">
                 <Label Text="{Loc 'id-card-console-window-privileged-id'}" />
@@ -16,6 +17,7 @@
             </BoxContainer>
         </GridContainer>
         <Control MinSize="0 8" />
+        <!-- Full name and job title editing. -->
         <GridContainer Columns="3" HSeparationOverride="4">
             <Label Name="FullNameLabel" Text="{Loc 'id-card-console-window-full-name-label'}" />
             <LineEdit Name="FullNameLineEdit" HorizontalExpand="True" />
             <Button Name="JobTitleSaveButton" Text="{Loc 'id-card-console-window-save-button'}" Disabled="True" />
         </GridContainer>
         <Control MinSize="0 8" />
-        <GridContainer Columns="2">
-            <Label Text="{Loc 'id-card-console-window-job-selection-label'}" />
-            <OptionButton Name="JobPresetOptionButton" />
-        </GridContainer>
+        <!-- Job preset selection, grant/revoke all access buttons. -->
+        <BoxContainer Margin="0 8 0 4">
+            <BoxContainer>
+                <Label Text="{Loc 'id-card-console-window-job-selection-label'}" />
+                <OptionButton Name="JobPresetOptionButton" />
+            </BoxContainer>
+            <Control HorizontalExpand="True"/>
+            <BoxContainer>
+                <Button Name="SelectAllButton" Text="{Loc 'id-card-console-window-select-all-button'}" />
+                <Button Name="DeselectAllButton" Text="{Loc 'id-card-console-window-deselect-all-button'}" />
+            </BoxContainer>
+        </BoxContainer>
+        <!-- Individual access buttons -->
         <Control Name="AccessLevelControlContainer" />
     </BoxContainer>
 </DefaultWindow>
index 202653f700ec65a55bc98b4181648f9cee985ad3..30a7d969b61590e3f83d90f318b6817609a95e64 100644 (file)
@@ -79,6 +79,18 @@ namespace Content.Client.Access.UI
                 JobPresetOptionButton.AddItem(Loc.GetString(job.Name), _jobPrototypeIds.Count - 1);
             }
 
+            SelectAllButton.OnPressed += _ =>
+            {
+                SetAllAccess(true);
+                SubmitData();
+            };
+
+            DeselectAllButton.OnPressed += _ =>
+            {
+                SetAllAccess(false);
+                SubmitData();
+            };
+
             JobPresetOptionButton.OnItemSelected += SelectJobPreset;
             _accessButtons.Populate(accessLevels, prototypeManager);
             AccessLevelControlContainer.AddChild(_accessButtons);
@@ -89,14 +101,13 @@ namespace Content.Client.Access.UI
             }
         }
 
-        private void ClearAllAccess()
+        /// <param name="enabled">If true, every individual access button will be pressed. If false, each will be depressed.</param>
+        private void SetAllAccess(bool enabled)
         {
             foreach (var button in _accessButtons.ButtonsList.Values)
             {
-                if (button.Pressed)
-                {
-                    button.Pressed = false;
-                }
+                if (!button.Disabled && button.Pressed != enabled)
+                    button.Pressed = enabled;
             }
         }
 
@@ -110,7 +121,7 @@ namespace Content.Client.Access.UI
             JobTitleLineEdit.Text = Loc.GetString(job.Name);
             args.Button.SelectId(args.Id);
 
-            ClearAllAccess();
+            SetAllAccess(false);
 
             // this is a sussy way to do this
             foreach (var access in job.Access)
index 7793b34846ba4f9923ae2a074fa698e782a21743..0418d32062bf3d835703449a6c1781028c1e82e7 100644 (file)
@@ -5,7 +5,9 @@ id-card-console-window-save-button = Save
 id-card-console-window-job-title-label = Job title:
 id-card-console-window-eject-button = Eject
 id-card-console-window-insert-button = Insert
-id-card-console-window-job-selection-label = Job presets (sets department and job icon):
+id-card-console-window-job-selection-label = Job preset (sets department and job icon):
+id-card-console-window-select-all-button = Grant all
+id-card-console-window-deselect-all-button = Revoke all
 
 access-id-card-console-component-no-hands-error = You have no hands.
 id-card-console-privileged-id = Privileged ID