mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-09 16:05:07 +00:00
Deleting characters (#83989)
## About The Pull Request Adds a button to delete characters, and when deleted it flips to the nearest character, wow(the last character can't be deleted(I guess)). ### Video: https://github.com/tgstation/tgstation/assets/78199449/3ad1157a-6c1c-4fb2-9b0d-1da791cad989 ## Why It's Good For The Game Once you know how to create characters, you sometimes want to be able to delete them. The reasons for this can be... as simple as freeing up a slot, or deleting them in order to remake them. I think this is quite a useful feature that should have been there before. ## Changelog 🆑 Vishenka0704 qol: Ability to delete characters(yourself) /🆑
This commit is contained in:
@@ -223,6 +223,25 @@ GLOBAL_LIST_EMPTY(preferences_datums)
|
||||
|
||||
character_preview_view.update_body()
|
||||
|
||||
return TRUE
|
||||
if ("remove_slot")
|
||||
var/picked_slot = params["slot"]
|
||||
var/confidence_check = tgui_input_text(usr, "To confirm the deletion of a character, type the name of the character.", "Character Deletion")
|
||||
if(confidence_check != params["name"])
|
||||
return FALSE
|
||||
|
||||
if(!remove_character(picked_slot))
|
||||
return FALSE
|
||||
|
||||
if (!load_character(params["slotToJump"]))
|
||||
randomise_appearance_prefs()
|
||||
save_character()
|
||||
|
||||
for (var/datum/preference_middleware/preference_middleware as anything in middleware)
|
||||
preference_middleware.on_new_character(usr)
|
||||
|
||||
tainted_character_profiles = TRUE
|
||||
character_preview_view.update_body();
|
||||
return TRUE
|
||||
if ("rotate")
|
||||
character_preview_view.setDir(turn(character_preview_view.dir, -90))
|
||||
|
||||
@@ -368,6 +368,16 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
|
||||
|
||||
return TRUE
|
||||
|
||||
/datum/preferences/proc/remove_character(slot)
|
||||
SHOULD_NOT_SLEEP(TRUE)
|
||||
if(!slot)
|
||||
return FALSE
|
||||
slot = sanitize_integer(slot, 1, max_save_slots, initial(default_slot))
|
||||
|
||||
var/tree_key = "character[slot]"
|
||||
savefile.remove_entry(tree_key)
|
||||
return TRUE
|
||||
|
||||
/datum/preferences/proc/sanitize_be_special(list/input_be_special)
|
||||
var/list/output = list()
|
||||
|
||||
|
||||
@@ -101,15 +101,44 @@ export const CharacterPreferenceWindow = (props) => {
|
||||
profiles={data.character_profiles}
|
||||
/>
|
||||
</Stack.Item>
|
||||
<Stack.Item align="center">
|
||||
<Button
|
||||
color="red"
|
||||
disabled={
|
||||
Object.values(data.character_profiles).filter((val) => val)
|
||||
.length < 2
|
||||
} // check if existing chars more than one
|
||||
onClick={() => {
|
||||
let choicedSlot = data.active_slot - 1;
|
||||
let availableSlots = Object.keys(data.character_profiles)
|
||||
.filter((slot) => data.character_profiles[slot] !== null)
|
||||
.map((slot) => parseInt(slot, 10)); // get all busy slots as num
|
||||
|
||||
availableSlots.splice(availableSlots.indexOf(choicedSlot), 1); // remove our slot(which we want to delete)
|
||||
|
||||
let slotToJump = availableSlots.reduce((prev, curr) => {
|
||||
return Math.abs(curr - choicedSlot) <
|
||||
Math.abs(prev - choicedSlot)
|
||||
? curr
|
||||
: prev;
|
||||
}); // get nearest slot
|
||||
|
||||
act('remove_slot', {
|
||||
slot: data.active_slot,
|
||||
name: Object.values(data.character_profiles)[choicedSlot],
|
||||
slotToJump: slotToJump + 1,
|
||||
});
|
||||
}}
|
||||
>
|
||||
Delete Character
|
||||
</Button>
|
||||
</Stack.Item>
|
||||
{!data.content_unlocked && (
|
||||
<Stack.Item align="center">
|
||||
Buy BYOND premium for more slots!
|
||||
</Stack.Item>
|
||||
)}
|
||||
|
||||
<Stack.Divider />
|
||||
|
||||
<Stack.Item>
|
||||
<Stack fill>
|
||||
<Stack.Item grow>
|
||||
@@ -168,9 +197,7 @@ export const CharacterPreferenceWindow = (props) => {
|
||||
</Stack.Item>
|
||||
</Stack>
|
||||
</Stack.Item>
|
||||
|
||||
<Stack.Divider />
|
||||
|
||||
<Stack.Item>{pageContents}</Stack.Item>
|
||||
</Stack>
|
||||
</Window.Content>
|
||||
|
||||
Reference in New Issue
Block a user