forked from new-frontiers-14/frontier-station-14
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from Corvax-Frontier/up141224
Апстримчик
- Loading branch information
Showing
331 changed files
with
22,930 additions
and
9,925 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
Content.Client/DeltaV/Administration/UI/DepartmentWhitelistPanel.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<PanelContainer | ||
xmlns="https://spacestation14.io" | ||
xmlns:cc="clr-namespace:Content.Client.DeltaV.Administration.UI" | ||
StyleClasses="BackgroundDark" | ||
HorizontalExpand="True" | ||
Margin="4"> | ||
<BoxContainer Orientation="Vertical"> | ||
<CheckBox Name="Department"/> <!-- Toggles all jobs in the department at once --> | ||
<GridContainer Name="JobsContainer" Columns="4"/> <!-- Populated with each job to toggle individually--> | ||
</BoxContainer> | ||
</PanelContainer> |
82 changes: 82 additions & 0 deletions
82
Content.Client/DeltaV/Administration/UI/DepartmentWhitelistPanel.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using Content.Shared.Roles; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.CustomControls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Client.DeltaV.Administration.UI; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class DepartmentWhitelistPanel : PanelContainer | ||
{ | ||
public Action<ProtoId<JobPrototype>, bool>? OnSetJob; | ||
|
||
public DepartmentWhitelistPanel(DepartmentPrototype department, IPrototypeManager proto, HashSet<ProtoId<JobPrototype>> whitelists, bool globalWhitelist) // Frontier: add globalWhitelist | ||
{ | ||
RobustXamlLoader.Load(this); | ||
|
||
var anyValid = false;// | ||
var allWhitelisted = true; | ||
var grey = Color.FromHex("#ccc"); | ||
foreach (var id in department.Roles) | ||
{ | ||
var thisJob = id; // closure capturing funny | ||
|
||
// Frontier: skip non-whitelisted roles, cache prototype | ||
var jobProto = proto.Index(id); | ||
if (!jobProto.Whitelisted) | ||
continue; | ||
else | ||
anyValid = true; | ||
// End Frontier | ||
|
||
var button = new CheckBox(); | ||
button.Text = jobProto.LocalizedName; | ||
if (!jobProto.Whitelisted) | ||
button.Modulate = grey; // Let admins know whitelisting this job is only for futureproofing. | ||
button.Pressed = whitelists.Contains(id) || globalWhitelist; | ||
button.OnPressed += _ => OnButtonPressed(thisJob, button, globalWhitelist); // Frontier: check global whitelist | ||
JobsContainer.AddChild(button); | ||
|
||
allWhitelisted &= button.Pressed; | ||
} | ||
|
||
if (!anyValid) // Frontier: hide checkbox set if no valid events | ||
Visible = false; // Frontier | ||
|
||
Department.Text = Loc.GetString(department.Name); | ||
Department.Modulate = department.Color; | ||
Department.Pressed = allWhitelisted; | ||
Department.OnPressed += args => OnDepartmentPressed(department, proto, whitelists, globalWhitelist); // Frontier: check global whitelist | ||
} | ||
|
||
// Frontier: global whitelist handling | ||
private void OnButtonPressed(ProtoId<JobPrototype> thisJob, CheckBox button, bool globalWhitelist) | ||
{ | ||
if (globalWhitelist) | ||
button.Pressed = true; // Force the button on. | ||
else | ||
OnSetJob?.Invoke(thisJob, button.Pressed); | ||
} | ||
|
||
private void OnDepartmentPressed(DepartmentPrototype department, IPrototypeManager proto, HashSet<ProtoId<JobPrototype>> whitelists, bool globalWhitelist) | ||
{ | ||
// Frontier: global override | ||
if (globalWhitelist) | ||
{ | ||
Department.Pressed = true; | ||
return; | ||
} | ||
// End Frontier: global override | ||
|
||
foreach (var id in department.Roles) | ||
{ | ||
// only request to whitelist roles that aren't already whitelisted, and vice versa - Frontier: roles must be whitelisted | ||
if (whitelists.Contains(id) != Department.Pressed && proto.Index(id).Whitelisted) | ||
OnSetJob?.Invoke(id, Department.Pressed); | ||
} | ||
} | ||
// End Frontier | ||
} |
11 changes: 11 additions & 0 deletions
11
Content.Client/DeltaV/Administration/UI/GhostRoleSetWhitelistPanel.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<PanelContainer | ||
xmlns="https://spacestation14.io" | ||
xmlns:cc="clr-namespace:Content.Client.DeltaV.Administration.UI" | ||
StyleClasses="BackgroundDark" | ||
HorizontalExpand="True" | ||
Margin="4"> <!-- Frontier: ghost role set whitelist --> | ||
<BoxContainer Orientation="Vertical"> | ||
<CheckBox Name="GhostRoleSet"/> <!-- Toggles all jobs in the department at once --> | ||
<GridContainer Name="RolesContainer" Columns="4"/> <!-- Populated with each job to toggle individually--> | ||
</BoxContainer> | ||
</PanelContainer> |
67 changes: 67 additions & 0 deletions
67
Content.Client/DeltaV/Administration/UI/GhostRoleSetWhitelistPanel.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using Content.Shared.Ghost.Roles; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Client.DeltaV.Administration.UI; | ||
|
||
// Frontier: ghost role whitelist set | ||
[GenerateTypedNameReferences] | ||
public sealed partial class GhostRoleSetWhitelistPanel : PanelContainer | ||
{ | ||
public Action<ProtoId<GhostRolePrototype>, bool>? OnSetGhostRole; | ||
|
||
public GhostRoleSetWhitelistPanel(List<ProtoId<GhostRolePrototype>> ghostRoleList, string ghostRoleSetName, Color ghostRoleSetColor, IPrototypeManager proto, HashSet<ProtoId<GhostRolePrototype>> whitelists, bool globalWhitelist) | ||
{ | ||
RobustXamlLoader.Load(this); | ||
|
||
var allWhitelisted = true; | ||
foreach (var id in ghostRoleList) | ||
{ | ||
var thisRole = id; // closure capturing funny | ||
var button = new CheckBox(); | ||
button.Text = Loc.GetString(proto.Index(id).Name); | ||
button.Pressed = whitelists.Contains(id) || globalWhitelist; | ||
button.OnPressed += _ => OnButtonPressed(thisRole, button, globalWhitelist); | ||
RolesContainer.AddChild(button); | ||
|
||
allWhitelisted &= button.Pressed; | ||
} | ||
|
||
GhostRoleSet.Text = Loc.GetString(ghostRoleSetName); | ||
GhostRoleSet.Modulate = ghostRoleSetColor; | ||
GhostRoleSet.Pressed = allWhitelisted; | ||
GhostRoleSet.OnPressed += args => OnDepartmentPressed(ghostRoleList, whitelists, globalWhitelist); | ||
} | ||
|
||
// Frontier: global whitelist | ||
private void OnButtonPressed(ProtoId<GhostRolePrototype> thisRole, CheckBox button, bool globalWhitelist) | ||
{ | ||
if (globalWhitelist) | ||
button.Pressed = true; // Force the button on. | ||
else | ||
OnSetGhostRole?.Invoke(thisRole, button.Pressed); | ||
} | ||
|
||
private void OnDepartmentPressed(List<ProtoId<GhostRolePrototype>> ghostRoleList, HashSet<ProtoId<GhostRolePrototype>> whitelists, bool globalWhitelist) | ||
{ | ||
// Frontier: global override | ||
if (globalWhitelist) | ||
{ | ||
GhostRoleSet.Pressed = true; | ||
return; | ||
} | ||
// End Frontier: global override | ||
|
||
foreach (var id in ghostRoleList) | ||
{ | ||
// only request to whitelist roles that aren't already whitelisted, and vice versa | ||
if (whitelists.Contains(id) != GhostRoleSet.Pressed) | ||
OnSetGhostRole?.Invoke(id, GhostRoleSet.Pressed); | ||
} | ||
} | ||
// End Frontier | ||
|
||
} | ||
// End Frontier |
42 changes: 42 additions & 0 deletions
42
Content.Client/DeltaV/Administration/UI/JobWhitelistsEui.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Content.Client.Eui; | ||
using Content.Shared.DeltaV.Administration; | ||
using Content.Shared.Eui; | ||
|
||
namespace Content.Client.DeltaV.Administration.UI; | ||
|
||
public sealed class JobWhitelistsEui : BaseEui | ||
{ | ||
private JobWhitelistsWindow Window; | ||
|
||
public JobWhitelistsEui() | ||
{ | ||
Window = new JobWhitelistsWindow(); | ||
Window.OnClose += () => SendMessage(new CloseEuiMessage()); | ||
Window.OnSetJob += (id, whitelisted) => SendMessage(new SetJobWhitelistedMessage(id, whitelisted)); | ||
Window.OnSetGhostRole += (id, whitelisted) => SendMessage(new SetGhostRoleWhitelistedMessage(id, whitelisted)); // Frontier | ||
Window.OnSetGlobal += (whitelisted) => SendMessage(new SetGlobalWhitelistMessage(whitelisted)); // Frontier | ||
} | ||
|
||
public override void HandleState(EuiStateBase state) | ||
{ | ||
if (state is not JobWhitelistsEuiState cast) | ||
return; | ||
|
||
Window.HandleState(cast); | ||
} | ||
|
||
public override void Opened() | ||
{ | ||
base.Opened(); | ||
|
||
Window.OpenCentered(); | ||
} | ||
|
||
public override void Closed() | ||
{ | ||
base.Closed(); | ||
|
||
Window.Close(); | ||
Window.Dispose(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
Content.Client/DeltaV/Administration/UI/JobWhitelistsWindow.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<controls:FancyWindow | ||
xmlns="https://spacestation14.io" | ||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
Title="{Loc player-panel-job-whitelists}" MinSize="750 600"> | ||
<BoxContainer Orientation="Vertical"> | ||
<Label Name="PlayerName" Margin="4"/> | ||
<BoxContainer Orientation="Horizontal" Margin="4"> | ||
<BoxContainer Name="TierButtons" Orientation="Horizontal"/> | ||
</BoxContainer> | ||
<ScrollContainer VerticalExpand="True"> | ||
<!-- Frontier: global checkbox --> | ||
<BoxContainer Orientation="Vertical"> | ||
<CheckBox Name="Global" Margin="4"/> | ||
<BoxContainer Name="Departments" Orientation="Vertical"/> | ||
<BoxContainer Name="GhostRoles" Orientation="Vertical"/> <!-- Frontier: ghost roles --> | ||
</BoxContainer> | ||
<!-- End Frontier: global checkbox --> | ||
</ScrollContainer> | ||
</BoxContainer> | ||
</controls:FancyWindow> |
108 changes: 108 additions & 0 deletions
108
Content.Client/DeltaV/Administration/UI/JobWhitelistsWindow.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
using Content.Client.UserInterface.Controls; | ||
using Content.Shared.Database; | ||
using Content.Shared.DeltaV.Administration; | ||
using Content.Shared.Roles; | ||
using Content.Shared.DeltaV.Whitelist; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.CustomControls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Prototypes; | ||
using Content.Shared.Ghost.Roles; | ||
|
||
namespace Content.Client.DeltaV.Administration.UI; | ||
|
||
/// <summary> | ||
/// An admin panel to toggle whitelists for individual jobs or entire departments. | ||
/// This should generally be preferred to a blanket whitelist (Whitelisted: True) since | ||
/// being good with a batong doesn't mean you know engineering and vice versa. | ||
/// </summary> | ||
[GenerateTypedNameReferences] | ||
public sealed partial class JobWhitelistsWindow : FancyWindow | ||
{ | ||
[Dependency] private readonly IPrototypeManager _proto = default!; | ||
|
||
public Action<ProtoId<JobPrototype>, bool>? OnSetJob; | ||
public Action<ProtoId<GhostRolePrototype>, bool>? OnSetGhostRole; // Frontier | ||
public Action<bool>? OnSetGlobal; // Frontier | ||
|
||
public JobWhitelistsWindow() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
IoCManager.InjectDependencies(this); | ||
|
||
PlayerName.Text = "???"; | ||
InitializeTierButtons(); | ||
|
||
// Frontier: global whitelist button | ||
Global.Text = Loc.GetString("player-panel-global-whitelist"); | ||
Global.OnPressed += _ => OnSetGlobal?.Invoke(Global.Pressed); | ||
Global.Modulate = Color.FromHex("#f0c65d"); | ||
// End Frontier | ||
} | ||
|
||
private void InitializeTierButtons() | ||
{ | ||
foreach (var tier in _proto.EnumeratePrototypes<WhitelistTierPrototype>()) | ||
{ | ||
var button = new Button | ||
{ | ||
Text = Loc.GetString(tier.Name), | ||
Modulate = tier.Color | ||
}; | ||
|
||
button.OnPressed += _ => ApplyWhitelistTier(tier); | ||
TierButtons.AddChild(button); | ||
} | ||
} | ||
|
||
private void ApplyWhitelistTier(WhitelistTierPrototype tier) | ||
{ | ||
foreach (var jobId in tier.Jobs) | ||
{ | ||
OnSetJob?.Invoke(jobId, true); | ||
} | ||
|
||
// Frontier: ghost role prototypes | ||
foreach (var ghostRoleId in tier.GhostRoles) | ||
{ | ||
OnSetGhostRole?.Invoke(ghostRoleId, true); | ||
} | ||
// End Frontier | ||
} | ||
|
||
public void HandleState(JobWhitelistsEuiState state) | ||
{ | ||
PlayerName.Text = state.PlayerName; | ||
|
||
// Frontier: global whitelist | ||
Global.Pressed = state.GlobalWhitelist; | ||
// End Frontier | ||
|
||
Departments.RemoveAllChildren(); | ||
foreach (var proto in _proto.EnumeratePrototypes<DepartmentPrototype>()) | ||
{ | ||
// Frontier: skip empty departments | ||
if (proto.Roles.Count <= 0) | ||
continue; | ||
// End Frontier | ||
|
||
var panel = new DepartmentWhitelistPanel(proto, _proto, state.Whitelists, state.GlobalWhitelist); | ||
panel.OnSetJob += (id, whitelisting) => OnSetJob?.Invoke(id, whitelisting); | ||
Departments.AddChild(panel); | ||
} | ||
// Frontier: ghost role prototypes | ||
GhostRoles.RemoveAllChildren(); | ||
List<ProtoId<GhostRolePrototype>> ghostRoles = new(); | ||
foreach (var proto in _proto.EnumeratePrototypes<GhostRolePrototype>()) | ||
{ | ||
if (proto.Whitelisted) | ||
ghostRoles.Add(proto.ID); | ||
} | ||
var ghostRolePanel = new GhostRoleSetWhitelistPanel(ghostRoles, Loc.GetString("player-panel-ghost-role-whitelists"), Color.FromHex("#71f0ca"), _proto, state.GhostRoleWhitelists, state.GlobalWhitelist); | ||
ghostRolePanel.OnSetGhostRole += (id, whitelisting) => OnSetGhostRole?.Invoke(id, whitelisting); | ||
GhostRoles.AddChild(ghostRolePanel); | ||
// End Frontier | ||
} | ||
} |
Oops, something went wrong.