Hop console grant all and revoke all access buttons (#39375)

* add hop console select and deselect all access buttons

* align the buttons right

* document code
This commit is contained in:
qwerltaz
2025-10-11 02:41:22 +02:00
committed by GitHub
parent 228ed0288c
commit 5b38148651
3 changed files with 35 additions and 11 deletions

View 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" />
@@ -26,10 +28,19 @@
<Button Name="JobTitleSaveButton" Text="{Loc 'id-card-console-window-save-button'}" Disabled="True" />
</GridContainer>
<Control MinSize="0 8" />
<GridContainer Columns="2">
<!-- 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" />
</GridContainer>
</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>

View 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)

View 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