Skip to content

Commit

Permalink
Merge pull request #1501 from space-syndicate/upstream-sync
Browse files Browse the repository at this point in the history
Upstream sync
  • Loading branch information
Morb0 authored Oct 14, 2023
2 parents 85ea85b + f310661 commit 3947cb3
Show file tree
Hide file tree
Showing 99 changed files with 2,654 additions and 453 deletions.
8 changes: 8 additions & 0 deletions Content.Client/Administration/Managers/ClientAdminManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,13 @@ void IPostInjectInit.PostInject()

return null;
}

public AdminData? GetAdminData(bool includeDeAdmin = false)
{
if (_player.LocalPlayer is { Session: { } session })
return GetAdminData(session, includeDeAdmin);

return null;
}
}
}
24 changes: 22 additions & 2 deletions Content.Client/Administration/Managers/IClientAdminManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Content.Shared.Administration;
using Content.Shared.Administration;

namespace Content.Client.Administration.Managers
{
Expand All @@ -13,6 +12,15 @@ public interface IClientAdminManager
/// </summary>
event Action AdminStatusUpdated;

/// <summary>
/// Gets the admin data for the client, if they are an admin.
/// </summary>
/// <param name="includeDeAdmin">
/// Whether to return admin data for admins that are current de-adminned.
/// </param>
/// <returns><see langword="null" /> if the player is not an admin.</returns>
AdminData? GetAdminData(bool includeDeAdmin = false);

/// <summary>
/// Checks whether the local player is an admin.
/// </summary>
Expand Down Expand Up @@ -52,5 +60,17 @@ public interface IClientAdminManager
bool CanAdminMenu();

void Initialize();

/// <summary>
/// Checks if the client is an admin.
/// </summary>
/// <param name="includeDeAdmin">
/// Whether to return admin data for admins that are current de-adminned.
/// </param>
/// <returns>true if the player is an admin, false otherwise.</returns>
bool IsAdmin(bool includeDeAdmin = false)
{
return GetAdminData(includeDeAdmin) != null;
}
}
}
4 changes: 3 additions & 1 deletion Content.Client/Administration/UI/AdminMenuWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
xmlns:atmosTab="clr-namespace:Content.Client.Administration.UI.Tabs.AtmosTab"
xmlns:tabs="clr-namespace:Content.Client.Administration.UI.Tabs"
xmlns:playerTab="clr-namespace:Content.Client.Administration.UI.Tabs.PlayerTab"
xmlns:objectsTab="clr-namespace:Content.Client.Administration.UI.Tabs.ObjectsTab">
xmlns:objectsTab="clr-namespace:Content.Client.Administration.UI.Tabs.ObjectsTab"
xmlns:panic="clr-namespace:Content.Client.Administration.UI.Tabs.PanicBunkerTab">
<TabContainer Name="MasterTabContainer">
<adminTab:AdminTab />
<adminbusTab:AdminbusTab />
<atmosTab:AtmosTab />
<tabs:RoundTab />
<tabs:ServerTab />
<panic:PanicBunkerTab Name="PanicBunkerControl" Access="Public" />
<playerTab:PlayerTab Name="PlayerTabControl" Access="Public" />
<objectsTab:ObjectsTab Name="ObjectsTabControl" Access="Public" />
</TabContainer>
Expand Down
7 changes: 4 additions & 3 deletions Content.Client/Administration/UI/AdminMenuWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ public sealed partial class AdminMenuWindow : DefaultWindow

public AdminMenuWindow()
{
MinSize = new Vector2(600, 250); // Corvax-Resize
MinSize = new Vector2(650, 250);
Title = Loc.GetString("admin-menu-title");
RobustXamlLoader.Load(this);
MasterTabContainer.SetTabTitle(0, Loc.GetString("admin-menu-admin-tab"));
MasterTabContainer.SetTabTitle(1, Loc.GetString("admin-menu-adminbus-tab"));
MasterTabContainer.SetTabTitle(2, Loc.GetString("admin-menu-atmos-tab"));
MasterTabContainer.SetTabTitle(3, Loc.GetString("admin-menu-round-tab"));
MasterTabContainer.SetTabTitle(4, Loc.GetString("admin-menu-server-tab"));
MasterTabContainer.SetTabTitle(5, Loc.GetString("admin-menu-players-tab"));
MasterTabContainer.SetTabTitle(6, Loc.GetString("admin-menu-objects-tab"));
MasterTabContainer.SetTabTitle(5, Loc.GetString("admin-menu-panic-bunker-tab"));
MasterTabContainer.SetTabTitle(6, Loc.GetString("admin-menu-players-tab"));
MasterTabContainer.SetTabTitle(7, Loc.GetString("admin-menu-objects-tab"));
}

protected override void Dispose(bool disposing)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<controls:PanicBunkerStatusWindow
xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.Administration.UI.Tabs.PanicBunkerTab"
Title="{Loc admin-ui-panic-bunker-window-title}">
<Label Name="MessageLabel" Access="Public" Text="{Loc admin-ui-panic-bunker-is-enabled}" />
</controls:PanicBunkerStatusWindow>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client.Administration.UI.Tabs.PanicBunkerTab;

[GenerateTypedNameReferences]
public sealed partial class PanicBunkerStatusWindow : DefaultWindow
{
public PanicBunkerStatusWindow()
{
RobustXamlLoader.Load(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<controls:PanicBunkerTab
xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.Administration.UI.Tabs.PanicBunkerTab"
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
Margin="4">
<BoxContainer Orientation="Vertical">
<cc:CommandButton Name="EnabledButton" Command="panicbunker" ToggleMode="True"
Text="{Loc admin-ui-panic-bunker-disabled}"
ToolTip="{Loc admin-ui-panic-bunker-tooltip}" />
<BoxContainer Orientation="Horizontal">
<cc:CommandButton Name="DisableAutomaticallyButton" HorizontalExpand="True"
Command="panicbunker_disable_with_admins"
ToggleMode="True"
Text="{Loc admin-ui-panic-bunker-disable-automatically}"
ToolTip="{Loc admin-ui-panic-bunker-disable-automatically-tooltip}" />
<cc:CommandButton Name="EnableAutomaticallyButton" HorizontalExpand="True"
Command="panicbunker_enable_without_admins"
ToggleMode="True"
Text="{Loc admin-ui-panic-bunker-enable-automatically}"
ToolTip="{Loc admin-ui-panic-bunker-enable-automatically-tooltip}" />
<cc:CommandButton Name="CountDeadminnedButton" HorizontalExpand="True"
Command="panicbunker_count_deadminned_admins"
ToggleMode="True"
Text="{Loc admin-ui-panic-bunker-count-deadminned-admins}"
ToolTip="{Loc admin-ui-panic-bunker-count-deadminned-admins-tooltip}" />
</BoxContainer>
<cc:CommandButton Name="ShowReasonButton" Command="panicbunker_show_reason"
ToggleMode="True" Text="{Loc admin-ui-panic-bunker-show-reason}"
ToolTip="{Loc admin-ui-panic-bunker-show-reason-tooltip}" />
<BoxContainer Orientation="Vertical" Margin="0 10 0 0">
<BoxContainer Orientation="Horizontal" Margin="2">
<Label Text="{Loc admin-ui-panic-bunker-min-account-age}" MinWidth="175" />
<LineEdit Name="MinAccountAge" MinWidth="50" Margin="0 0 5 0" />
<Label Text="{Loc generic-hours}" />
</BoxContainer>
<BoxContainer Orientation="Horizontal" Margin="2">
<Label Text="{Loc admin-ui-panic-bunker-min-overall-hours}" MinWidth="175" />
<LineEdit Name="MinOverallHours" MinWidth="50" Margin="0 0 5 0" />
<Label Text="{Loc generic-hours}" />
</BoxContainer>
</BoxContainer>
</BoxContainer>
</controls:PanicBunkerTab>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Content.Shared.Administration.Events;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Console;

namespace Content.Client.Administration.UI.Tabs.PanicBunkerTab;

[GenerateTypedNameReferences]
public sealed partial class PanicBunkerTab : Control
{
[Dependency] private readonly IConsoleHost _console = default!;

public PanicBunkerTab()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

DisableAutomaticallyButton.ToolTip = Loc.GetString("admin-ui-panic-bunker-disable-automatically-tooltip");

MinAccountAge.OnTextEntered += args =>
{
if (string.IsNullOrWhiteSpace(args.Text) || !int.TryParse(args.Text, out var minutes))
return;

_console.ExecuteCommand($"panicbunker_min_account_age {minutes}");
};

MinOverallHours.OnTextEntered += args =>
{
if (string.IsNullOrWhiteSpace(args.Text) || !int.TryParse(args.Text, out var hours))
return;

_console.ExecuteCommand($"panicbunker_min_overall_hours {hours}");
};
}

public void UpdateStatus(PanicBunkerStatus status)
{
EnabledButton.Pressed = status.Enabled;
EnabledButton.Text = Loc.GetString(status.Enabled
? "admin-ui-panic-bunker-enabled"
: "admin-ui-panic-bunker-disabled"
);
EnabledButton.ModulateSelfOverride = status.Enabled ? Color.Red : null;

DisableAutomaticallyButton.Pressed = status.DisableWithAdmins;
EnableAutomaticallyButton.Pressed = status.EnableWithoutAdmins;
CountDeadminnedButton.Pressed = status.CountDeadminnedAdmins;
ShowReasonButton.Pressed = status.ShowReason;
MinAccountAge.Text = status.MinAccountAgeHours.ToString();
MinOverallHours.Text = status.MinOverallHours.ToString();
}
}
1 change: 0 additions & 1 deletion Content.Client/Administration/UI/Tabs/ServerTab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
<cc:CommandButton Command="shutdown" Text="{Loc server-shutdown}" />
<cc:CommandButton Name="SetOocButton" Command="setooc" Text="{Loc server-ooc-toggle}" ToggleMode="True" />
<cc:CommandButton Name="SetLoocButton" Command="setlooc" Text="{Loc server-looc-toggle}" ToggleMode="True" />
<cc:CommandButton Name="SetPanicbunkerButton" Command="panicbunker" Text="{Loc server-panicbunker-toggle}" ToggleMode="True" />
</GridContainer>
</Control>
7 changes: 0 additions & 7 deletions Content.Client/Administration/UI/Tabs/ServerTab.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public ServerTab()

_config.OnValueChanged(CCVars.OocEnabled, OocEnabledChanged, true);
_config.OnValueChanged(CCVars.LoocEnabled, LoocEnabledChanged, true);
_config.OnValueChanged(CCVars.PanicBunkerEnabled, BunkerEnabledChanged, true);
}

private void OocEnabledChanged(bool value)
Expand All @@ -31,11 +30,6 @@ private void LoocEnabledChanged(bool value)
SetLoocButton.Pressed = value;
}

private void BunkerEnabledChanged(bool value)
{
SetPanicbunkerButton.Pressed = value;
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
Expand All @@ -44,7 +38,6 @@ protected override void Dispose(bool disposing)
{
_config.UnsubValueChanged(CCVars.OocEnabled, OocEnabledChanged);
_config.UnsubValueChanged(CCVars.LoocEnabled, LoocEnabledChanged);
_config.UnsubValueChanged(CCVars.PanicBunkerEnabled, BunkerEnabledChanged);
}
}
}
Expand Down
Loading

0 comments on commit 3947cb3

Please sign in to comment.