Admin announcement panel. (#4803)
This commit is contained in:
15
Content.Client/Administration/UI/AdminAnnounceWindow.xaml
Normal file
15
Content.Client/Administration/UI/AdminAnnounceWindow.xaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<SS14Window
|
||||||
|
xmlns="https://spacestation14.io"
|
||||||
|
Title="{Loc 'admin-announce-title'}"
|
||||||
|
MinWidth="500">
|
||||||
|
<GridContainer Columns="1">
|
||||||
|
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
|
||||||
|
<LineEdit Name="_announcer" PlaceHolder="{Loc 'announcer-placeholder'}" Text="{Loc 'Central Command'}" HorizontalExpand="True" SizeFlagsStretchRatio="2"/>
|
||||||
|
<Control HorizontalExpand="True" SizeFlagsStretchRatio="1" />
|
||||||
|
<OptionButton Name="_announceMethod" HorizontalExpand="True" SizeFlagsStretchRatio="2"/>
|
||||||
|
</BoxContainer>
|
||||||
|
<LineEdit Name="_announcement" PlaceHolder="{Loc 'announcement-placeholder'}"/>
|
||||||
|
|
||||||
|
<Button Name="_announceButton" Disabled="True" Text="{Loc 'Announce'}" HorizontalAlignment="Center"/>
|
||||||
|
</GridContainer>
|
||||||
|
</SS14Window>
|
||||||
47
Content.Client/Administration/UI/AdminAnnounceWindow.xaml.cs
Normal file
47
Content.Client/Administration/UI/AdminAnnounceWindow.xaml.cs
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
using Content.Client.HUD;
|
||||||
|
using Content.Shared.Administration;
|
||||||
|
using Robust.Client.AutoGenerated;
|
||||||
|
using Robust.Client.UserInterface.Controls;
|
||||||
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
|
using Robust.Client.UserInterface.XAML;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Localization;
|
||||||
|
|
||||||
|
namespace Content.Client.Administration.UI
|
||||||
|
{
|
||||||
|
[GenerateTypedNameReferences]
|
||||||
|
public partial class AdminAnnounceWindow : SS14Window
|
||||||
|
{
|
||||||
|
[Dependency] private readonly IGameHud? _gameHud = default!;
|
||||||
|
[Dependency] private readonly ILocalizationManager _localization = default!;
|
||||||
|
public Button AnnounceButton => _announceButton;
|
||||||
|
public OptionButton AnnounceMethod => _announceMethod;
|
||||||
|
public LineEdit Announcer => _announcer;
|
||||||
|
public LineEdit Announcement => _announcement;
|
||||||
|
|
||||||
|
public AdminAnnounceWindow()
|
||||||
|
{
|
||||||
|
RobustXamlLoader.Load(this);
|
||||||
|
IoCManager.InjectDependencies(this);
|
||||||
|
|
||||||
|
AnnounceMethod.AddItem(_localization.GetString("announce-type-station"));
|
||||||
|
AnnounceMethod.SetItemMetadata(0, AdminAnnounceType.Station);
|
||||||
|
AnnounceMethod.AddItem(_localization.GetString("announce-type-server"));
|
||||||
|
AnnounceMethod.SetItemMetadata(1, AdminAnnounceType.Server);
|
||||||
|
AnnounceMethod.OnItemSelected += AnnounceMethodOnOnItemSelected;
|
||||||
|
Announcement.OnTextChanged += AnnouncementOnOnTextChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void AnnouncementOnOnTextChanged(LineEdit.LineEditEventArgs args)
|
||||||
|
{
|
||||||
|
AnnounceButton.Disabled = args.Text.TrimStart() == "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AnnounceMethodOnOnItemSelected(OptionButton.ItemSelectedEventArgs args)
|
||||||
|
{
|
||||||
|
AnnounceMethod.SelectId(args.Id);
|
||||||
|
Announcer.Editable = ((AdminAnnounceType?)args.Button.SelectedMetadata ?? AdminAnnounceType.Station) == AdminAnnounceType.Station;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
40
Content.Client/Administration/UI/AdminMenuWindowEui.cs
Normal file
40
Content.Client/Administration/UI/AdminMenuWindowEui.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
using Content.Client.Eui;
|
||||||
|
using Content.Shared.Administration;
|
||||||
|
using Robust.Client.UserInterface.Controls;
|
||||||
|
|
||||||
|
namespace Content.Client.Administration.UI
|
||||||
|
{
|
||||||
|
public class AdminAnnounceEui : BaseEui
|
||||||
|
{
|
||||||
|
private readonly AdminAnnounceWindow _window;
|
||||||
|
|
||||||
|
public AdminAnnounceEui()
|
||||||
|
{
|
||||||
|
_window = new AdminAnnounceWindow();
|
||||||
|
_window.OnClose += () => SendMessage(new AdminAnnounceEuiMsg.Close());
|
||||||
|
_window.AnnounceButton.OnPressed += AnnounceButtonOnOnPressed;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AnnounceButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||||
|
{
|
||||||
|
SendMessage(new AdminAnnounceEuiMsg.DoAnnounce
|
||||||
|
{
|
||||||
|
Announcement = _window.Announcement.Text,
|
||||||
|
Announcer = _window.Announcer.Text,
|
||||||
|
AnnounceType = (AdminAnnounceType) (_window.AnnounceMethod.SelectedMetadata ?? AdminAnnounceType.Station),
|
||||||
|
CloseAfter = true,
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Opened()
|
||||||
|
{
|
||||||
|
_window.OpenCentered();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Closed()
|
||||||
|
{
|
||||||
|
_window.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
<cc:CommandButton Command="aghost" Text="{Loc Admin Ghost}" />
|
<cc:CommandButton Command="aghost" Text="{Loc Admin Ghost}" />
|
||||||
<cc:UICommandButton Command="tpto" Text="{Loc Teleport}" WindowType="{x:Type at:TeleportWindow}" />
|
<cc:UICommandButton Command="tpto" Text="{Loc Teleport}" WindowType="{x:Type at:TeleportWindow}" />
|
||||||
<cc:CommandButton Command="permissions" Text="{Loc Permissions Panel}" />
|
<cc:CommandButton Command="permissions" Text="{Loc Permissions Panel}" />
|
||||||
|
<cc:CommandButton Command="announceui" Text="{Loc Announce}"/>
|
||||||
</GridContainer>
|
</GridContainer>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
</Control>
|
</Control>
|
||||||
|
|||||||
33
Content.Server/Administration/Commands/AnnounceUiCommand.cs
Normal file
33
Content.Server/Administration/Commands/AnnounceUiCommand.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
using Content.Server.Administration.UI;
|
||||||
|
using Content.Server.EUI;
|
||||||
|
using Content.Shared.Administration;
|
||||||
|
using Robust.Server.Player;
|
||||||
|
using Robust.Shared.Console;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
|
||||||
|
namespace Content.Server.Administration.Commands
|
||||||
|
{
|
||||||
|
[AdminCommand(AdminFlags.Fun)]
|
||||||
|
public class AnnounceUiCommand : IConsoleCommand
|
||||||
|
{
|
||||||
|
public string Command => "announceui";
|
||||||
|
|
||||||
|
public string Description => "Opens the announcement UI";
|
||||||
|
|
||||||
|
public string Help => $"{Command}";
|
||||||
|
|
||||||
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
|
{
|
||||||
|
var player = shell.Player as IPlayerSession;
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
shell.WriteLine("This does not work from the server console.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var eui = IoCManager.Resolve<EuiManager>();
|
||||||
|
var ui = new AdminAnnounceEui();
|
||||||
|
eui.OpenEui(ui, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
63
Content.Server/Administration/UI/AdminAnnounceEui.cs
Normal file
63
Content.Server/Administration/UI/AdminAnnounceEui.cs
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
using Content.Server.Administration.Managers;
|
||||||
|
using Content.Server.Chat.Managers;
|
||||||
|
using Content.Server.EUI;
|
||||||
|
using Content.Shared.Administration;
|
||||||
|
using Content.Shared.Eui;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
|
||||||
|
namespace Content.Server.Administration.UI
|
||||||
|
{
|
||||||
|
public sealed class AdminAnnounceEui : BaseEui
|
||||||
|
{
|
||||||
|
[Dependency] private readonly IAdminManager _adminManager = default!;
|
||||||
|
[Dependency] private readonly IChatManager _chatManager = default!;
|
||||||
|
|
||||||
|
public AdminAnnounceEui()
|
||||||
|
{
|
||||||
|
IoCManager.InjectDependencies(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Opened()
|
||||||
|
{
|
||||||
|
StateDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override EuiStateBase GetNewState()
|
||||||
|
{
|
||||||
|
return new AdminAnnounceEuiState();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void HandleMessage(EuiMessageBase msg)
|
||||||
|
{
|
||||||
|
switch (msg)
|
||||||
|
{
|
||||||
|
case AdminAnnounceEuiMsg.Close:
|
||||||
|
Close();
|
||||||
|
break;
|
||||||
|
case AdminAnnounceEuiMsg.DoAnnounce doAnnounce:
|
||||||
|
if (!_adminManager.HasAdminFlag(Player, AdminFlags.Fun))
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (doAnnounce.AnnounceType)
|
||||||
|
{
|
||||||
|
case AdminAnnounceType.Server:
|
||||||
|
_chatManager.DispatchServerAnnouncement(doAnnounce.Announcement);
|
||||||
|
break;
|
||||||
|
case AdminAnnounceType.Station:
|
||||||
|
_chatManager.DispatchStationAnnouncement(doAnnounce.Announcement, doAnnounce.Announcer);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
StateDirty();
|
||||||
|
|
||||||
|
if (doAnnounce.CloseAfter)
|
||||||
|
Close();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
32
Content.Shared/Administration/AdminAnnounceEuiState.cs
Normal file
32
Content.Shared/Administration/AdminAnnounceEuiState.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using System;
|
||||||
|
using Content.Shared.Eui;
|
||||||
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
|
namespace Content.Shared.Administration
|
||||||
|
{
|
||||||
|
public enum AdminAnnounceType
|
||||||
|
{
|
||||||
|
Station,
|
||||||
|
Server,
|
||||||
|
}
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public sealed class AdminAnnounceEuiState : EuiStateBase {}
|
||||||
|
|
||||||
|
public static class AdminAnnounceEuiMsg
|
||||||
|
{
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public sealed class Close : EuiMessageBase
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public sealed class DoAnnounce : EuiMessageBase
|
||||||
|
{
|
||||||
|
public bool CloseAfter;
|
||||||
|
public string Announcer = default!;
|
||||||
|
public string Announcement = default!;
|
||||||
|
public AdminAnnounceType AnnounceType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
admin-announce-title = Make Announcement
|
||||||
|
announcer-placeholder = Announcer
|
||||||
|
announcement-placeholder = Announcement text
|
||||||
|
announce-type-station = Station
|
||||||
|
announce-type-server = Server
|
||||||
Reference in New Issue
Block a user