From e4a24a1bb5529b32ddae45bec2f57092093f505c Mon Sep 17 00:00:00 2001 From: haiwwkes <49613070+rhailrake@users.noreply.github.com> Date: Thu, 24 Jul 2025 21:34:39 +0500 Subject: [PATCH] save pos when closing by button (#2644) --- .../InteractionsPanel/InteractionsUIWindow.xaml.cs | 7 +++++++ .../InteractionsUIWindowBoundUserInterface.cs | 8 ++++++++ .../InteractionsPanel/InteractionsPanel.Interactions.cs | 2 +- Content.Shared/_Sunrise/InteractionsPanel/Data/UI/BUI.cs | 5 +++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Content.Client/_Sunrise/InteractionsPanel/InteractionsUIWindow.xaml.cs b/Content.Client/_Sunrise/InteractionsPanel/InteractionsUIWindow.xaml.cs index ccc193f143..c4e64ce904 100644 --- a/Content.Client/_Sunrise/InteractionsPanel/InteractionsUIWindow.xaml.cs +++ b/Content.Client/_Sunrise/InteractionsPanel/InteractionsUIWindow.xaml.cs @@ -131,6 +131,13 @@ public sealed partial class InteractionsUIWindow : DefaultWindow base.Close(); } + public void SavePos() + { + _cfg.SetCVar(InteractionsCVars.WindowPosX, (int)Position.X); + _cfg.SetCVar(InteractionsCVars.WindowPosY, (int)Position.Y); + _cfg.SaveToFile(); + } + private bool IsInteractionOnCooldown(string interactionId) { var userEntity = _owner?.Owner ?? default; diff --git a/Content.Client/_Sunrise/InteractionsPanel/InteractionsUIWindowBoundUserInterface.cs b/Content.Client/_Sunrise/InteractionsPanel/InteractionsUIWindowBoundUserInterface.cs index 267b369df9..2bf5fe08d0 100644 --- a/Content.Client/_Sunrise/InteractionsPanel/InteractionsUIWindowBoundUserInterface.cs +++ b/Content.Client/_Sunrise/InteractionsPanel/InteractionsUIWindowBoundUserInterface.cs @@ -36,6 +36,14 @@ public sealed class InteractionsWindowBoundUserInterface : BoundUserInterface } + protected override void ReceiveMessage(BoundUserInterfaceMessage message) + { + if (message is RequestSavePosAndCloseMessage save) + { + _slave?.Close(); + } + } + protected override void UpdateState(BoundUserInterfaceState state) { base.UpdateState(state); diff --git a/Content.Server/_Sunrise/InteractionsPanel/InteractionsPanel.Interactions.cs b/Content.Server/_Sunrise/InteractionsPanel/InteractionsPanel.Interactions.cs index d5eead5494..503be0cc89 100644 --- a/Content.Server/_Sunrise/InteractionsPanel/InteractionsPanel.Interactions.cs +++ b/Content.Server/_Sunrise/InteractionsPanel/InteractionsPanel.Interactions.cs @@ -51,7 +51,7 @@ public partial class InteractionsPanel if (_ui.IsUiOpen(player, InteractionWindowUiKey.Key)) { - _ui.CloseUi(player, InteractionWindowUiKey.Key); + _ui.ServerSendUiMessage(player, InteractionWindowUiKey.Key, new RequestSavePosAndCloseMessage()); return; } diff --git a/Content.Shared/_Sunrise/InteractionsPanel/Data/UI/BUI.cs b/Content.Shared/_Sunrise/InteractionsPanel/Data/UI/BUI.cs index 882dd9386e..47ba130889 100644 --- a/Content.Shared/_Sunrise/InteractionsPanel/Data/UI/BUI.cs +++ b/Content.Shared/_Sunrise/InteractionsPanel/Data/UI/BUI.cs @@ -39,6 +39,11 @@ public sealed class InteractionMessage : BoundUserInterfaceMessage } } +[Serializable, NetSerializable] +public sealed class RequestSavePosAndCloseMessage : BoundUserInterfaceMessage +{ +} + [Serializable, NetSerializable] public sealed class CustomInteractionData {