11using System . Linq ;
2+ using Content . Client . _Starlight . Access . UI ; // Starlight-edit
23using Content . Shared . Access ;
34using Content . Shared . Access . Systems ;
45using 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.
0 commit comments