id card computer now sets access when selecting a job preset (#4441)

This commit is contained in:
Charlie Morley 2025-09-21 14:49:45 -06:00 committed by GitHub
parent f0ba366f61
commit 1462f5bd1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 29 deletions

View File

@ -92,16 +92,8 @@ namespace Content.Client.Access.UI
}
}
private void ClearAllAccess()
{
foreach (var button in _accessButtons.ButtonsList.Values)
{
if (button.Pressed)
{
button.Pressed = false;
}
}
}
// DeltaV - removed as part of job preset access fix
// private void ClearAllAccess()
private void SelectJobPreset(OptionButton.ItemSelectedEventArgs args)
{
@ -113,34 +105,28 @@ namespace Content.Client.Access.UI
JobTitleLineEdit.Text = Loc.GetString(job.Name);
args.Button.SelectId(args.Id);
ClearAllAccess();
// this is a sussy way to do this
foreach (var access in job.Access)
{
if (_accessButtons.ButtonsList.TryGetValue(access, out var button) && !button.Disabled)
{
button.Pressed = true;
}
}
// DeltaV - start of job preset access fix
SubmitData();
var targetAccesses = job.Access.ToHashSet();
foreach (var group in job.AccessGroups)
{
if (!_prototypeManager.TryIndex(group, out AccessGroupPrototype? groupPrototype))
{
continue;
}
foreach (var access in groupPrototype.Tags)
{
if (_accessButtons.ButtonsList.TryGetValue(access, out var button) && !button.Disabled)
{
button.Pressed = true;
}
}
targetAccesses.UnionWith(groupPrototype.Tags);
}
SubmitData();
// this is a sussy way to do this
foreach (var (id, button) in _accessButtons.ButtonsList)
{
if (!button.Disabled && button.Pressed != targetAccesses.Contains(id))
{
OnToggleAccess?.Invoke(id);
}
}
// DeltaV - end of job preset access fix
}
public void UpdateState(IdCardConsoleBoundUserInterfaceState state)

View File

@ -55,5 +55,7 @@ public sealed partial class IdCardConsoleSystem
// TODO: only log changes when ejecting the id
_adminLogger.Add(LogType.Action, LogImpact.Medium,
$"{ToPrettyString(user):user} has {verb} access level '{args.Id}' {prefix} {ToPrettyString(targetId):entity}");
UpdateUserInterface(ent.Owner, ent.Comp, args);
}
}