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.Lobby.UI;
using Content.Client.Resources;
using Content.Client.Stylesheets;
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Preferences;
@@ -130,7 +131,7 @@ namespace Content.Client.Preferences.UI
var characterIndexCopy = slot;
characterPickerButton.OnPressed += args =>
{
_humanoidProfileEditor.Profile = (HumanoidCharacterProfile) character;
_humanoidProfileEditor.Profile = (HumanoidCharacterProfile)character;
_humanoidProfileEditor.CharacterSlot = characterIndexCopy;
_humanoidProfileEditor.UpdateControls();
_preferencesManager.SelectCharacter(character);
@@ -170,7 +171,7 @@ namespace Content.Client.Preferences.UI
_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)
{
@@ -209,11 +210,25 @@ namespace Content.Client.Preferences.UI
Text = Loc.GetString("character-setup-gui-character-picker-button-delete-button"),
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(confirmDeleteButton);
preferencesManager.DeleteCharacter(profile);
};
deleteButton.OnPressed += _ =>
{
deleteButton.Visible = false;
confirmDeleteButton.Visible = true;
};
var internalHBox = new BoxContainer
{
@@ -224,7 +239,8 @@ namespace Content.Client.Preferences.UI
{
view,
descriptionLabel,
deleteButton
deleteButton,
confirmDeleteButton
}
};