[TGUI] Adds a HUD management UI for ghosts (#16302)

* ghost hud panel

* changes up UI a bit, fix conflicts

* no resizable
This commit is contained in:
SteelSlayer
2021-07-13 14:19:41 +01:00
committed by GitHub
parent e98d81ac46
commit 5124f5ef7e
10 changed files with 147 additions and 89 deletions
+2 -5
View File
@@ -278,11 +278,9 @@
var/action=""
if(config.antag_hud_allowed)
for(var/mob/dead/observer/g in get_ghosts())
if(!g.client.holder) //Remove the verb from non-admin ghosts
g.verbs -= /mob/dead/observer/verb/toggle_antagHUD
if(g.antagHUD)
g.antagHUD = FALSE // Disable it on those that have it enabled
g.has_enabled_antagHUD = 2 // We'll allow them to respawn
g.has_enabled_antagHUD = FALSE // We'll allow them to respawn
to_chat(g, "<span class='danger'>The Administrator has disabled AntagHUD </span>")
config.antag_hud_allowed = 0
to_chat(src, "<span class='danger'>AntagHUD usage has been disabled</span>")
@@ -290,7 +288,6 @@
else
for(var/mob/dead/observer/g in get_ghosts())
if(!g.client.holder) // Add the verb back for all non-admin ghosts
g.verbs += /mob/dead/observer/verb/toggle_antagHUD
to_chat(g, "<span class='boldnotice'>The Administrator has enabled AntagHUD </span>")// Notify all observers they can now use AntagHUD
config.antag_hud_allowed = 1
@@ -321,7 +318,7 @@
to_chat(g, "<span class='danger'>The administrator has placed restrictions on joining the round if you use AntagHUD</span>")
to_chat(g, "<span class='danger'>Your AntagHUD has been disabled, you may choose to re-enabled it but will be under restrictions </span>")
g.antagHUD = FALSE
g.has_enabled_antagHUD = 0
g.has_enabled_antagHUD = FALSE
action = "placed restrictions"
config.antag_hud_restricted = 1
to_chat(src, "<span class='danger'>AntagHUD restrictions have been enabled</span>")
+12 -76
View File
@@ -26,7 +26,8 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER)
var/image/ghostimage = null //this mobs ghost image, for deleting and stuff
var/ghostvision = TRUE //is the ghost able to see things humans can't?
var/seedarkness = TRUE
var/data_hud_seen = FALSE //this should one of the defines in __DEFINES/hud.dm
/// Defines from __DEFINES/hud.dm go here based on which huds the ghost has activated.
var/list/data_hud_seen = list()
var/ghost_orbit = GHOST_ORBIT_CIRCLE
var/health_scan = FALSE //does the ghost have health scanner mode on? by default it should be off
var/datum/orbit_menu/orbit_menu
@@ -86,7 +87,7 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER)
real_name = name
//starts ghosts off with all HUDs.
toggle_medHUD()
toggle_all_huds_on()
..()
/mob/dead/observer/Destroy()
@@ -162,8 +163,6 @@ Works together with spawning an observer, noted above.
else
GLOB.non_respawnable_keys[ckey] = 1
ghost.key = key
if(!(ghost.client && ghost.client.holder) && !config.antag_hud_allowed) // For new ghosts we remove the verb from even showing up if it's not allowed.
ghost.verbs -= /mob/dead/observer/verb/toggle_antagHUD // Poor guys, don't know what they are missing!
return ghost
/*
@@ -310,87 +309,24 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
/mob/dead/observer/proc/show_me_the_hud(hud_index)
var/datum/atom_hud/H = GLOB.huds[hud_index]
H.add_hud_to(src)
data_hud_seen |= hud_index
/mob/dead/observer/proc/remove_the_hud(hud_index) //remove old huds
var/datum/atom_hud/H = GLOB.huds[hud_index]
H.remove_hud_from(src)
data_hud_seen -= hud_index
/mob/dead/observer/verb/toggle_medHUD()
/mob/dead/observer/verb/open_hud_panel()
set category = "Ghost"
set name = "Toggle All/Sec/Med/Diag HUDs"
set desc = "Toggles the HUDs."
set name = "Ghost HUD Panel"
if(!client)
return
GLOB.ghost_hud_panel.ui_interact(src)
switch(data_hud_seen) //give new huds
if(FALSE)
data_hud_seen = DATA_HUD_DIAGNOSTIC + DATA_HUD_SECURITY_ADVANCED + DATA_HUD_MEDICAL_ADVANCED
show_me_the_hud(DATA_HUD_DIAGNOSTIC)
show_me_the_hud(DATA_HUD_SECURITY_ADVANCED)
show_me_the_hud(DATA_HUD_MEDICAL_ADVANCED)
to_chat(src, "<span class='notice'>All HUDs enabled.</span>")
if(DATA_HUD_DIAGNOSTIC + DATA_HUD_SECURITY_ADVANCED + DATA_HUD_MEDICAL_ADVANCED)
data_hud_seen = DATA_HUD_SECURITY_ADVANCED
remove_the_hud(DATA_HUD_DIAGNOSTIC)
remove_the_hud(DATA_HUD_MEDICAL_ADVANCED)
to_chat(src, "<span class='notice'>Security HUD set.</span>")
if(DATA_HUD_SECURITY_ADVANCED)
data_hud_seen = DATA_HUD_MEDICAL_ADVANCED
remove_the_hud(DATA_HUD_SECURITY_ADVANCED)
show_me_the_hud(DATA_HUD_MEDICAL_ADVANCED)
to_chat(src, "<span class='notice'>Medical HUD set.</span>")
if(DATA_HUD_MEDICAL_ADVANCED)
data_hud_seen = DATA_HUD_DIAGNOSTIC
remove_the_hud(DATA_HUD_MEDICAL_ADVANCED)
show_me_the_hud(DATA_HUD_DIAGNOSTIC)
to_chat(src, "<span class='notice'>Diagnostic HUD set.</span>")
else
data_hud_seen = FALSE
remove_the_hud(DATA_HUD_MEDICAL_ADVANCED)
to_chat(src, "<span class='notice'>HUDs disabled.</span>")
/mob/dead/observer/verb/toggle_antagHUD()
set category = "Ghost"
set name = "Toggle AntagHUD"
set desc = "Toggles AntagHUD allowing you to see who is the antagonist"
if(!config.antag_hud_allowed && !client.holder)
to_chat(src, "<span class='warning'>Admins have disabled this for this round.</span>")
return
if(!client)
return
var/mob/dead/observer/M = src
if(jobban_isbanned(M, ROLEBAN_AHUD))
to_chat(src, "<span class='danger'>You have been banned from using this feature</span>")
return
var/restricted_use = (!M.has_enabled_antagHUD && !check_rights(R_ADMIN|R_MOD, FALSE)) // Admins can freely toggle it
if(config.antag_hud_restricted && restricted_use)
var/response = alert(src, "If you turn this on, you will not be able to take any part in the round.", "Are you sure you want to turn this feature on?", "Yes", "No")
if(response == "No")
return
M.can_reenter_corpse = FALSE
if(M in GLOB.respawnable_list)
GLOB.respawnable_list -= M
if(restricted_use)
M.has_enabled_antagHUD = TRUE
for(var/datum/atom_hud/antag/H in (GLOB.huds))
if(!M.antagHUD)
H.add_hud_to(usr)
else
H.remove_hud_from(usr)
if(!M.antagHUD)
to_chat(usr, "AntagHud Toggled ON")
create_log(MISC_LOG, "Enabled AntagHUD")
log_game("[key_name(usr)] has enabled AntagHUD.")
M.antagHUD = TRUE
else
to_chat(usr, "AntagHud Toggled OFF")
create_log(MISC_LOG, "Disabled AntagHUD")
log_game("[key_name(usr)] has disabled AntagHUD.")
M.antagHUD = FALSE
/mob/dead/observer/proc/toggle_all_huds_on()
show_me_the_hud(DATA_HUD_DIAGNOSTIC)
show_me_the_hud(DATA_HUD_SECURITY_ADVANCED)
show_me_the_hud(DATA_HUD_MEDICAL_ADVANCED)
/mob/dead/observer/verb/set_dnr()
set name = "Set DNR"
@@ -433,7 +433,7 @@
else if(isobserver(M))
var/mob/dead/observer/O = M
if(O.data_hud_seen == DATA_HUD_SECURITY_ADVANCED || O.data_hud_seen == DATA_HUD_DIAGNOSTIC + DATA_HUD_SECURITY_ADVANCED + DATA_HUD_MEDICAL_ADVANCED)
if(DATA_HUD_SECURITY_ADVANCED in O.data_hud_seen)
return (hudtype in list(EXAMINE_HUD_SECURITY_READ, EXAMINE_HUD_SKILLS))
return FALSE
+2 -2
View File
@@ -111,8 +111,8 @@
var/move_on_shuttle = 1 // Can move on the shuttle.
var/has_enabled_antagHUD = 0 // Whether antagHUD was ever enabled. Not a true boolean - sometimes it is set to 2, because reasons.
/// Whether antagHUD has been enabled previously.
var/has_enabled_antagHUD = FALSE
var/antagHUD = FALSE // Whether AntagHUD is active right now
var/can_change_intents = 1 //all mobs can change intents by default.
///Override for sound_environments. If this is set the user will always hear a specific type of reverb (Instead of the area defined reverb)
+1 -1
View File
@@ -79,7 +79,7 @@
/proc/cannotPossess(A)
var/mob/dead/observer/G = A
if(G.has_enabled_antagHUD == 1 && config.antag_hud_restricted)
if(G.has_enabled_antagHUD && config.antag_hud_restricted)
return 1
return 0
@@ -192,8 +192,6 @@
client.prefs.real_name = random_name(client.prefs.gender,client.prefs.species)
observer.real_name = client.prefs.real_name
observer.name = observer.real_name
if(!client.holder && !config.antag_hud_allowed) // For new ghosts we remove the verb from even showing up if it's not allowed.
observer.verbs -= /mob/dead/observer/verb/toggle_antagHUD // Poor guys, don't know what they are missing!
observer.key = key
QDEL_NULL(mind)
GLOB.respawnable_list += observer
@@ -0,0 +1,73 @@
/// Stores an instance of [/datum/ui_module/ghost_hud_panel] so that ghosts can use this to open their HUD panel.
GLOBAL_DATUM_INIT(ghost_hud_panel, /datum/ui_module/ghost_hud_panel, new)
/**
* # Ghost HUD panel
*
* Allows ghosts to view a TGUI window which contains toggles for all HUD types available to them.
*/
/datum/ui_module/ghost_hud_panel
name = "Ghost HUD Panel"
/// Associative list to get the appropriate hud type based on the string passed from TGUI.
var/list/hud_type_lookup = list(
"medical" = DATA_HUD_MEDICAL_ADVANCED,
"security" = DATA_HUD_SECURITY_ADVANCED,
"diagnostic" = DATA_HUD_DIAGNOSTIC
)
/datum/ui_module/ghost_hud_panel/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.observer_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui)
if(!ui)
ui = new(user, src, ui_key, "GhostHudPanel", name, 250, 171, master_ui, state)
ui.set_autoupdate(FALSE)
ui.open()
/datum/ui_module/ghost_hud_panel/ui_data(mob/dead/observer/ghost)
var/list/data = list()
for(var/hud in hud_type_lookup)
data[hud] = (hud_type_lookup[hud] in ghost.data_hud_seen)
data["ahud"] = ghost.antagHUD
return data
/datum/ui_module/ghost_hud_panel/ui_act(action, list/params)
if(..())
return
var/mob/dead/observer/ghost = usr
. = TRUE
switch(action)
if("hud_on")
var/hud_type = hud_type_lookup[params["hud_type"]]
ghost.show_me_the_hud(hud_type)
if("hud_off")
var/hud_type = hud_type_lookup[params["hud_type"]]
ghost.remove_the_hud(hud_type)
if("ahud_on")
if(!config.antag_hud_allowed && !ghost.client.holder)
to_chat(ghost, "<span class='warning'>Admins have disabled this for this round.</span>")
return FALSE
if(jobban_isbanned(ghost, "AntagHUD"))
to_chat(ghost, "<span class='danger'>You have been banned from using this feature.</span>")
return FALSE
// Check if this is the first time they're turning on Antag HUD.
if(!check_rights(R_ADMIN | R_MOD, FALSE) && !ghost.has_enabled_antagHUD && config.antag_hud_restricted)
var/response = alert(ghost, "If you turn this on, you will not be able to take any part in the round.", "Are you sure you want to enable antag HUD?", "Yes", "No")
if(response == "No")
return FALSE
ghost.has_enabled_antagHUD = TRUE
ghost.can_reenter_corpse = FALSE
GLOB.respawnable_list -= ghost
ghost.antagHUD = TRUE
for(var/datum/atom_hud/antag/H in GLOB.huds)
H.add_hud_to(ghost)
if("ahud_off")
ghost.antagHUD = FALSE
for(var/datum/atom_hud/antag/H in GLOB.huds)
H.add_hud_to(ghost)