save pos when closing by button (#2644)

This commit is contained in:
haiwwkes 2025-07-24 21:34:39 +05:00 committed by GitHub
parent 3e4d6999d1
commit e4a24a1bb5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 21 additions and 1 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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;
}

View file

@ -39,6 +39,11 @@ public sealed class InteractionMessage : BoundUserInterfaceMessage
}
}
[Serializable, NetSerializable]
public sealed class RequestSavePosAndCloseMessage : BoundUserInterfaceMessage
{
}
[Serializable, NetSerializable]
public sealed class CustomInteractionData
{