Skip to content

Commit

Permalink
Makes TGUI transfer over when changing bodies (#5388)
Browse files Browse the repository at this point in the history
# About the pull request

Makes any open TGUI windows transfer over when a player's mind is
transferred to a new body. *(At least if it's done through
`/datum/mind/proc/transfer_to()`)*
This is mainly useful for xeno players who want to evolve, since it
means they won't need to re-open any interfaces they had open.

The changes in `code/controllers/subsystem/minimap.dm` are there so that
the tacmap image remains visible to the player after a transfer, since
the client changing bodies seems to remove it from their
[`screen`](https://www.byond.com/docs/ref/#/client/var/screen) list.

(This *could* have hidden side effects of interfaces staying open when
they shouldn't, so I'd appreciate this being testmerged for a bit just
in case.)

# Explain why it's good for the game

QOL addition so that you don't have to manually re-open them yourself.

# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>


https://github.com/cmss13-devs/cmss13/assets/57483089/70549c92-915b-4881-95ca-d1625a346f4b

</details>


# Changelog
:cl:
qol: Made open TGUI windows transfer over when a xeno player evolves.
/:cl:
  • Loading branch information
SabreML committed Jan 18, 2024
1 parent 4a7a51d commit 46cc269
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions code/__DEFINES/dcs/signals/atom/mob/signals_mind.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
///from mind/transfer_to. Sent after the mind has been transferred to a different body: (mob/previous_body)
#define COMSIG_MIND_TRANSFERRED "mind_transferred"
10 changes: 10 additions & 0 deletions code/controllers/subsystem/minimap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ SUBSYSTEM_DEF(minimaps)
user.client.register_map_obj(map_holder.map)
ui = new(user, src, "TacticalMap")
ui.open()
RegisterSignal(user.mind, COMSIG_MIND_TRANSFERRED, PROC_REF(on_mind_transferred))

/datum/tacmap/drawing/tgui_interact(mob/user, datum/tgui/ui)
var/mob/living/carbon/xenomorph/xeno = user
Expand Down Expand Up @@ -726,6 +727,7 @@ SUBSYSTEM_DEF(minimaps)
tacmap_ready_time = SSminimaps.next_fire + 2 SECONDS
addtimer(CALLBACK(src, PROC_REF(on_tacmap_fire), faction), SSminimaps.next_fire - world.time + 1 SECONDS)
user.client.register_map_obj(map_holder.map)
RegisterSignal(user.mind, COMSIG_MIND_TRANSFERRED, PROC_REF(on_mind_transferred))

ui = new(user, src, "TacticalMap")
ui.open()
Expand Down Expand Up @@ -811,6 +813,9 @@ SUBSYSTEM_DEF(minimaps)

return data

/datum/tacmap/ui_close(mob/user)
UnregisterSignal(user.mind, COMSIG_MIND_TRANSFERRED)

/datum/tacmap/drawing/ui_close(mob/user)
. = ..()
action_queue_change = 0
Expand Down Expand Up @@ -939,6 +944,11 @@ SUBSYSTEM_DEF(minimaps)

return UI_INTERACTIVE

// This gets removed when the player changes bodies (i.e. xeno evolution), so re-register it when that happens.
/datum/tacmap/proc/on_mind_transferred(datum/mind/source, mob/previous_body)
SIGNAL_HANDLER
source.current.client.register_map_obj(map_holder.map)

/datum/tacmap_holder
var/map_ref
var/atom/movable/screen/minimap/map
Expand Down
3 changes: 3 additions & 0 deletions code/datums/mind.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@
msg_admin_niche("[key]/[ckey] has tried to transfer to deleted [new_character].")
return

var/mob/old_current = current
if(current)
current.mind = null //remove ourself from our old body's mind variable
SSnano.nanomanager.user_transferred(current, new_character) // transfer active NanoUI instances to new user
SStgui.on_transfer(current, new_character) // and active TGUI instances

if(key)
if(new_character.key != key)
Expand Down Expand Up @@ -76,6 +78,7 @@
continue
player_entity = setup_player_entity(ckey)

SEND_SIGNAL(src, COMSIG_MIND_TRANSFERRED, old_current)
SEND_SIGNAL(new_character, COMSIG_MOB_NEW_MIND, current.client)

new_character.refresh_huds(current) //inherit the HUDs from the old body
Expand Down
1 change: 0 additions & 1 deletion code/modules/mob/dead/observer/observer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,6 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
return

mind.transfer_to(mind.original, TRUE)
SStgui.on_transfer(src, mind.current)
qdel(src)
return TRUE

Expand Down
1 change: 1 addition & 0 deletions colonialmarines.dme
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
#include "code\__DEFINES\dcs\signals\atom\signals_obj.dm"
#include "code\__DEFINES\dcs\signals\atom\signals_projectile.dm"
#include "code\__DEFINES\dcs\signals\atom\signals_turf.dm"
#include "code\__DEFINES\dcs\signals\atom\mob\signals_mind.dm"
#include "code\__DEFINES\dcs\signals\atom\mob\signals_mob.dm"
#include "code\__DEFINES\dcs\signals\atom\mob\living\signals_human.dm"
#include "code\__DEFINES\dcs\signals\atom\mob\living\signals_living.dm"
Expand Down

0 comments on commit 46cc269

Please sign in to comment.