mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-29 08:08:49 +01:00
Adds screen hud elements for ghost toggles (#94570)
## About The Pull Request On the bottom right of the ghost hud, there will be buttons to toggle the various ghost hud changes <img width="253" height="130" alt="image" src="https://github.com/user-attachments/assets/98e66f4f-b211-4d45-9f18-382d4a50de37" /> - Darkness level - Atmos click scan - Heath click scan - Chem click scan - Data huds - Tray scan - Ghost vision ## Why It's Good For The Game Provides an easy place to toggle things without needing to fish though a side panel or UI, or type something in chat. Plus shows you at a glance what you all have on. ## Changelog 🆑 Melbert add: Adds screen hud elements for ghost toggles /🆑
This commit is contained in:
@@ -65,6 +65,10 @@
|
||||
#define GHOST_HEALTH (1<<2)
|
||||
#define GHOST_CHEM (1<<3)
|
||||
#define GHOST_GAS (1<<4)
|
||||
/// Represents tray view. Not a real view flag, as tray is not persistent, but used as an identifier for one.
|
||||
#define GHOST_TRAY (1<<5)
|
||||
/// Repesents darkness level setting. Not a real view flag, as darkness level cycles through values, but used as an identifier for one.
|
||||
#define GHOST_DARKNESS_LEVEL (1<<6)
|
||||
|
||||
#define ALL_GHOST_FLAGS list( \
|
||||
GHOST_DATA_HUDS, \
|
||||
|
||||
@@ -64,6 +64,83 @@
|
||||
var/mob/dead/observer/observer = usr
|
||||
observer.open_minigames_menu()
|
||||
|
||||
/atom/movable/screen/ghost/hudbox
|
||||
icon_state = "smallbox"
|
||||
abstract_type = /atom/movable/screen/ghost/hudbox
|
||||
/// Icon state used for the overlay representing this hudbox
|
||||
var/hud_icon_state
|
||||
/// The flag this hudbox toggles
|
||||
var/relevant_flag
|
||||
|
||||
/atom/movable/screen/ghost/hudbox/update_overlays()
|
||||
. = ..()
|
||||
. += hud_icon_state
|
||||
|
||||
/atom/movable/screen/ghost/hudbox/update_icon_state()
|
||||
. = ..()
|
||||
var/mob/dead/observer/observer = hud?.mymob
|
||||
if(!istype(observer))
|
||||
return
|
||||
|
||||
icon_state = "smallbox[is_active(observer) ? "_active" : ""]"
|
||||
|
||||
/atom/movable/screen/ghost/hudbox/proc/is_active(mob/dead/observer/observer)
|
||||
return (observer.ghost_hud_flags & relevant_flag)
|
||||
|
||||
/atom/movable/screen/ghost/hudbox/Click(location, control, params)
|
||||
var/mob/dead/observer/observer = usr
|
||||
switch(relevant_flag)
|
||||
if(GHOST_DARKNESS_LEVEL)
|
||||
observer.toggle_darkness()
|
||||
if(GHOST_TRAY)
|
||||
observer.tray_view()
|
||||
else
|
||||
observer.toggle_ghost_hud_flag(relevant_flag)
|
||||
|
||||
update_appearance(UPDATE_ICON_STATE)
|
||||
|
||||
/atom/movable/screen/ghost/hudbox/health_scanner
|
||||
name = "Health Scanner"
|
||||
desc = "Toggles your ability to health scan mobs on click."
|
||||
hud_icon_state = "health_vision"
|
||||
relevant_flag = GHOST_HEALTH
|
||||
|
||||
/atom/movable/screen/ghost/hudbox/chem_scanner
|
||||
name = "Chem Scanner"
|
||||
desc = "Toggles your ability to chemical scan mobs on click."
|
||||
hud_icon_state = "chem_vision"
|
||||
relevant_flag = GHOST_CHEM
|
||||
|
||||
/atom/movable/screen/ghost/hudbox/gas_scanner
|
||||
name = "Gas Scanner"
|
||||
desc = "Toggles your ability to gas scan objects on click."
|
||||
hud_icon_state = "atmos_vision"
|
||||
relevant_flag = GHOST_GAS
|
||||
|
||||
/atom/movable/screen/ghost/hudbox/ghost
|
||||
name = "Ghost Vision"
|
||||
desc = "Toggles whether you can see other ghosts."
|
||||
hud_icon_state = "ghost_vision"
|
||||
relevant_flag = GHOST_VISION
|
||||
|
||||
/atom/movable/screen/ghost/hudbox/data_huds
|
||||
name = "Data HUDs"
|
||||
desc = "Toggles the display of data HUDs (health, security, diagnostics, etc)."
|
||||
hud_icon_state = "data_vision"
|
||||
relevant_flag = GHOST_DATA_HUDS
|
||||
|
||||
/atom/movable/screen/ghost/hudbox/tray_icon
|
||||
name = "Tray View"
|
||||
desc = "Shows the t-ray view of the area around your ghost."
|
||||
hud_icon_state = "tray_vision"
|
||||
relevant_flag = GHOST_TRAY
|
||||
|
||||
/atom/movable/screen/ghost/hudbox/darkness_level
|
||||
name = "Darkness Level"
|
||||
desc = "Cycles through different darkness levels for ghost vision."
|
||||
hud_icon_state = "darkness_vision"
|
||||
relevant_flag = GHOST_DARKNESS_LEVEL
|
||||
|
||||
/datum/hud/ghost/New(mob/owner)
|
||||
..()
|
||||
var/atom/movable/screen/using
|
||||
@@ -104,6 +181,19 @@
|
||||
floor_change.screen_loc = ui_ghost_floor_changer
|
||||
static_inventory += floor_change
|
||||
|
||||
var/list/hudboxes = valid_subtypesof(/atom/movable/screen/ghost/hudbox)
|
||||
for(var/i in 1 to length(hudboxes))
|
||||
var/hudbox_type = hudboxes[i]
|
||||
var/atom/movable/screen/ghost/hudbox/hudbox = new hudbox_type(null, src)
|
||||
hudbox.screen_loc = position_hudbox(i - 1)
|
||||
static_inventory += hudbox
|
||||
hudbox.update_appearance()
|
||||
|
||||
/datum/hud/ghost/proc/position_hudbox(i)
|
||||
var/row = floor(i / 3)
|
||||
var/column = i % 3
|
||||
return "SOUTH:[6 + row * 16], CENTER+5:[7 + column * 15]"
|
||||
|
||||
/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
|
||||
@@ -116,7 +206,9 @@
|
||||
return
|
||||
var/mob/screenmob = viewmob || mymob
|
||||
if(screenmob.client.prefs.read_preference(/datum/preference/toggle/ghost_hud))
|
||||
screenmob.client.screen += static_inventory
|
||||
screenmob.client.screen |= static_inventory
|
||||
for(var/atom/movable/screen/ghost/hudbox/hud in static_inventory)
|
||||
hud.update_appearance()
|
||||
else
|
||||
screenmob.client.screen -= static_inventory
|
||||
|
||||
|
||||
@@ -159,16 +159,7 @@ GLOBAL_DATUM_INIT(ghost_menu, /datum/ghost_menu, new)
|
||||
user.update_sight()
|
||||
|
||||
/datum/ghost_menu/proc/toggle_hud_type(mob/dead/observer/user, hud_type)
|
||||
user.ghost_hud_flags ^= hud_type
|
||||
//special aftereffects for specific flags.
|
||||
switch(hud_type)
|
||||
if(GHOST_VISION)
|
||||
user.update_sight()
|
||||
if(GHOST_DATA_HUDS)
|
||||
if(user.ghost_hud_flags & GHOST_DATA_HUDS)
|
||||
user.show_data_huds()
|
||||
else
|
||||
user.remove_data_huds()
|
||||
user.toggle_ghost_hud_flag(hud_type)
|
||||
|
||||
/datum/ghost_menu/proc/restore_ghost_appearance(mob/dead/observer/user)
|
||||
user.set_ghost_appearance()
|
||||
|
||||
@@ -40,7 +40,7 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER)
|
||||
|
||||
///Flags of huds the ghost currently has enabled, data huds & ghost vision by default.
|
||||
///Selection: GHOST_DATA_HUDS | GHOST_VISION | GHOST_HEALTH | GHOST_CHEM | GHOST_GAS
|
||||
var/ghost_hud_flags = GHOST_DATA_HUDS | GHOST_VISION
|
||||
var/ghost_hud_flags = NONE
|
||||
///The shape the ghost will make while orbiting mobs.
|
||||
var/ghost_orbit = GHOST_ORBIT_CIRCLE
|
||||
|
||||
@@ -145,7 +145,7 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER)
|
||||
|
||||
grant_all_languages()
|
||||
setup_hud_traits()
|
||||
show_data_huds()
|
||||
toggle_ghost_hud_flag(GHOST_VISION | GHOST_DATA_HUDS)
|
||||
|
||||
SSpoints_of_interest.make_point_of_interest(src)
|
||||
ADD_TRAIT(src, TRAIT_HEAR_THROUGH_DARKNESS, INNATE_TRAIT)
|
||||
@@ -524,7 +524,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
|
||||
/mob/dead/observer/verb/toggle_ghostsee()
|
||||
set name = "Toggle Ghost Vision"
|
||||
|
||||
ghost_hud_flags ^= GHOST_VISION
|
||||
toggle_ghost_hud_flag(GHOST_VISION)
|
||||
update_sight()
|
||||
to_chat(usr, span_boldnotice("You [(ghost_hud_flags & GHOST_VISION) ? "now" : "no longer"] have ghost vision."))
|
||||
|
||||
@@ -590,18 +590,16 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
|
||||
/mob/dead/observer/verb/toggle_data_huds()
|
||||
set name = "Toggle Sec/Med/Diag HUD"
|
||||
|
||||
ghost_hud_flags ^= GHOST_DATA_HUDS
|
||||
toggle_ghost_hud_flag(GHOST_DATA_HUDS)
|
||||
if(ghost_hud_flags & GHOST_DATA_HUDS)
|
||||
show_data_huds()
|
||||
to_chat(src, span_notice("Data HUDs enabled."))
|
||||
else
|
||||
remove_data_huds()
|
||||
to_chat(src, span_notice("Data HUDs disabled."))
|
||||
|
||||
/mob/dead/observer/verb/toggle_health_scan()
|
||||
set name = "Toggle Health Scan"
|
||||
|
||||
ghost_hud_flags ^= GHOST_HEALTH
|
||||
toggle_ghost_hud_flag(GHOST_HEALTH)
|
||||
if(ghost_hud_flags & GHOST_HEALTH)
|
||||
to_chat(src, span_notice("Health scan enabled."))
|
||||
else
|
||||
@@ -610,7 +608,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
|
||||
/mob/dead/observer/verb/toggle_chem_scan()
|
||||
set name = "Toggle Chem Scan"
|
||||
|
||||
ghost_hud_flags ^= GHOST_CHEM
|
||||
toggle_ghost_hud_flag(GHOST_CHEM)
|
||||
if(ghost_hud_flags & GHOST_CHEM)
|
||||
to_chat(src, span_notice("Chem scan enabled."))
|
||||
else
|
||||
@@ -619,7 +617,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
|
||||
/mob/dead/observer/verb/toggle_gas_scan()
|
||||
set name = "Toggle Gas Scan"
|
||||
|
||||
ghost_hud_flags ^= GHOST_GAS
|
||||
toggle_ghost_hud_flag(GHOST_GAS)
|
||||
if(ghost_hud_flags & GHOST_GAS)
|
||||
to_chat(src, span_notice("Gas scan enabled."))
|
||||
else
|
||||
@@ -636,6 +634,18 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
|
||||
mind.ghostname = real_name
|
||||
name = real_name
|
||||
|
||||
/// Toggles a flag from ghost hud and updates the mob accordingly
|
||||
/mob/dead/observer/proc/toggle_ghost_hud_flag(toggled)
|
||||
ghost_hud_flags ^= toggled
|
||||
if(ghost_hud_flags & GHOST_DATA_HUDS)
|
||||
show_data_huds()
|
||||
else
|
||||
remove_data_huds()
|
||||
update_sight()
|
||||
for(var/atom/movable/screen/ghost/hudbox/hud in hud_used?.static_inventory)
|
||||
if(hud.relevant_flag & toggled)
|
||||
hud.update_appearance(UPDATE_ICON_STATE)
|
||||
|
||||
// This is the ghost's follow verb with an argument
|
||||
/mob/dead/observer/proc/ManualFollow(atom/movable/target)
|
||||
if (!istype(target) || (is_secret_level(target.z) && !client?.holder))
|
||||
@@ -702,7 +712,6 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
|
||||
else
|
||||
set_invis_see(SEE_INVISIBLE_OBSERVER)
|
||||
|
||||
|
||||
updateghostimages()
|
||||
..()
|
||||
|
||||
@@ -828,9 +837,13 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
|
||||
return
|
||||
|
||||
/mob/dead/observer/proc/show_data_huds()
|
||||
PRIVATE_PROC(TRUE)
|
||||
ghost_hud_flags |= GHOST_DATA_HUDS // only for safety, it should be set already.
|
||||
add_traits(observer_hud_traits, REF(src))
|
||||
|
||||
/mob/dead/observer/proc/remove_data_huds()
|
||||
PRIVATE_PROC(TRUE)
|
||||
ghost_hud_flags &= ~GHOST_DATA_HUDS // only for safety, it should be unset already.
|
||||
remove_traits(observer_hud_traits, REF(src))
|
||||
|
||||
/mob/dead/observer/proc/set_ghost_appearance()
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 34 KiB |
Reference in New Issue
Block a user