Confirmation button (#12671)

Closes https://github.com/space-wizards/space-station-14/issues/12579
This commit is contained in:
nikthechampiongr
2022-12-07 01:14:48 +02:00
committed by GitHub
parent f7713c63fe
commit 3d86baa92e
2 changed files with 21 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ using Content.Client.Humanoid;
using Content.Client.Info; using Content.Client.Info;
using Content.Client.Lobby.UI; using Content.Client.Lobby.UI;
using Content.Client.Resources; using Content.Client.Resources;
using Content.Client.Stylesheets;
using Content.Shared.Humanoid; using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Prototypes; using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Preferences; using Content.Shared.Preferences;
@@ -130,7 +131,7 @@ namespace Content.Client.Preferences.UI
var characterIndexCopy = slot; var characterIndexCopy = slot;
characterPickerButton.OnPressed += args => characterPickerButton.OnPressed += args =>
{ {
_humanoidProfileEditor.Profile = (HumanoidCharacterProfile) character; _humanoidProfileEditor.Profile = (HumanoidCharacterProfile)character;
_humanoidProfileEditor.CharacterSlot = characterIndexCopy; _humanoidProfileEditor.CharacterSlot = characterIndexCopy;
_humanoidProfileEditor.UpdateControls(); _humanoidProfileEditor.UpdateControls();
_preferencesManager.SelectCharacter(character); _preferencesManager.SelectCharacter(character);
@@ -170,7 +171,7 @@ namespace Content.Client.Preferences.UI
_previewDummy = entityManager.SpawnEntity(prototypeManager.Index<SpeciesPrototype>(SharedHumanoidSystem.DefaultSpecies).DollPrototype, MapCoordinates.Nullspace); _previewDummy = entityManager.SpawnEntity(prototypeManager.Index<SpeciesPrototype>(SharedHumanoidSystem.DefaultSpecies).DollPrototype, MapCoordinates.Nullspace);
} }
EntitySystem.Get<HumanoidSystem>().LoadProfile(_previewDummy, (HumanoidCharacterProfile) profile); EntitySystem.Get<HumanoidSystem>().LoadProfile(_previewDummy, (HumanoidCharacterProfile)profile);
if (humanoid != null) if (humanoid != null)
{ {
@@ -209,11 +210,25 @@ namespace Content.Client.Preferences.UI
Text = Loc.GetString("character-setup-gui-character-picker-button-delete-button"), Text = Loc.GetString("character-setup-gui-character-picker-button-delete-button"),
Visible = !isSelectedCharacter, Visible = !isSelectedCharacter,
}; };
deleteButton.OnPressed += _ => var confirmDeleteButton = new Button
{
Text = Loc.GetString("character-setup-gui-character-picker-button-confirm-delete-button"),
Visible = false,
};
confirmDeleteButton.ModulateSelfOverride = StyleNano.ButtonColorCautionDefault;
confirmDeleteButton.OnPressed += _ =>
{ {
Parent?.RemoveChild(this); Parent?.RemoveChild(this);
Parent?.RemoveChild(confirmDeleteButton);
preferencesManager.DeleteCharacter(profile); preferencesManager.DeleteCharacter(profile);
}; };
deleteButton.OnPressed += _ =>
{
deleteButton.Visible = false;
confirmDeleteButton.Visible = true;
};
var internalHBox = new BoxContainer var internalHBox = new BoxContainer
{ {
@@ -224,7 +239,8 @@ namespace Content.Client.Preferences.UI
{ {
view, view,
descriptionLabel, descriptionLabel,
deleteButton deleteButton,
confirmDeleteButton
} }
}; };

View File

@@ -5,3 +5,4 @@ character-setup-gui-character-setup-close-button = Close
character-setup-gui-create-new-character-button = Create new slot... 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-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-delete-button = Delete
character-setup-gui-character-picker-button-confirm-delete-button = Confirm