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>
This commit is contained in:
@@ -46,6 +46,7 @@ public sealed class LobbyUIController : UIController, IOnStateEntered<LobbyState
|
||||
|
||||
private CharacterSetupGui? _characterSetup;
|
||||
private HumanoidProfileEditor? _profileEditor;
|
||||
private CharacterSetupGuiSavePanel? _savePanel;
|
||||
|
||||
/// <summary>
|
||||
/// 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<LobbyState
|
||||
ReloadCharacterSetup();
|
||||
}
|
||||
|
||||
private void CloseProfileEditor()
|
||||
{
|
||||
if (_profileEditor == null)
|
||||
return;
|
||||
|
||||
_profileEditor.SetProfile(null, null);
|
||||
_profileEditor.Visible = false;
|
||||
|
||||
if (_stateManager.CurrentState is LobbyState lobbyGui)
|
||||
{
|
||||
lobbyGui.SwitchState(LobbyGui.LobbyGuiState.Default);
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenSavePanel()
|
||||
{
|
||||
if (_savePanel is { IsOpen: true })
|
||||
return;
|
||||
|
||||
_savePanel = new CharacterSetupGuiSavePanel();
|
||||
|
||||
_savePanel.SaveButton.OnPressed += _ =>
|
||||
{
|
||||
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<LobbyState
|
||||
|
||||
_characterSetup.CloseButton.OnPressed += _ =>
|
||||
{
|
||||
// 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;
|
||||
|
||||
10
Content.Client/Lobby/UI/CharacterSetupGuiSavePanel.xaml
Normal file
10
Content.Client/Lobby/UI/CharacterSetupGuiSavePanel.xaml
Normal file
@@ -0,0 +1,10 @@
|
||||
<DefaultWindow xmlns="https://spacestation14.io"
|
||||
Title="{Loc 'character-setup-gui-save-panel-title'}"
|
||||
Resizable="False">
|
||||
|
||||
<BoxContainer Orientation="Horizontal" SeparationOverride="4" MinSize="200 40">
|
||||
<Button Name="SaveButton" Access="Public" Text="{Loc 'character-setup-gui-save-panel-save'}" StyleClasses="ButtonBig"/>
|
||||
<Button Name="NoSaveButton" Access="Public" Text="{Loc 'character-setup-gui-save-panel-nosave'}" StyleClasses="ButtonBig"/>
|
||||
<Button Name="CancelButton" Access="Public" Text="{Loc 'character-setup-gui-save-panel-cancel'}" StyleClasses="ButtonBig"/>
|
||||
</BoxContainer>
|
||||
</DefaultWindow>
|
||||
21
Content.Client/Lobby/UI/CharacterSetupGuiSavePanel.xaml.cs
Normal file
21
Content.Client/Lobby/UI/CharacterSetupGuiSavePanel.xaml.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
|
||||
namespace Content.Client.Lobby.UI;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class CharacterSetupGuiSavePanel : DefaultWindow
|
||||
{
|
||||
public CharacterSetupGuiSavePanel()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
CancelButton.OnPressed += _ =>
|
||||
{
|
||||
Close();
|
||||
};
|
||||
|
||||
CloseButton.Visible = false;
|
||||
}
|
||||
}
|
||||
@@ -1190,7 +1190,7 @@ namespace Content.Client.Lobby.UI
|
||||
SetDirty();
|
||||
}
|
||||
|
||||
private bool IsDirty
|
||||
public bool IsDirty
|
||||
{
|
||||
get => _isDirty;
|
||||
set
|
||||
|
||||
@@ -6,3 +6,8 @@ character-setup-gui-create-new-character-button = Create new slot...
|
||||
character-setup-gui-create-new-character-button-tooltip = A maximum of {$maxCharacters} characters are allowed.
|
||||
character-setup-gui-character-picker-button-delete-button = Delete
|
||||
character-setup-gui-character-picker-button-confirm-delete-button = Confirm
|
||||
|
||||
character-setup-gui-save-panel-title = Unsaved character changes
|
||||
character-setup-gui-save-panel-save = Save
|
||||
character-setup-gui-save-panel-nosave = Don't save
|
||||
character-setup-gui-save-panel-cancel = Cancel
|
||||
Reference in New Issue
Block a user