diff --git a/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml b/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml
new file mode 100644
index 0000000000..89e5694b0d
--- /dev/null
+++ b/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Content.Client/Administration/UI/BwoinkWindow.xaml.cs b/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml.cs
similarity index 89%
rename from Content.Client/Administration/UI/BwoinkWindow.xaml.cs
rename to Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml.cs
index 7b80b6d536..86509ad096 100644
--- a/Content.Client/Administration/UI/BwoinkWindow.xaml.cs
+++ b/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml.cs
@@ -1,4 +1,4 @@
-using System.Text;
+using System.Text;
using System.Threading;
using Content.Client.Administration.Managers;
using Content.Client.Administration.UI.CustomControls;
@@ -16,27 +16,33 @@ using Robust.Shared.Network;
using Robust.Shared.Utility;
using Timer = Robust.Shared.Timing.Timer;
-namespace Content.Client.Administration.UI
+namespace Content.Client.Administration.UI.Bwoink
{
///
/// This window connects to a BwoinkSystem channel. BwoinkSystem manages the rest.
///
[GenerateTypedNameReferences]
- public sealed partial class BwoinkWindow : DefaultWindow
+ public sealed partial class BwoinkControl : Control
{
[Dependency] private readonly IClientAdminManager _adminManager = default!;
[Dependency] private readonly IClientConsoleHost _console = default!;
- private readonly AdminAHelpUIHandler _adminAHelpHelper;
+ [Dependency] private readonly IUserInterfaceManager _ui = default!;
+ public AdminAHelpUIHandler AHelpHelper = default!;
//private readonly BwoinkSystem _bwoinkSystem;
private PlayerInfo? _currentPlayer = default;
- public BwoinkWindow(AdminAHelpUIHandler adminAHelpHelper)
+ public BwoinkControl()
{
- _adminAHelpHelper = adminAHelpHelper;
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
+ var uiController = _ui.GetUIController();
+ if (uiController.UIHelper is not AdminAHelpUIHandler helper)
+ return;
+
+ AHelpHelper = helper;
+
_adminManager.AdminStatusUpdated += FixButtons;
FixButtons();
@@ -46,7 +52,6 @@ namespace Content.Client.Administration.UI
if (sel is not null)
{
SwitchToChannel(sel.SessionId);
- Title = $"{sel.CharacterName} / {sel.Username}";
}
ChannelSelector.PlayerListContainer.DirtyList();
@@ -62,7 +67,7 @@ namespace Content.Client.Administration.UI
sb.Append(info.ActiveThisRound ? '○' : '·');
sb.Append(' ');
- if (_adminAHelpHelper.TryGetChannel(info.SessionId, out var panel) && panel.Unread > 0)
+ if (AHelpHelper.TryGetChannel(info.SessionId, out var panel) && panel.Unread > 0)
{
if (panel.Unread < 11)
sb.Append(new Rune('➀' + (panel.Unread-1)));
@@ -81,8 +86,8 @@ namespace Content.Client.Administration.UI
ChannelSelector.Comparison = (a, b) =>
{
- var ach = _adminAHelpHelper.EnsurePanel(a.SessionId);
- var bch = _adminAHelpHelper.EnsurePanel(b.SessionId);
+ var ach = AHelpHelper.EnsurePanel(a.SessionId);
+ var bch = AHelpHelper.EnsurePanel(b.SessionId);
// First, sort by unread. Any chat with unread messages appears first. We just sort based on unread
// status, not number of unread messages, so that more recent unread messages take priority.
@@ -153,7 +158,10 @@ namespace Content.Client.Administration.UI
_console.ExecuteCommand($"respawn \"{_currentPlayer.Username}\"");
};
- OnOpen += () => ChannelSelector.PopulateList();
+ PopOut.OnPressed += _ =>
+ {
+ uiController.PopOut();
+ };
}
private Dictionary Confirmations { get; } = new();
@@ -199,7 +207,7 @@ namespace Content.Client.Administration.UI
var sb = new StringBuilder();
sb.Append(pl.Connected ? '●' : '○');
sb.Append(' ');
- if (_adminAHelpHelper.TryGetChannel(pl.SessionId, out var panel) && panel.Unread > 0)
+ if (AHelpHelper.TryGetChannel(pl.SessionId, out var panel) && panel.Unread > 0)
{
if (panel.Unread < 11)
sb.Append(new Rune('➀' + (panel.Unread-1)));
@@ -225,7 +233,7 @@ namespace Content.Client.Administration.UI
{
foreach (var bw in BwoinkArea.Children)
bw.Visible = false;
- var panel = _adminAHelpHelper.EnsurePanel(ch);
+ var panel = AHelpHelper.EnsurePanel(ch);
panel.Visible = true;
}
diff --git a/Content.Client/Administration/UI/CustomControls/BwoinkPanel.xaml b/Content.Client/Administration/UI/Bwoink/BwoinkPanel.xaml
similarity index 100%
rename from Content.Client/Administration/UI/CustomControls/BwoinkPanel.xaml
rename to Content.Client/Administration/UI/Bwoink/BwoinkPanel.xaml
diff --git a/Content.Client/Administration/UI/CustomControls/BwoinkPanel.xaml.cs b/Content.Client/Administration/UI/Bwoink/BwoinkPanel.xaml.cs
similarity index 87%
rename from Content.Client/Administration/UI/CustomControls/BwoinkPanel.xaml.cs
rename to Content.Client/Administration/UI/Bwoink/BwoinkPanel.xaml.cs
index 16edcc1270..f545aff422 100644
--- a/Content.Client/Administration/UI/CustomControls/BwoinkPanel.xaml.cs
+++ b/Content.Client/Administration/UI/Bwoink/BwoinkPanel.xaml.cs
@@ -1,15 +1,11 @@
-#nullable enable
-using System;
-using Content.Client.Administration.Systems;
-using Content.Client.UserInterface.Systems.Bwoink;
using Content.Shared.Administration;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
-using Robust.Shared.Network;
using Robust.Shared.Utility;
+using Content.Client.Administration.UI.CustomControls;
-namespace Content.Client.Administration.UI.CustomControls
+namespace Content.Client.Administration.UI.Bwoink
{
[GenerateTypedNameReferences]
public sealed partial class BwoinkPanel : BoxContainer
diff --git a/Content.Client/Administration/UI/Bwoink/BwoinkWindow.xaml b/Content.Client/Administration/UI/Bwoink/BwoinkWindow.xaml
new file mode 100644
index 0000000000..4e0156d7a0
--- /dev/null
+++ b/Content.Client/Administration/UI/Bwoink/BwoinkWindow.xaml
@@ -0,0 +1,8 @@
+
+
+
diff --git a/Content.Client/Administration/UI/Bwoink/BwoinkWindow.xaml.cs b/Content.Client/Administration/UI/Bwoink/BwoinkWindow.xaml.cs
new file mode 100644
index 0000000000..58217052b4
--- /dev/null
+++ b/Content.Client/Administration/UI/Bwoink/BwoinkWindow.xaml.cs
@@ -0,0 +1,42 @@
+using System.Text;
+using System.Threading;
+using Content.Client.Administration.Managers;
+using Content.Client.Administration.UI.CustomControls;
+using Content.Client.Administration.UI.Tabs.AdminTab;
+using Content.Client.Stylesheets;
+using Content.Client.UserInterface.Systems.Bwoink;
+using Content.Shared.Administration;
+using Robust.Client.AutoGenerated;
+using Robust.Client.Console;
+using Robust.Client.UserInterface;
+using Robust.Client.UserInterface.Controls;
+using Robust.Client.UserInterface.CustomControls;
+using Robust.Client.UserInterface.XAML;
+using Robust.Shared.Network;
+using Robust.Shared.Utility;
+using Timer = Robust.Shared.Timing.Timer;
+
+namespace Content.Client.Administration.UI.Bwoink
+{
+ ///
+ /// This window connects to a BwoinkSystem channel. BwoinkSystem manages the rest.
+ ///
+ [GenerateTypedNameReferences]
+ public sealed partial class BwoinkWindow : DefaultWindow
+ {
+ public BwoinkWindow()
+ {
+ RobustXamlLoader.Load(this);
+
+ Bwoink.ChannelSelector.OnSelectionChanged += sel =>
+ {
+ if (sel is not null)
+ {
+ Title = $"{sel.CharacterName} / {sel.Username}";
+ }
+ };
+
+ OnOpen += () => Bwoink.ChannelSelector.PopulateList();
+ }
+ }
+}
diff --git a/Content.Client/Administration/UI/BwoinkWindow.xaml b/Content.Client/Administration/UI/BwoinkWindow.xaml
deleted file mode 100644
index 5b40e57513..0000000000
--- a/Content.Client/Administration/UI/BwoinkWindow.xaml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Content.Client/UserInterface/Systems/Bwoink/AHelpUIController.cs b/Content.Client/UserInterface/Systems/Bwoink/AHelpUIController.cs
index 7bdbc0b576..8522cf0e37 100644
--- a/Content.Client/UserInterface/Systems/Bwoink/AHelpUIController.cs
+++ b/Content.Client/UserInterface/Systems/Bwoink/AHelpUIController.cs
@@ -1,7 +1,9 @@
using System.Diagnostics.CodeAnalysis;
+using System.Linq;
using Content.Client.Administration.Managers;
using Content.Client.Administration.Systems;
using Content.Client.Administration.UI;
+using Content.Client.Administration.UI.Bwoink;
using Content.Client.Administration.UI.CustomControls;
using Content.Client.Gameplay;
using Content.Client.UserInterface.Controls;
@@ -11,6 +13,7 @@ using Content.Shared.Input;
using JetBrains.Annotations;
using Robust.Client.Graphics;
using Robust.Client.Player;
+using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controllers;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
@@ -19,6 +22,7 @@ using Robust.Shared.Input.Binding;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Utility;
+using BwoinkPanel = Content.Client.Administration.UI.Bwoink.BwoinkPanel;
namespace Content.Client.UserInterface.Systems.Bwoink;
@@ -28,13 +32,14 @@ public sealed class AHelpUIController: UIController, IOnStateChanged UIManager.GetActiveUIWidgetOrNull()?.AHelpButton;
- private IAHelpUIHandler? _uiHelper;
+ public IAHelpUIHandler? UIHelper;
public void OnStateEntered(GameplayState state)
{
- DebugTools.Assert(_uiHelper == null);
+ DebugTools.Assert(UIHelper == null);
_adminManager.AdminStatusUpdated += OnAdminStatusUpdated;
CommandBinds.Builder
@@ -65,23 +70,24 @@ public sealed class AHelpUIController: UIController, IOnStateChanged();
}
public void OnSystemLoaded(BwoinkSystem system)
@@ -120,33 +126,33 @@ public sealed class AHelpUIController: UIController, IOnStateChanged _bwoinkSystem?.Send(userId, textMessage);
- _uiHelper.OnClose += () => { SetAHelpPressed(false); };
- _uiHelper.OnOpen += () => { SetAHelpPressed(true); };
- SetAHelpPressed(_uiHelper.IsOpen);
+ UIHelper.SendMessageAction = (userId, textMessage) => _bwoinkSystem?.Send(userId, textMessage);
+ UIHelper.OnClose += () => { SetAHelpPressed(false); };
+ UIHelper.OnOpen += () => { SetAHelpPressed(true); };
+ SetAHelpPressed(UIHelper.IsOpen);
}
public void Close()
{
- _uiHelper?.Close();
+ UIHelper?.Close();
}
public void Open()
@@ -157,24 +163,63 @@ public sealed class AHelpUIController: UIController, IOnStateChanged _activePanelMap = new();
public bool IsAdmin => true;
- public bool IsOpen => _window is { Disposed: false, IsOpen: true };
- private BwoinkWindow? _window;
+ public bool IsOpen => Window is { Disposed: false, IsOpen: true } || ClydeWindow is { IsDisposed: false };
+
+ public BwoinkWindow? Window;
+ public WindowRoot? WindowRoot;
+ public IClydeWindow? ClydeWindow;
+ public BwoinkControl? Control;
public void Receive(SharedBwoinkSystem.BwoinkTextMessage message)
{
- var window = EnsurePanel(message.UserId);
- window.ReceiveLine(message);
- _window?.OnBwoink(message.UserId);
+ var panel = EnsurePanel(message.UserId);
+ panel.ReceiveLine(message);
+ Control?.OnBwoink(message.UserId);
}
public void Close()
{
- _window?.Close();
+ Window?.Close();
+
+ // popped-out window is being closed
+ if (ClydeWindow != null)
+ {
+ ClydeWindow.RequestClosed -= OnRequestClosed;
+ ClydeWindow.Dispose();
+ // need to dispose control cause we cant reattach it directly back to the window
+ // but orphan panels first so -they- can get readded when the window is opened again
+ if (Control != null)
+ {
+ foreach (var (_, panel) in _activePanelMap)
+ {
+ panel.Orphan();
+ }
+ Control?.Dispose();
+ }
+ // window wont be closed here so we will invoke ourselves
+ OnClose?.Invoke();
+ }
}
public void ToggleWindow()
{
EnsurePanel(_ownerId);
- if (_window!.IsOpen)
+ if (IsOpen)
{
- _window.Close();
+ Close();
}
else
{
- _window.OpenCentered();
+ Window!.OpenCentered();
}
}
@@ -231,28 +299,46 @@ public sealed class AdminAHelpUIHandler : IAHelpUIHandler
public void Open(NetUserId channelId)
{
SelectChannel(channelId);
- _window?.OpenCentered();
+ Window?.OpenCentered();
}
- private void EnsureWindow()
+ public void OnRequestClosed(WindowRequestClosedEventArgs args)
{
- if (_window is { Disposed: false })
- return;
- _window = new BwoinkWindow(this);
- _window.OnClose += () => { OnClose?.Invoke(); };
- _window.OnOpen += () => { OnOpen?.Invoke(); };
+ Close();
}
+
+ private void EnsureControl()
+ {
+ if (Control is { Disposed: false })
+ return;
+
+ Window = new BwoinkWindow();
+ Control = Window.Bwoink;
+ Window.OnClose += () => { OnClose?.Invoke(); };
+ Window.OnOpen += () => { OnOpen?.Invoke(); };
+
+ // need to readd any unattached panels..
+ foreach (var (_, panel) in _activePanelMap)
+ {
+ if (!Control!.BwoinkArea.Children.Contains(panel))
+ {
+ Control!.BwoinkArea.AddChild(panel);
+ }
+ panel.Visible = false;
+ }
+ }
+
public BwoinkPanel EnsurePanel(NetUserId channelId)
{
- EnsureWindow();
+ EnsureControl();
if (_activePanelMap.TryGetValue(channelId, out var existingPanel))
return existingPanel;
_activePanelMap[channelId] = existingPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(channelId, text));
existingPanel.Visible = false;
- if (!_window!.BwoinkArea.Children.Contains(existingPanel))
- _window.BwoinkArea.AddChild(existingPanel);
+ if (!Control!.BwoinkArea.Children.Contains(existingPanel))
+ Control.BwoinkArea.AddChild(existingPanel);
return existingPanel;
}
@@ -261,13 +347,14 @@ public sealed class AdminAHelpUIHandler : IAHelpUIHandler
private void SelectChannel(NetUserId uid)
{
EnsurePanel(uid);
- _window!.SelectChannel(uid);
+ Control!.SelectChannel(uid);
}
public void Dispose()
{
- _window?.Dispose();
- _window = null;
+ Window?.Dispose();
+ Window = null;
+ Control = null;
_activePanelMap.Clear();
}
}
@@ -309,6 +396,11 @@ public sealed class UserAHelpUIHandler : IAHelpUIHandler
}
}
+ // user can't pop out their window.
+ public void PopOut()
+ {
+ }
+
public event Action? OnClose;
public event Action? OnOpen;
public Action? SendMessageAction { get; set; }