diff --git a/code/modules/admin/verbs/randomverbs.dm b/code/modules/admin/verbs/randomverbs.dm index 0d724e68420..85b9fa20941 100644 --- a/code/modules/admin/verbs/randomverbs.dm +++ b/code/modules/admin/verbs/randomverbs.dm @@ -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, "The Administrator has disabled AntagHUD ") config.antag_hud_allowed = 0 to_chat(src, "AntagHUD usage has been disabled") @@ -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, "The Administrator has enabled AntagHUD ")// Notify all observers they can now use AntagHUD config.antag_hud_allowed = 1 @@ -321,7 +318,7 @@ to_chat(g, "The administrator has placed restrictions on joining the round if you use AntagHUD") to_chat(g, "Your AntagHUD has been disabled, you may choose to re-enabled it but will be under restrictions ") g.antagHUD = FALSE - g.has_enabled_antagHUD = 0 + g.has_enabled_antagHUD = FALSE action = "placed restrictions" config.antag_hud_restricted = 1 to_chat(src, "AntagHUD restrictions have been enabled") diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index 42d86e0553a..953b13f0bda 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -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, "All HUDs enabled.") - 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, "Security HUD set.") - 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, "Medical HUD set.") - 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, "Diagnostic HUD set.") - else - data_hud_seen = FALSE - remove_the_hud(DATA_HUD_MEDICAL_ADVANCED) - to_chat(src, "HUDs disabled.") - - -/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, "Admins have disabled this for this round.") - return - if(!client) - return - var/mob/dead/observer/M = src - if(jobban_isbanned(M, ROLEBAN_AHUD)) - to_chat(src, "You have been banned from using this feature") - 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" diff --git a/code/modules/mob/living/carbon/human/examine.dm b/code/modules/mob/living/carbon/human/examine.dm index 92ee3c2195d..cc85d785a86 100644 --- a/code/modules/mob/living/carbon/human/examine.dm +++ b/code/modules/mob/living/carbon/human/examine.dm @@ -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 diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index cb39d6cc9c0..6bc7b9d454b 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -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) diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index e10a405a749..00d7336e380 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -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 diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index 003a3b819ca..27226bff98f 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -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 diff --git a/code/modules/tgui/modules/ghost_hud_panel.dm b/code/modules/tgui/modules/ghost_hud_panel.dm new file mode 100644 index 00000000000..fe35872bc04 --- /dev/null +++ b/code/modules/tgui/modules/ghost_hud_panel.dm @@ -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, "Admins have disabled this for this round.") + return FALSE + if(jobban_isbanned(ghost, "AntagHUD")) + to_chat(ghost, "You have been banned from using this feature.") + 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) diff --git a/paradise.dme b/paradise.dme index 6295af0a3dd..10c27234feb 100644 --- a/paradise.dme +++ b/paradise.dme @@ -2454,6 +2454,7 @@ #include "code\modules\tgui\modules\crew_monitor.dm" #include "code\modules\tgui\modules\ert_manager.dm" #include "code\modules\tgui\modules\generic_crew_manifest.dm" +#include "code\modules\tgui\modules\ghost_hud_panel.dm" #include "code\modules\tgui\modules\law_manager.dm" #include "code\modules\tgui\modules\power_monitor.dm" #include "code\modules\tgui\modules\volume_mixer.dm" diff --git a/tgui/packages/tgui/interfaces/GhostHudPanel.js b/tgui/packages/tgui/interfaces/GhostHudPanel.js new file mode 100644 index 00000000000..766786067ef --- /dev/null +++ b/tgui/packages/tgui/interfaces/GhostHudPanel.js @@ -0,0 +1,53 @@ +import { useBackend } from "../backend"; +import { Button, Section, Flex, Divider } from "../components"; +import { Window } from "../layouts"; + +export const GhostHudPanel = (props, context) => { + const { data } = useBackend(context); + const { + security, + medical, + diagnostic, + ahud, + } = data; + return ( + + +
+ + + + + +
+
+
+ ); +}; + +const HudEntry = (props, context) => { + const { act } = useBackend(context); + const { + label, + type = null, + is_active, + act_on = 'hud_on', + act_off = 'hud_off', + } = props; + return ( + + + {label} + + +