diff --git a/Content.Client/Administration/Managers/ClientAdminManager.cs b/Content.Client/Administration/Managers/ClientAdminManager.cs index d33761be8f2..fdd62fb6a2d 100644 --- a/Content.Client/Administration/Managers/ClientAdminManager.cs +++ b/Content.Client/Administration/Managers/ClientAdminManager.cs @@ -2,6 +2,7 @@ using Content.Shared.Administration.Managers; using Robust.Client.Console; using Robust.Client.Player; +using Robust.Client.UserInterface; using Robust.Shared.ContentPack; using Robust.Shared.Network; using Robust.Shared.Player; @@ -16,6 +17,7 @@ public sealed class ClientAdminManager : IClientAdminManager, IClientConGroupImp [Dependency] private readonly IClientConGroupController _conGroup = default!; [Dependency] private readonly IResourceManager _res = default!; [Dependency] private readonly ILogManager _logManager = default!; + [Dependency] private readonly IUserInterfaceManager _userInterface = default!; private AdminData? _adminData; private readonly HashSet _availableCommands = new(); @@ -101,6 +103,9 @@ private void UpdateMessageRx(MsgUpdateAdminStatus message) { var flagsText = string.Join("|", AdminFlagsHelper.FlagsToNames(_adminData.Flags)); _sawmill.Info($"Updated admin status: {_adminData.Active}/{_adminData.Title}/{flagsText}"); + + if (_adminData.Active) + _userInterface.DebugMonitors.SetMonitor(DebugMonitor.Coords, true); } else { diff --git a/Content.Client/Administration/Systems/BwoinkSystem.cs b/Content.Client/Administration/Systems/BwoinkSystem.cs index eafd40cc9c3..5166dc8416b 100644 --- a/Content.Client/Administration/Systems/BwoinkSystem.cs +++ b/Content.Client/Administration/Systems/BwoinkSystem.cs @@ -19,11 +19,11 @@ protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySes OnBwoinkTextMessageRecieved?.Invoke(this, message); } - public void Send(NetUserId channelId, string text) + public void Send(NetUserId channelId, string text, bool playSound) { // Reuse the channel ID as the 'true sender'. // Server will ignore this and if someone makes it not ignore this (which is bad, allows impersonation!!!), that will help. - RaiseNetworkEvent(new BwoinkTextMessage(channelId, channelId, text)); + RaiseNetworkEvent(new BwoinkTextMessage(channelId, channelId, text, playSound: playSound)); SendInputTextUpdated(channelId, false); } diff --git a/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml b/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml index e5269c027a9..39ea50edbef 100644 --- a/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml +++ b/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml @@ -7,6 +7,8 @@ + + - - - diff --git a/Content.Client/MassMedia/Ui/NewsWriteMenu.xaml.cs b/Content.Client/MassMedia/Ui/NewsWriteMenu.xaml.cs deleted file mode 100644 index 89ab1490af3..00000000000 --- a/Content.Client/MassMedia/Ui/NewsWriteMenu.xaml.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Robust.Client.AutoGenerated; -using Robust.Client.UserInterface.CustomControls; -using Robust.Client.UserInterface.XAML; -using Robust.Shared.Prototypes; -using Content.Shared.MassMedia.Systems; - -namespace Content.Client.MassMedia.Ui; - -[GenerateTypedNameReferences] -public sealed partial class NewsWriteMenu : DefaultWindow -{ - public event Action? ShareButtonPressed; - public event Action? DeleteButtonPressed; - - public NewsWriteMenu(string name) - { - RobustXamlLoader.Load(this); - IoCManager.InjectDependencies(this); - - if (Window != null) - Window.Title = name; - - Share.OnPressed += _ => ShareButtonPressed?.Invoke(); - } - - public void UpdateUI(NewsArticle[] articles, bool shareAvalible) - { - ArticleCardsContainer.Children.Clear(); - - for (int i = 0; i < articles.Length; i++) - { - var article = articles[i]; - var mini = new MiniArticleCardControl(article.Name, (article.Author != null ? article.Author : Loc.GetString("news-read-ui-no-author"))); - mini.ArticleNum = i; - mini.OnDeletePressed += () => DeleteButtonPressed?.Invoke(mini.ArticleNum); - - ArticleCardsContainer.AddChild(mini); - } - - Share.Disabled = !shareAvalible; - } -} diff --git a/Content.Client/MassMedia/Ui/NewsWriterBoundUserInterface.cs b/Content.Client/MassMedia/Ui/NewsWriterBoundUserInterface.cs new file mode 100644 index 00000000000..80eca82e324 --- /dev/null +++ b/Content.Client/MassMedia/Ui/NewsWriterBoundUserInterface.cs @@ -0,0 +1,84 @@ +using JetBrains.Annotations; +using Content.Shared.MassMedia.Systems; +using Content.Shared.MassMedia.Components; +using Robust.Shared.Timing; +using Robust.Shared.Utility; + +namespace Content.Client.MassMedia.Ui; + +[UsedImplicitly] +public sealed class NewsWriterBoundUserInterface : BoundUserInterface +{ + [Dependency] private readonly IGameTiming _gameTiming = default!; + + [ViewVariables] + private NewsWriterMenu? _menu; + + public NewsWriterBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) + { + + } + + protected override void Open() + { + _menu = new NewsWriterMenu(_gameTiming); + + _menu.OpenCentered(); + _menu.OnClose += Close; + + _menu.ArticleEditorPanel.PublishButtonPressed += OnPublishButtonPressed; + _menu.DeleteButtonPressed += OnDeleteButtonPressed; + + SendMessage(new NewsWriterArticlesRequestMessage()); + } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + if (!disposing) + return; + + _menu?.Close(); + _menu?.Dispose(); + } + + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + if (state is not NewsWriterBoundUserInterfaceState cast) + return; + + _menu?.UpdateUI(cast.Articles, cast.PublishEnabled, cast.NextPublish); + } + + private void OnPublishButtonPressed() + { + var title = _menu?.ArticleEditorPanel.TitleField.Text.Trim() ?? ""; + if (_menu == null || title.Length == 0) + return; + + var stringContent = Rope.Collapse(_menu.ArticleEditorPanel.ContentField.TextRope).Trim(); + + if (stringContent.Length == 0) + return; + + var name = title.Length <= SharedNewsSystem.MaxTitleLength + ? title + : $"{title[..(SharedNewsSystem.MaxTitleLength - 3)]}..."; + + var content = stringContent.Length <= SharedNewsSystem.MaxContentLength + ? stringContent + : $"{stringContent[..(SharedNewsSystem.MaxContentLength - 3)]}..."; + + + SendMessage(new NewsWriterPublishMessage(name, content)); + } + + private void OnDeleteButtonPressed(int articleNum) + { + if (_menu == null) + return; + + SendMessage(new NewsWriterDeleteMessage(articleNum)); + } +} diff --git a/Content.Client/MassMedia/Ui/NewsWriterMenu.xaml b/Content.Client/MassMedia/Ui/NewsWriterMenu.xaml new file mode 100644 index 00000000000..64932bc6cfe --- /dev/null +++ b/Content.Client/MassMedia/Ui/NewsWriterMenu.xaml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + +