From b6cd6b438496207e1e2b95db7ae4dc5200fcbab3 Mon Sep 17 00:00:00 2001 From: SamCroswell Date: Thu, 11 Jun 2015 21:42:15 -0400 Subject: [PATCH] Rewrites HUD Handling for Glasses --- code/__DEFINES/sight.dm | 4 ++ code/_globalvars/lists/mobs.dm | 1 + code/defines/procs/hud.dm | 16 +++++- code/game/mecha/medical/odysseus.dm | 54 +------------------ code/modules/clothing/glasses/glasses.dm | 8 +-- code/modules/clothing/glasses/hud.dm | 28 ++-------- code/modules/mob/living/carbon/human/life.dm | 20 ++++--- code/modules/mob/living/silicon/robot/life.dm | 14 ++--- 8 files changed, 39 insertions(+), 106 deletions(-) diff --git a/code/__DEFINES/sight.dm b/code/__DEFINES/sight.dm index 677d33ecddc..093f6a7f6f0 100644 --- a/code/__DEFINES/sight.dm +++ b/code/__DEFINES/sight.dm @@ -29,3 +29,7 @@ #define BORGMESON 1 #define BORGTHERM 2 #define BORGXRAY 4 + +#define SECHUD 1 +#define MEDHUD 2 +#define ANTAGHUD 3 diff --git a/code/_globalvars/lists/mobs.dm b/code/_globalvars/lists/mobs.dm index 153a81c4aa0..5de92892b30 100644 --- a/code/_globalvars/lists/mobs.dm +++ b/code/_globalvars/lists/mobs.dm @@ -50,6 +50,7 @@ var/global/list/blocked_mobs = list(/mob/living/simple_animal/hostile, var/global/list/med_hud_users = list() var/global/list/sec_hud_users = list() +var/global/list/antag_hud_users = list() //items that ask to be called every cycle var/global/list/active_diseases = list() //Diseases are mob-based, so they get to go here \ No newline at end of file diff --git a/code/defines/procs/hud.dm b/code/defines/procs/hud.dm index c225a896cf5..14e24033e68 100644 --- a/code/defines/procs/hud.dm +++ b/code/defines/procs/hud.dm @@ -9,7 +9,7 @@ proc/process_med_hud(var/mob/M, var/local_scanner, var/mob/Alt) var/datum/arranged_hud_process/P = arrange_hud_process(M, Alt, med_hud_users) for(var/mob/living/carbon/human/patient in P.Mob.in_view(P.Turf)) - if(P.Mob.see_invisible < patient.invisibility) + if(P.Mob.see_invisible < patient.invisibility || patient.alpha < 127) continue if(!local_scanner) @@ -30,7 +30,7 @@ proc/process_sec_hud(var/mob/M, var/advanced_mode, var/mob/Alt) return var/datum/arranged_hud_process/P = arrange_hud_process(M, Alt, sec_hud_users) for(var/mob/living/carbon/human/perp in P.Mob.in_view(P.Turf)) - if(P.Mob.see_invisible < perp.invisibility) + if(P.Mob.see_invisible < perp.invisibility || perp.alpha < 127) continue P.Client.images += perp.hud_list[ID_HUD] @@ -40,6 +40,17 @@ proc/process_sec_hud(var/mob/M, var/advanced_mode, var/mob/Alt) P.Client.images += perp.hud_list[IMPLOYAL_HUD] P.Client.images += perp.hud_list[IMPCHEM_HUD] + +proc/process_antag_hud(var/mob/M, var/mob/Alt) + if(!can_process_hud(M)) + return + var/datum/arranged_hud_process/P = arrange_hud_process(M, Alt, antag_hud_users) + for(var/mob/living/carbon/human/target in P.Mob.in_view(P.Turf)) + if(P.Mob.see_invisible < target.invisibility || target.alpha < 127) + continue + + P.Client.images += target.hud_list[SPECIALROLE_HUD] + datum/arranged_hud_process var/client/Client var/mob/Mob @@ -70,6 +81,7 @@ mob/proc/regular_hud_updates() //Used in the life.dm of mobs that can use HUDs. client.images -= hud med_hud_users -= src sec_hud_users -= src + antag_hud_users -= src mob/proc/in_view(var/turf/T) return view(T) diff --git a/code/game/mecha/medical/odysseus.dm b/code/game/mecha/medical/odysseus.dm index 180c6a0c537..e6c169e843d 100644 --- a/code/game/mecha/medical/odysseus.dm +++ b/code/game/mecha/medical/odysseus.dm @@ -61,56 +61,4 @@ //TODO - Check documentation for client.eye and client.perspective... /obj/item/clothing/glasses/hud/health/mech name = "Integrated Medical Hud" - - - process_hud(var/mob/M) -/* - world<< "view(M)" - for(var/mob/mob in view(M)) - world << "[mob]" - world<< "view(M.client)" - for(var/mob/mob in view(M.client)) - world << "[mob]" - world<< "view(M.loc)" - for(var/mob/mob in view(M.loc)) - world << "[mob]" -*/ - - if(!M || M.stat || !(M in view(M))) return - if(!M.client) return - var/client/C = M.client - var/image/holder - for(var/mob/living/carbon/human/patient in view(M.loc)) - if(M.see_invisible < patient.invisibility) - continue - var/foundVirus = 0 - - for (var/ID in patient.virus2) - if (ID in virusDB) - foundVirus = 1 - break - - holder = patient.hud_list[HEALTH_HUD] - if(patient.stat == 2) - holder.icon_state = "hudhealth-100" - C.images += holder - else - holder.icon_state = "hud[RoundHealth(patient.health)]" - C.images += holder - - holder = patient.hud_list[STATUS_HUD] - if(patient.stat == 2) - holder.icon_state = "huddead" - else if(patient.status_flags & XENO_HOST) - holder.icon_state = "hudxeno" - else if(foundVirus) - holder.icon_state = "hudill" - else if(patient.has_brain_worms()) - var/mob/living/simple_animal/borer/B = patient.has_brain_worms() - if(B.controlling) - holder.icon_state = "hudbrainworm" - else - holder.icon_state = "hudhealthy" - else - holder.icon_state = "hudhealthy" - C.images += holder + HUDType = MEDHUD diff --git a/code/modules/clothing/glasses/glasses.dm b/code/modules/clothing/glasses/glasses.dm index c2d333dd849..7e825d76539 100644 --- a/code/modules/clothing/glasses/glasses.dm +++ b/code/modules/clothing/glasses/glasses.dm @@ -9,6 +9,7 @@ //var/invisa_view = 0 var/prescription = 0 var/see_darkness = 1 + var/HUDType = 0 /obj/item/clothing/glasses/meson name = "Optical Meson Scanner" @@ -258,17 +259,12 @@ darkness_view = 1 flash_protect = 1 tint = 1 - var/obj/item/clothing/glasses/hud/security/hud = null + HUDType = SECHUD species_fit = list("Vox") sprite_sheets = list( "Vox" = 'icons/mob/species/vox/eyes.dmi' ) - New() - ..() - src.hud = new/obj/item/clothing/glasses/hud/security(src) - return - /obj/item/clothing/glasses/thermal name = "Optical Thermal Scanner" desc = "Thermals in the shape of glasses." diff --git a/code/modules/clothing/glasses/hud.dm b/code/modules/clothing/glasses/hud.dm index 3942b732624..541eb9321f3 100644 --- a/code/modules/clothing/glasses/hud.dm +++ b/code/modules/clothing/glasses/hud.dm @@ -3,23 +3,22 @@ desc = "A heads-up display that provides important info in (almost) real time." flags = null //doesn't protect eyes because it's a monocle, duh origin_tech = "magnets=3;biotech=2" + HUDType = SECHUD var/list/icon/current = list() //the current hud icons - proc - process_hud(var/mob/M) return - - /obj/item/clothing/glasses/hud/health name = "Health Scanner HUD" desc = "A heads-up display that scans the humans in view and provides accurate data about their health status." icon_state = "healthhud" + HUDType = MEDHUD /obj/item/clothing/glasses/hud/health_advanced name = "Advanced Health Scanner HUD" desc = "A heads-up display that scans the humans in view and provides accurate data about their health status. Includes anti-flash filter." icon_state = "advmedhud" flash_protect = 1 + HUDType = MEDHUD /obj/item/clothing/glasses/hud/health/night name = "Night Vision Health Scanner HUD" @@ -29,12 +28,6 @@ darkness_view = 8 see_darkness = 0 -/obj/item/clothing/glasses/hud/health/process_hud(var/mob/M) - process_med_hud(M,1) - -/obj/item/clothing/glasses/hud/health_advanced/process_hud(var/mob/M) - process_med_hud(M,1) - /obj/item/clothing/glasses/hud/security name = "Security HUD" @@ -57,18 +50,3 @@ icon_state = "securityhudnight" darkness_view = 8 see_darkness = 0 - -/obj/item/clothing/glasses/hud/security/process_hud(var/mob/M) - - if(!M) return - if(!M.client) return - var/client/C = M.client - for(var/mob/living/carbon/human/perp in view(get_turf(M))) - if(M.see_invisible < perp.invisibility) - continue - if(!C) continue - C.images += perp.hud_list[ID_HUD] - C.images += perp.hud_list[WANTED_HUD] - C.images += perp.hud_list[IMPTRACK_HUD] - C.images += perp.hud_list[IMPLOYAL_HUD] - C.images += perp.hud_list[IMPCHEM_HUD] diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index ad7508c5b8d..eecff996b82 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -1192,18 +1192,16 @@ var/global/list/brutefireloss_overlays = list("1" = image("icon" = 'icons/mob/sc /* HUD shit goes here, as long as it doesn't modify sight flags */ // The purpose of this is to stop xray and w/e from preventing you from using huds -- Love, Doohl - if(istype(glasses, /obj/item/clothing/glasses/sunglasses)) - see_in_dark = 1 - if(istype(glasses, /obj/item/clothing/glasses/sunglasses/sechud)) - var/obj/item/clothing/glasses/sunglasses/sechud/O = glasses - if(O.hud) O.hud.process_hud(src) - if(!druggy) see_invisible = (!O.see_darkness || O.vision_flags ? SEE_INVISIBLE_MINIMUM : SEE_INVISIBLE_LIVING) // So we can have meson/thermal/material sunglasses + switch(G.HUDType) + if(SECHUD) + process_sec_hud(src,1) + if(MEDHUD) + process_med_hud(src,1) + if(ANTAGHUD) + process_antag_hud(src) + + - if(istype(glasses, /obj/item/clothing/glasses/hud)) - var/obj/item/clothing/glasses/hud/O = glasses - O.process_hud(src) - if(!druggy) - see_invisible = (!O.see_darkness || O.vision_flags ? SEE_INVISIBLE_MINIMUM : SEE_INVISIBLE_LIVING) else if(!seer) see_in_dark = species.darksight see_invisible = SEE_INVISIBLE_LIVING diff --git a/code/modules/mob/living/silicon/robot/life.dm b/code/modules/mob/living/silicon/robot/life.dm index 4694cf22d53..5400fa55d9d 100644 --- a/code/modules/mob/living/silicon/robot/life.dm +++ b/code/modules/mob/living/silicon/robot/life.dm @@ -195,15 +195,11 @@ regular_hud_updates() - var/obj/item/borg/sight/hud/hud = (locate(/obj/item/borg/sight/hud) in src) - if(hud && hud.hud) - hud.hud.process_hud(src) - else - switch(src.sensor_mode) - if (SEC_HUD) - process_sec_hud(src,1) - if (MED_HUD) - process_med_hud(src,1) + switch(src.sensor_mode) + if (SEC_HUD) + process_sec_hud(src,1) + if (MED_HUD) + process_med_hud(src,1) if (src.healths) if (src.stat != 2)