Merge pull request #13494 from monster860/patch-4

Makes the slimeperson swap-body UI stay open when you switch bodies
This commit is contained in:
silicons
2020-10-03 14:22:11 -07:00
committed by GitHub

View File

@@ -274,7 +274,17 @@
\"steps out\" of [H.p_them()].</span>",
"<span class='notice'>...and after a moment of disorentation, \
you're besides yourself!</span>")
if(H != spare && isslimeperson(spare) && isslimeperson(H))
// transfer the swap-body ui if it's open
var/datum/action/innate/swap_body/this_swap = origin_datum.swap_body
var/datum/action/innate/swap_body/other_swap = spare_datum.swap_body
var/datum/tgui/ui = SStgui.get_open_ui(H, this_swap, "main") || SStgui.get_open_ui(spare, this_swap, "main")
if(ui)
SStgui.on_close(ui) // basically removes it from lists is all this proc does.
ui.user = spare
ui.src_object = other_swap
SStgui.on_open(ui) // stick it back on the lists
ui.process(force = TRUE)
/datum/action/innate/swap_body
name = "Swap Body"
@@ -327,6 +337,8 @@
stat = "Conscious"
if(UNCONSCIOUS)
stat = "Unconscious"
if(SOFT_CRIT)
stat = "Barely Conscious"
if(DEAD)
stat = "Dead"
var/occupied
@@ -373,7 +385,6 @@
var/mob/living/carbon/human/selected = locate(params["ref"]) in SS.bodies
if(!can_swap(selected))
return
SStgui.close_uis(src)
swap_to_dupe(H.mind, selected)
/datum/action/innate/swap_body/proc/can_swap(mob/living/carbon/human/dupe)
@@ -407,6 +418,7 @@
/datum/action/innate/swap_body/proc/swap_to_dupe(datum/mind/M, mob/living/carbon/human/dupe)
if(!can_swap(dupe)) //sanity check
return
var/mob/living/carbon/human/old = M.current
if(M.current.stat == CONSCIOUS)
M.current.visible_message("<span class='notice'>[M.current] \
stops moving and starts staring vacantly into space.</span>",
@@ -418,7 +430,20 @@
dupe.visible_message("<span class='notice'>[dupe] blinks and looks \
around.</span>",
"<span class='notice'>...and move this one instead.</span>")
if(old != M.current && dupe == M.current && isslimeperson(dupe))
var/datum/species/jelly/slime/other_spec = dupe.dna.species
var/datum/action/innate/swap_body/other_swap = other_spec.swap_body
// theoretically the transfer_to proc is supposed to transfer the ui from the mob.
// so I try to get the UI from one of the two mobs and schlump it over to the new action button
var/datum/tgui/ui = SStgui.get_open_ui(old, src, "main") || SStgui.get_open_ui(dupe, src, "main")
if(ui)
// transfer the UI over. This code is slightly hacky but it fixes the problem
// I'd use SStgui.on_transfer but that doesn't let you transfer the src_object as well s
SStgui.on_close(ui) // basically removes it from lists is all this proc does.
ui.user = dupe
ui.src_object = other_swap
SStgui.on_open(ui) // stick it back on the lists
ui.process(force = TRUE)
////////////////////////////////////////////////////////Round Start Slimes///////////////////////////////////////////////////////////////////