From adcbe8d0be2ccdc76dd5e17af0206c623786874b Mon Sep 17 00:00:00 2001 From: Winkarst-cpu <74284083+Winkarst-cpu@users.noreply.github.com> Date: Thu, 11 Jul 2024 03:24:37 +0300 Subject: [PATCH] Character menu asks if you want to save your character on exit (#29875) * Character menu asks if you want to save your character on exit * Fix * Another fix, little mistake by me * Update Content.Client/Lobby/UI/CharacterSetupGuiSavePanel.xaml.cs --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> --- Content.Client/Lobby/LobbyUIController.cs | 55 +++++++++++++++++-- .../Lobby/UI/CharacterSetupGuiSavePanel.xaml | 10 ++++ .../UI/CharacterSetupGuiSavePanel.xaml.cs | 21 +++++++ .../Lobby/UI/HumanoidProfileEditor.xaml.cs | 2 +- .../preferences/ui/character-setup-gui.ftl | 5 ++ 5 files changed, 86 insertions(+), 7 deletions(-) create mode 100644 Content.Client/Lobby/UI/CharacterSetupGuiSavePanel.xaml create mode 100644 Content.Client/Lobby/UI/CharacterSetupGuiSavePanel.xaml.cs diff --git a/Content.Client/Lobby/LobbyUIController.cs b/Content.Client/Lobby/LobbyUIController.cs index e4a13ed8c6..824a842d56 100644 --- a/Content.Client/Lobby/LobbyUIController.cs +++ b/Content.Client/Lobby/LobbyUIController.cs @@ -46,6 +46,7 @@ public sealed class LobbyUIController : UIController, IOnStateEntered /// This is the characher preview panel in the chat. This should only update if their character updates. @@ -214,6 +215,46 @@ public sealed class LobbyUIController : UIController, IOnStateEntered + { + SaveProfile(); + + _savePanel.Close(); + + CloseProfileEditor(); + }; + + _savePanel.NoSaveButton.OnPressed += _ => + { + _savePanel.Close(); + + CloseProfileEditor(); + }; + + _savePanel.OpenCentered(); + } + private (CharacterSetupGui, HumanoidProfileEditor) EnsureGui() { if (_characterSetup != null && _profileEditor != null) @@ -240,14 +281,16 @@ public sealed class LobbyUIController : UIController, IOnStateEntered { - // Reset sliders etc. - _profileEditor.SetProfile(null, null); - _profileEditor.Visible = false; - - if (_stateManager.CurrentState is LobbyState lobbyGui) + // Open the save panel if we have unsaved changes. + if (_profileEditor.Profile != null && _profileEditor.IsDirty) { - lobbyGui.SwitchState(LobbyGui.LobbyGuiState.Default); + OpenSavePanel(); + + return; } + + // Reset sliders etc. + CloseProfileEditor(); }; _profileEditor.Save += SaveProfile; diff --git a/Content.Client/Lobby/UI/CharacterSetupGuiSavePanel.xaml b/Content.Client/Lobby/UI/CharacterSetupGuiSavePanel.xaml new file mode 100644 index 0000000000..2dcf914353 --- /dev/null +++ b/Content.Client/Lobby/UI/CharacterSetupGuiSavePanel.xaml @@ -0,0 +1,10 @@ + + + +