Move access levels to prototypes.
Also adds captain & ID computer access levels. Fixes ID computer not saving access changes correctly.
This commit is contained in:
@@ -3,6 +3,7 @@ using Robust.Client.GameObjects.Components.UserInterface;
|
|||||||
using Robust.Shared.GameObjects.Components.UserInterface;
|
using Robust.Shared.GameObjects.Components.UserInterface;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
using static Content.Shared.GameObjects.Components.Access.SharedIdCardConsoleComponent;
|
using static Content.Shared.GameObjects.Components.Access.SharedIdCardConsoleComponent;
|
||||||
|
|
||||||
namespace Content.Client.GameObjects.Components.Access
|
namespace Content.Client.GameObjects.Components.Access
|
||||||
@@ -11,6 +12,7 @@ namespace Content.Client.GameObjects.Components.Access
|
|||||||
{
|
{
|
||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
[Dependency] private readonly ILocalizationManager _localizationManager;
|
[Dependency] private readonly ILocalizationManager _localizationManager;
|
||||||
|
[Dependency] private readonly IPrototypeManager _prototypeManager;
|
||||||
#pragma warning restore 649
|
#pragma warning restore 649
|
||||||
public IdCardConsoleBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
|
public IdCardConsoleBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
|
||||||
{
|
{
|
||||||
@@ -22,7 +24,7 @@ namespace Content.Client.GameObjects.Components.Access
|
|||||||
{
|
{
|
||||||
base.Open();
|
base.Open();
|
||||||
|
|
||||||
_window = new IdCardConsoleWindow(this, _localizationManager);
|
_window = new IdCardConsoleWindow(this, _localizationManager, _prototypeManager);
|
||||||
_window.Title = Owner.Owner.Name;
|
_window.Title = Owner.Owner.Name;
|
||||||
_window.OnClose += Close;
|
_window.OnClose += Close;
|
||||||
_window.OpenCentered();
|
_window.OpenCentered();
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using Robust.Client.UserInterface.Controls;
|
|||||||
using Robust.Client.UserInterface.CustomControls;
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
using static Content.Shared.GameObjects.Components.Access.SharedIdCardConsoleComponent;
|
using static Content.Shared.GameObjects.Components.Access.SharedIdCardConsoleComponent;
|
||||||
|
|
||||||
namespace Content.Client.GameObjects.Components.Access
|
namespace Content.Client.GameObjects.Components.Access
|
||||||
@@ -40,7 +41,7 @@ namespace Content.Client.GameObjects.Components.Access
|
|||||||
|
|
||||||
protected override Vector2? CustomSize => (650, 270);
|
protected override Vector2? CustomSize => (650, 270);
|
||||||
|
|
||||||
public IdCardConsoleWindow(IdCardConsoleBoundUserInterface owner, ILocalizationManager loc)
|
public IdCardConsoleWindow(IdCardConsoleBoundUserInterface owner, ILocalizationManager loc, IPrototypeManager prototypeManager)
|
||||||
{
|
{
|
||||||
_loc = loc;
|
_loc = loc;
|
||||||
_owner = owner;
|
_owner = owner;
|
||||||
@@ -126,20 +127,21 @@ namespace Content.Client.GameObjects.Components.Access
|
|||||||
{
|
{
|
||||||
var grid = new GridContainer
|
var grid = new GridContainer
|
||||||
{
|
{
|
||||||
Columns = 4,
|
Columns = 5,
|
||||||
SizeFlagsHorizontal = SizeFlags.ShrinkCenter
|
SizeFlagsHorizontal = SizeFlags.ShrinkCenter
|
||||||
};
|
};
|
||||||
vBox.AddChild(grid);
|
vBox.AddChild(grid);
|
||||||
|
|
||||||
foreach (var accessName in SharedAccess.AllAccess)
|
foreach (var accessLevel in prototypeManager.EnumeratePrototypes<AccessLevelPrototype>())
|
||||||
{
|
{
|
||||||
var newButton = new Button
|
var newButton = new Button
|
||||||
{
|
{
|
||||||
Text = accessName,
|
Text = accessLevel.Name,
|
||||||
ToggleMode = true,
|
ToggleMode = true,
|
||||||
};
|
};
|
||||||
grid.AddChild(newButton);
|
grid.AddChild(newButton);
|
||||||
_accessButtons.Add(accessName, newButton);
|
_accessButtons.Add(accessLevel.ID, newButton);
|
||||||
|
newButton.OnPressed += _ => SubmitData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using Content.Server.GameObjects.EntitySystems;
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
using Content.Server.Interfaces;
|
using Content.Server.Interfaces;
|
||||||
using Content.Server.Interfaces.GameObjects;
|
using Content.Server.Interfaces.GameObjects;
|
||||||
@@ -13,6 +12,7 @@ using Robust.Shared.Interfaces.GameObjects;
|
|||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Access
|
namespace Content.Server.GameObjects.Components.Access
|
||||||
{
|
{
|
||||||
@@ -23,6 +23,7 @@ namespace Content.Server.GameObjects.Components.Access
|
|||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
[Dependency] private readonly IServerNotifyManager _notifyManager;
|
[Dependency] private readonly IServerNotifyManager _notifyManager;
|
||||||
[Dependency] private readonly ILocalizationManager _localizationManager;
|
[Dependency] private readonly ILocalizationManager _localizationManager;
|
||||||
|
[Dependency] private readonly IPrototypeManager _prototypeManager;
|
||||||
#pragma warning restore 649
|
#pragma warning restore 649
|
||||||
|
|
||||||
private BoundUserInterface _userInterface;
|
private BoundUserInterface _userInterface;
|
||||||
@@ -93,7 +94,7 @@ namespace Content.Server.GameObjects.Components.Access
|
|||||||
targetIdComponent.FullName = newFullName;
|
targetIdComponent.FullName = newFullName;
|
||||||
targetIdComponent.JobTitle = newJobTitle;
|
targetIdComponent.JobTitle = newJobTitle;
|
||||||
|
|
||||||
if (!newAccessList.TrueForAll(x => SharedAccess.AllAccess.Contains(x)))
|
if (!newAccessList.TrueForAll(x => _prototypeManager.HasIndex<AccessLevelPrototype>(x)))
|
||||||
{
|
{
|
||||||
Logger.Warning($"Tried to write unknown access tag.");
|
Logger.Warning($"Tried to write unknown access tag.");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
namespace Content.Shared.Access
|
|
||||||
{
|
|
||||||
public static class SharedAccess
|
|
||||||
{
|
|
||||||
public static readonly string[] AllAccess = {
|
|
||||||
"command",
|
|
||||||
"security",
|
|
||||||
"engineering",
|
|
||||||
"medical",
|
|
||||||
"cargo",
|
|
||||||
"research",
|
|
||||||
"service",
|
|
||||||
"maintenance",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
2
Resources/Prototypes/AccessLevels/Cargo.yml
Normal file
2
Resources/Prototypes/AccessLevels/Cargo.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
- type: accessLevel
|
||||||
|
id: cargo
|
||||||
9
Resources/Prototypes/AccessLevels/Command.yml
Normal file
9
Resources/Prototypes/AccessLevels/Command.yml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
- type: accessLevel
|
||||||
|
id: command
|
||||||
|
|
||||||
|
- type: accessLevel
|
||||||
|
id: captain
|
||||||
|
|
||||||
|
- type: accessLevel
|
||||||
|
id: idCard
|
||||||
|
name: ID modification
|
||||||
2
Resources/Prototypes/AccessLevels/Engineering.yml
Normal file
2
Resources/Prototypes/AccessLevels/Engineering.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
- type: accessLevel
|
||||||
|
id: engineering
|
||||||
2
Resources/Prototypes/AccessLevels/Maintenance.yml
Normal file
2
Resources/Prototypes/AccessLevels/Maintenance.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
- type: accessLevel
|
||||||
|
id: maintenance
|
||||||
2
Resources/Prototypes/AccessLevels/Medical.yml
Normal file
2
Resources/Prototypes/AccessLevels/Medical.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
- type: accessLevel
|
||||||
|
id: medical
|
||||||
2
Resources/Prototypes/AccessLevels/Research.yml
Normal file
2
Resources/Prototypes/AccessLevels/Research.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
- type: accessLevel
|
||||||
|
id: research
|
||||||
2
Resources/Prototypes/AccessLevels/Security.yml
Normal file
2
Resources/Prototypes/AccessLevels/Security.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
- type: accessLevel
|
||||||
|
id: security
|
||||||
2
Resources/Prototypes/AccessLevels/Service.yml
Normal file
2
Resources/Prototypes/AccessLevels/Service.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
- type: accessLevel
|
||||||
|
id: service
|
||||||
@@ -144,7 +144,7 @@
|
|||||||
name: ID Card Computer
|
name: ID Card Computer
|
||||||
components:
|
components:
|
||||||
- type: AccessReader
|
- type: AccessReader
|
||||||
necessary: ["command"]
|
necessary: ["idCard"]
|
||||||
- type: IdCardConsole
|
- type: IdCardConsole
|
||||||
- type: UserInterface
|
- type: UserInterface
|
||||||
interfaces:
|
interfaces:
|
||||||
|
|||||||
Reference in New Issue
Block a user