Files
Bubberstation/code/_onclick/hud/ghost.dm
John Willard 06ca7a4481 Hud screens now set hud owner in Initialize. (#76772)
## About The Pull Request

Adds an arg in huds' screens to add the hud owner in the Initialize,
instead of manually setting it every time we need to.
This is already done in ``New()`` for lobby screens, which I left intact
as lobby screens are used for new players, and are given out before
atoms are Initialized. Everything else, however, uses Initialize, so it
does not mess with any other args in their own Initializes (like the
Escape menu).
This also allows us to set the screens' HUDs as a private var, to ensure
this won't be messed with in the future.
Lastly I replaced instances of ``client`` with ``cannon_client`` to be
consistent with a lot of other parts of hud code.

## Why It's Good For The Game

Huds are easy to break when they do not have a hud owner, and for
something as important as that I believe it should be something you
opt-out of when you don't want it, rather than something you opt-into by
manually setting hud owner every time.
This cuts down on a lot of copy paste in hud code for humans, aliens,
etc.

## Changelog

🆑
refactor: Huds now have their hud owner set in Initialize
/🆑
2023-07-16 21:00:22 +02:00

112 lines
2.9 KiB
Plaintext

/atom/movable/screen/ghost
icon = 'icons/hud/screen_ghost.dmi'
/atom/movable/screen/ghost/MouseEntered(location, control, params)
. = ..()
flick(icon_state + "_anim", src)
/atom/movable/screen/ghost/spawners_menu
name = "Spawners menu"
icon_state = "spawners"
/atom/movable/screen/ghost/spawners_menu/Click()
var/mob/dead/observer/observer = usr
observer.open_spawners_menu()
/atom/movable/screen/ghost/orbit
name = "Orbit"
icon_state = "orbit"
/atom/movable/screen/ghost/orbit/Click()
var/mob/dead/observer/G = usr
G.follow()
/atom/movable/screen/ghost/reenter_corpse
name = "Reenter corpse"
icon_state = "reenter_corpse"
/atom/movable/screen/ghost/reenter_corpse/Click()
var/mob/dead/observer/G = usr
G.reenter_corpse()
/atom/movable/screen/ghost/teleport
name = "Teleport"
icon_state = "teleport"
/atom/movable/screen/ghost/teleport/Click()
var/mob/dead/observer/G = usr
G.dead_tele()
/atom/movable/screen/ghost/pai
name = "pAI Candidate"
icon_state = "pai"
/atom/movable/screen/ghost/pai/Click()
var/mob/dead/observer/G = usr
G.register_pai()
/atom/movable/screen/ghost/minigames_menu
name ="Minigames"
icon_state = "minigames"
/atom/movable/screen/ghost/minigames_menu/Click()
var/mob/dead/observer/observer = usr
observer.open_minigames_menu()
/datum/hud/ghost/New(mob/owner)
..()
var/atom/movable/screen/using
using = new /atom/movable/screen/ghost/spawners_menu(null, src)
using.screen_loc = ui_ghost_spawners_menu
static_inventory += using
using = new /atom/movable/screen/ghost/orbit(null, src)
using.screen_loc = ui_ghost_orbit
static_inventory += using
using = new /atom/movable/screen/ghost/reenter_corpse(null, src)
using.screen_loc = ui_ghost_reenter_corpse
static_inventory += using
using = new /atom/movable/screen/ghost/teleport(null, src)
using.screen_loc = ui_ghost_teleport
static_inventory += using
using = new /atom/movable/screen/ghost/pai(null, src)
using.screen_loc = ui_ghost_pai
static_inventory += using
using = new /atom/movable/screen/ghost/minigames_menu(null, src)
using.screen_loc = ui_ghost_minigames
static_inventory += using
using = new /atom/movable/screen/language_menu(null, src)
using.screen_loc = ui_ghost_language_menu
using.icon = ui_style
static_inventory += using
/datum/hud/ghost/show_hud(version = 0, mob/viewmob)
// don't show this HUD if observing; show the HUD of the observee
var/mob/dead/observer/O = mymob
if (istype(O) && O.observetarget)
plane_masters_update()
return FALSE
. = ..()
if(!.)
return
var/mob/screenmob = viewmob || mymob
if(screenmob.client.prefs.read_preference(/datum/preference/toggle/ghost_hud))
screenmob.client.screen += static_inventory
else
screenmob.client.screen -= static_inventory
//We should only see observed mob alerts.
/datum/hud/ghost/reorganize_alerts(mob/viewmob)
var/mob/dead/observer/O = mymob
if (istype(O) && O.observetarget)
return
. = ..()