Skip to content

Commit e660720

Browse files
authored
Merge pull request #1750 from ss14Starlight/starlight-dev
Merge dev into stable
2 parents 0525321 + ed93f82 commit e660720

452 files changed

Lines changed: 584399 additions & 432343 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Content.Client/Access/UI/AccessLevelControl.xaml.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,20 @@ public void Populate(List<ProtoId<AccessLevelPrototype>> accessLevels, IPrototyp
4848

4949
public void UpdateState(
5050
List<ProtoId<AccessLevelPrototype>> pressedList,
51+
ProtoId<AccessGroupPrototype>? currentGroup, // Starlight-edit: access groups
52+
IPrototypeManager? prototypeManager = null, // Starlight-edit: access groups
5153
List<ProtoId<AccessLevelPrototype>>? enabledList = null)
5254
{
55+
// Starlight-start: Access groups
56+
if (currentGroup != null && prototypeManager != null && prototypeManager.TryIndex(currentGroup.Value, out var group))
57+
{
58+
RemoveAllChildren();
59+
ButtonsList.Clear();
60+
61+
Populate(group.Tags.ToList(), prototypeManager);
62+
}
63+
// Starlight-end
64+
5365
foreach (var (accessName, button) in ButtonsList)
5466
{
5567
button.Pressed = pressedList.Contains(accessName);

Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Content.Shared.CCVar;
55
using Content.Shared.Containers.ItemSlots;
66
using Content.Shared.CrewManifest;
7+
using Content.Shared._Starlight.Access; // Starlight-edit
78
using Content.Shared.Roles;
89
using Robust.Shared.Configuration;
910
using Robust.Shared.Prototypes;
@@ -34,23 +35,24 @@ public IdCardConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner
3435
protected override void Open()
3536
{
3637
base.Open();
37-
List<ProtoId<AccessLevelPrototype>> accessLevels;
38+
List<ProtoId<AccessGroupPrototype>> accessGroups; // Starlight-edit
3839

3940
if (EntMan.TryGetComponent<IdCardConsoleComponent>(Owner, out var idCard))
4041
{
41-
accessLevels = idCard.AccessLevels;
42+
accessGroups = idCard.AccessGroups; // Starlight-edit
4243
}
4344
else
4445
{
45-
accessLevels = new List<ProtoId<AccessLevelPrototype>>();
46+
accessGroups = new List<ProtoId<AccessGroupPrototype>>(); // Starlight-edit
4647
_idCardConsoleSystem.Log.Error($"No IdCardConsole component found for {EntMan.ToPrettyString(Owner)}!");
4748
}
4849

49-
_window = new IdCardConsoleWindow(this, _prototypeManager, accessLevels)
50+
_window = new IdCardConsoleWindow(this, _prototypeManager, accessGroups) // Starlight-edit
5051
{
5152
Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName
5253
};
5354

55+
_window.OnGroupSelected += group => SendMessage(new AccessGroupSelectedMessage(group)); // Starlight-edit
5456
_window.CrewManifestButton.OnPressed += _ => SendMessage(new CrewManifestOpenUiMessage());
5557
_window.PrivilegedIdButton.OnPressed += _ => SendMessage(new ItemSlotButtonPressedEvent(PrivilegedIdCardSlotId));
5658
_window.TargetIdButton.OnPressed += _ => SendMessage(new ItemSlotButtonPressedEvent(TargetIdCardSlotId));

Content.Client/Access/UI/IdCardConsoleWindow.xaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<DefaultWindow xmlns="https://spacestation14.io"
2+
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
23
MinSize="650 290">
34
<BoxContainer Orientation="Vertical">
45
<GridContainer Columns="2">
@@ -30,6 +31,12 @@
3031
<Label Text="{Loc 'id-card-console-window-job-selection-label'}" />
3132
<OptionButton Name="JobPresetOptionButton" />
3233
</GridContainer>
33-
<Control Name="AccessLevelControlContainer" />
34+
<!-- Starlight-start: Access Groups -->
35+
<BoxContainer Orientation="Horizontal">
36+
<Control Name="AccessGroupControlContainer" /> <!-- Access Groups Buttons -->
37+
<cc:VSeparator Color="#a88b5e" Margin="5 0 5 0" /> <!-- Separator -->
38+
<Control Name="AccessLevelControlContainer" /> <!-- Access Level Buttons -->
39+
</BoxContainer>
40+
<!-- Starlight-end: Access Groups -->
3441
</BoxContainer>
3542
</DefaultWindow>

Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Linq;
2+
using Content.Client._Starlight.Access.UI; // Starlight-edit
23
using Content.Shared.Access;
34
using Content.Shared.Access.Systems;
45
using Content.Shared.CCVar;
@@ -28,6 +29,7 @@ public sealed partial class IdCardConsoleWindow : DefaultWindow
2829
private int _maxIdJobLength;
2930

3031
private AccessLevelControl _accessButtons = new();
32+
private AccessGroupControl _accessGroups = new(); // Starlight-edit: Access Groups
3133
private readonly List<string> _jobPrototypeIds = new();
3234

3335
private string? _lastFullName;
@@ -37,8 +39,11 @@ public sealed partial class IdCardConsoleWindow : DefaultWindow
3739
// The job that will be picked if the ID doesn't have a job on the station.
3840
private static ProtoId<JobPrototype> _defaultJob = "Assistant";
3941

42+
private ProtoId<AccessGroupPrototype>? _selectedAccessGroup = null; // Starlight-edit
43+
public Action<ProtoId<AccessGroupPrototype>>? OnGroupSelected; // Starlight-edit
44+
4045
public IdCardConsoleWindow(IdCardConsoleBoundUserInterface owner, IPrototypeManager prototypeManager,
41-
List<ProtoId<AccessLevelPrototype>> accessLevels)
46+
List<ProtoId<AccessGroupPrototype>> accessGroups) // Starlight-edit
4247
{
4348
RobustXamlLoader.Load(this);
4449
IoCManager.InjectDependencies(this);
@@ -80,9 +85,30 @@ public IdCardConsoleWindow(IdCardConsoleBoundUserInterface owner, IPrototypeMana
8085
}
8186

8287
JobPresetOptionButton.OnItemSelected += SelectJobPreset;
83-
_accessButtons.Populate(accessLevels, prototypeManager);
88+
// Starlight-start: Access Groups
89+
var currentAccessGroup = _selectedAccessGroup ?? accessGroups.FirstOrDefault();
90+
_accessGroups.Populate(accessGroups, currentAccessGroup, prototypeManager);
91+
92+
List<ProtoId<AccessLevelPrototype>> accessLevels = new();
93+
if (prototypeManager.TryIndex(currentAccessGroup, out var accessGroup))
94+
{
95+
accessLevels.AddRange(accessGroup.Tags);
96+
_accessButtons.Populate(accessLevels, prototypeManager);
97+
}
98+
else
99+
_logMill.Error($"Unable to find accessgroup for {accessGroup}");
100+
101+
AccessGroupControlContainer.AddChild(_accessGroups);
102+
103+
// Starlight-end
104+
84105
AccessLevelControlContainer.AddChild(_accessButtons);
85106

107+
// Starlight-start: Access Groups
108+
foreach (var (id, button) in _accessGroups.ButtonsList)
109+
button.OnPressed += _ => OnGroupSelected?.Invoke(id);
110+
// Starlight-end
111+
86112
foreach (var (id, button) in _accessButtons.ButtonsList)
87113
{
88114
button.OnPressed += _ => SubmitData();
@@ -180,11 +206,26 @@ public void UpdateState(IdCardConsoleBoundUserInterfaceState state)
180206

181207
JobPresetOptionButton.Disabled = !interfaceEnabled;
182208

209+
// Starlight-start: Access Groups
210+
211+
_selectedAccessGroup = state.CurrentAccessGroup;
212+
213+
_accessGroups.UpdateState(state.CurrentAccessGroup);
214+
215+
// Starlight-end
216+
183217
_accessButtons.UpdateState(state.TargetIdAccessList?.ToList() ??
184218
new List<ProtoId<AccessLevelPrototype>>(),
219+
state.CurrentAccessGroup, // Starlight-edit
220+
_prototypeManager, // Starlight-edit
185221
state.AllowedModifyAccessList?.ToList() ??
186222
new List<ProtoId<AccessLevelPrototype>>());
187223

224+
// Starlight-start: Access Groups
225+
foreach (var (id, button) in _accessButtons.ButtonsList)
226+
button.OnPressed += _ => SubmitData();
227+
// Starlight-end
228+
188229
var jobIndex = _jobPrototypeIds.IndexOf(state.TargetIdJobPrototype);
189230
// If the job index is < 0 that means they don't have a job registered in the station records
190231
// or the IdCardComponent's JobPrototype field.

Content.Client/Administration/UI/CustomControls/HSeparator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public HSeparator(Color color)
2828
ContentMarginBottomOverride = 2,
2929
ContentMarginLeftOverride = 2
3030
};
31-
32-
AddChild(new PanelContainer { PanelOverride = _styleBox });
3331
// Starlight-end
32+
33+
AddChild(new PanelContainer { PanelOverride = _styleBox }); // Starlight-edit
3434
}
3535

3636
public HSeparator() : this(SeparatorColor) { }

Content.Client/Administration/UI/CustomControls/VSeparator.cs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,28 @@ public sealed class VSeparator : PanelContainer
99
{
1010
private static readonly Color SeparatorColor = Color.FromHex("#3D4059");
1111

12+
// Starlight-start
13+
private readonly StyleBoxFlat _styleBox;
14+
15+
public Color Color
16+
{
17+
get => _styleBox.BackgroundColor;
18+
set => _styleBox.BackgroundColor = value;
19+
}
20+
// Starlight-end
21+
1222
public VSeparator(Color color)
1323
{
1424
MinSize = new Vector2(2, 5);
1525

16-
AddChild(new PanelContainer
26+
// Starlight-start
27+
_styleBox = new StyleBoxFlat
1728
{
18-
PanelOverride = new StyleBoxFlat
19-
{
20-
BackgroundColor = color
21-
}
22-
});
29+
BackgroundColor = color,
30+
};
31+
32+
AddChild(new PanelContainer { PanelOverride = _styleBox });
33+
// Starlight-end
2334
}
2435

2536
public VSeparator() : this(SeparatorColor) { }

Content.Client/Content.Client.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<ProjectReference Include="..\RobustToolbox\Robust.Shared\Robust.Shared.csproj" />
2323
<ProjectReference Include="..\RobustToolbox\Robust.Client\Robust.Client.csproj" />
2424
<ProjectReference Include="..\Content.Shared\Content.Shared.csproj" />
25+
<ProjectReference Include="..\Content.Starlight.Codegen\Content.Starlight.Codegen.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
2526
</ItemGroup>
2627
<ItemGroup>
2728
<Folder Include="_Starlight\Achievement\" />

Content.Client/Doors/Electronics/DoorElectronicsConfigurationMenu.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ public void Reset(IPrototypeManager protoManager, List<ProtoId<AccessLevelProtot
3737

3838
public void UpdateState(DoorElectronicsConfigurationState state)
3939
{
40-
_buttonsList.UpdateState(state.AccessList);
40+
_buttonsList.UpdateState(state.AccessList, null); // Starlight-edit
4141
}
4242
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<BoxContainer xmlns="https://spacestation14.io"
2+
VerticalExpand="True"
3+
HorizontalExpand="True"
4+
HorizontalAlignment="Center"
5+
Orientation="Vertical">
6+
</BoxContainer>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using Robust.Client.AutoGenerated;
2+
using Robust.Client.UserInterface.Controls;
3+
using Robust.Client.UserInterface.XAML;
4+
using Robust.Shared.Prototypes;
5+
using Content.Shared.Access;
6+
7+
namespace Content.Client._Starlight.Access.UI;
8+
9+
[GenerateTypedNameReferences]
10+
public sealed partial class AccessGroupControl : BoxContainer
11+
{
12+
[Dependency] private readonly ILogManager _logManager = default!;
13+
14+
private readonly ISawmill _sawmill = default!;
15+
16+
public readonly Dictionary<ProtoId<AccessGroupPrototype>, Button> ButtonsList = new();
17+
18+
public AccessGroupControl()
19+
{
20+
RobustXamlLoader.Load(this);
21+
IoCManager.InjectDependencies(this);
22+
23+
_sawmill = _logManager.GetSawmill("accessgroupcontrol");
24+
}
25+
26+
public void Populate(List<ProtoId<AccessGroupPrototype>> accessGroups, ProtoId<AccessGroupPrototype> currentAccessGroup, IPrototypeManager prototypeManager)
27+
{
28+
foreach (var group in accessGroups)
29+
{
30+
if (!prototypeManager.TryIndex(group, out var accessGroup))
31+
{
32+
_sawmill.Error($"Unable to find accessgroup for {group}");
33+
continue;
34+
}
35+
36+
var newButton = new Button
37+
{
38+
Text = accessGroup.Name ?? accessGroup.ID
39+
};
40+
41+
if (group == currentAccessGroup)
42+
newButton.Disabled = true;
43+
44+
AddChild(newButton);
45+
ButtonsList.Add(accessGroup.ID, newButton);
46+
}
47+
}
48+
49+
public void UpdateState(ProtoId<AccessGroupPrototype> pressed)
50+
{
51+
foreach (var (groupName, button) in ButtonsList)
52+
button.Disabled = pressed == groupName;
53+
}
54+
}

0 commit comments

Comments
 (0)