From: Winkarst-cpu <74284083+Winkarst-cpu@users.noreply.github.com> Date: Thu, 11 Jul 2024 00:24:37 +0000 (+0300) Subject: Character menu asks if you want to save your character on exit (#29875) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=adcbe8d0be2ccdc76dd5e17af0206c623786874b;p=space-station-14.git 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> --- 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 @@ + + + +