QoL для ХоПа (#369)

* add: nice job icons ui for HoP console

* Ebanniy rot

* add: Changing id visuals with HoP console

* cleanup

* add: remove drop down list and replace it with icon-buttons

* add: colored and sorted by department buttons

* add: columns

* tweak: nicer colors

* cleanup
This commit is contained in:
ThereDrD0
2024-06-20 22:29:26 +03:00
committed by GitHub
parent 76e46de7e9
commit cb37ba5714
12 changed files with 332 additions and 122 deletions

View File

@@ -13,6 +13,7 @@ namespace Content.Client.Access.UI;
public sealed partial class AccessLevelControl : GridContainer
{
public readonly Dictionary<ProtoId<AccessLevelPrototype>, Button> ButtonsList = new();
public readonly List<Dictionary<ProtoId<AccessLevelPrototype>, Button>> ButtonGroups = new ();
public AccessLevelControl()
{
@@ -39,6 +40,61 @@ public sealed partial class AccessLevelControl : GridContainer
}
}
public void PopulateForConsole(List<List<ProtoId<AccessLevelPrototype>>> accessLevels, IPrototypeManager prototypeManager)
{
var departmentColors = new List<String> // Colors from StyleNano.cs
{
"ButtonColorCommandDepartment",
"ButtonColorSecurityDepartment",
"ButtonColorMedicalDepartment",
"ButtonColorEngineeringDepartment",
"ButtonColorResearchingDepartment",
"ButtonColorCargoDepartment",
"ButtonColorServiceDepartment"
};
var currentColorIndex = 0;
foreach (var department in accessLevels)
{
Dictionary<ProtoId<AccessLevelPrototype>, Button> buttons = new();
foreach (var access in department)
{
if (!prototypeManager.TryIndex(access, out var accessLevel))
{
Logger.Error($"Unable to find accesslevel for {access}");
continue;
}
var newButton = new Button
{
Text = accessLevel.GetAccessLevelName(),
ToggleMode = true,
};
newButton.AddStyleClass(departmentColors[currentColorIndex]);
buttons.Add(accessLevel.ID, newButton);
}
ButtonGroups.Add(buttons);
currentColorIndex++;
}
}
public void UpdateStateConsole(
List<ProtoId<AccessLevelPrototype>> pressedList,
List<ProtoId<AccessLevelPrototype>>? enabledList = null)
{
foreach (var department in ButtonGroups)
{
foreach (var (accessName, button) in department)
{
button.Pressed = pressedList.Contains(accessName);
button.Disabled = !(enabledList?.Contains(accessName) ?? true);
}
}
}
public void UpdateState(
List<ProtoId<AccessLevelPrototype>> pressedList,
List<ProtoId<AccessLevelPrototype>>? enabledList = null)