diff --git a/code/__DEFINES/hud.dm b/code/__DEFINES/hud.dm new file mode 100644 index 00000000000..8842b23e433 --- /dev/null +++ b/code/__DEFINES/hud.dm @@ -0,0 +1,26 @@ +// for secHUDs and medHUDs and variants. The number is the location of the image on the list hud_list +// note: if you add more HUDs, even for non-human atoms, make sure to use unique numbers for the defines! +// /datum/atom_hud expects these to be unique +// these need to be strings in order to make them associative lists +#define HEALTH_HUD "1" // dead, alive, sick, health status +#define STATUS_HUD "2" // a simple line rounding the mob's number health +#define ID_HUD "3" // the job asigned to your ID +#define WANTED_HUD "4" // wanted, released, parroled, security status +#define IMPLOYAL_HUD "5" // loyality implant +#define IMPCHEM_HUD "6" // chemical implant +#define IMPTRACK_HUD "7" // tracking implant +//for antag huds. these are used at the /mob level +#define ANTAG_HUD "8" + +//data HUD (medhud, sechud) defines +//Don't forget to update human/New() if you change these! +#define DATA_HUD_SECURITY_BASIC 1 +#define DATA_HUD_SECURITY_ADVANCED 2 +#define DATA_HUD_MEDICAL_BASIC 3 +#define DATA_HUD_MEDICAL_ADVANCED 4 +//antag HUD defines +#define ANTAG_HUD_CULT 5 +#define ANTAG_HUD_REV 6 +#define ANTAG_HUD_OPS 7 +#define ANTAG_HUD_GANG_A 8 +#define ANTAG_HUD_GANG_B 9 diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm index 4bd75185e3a..4af1675b4e7 100644 --- a/code/__DEFINES/misc.dm +++ b/code/__DEFINES/misc.dm @@ -51,11 +51,3 @@ #define STAGE_THREE 5 #define STAGE_FOUR 7 #define STAGE_FIVE 9 - -//data HUD (medhud, sechud) defines -//Don't forget to update human/New() if you change these! -#define DATA_HUD_SECURITY_BASIC 1 -#define DATA_HUD_SECURITY_ADVANCED 2 -#define DATA_HUD_MEDICAL_BASIC 3 -#define DATA_HUD_MEDICAL_ADVANCED 4 - diff --git a/code/__DEFINES/sight.dm b/code/__DEFINES/sight.dm index 69ced6e7ec2..40c56793bac 100644 --- a/code/__DEFINES/sight.dm +++ b/code/__DEFINES/sight.dm @@ -21,14 +21,3 @@ #define BORGMESON 1 #define BORGTHERM 2 #define BORGXRAY 4 - -// for secHUDs and medHUDs and variants. The number is the location of the image on the list hud_list -// note: if you add more HUDs, even for non-human atoms, make sure to use unique numbers for the defines! -// /datum/hud expects these to be unique -#define HEALTH_HUD 1 // dead, alive, sick, health status -#define STATUS_HUD 2 // a simple line rounding the mob's number health -#define ID_HUD 3 // the job asigned to your ID -#define WANTED_HUD 4 // wanted, released, parroled, security status -#define IMPLOYAL_HUD 5 // loyality implant -#define IMPCHEM_HUD 6 // chemical implant -#define IMPTRACK_HUD 7 // tracking implant diff --git a/code/datums/hud.dm b/code/datums/hud.dm index 01175665528..be80338e64e 100644 --- a/code/datums/hud.dm +++ b/code/datums/hud.dm @@ -1,50 +1,70 @@ /* HUD DATUMS */ -var/datum/hud/huds = list( \ - DATA_HUD_SECURITY_BASIC = new/datum/hud/data/security/basic(), \ - DATA_HUD_SECURITY_ADVANCED = new/datum/hud/data/security/advanced(), \ - DATA_HUD_MEDICAL_BASIC = new/datum/hud/data/medical/basic(), \ - DATA_HUD_MEDICAL_ADVANCED = new/datum/hud/data/medical/advanced() \ +//GLOBAL HUD LIST +var/datum/atom_hud/huds = list( \ + DATA_HUD_SECURITY_BASIC = new/datum/atom_hud/data/security/basic(), \ + DATA_HUD_SECURITY_ADVANCED = new/datum/atom_hud/data/security/advanced(), \ + DATA_HUD_MEDICAL_BASIC = new/datum/atom_hud/data/medical/basic(), \ + DATA_HUD_MEDICAL_ADVANCED = new/datum/atom_hud/data/medical/advanced(), \ + ANTAG_HUD_CULT = new/datum/atom_hud/antag(), \ + ANTAG_HUD_REV = new/datum/atom_hud/antag(), \ + ANTAG_HUD_OPS = new/datum/atom_hud/antag(), \ + ANTAG_HUD_GANG_A = new/datum/atom_hud/antag(), \ + ANTAG_HUD_GANG_B = new/datum/atom_hud/antag(), \ ) -/atom/proc/add_to_all_huds() - for(var/datum/hud/hud in huds) hud.add_to_hud(src) +/mob/proc/refresh_huds(var/mob/inherited_from = null) + var/mob/seek_for = (inherited_from) ? inherited_from : src + var/image/oldantagicon = seek_for.hud_list[ANTAG_HUD] + var/image/newantagicon = hud_list[ANTAG_HUD] + newantagicon.icon_state = oldantagicon.icon_state + if(istype(inherited_from, /mob/dead/observer)) + var/mob/dead/observer/G = inherited_from + for(var/datum/atom_hud/hud in G.oldhuds) + readd_hud(hud) + else + for(var/datum/atom_hud/hud in huds) + if(seek_for in hud.hudusers) + readd_hud(hud) -/atom/proc/remove_from_all_huds() - for(var/datum/hud/hud in huds) hud.remove_from_hud(src) +/mob/proc/readd_hud(var/datum/atom_hud/hud) + hud.add_hud_to(src) -/datum/hud +/mob/dead/observer/readd_hud(var/datum/atom_hud/hud) + oldhuds |= hud + +/datum/atom_hud var/list/atom/hudatoms = list() //list of all atoms which display this hud var/list/mob/hudusers = list() //list with all mobs who can see the hud var/list/hud_icons = list() //these will be the indexes for the atom's hud_list -/datum/hud/proc/remove_hud_from(var/mob/M) +/datum/atom_hud/proc/remove_hud_from(var/mob/M) for(var/atom/A in hudatoms) remove_from_single_hud(M, A) hudusers -= M -/datum/hud/proc/remove_from_hud(var/atom/A) +/datum/atom_hud/proc/remove_from_hud(var/atom/A) for(var/mob/M in hudusers) remove_from_single_hud(M, A) hudatoms -= A -/datum/hud/proc/remove_from_single_hud(var/mob/M, var/atom/A) //unsafe, no sanity apart from client +/datum/atom_hud/proc/remove_from_single_hud(var/mob/M, var/atom/A) //unsafe, no sanity apart from client if(!M.client) return for(var/i in hud_icons) M.client.images -= A.hud_list[i] -/datum/hud/proc/add_hud_to(var/mob/M) +/datum/atom_hud/proc/add_hud_to(var/mob/M) hudusers |= M for(var/atom/A in hudatoms) add_to_single_hud(M, A) -/datum/hud/proc/add_to_hud(var/atom/A) +/datum/atom_hud/proc/add_to_hud(var/atom/A) hudatoms |= A for(var/mob/M in hudusers) add_to_single_hud(M, A) -/datum/hud/proc/add_to_single_hud(var/mob/M, var/atom/A) //unsafe, no sanity apart from client +/datum/atom_hud/proc/add_to_single_hud(var/mob/M, var/atom/A) //unsafe, no sanity apart from client if(!M.client) return for(var/i in hud_icons) diff --git a/code/datums/mind.dm b/code/datums/mind.dm index 914c80fe622..51e2fa251f7 100644 --- a/code/datums/mind.dm +++ b/code/datums/mind.dm @@ -75,6 +75,7 @@ if(new_character.mind) //disassociate any mind currently in our new body's mind variable new_character.mind.current = null + new_character.refresh_huds(current) //inherit the HUDs from the old body current = new_character //associate ourself with our new body new_character.mind = src //and associate our new body with ourself diff --git a/code/game/atoms.dm b/code/game/atoms.dm index 9b7041c00c5..7a712a2001a 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -12,8 +12,10 @@ ///Chemistry. var/datum/reagents/reagents = null - //This atom's HUDs. associative list, e.g. hud_list[DATA_HUD_SECURITY] = list(sec_hud_images) + //This atom's HUD (med/sec, etc) images. Associative list. var/list/image/hud_list = list() + //HUD images that this atom can provide. + var/list/hud_possible //var/chem_is_open_container = 0 // replaced by OPENCONTAINER flags and atom/proc/is_open_container() diff --git a/code/game/data_huds.dm b/code/game/data_huds.dm index 908024c2835..19b37ee8d30 100644 --- a/code/game/data_huds.dm +++ b/code/game/data_huds.dm @@ -1,40 +1,47 @@ /* - * Data HUDs are now passive in order to reduce lag. - * Add then to a mob using add_data_hud. - * Update them when needed with the appropriate proc. (see below) + * Data HUDs have been rewritten in a more generic way. + * In short, they now use an observer-listener pattern. + * See code/datum/hud.dm for the generic hud datum. + * Update the HUD icons when needed with the appropriate hook. (see below) */ -//see code/datum/hud.dm for the generic hud datum +/* DATA HUD DATUMS */ -/datum/hud/data +/atom/proc/add_to_all_data_huds() + for(var/datum/atom_hud/data/hud in huds) hud.add_to_hud(src) -/datum/hud/data/medical +/atom/proc/remove_from_all_data_huds() + for(var/datum/atom_hud/data/hud in huds) hud.remove_from_hud(src) + +/datum/atom_hud/data + +/datum/atom_hud/data/medical hud_icons = list(HEALTH_HUD, STATUS_HUD) -/datum/hud/data/medical/basic +/datum/atom_hud/data/medical/basic -/datum/hud/data/medical/basic/proc/check_sensors(var/mob/living/carbon/human/H) +/datum/atom_hud/data/medical/basic/proc/check_sensors(var/mob/living/carbon/human/H) if(!istype(H)) return 0 var/obj/item/clothing/under/U = H.w_uniform if(!istype(U)) return 0 if(U.sensor_mode <= 2) return 0 return 1 -/datum/hud/data/medical/basic/add_to_single_hud(var/mob/M, var/mob/living/carbon/human/H) +/datum/atom_hud/data/medical/basic/add_to_single_hud(var/mob/M, var/mob/living/carbon/human/H) if(check_sensors(H)) ..() -/datum/hud/data/medical/basic/proc/update_suit_sensors(var/mob/living/carbon/human/H) +/datum/atom_hud/data/medical/basic/proc/update_suit_sensors(var/mob/living/carbon/human/H) check_sensors(H) ? add_to_hud(H) : remove_from_hud(H) -/datum/hud/data/medical/advanced +/datum/atom_hud/data/medical/advanced -/datum/hud/data/security +/datum/atom_hud/data/security -/datum/hud/data/security/basic +/datum/atom_hud/data/security/basic hud_icons = list(ID_HUD) -/datum/hud/data/security/advanced +/datum/atom_hud/data/security/advanced hud_icons = list(ID_HUD, IMPTRACK_HUD, IMPLOYAL_HUD, IMPCHEM_HUD, WANTED_HUD) /* MED/SEC HUD HOOKS */ @@ -83,7 +90,7 @@ //called when a human changes suit sensors /mob/living/carbon/human/proc/update_suit_sensors() - var/datum/hud/data/medical/basic/B = huds[DATA_HUD_MEDICAL_BASIC] + var/datum/atom_hud/data/medical/basic/B = huds[DATA_HUD_MEDICAL_BASIC] B.update_suit_sensors(src) //called when a human changes health diff --git a/code/game/gamemodes/antag_hud.dm b/code/game/gamemodes/antag_hud.dm new file mode 100644 index 00000000000..62a4f23b976 --- /dev/null +++ b/code/game/gamemodes/antag_hud.dm @@ -0,0 +1,14 @@ +/datum/atom_hud/antag + hud_icons = list(ANTAG_HUD) + +/datum/atom_hud/antag/proc/join_hud(var/mob/M) + add_to_hud(M) + add_hud_to(M) + +/datum/atom_hud/antag/proc/leave_hud(var/mob/M) + remove_from_hud(M) + remove_hud_from(M) + +/datum/game_mode/proc/set_antag_hud(var/mob/M, var/new_icon_state) + var/image/holder = M.hud_list[ANTAG_HUD] + holder.icon_state = new_icon_state diff --git a/code/game/gamemodes/cult/cult.dm b/code/game/gamemodes/cult/cult.dm index eb67ca4895d..a8394f6235f 100644 --- a/code/game/gamemodes/cult/cult.dm +++ b/code/game/gamemodes/cult/cult.dm @@ -241,52 +241,15 @@ for(var/mob/M in viewers(cult_mind.current)) M << "[cult_mind.current] looks like they just reverted to their old faith!" -/datum/game_mode/proc/update_all_cult_icons() - spawn(0) - for(var/datum/mind/cultist in cult) - if(cultist.current) - if(cultist.current.client) - for(var/image/I in cultist.current.client.images) - if(I.icon_state == "cult") - del(I) - - for(var/datum/mind/cultist in cult) - if(cultist.current) - if(cultist.current.client) - for(var/datum/mind/cultist_1 in cult) - if(cultist_1.current) - var/I = image('icons/mob/mob.dmi', loc = cultist_1.current, icon_state = "cult") - cultist.current.client.images += I - - /datum/game_mode/proc/update_cult_icons_added(datum/mind/cult_mind) - spawn(0) - for(var/datum/mind/cultist in cult) - if(cultist.current) - if(cultist.current.client) - var/I = image('icons/mob/mob.dmi', loc = cult_mind.current, icon_state = "cult") - cultist.current.client.images += I - if(cult_mind.current) - if(cult_mind.current.client) - var/image/J = image('icons/mob/mob.dmi', loc = cultist.current, icon_state = "cult") - cult_mind.current.client.images += J - + var/datum/atom_hud/antag/culthud = huds[ANTAG_HUD_CULT] + culthud.join_hud(cult_mind.current) + set_antag_hud(cult_mind.current, "cult") /datum/game_mode/proc/update_cult_icons_removed(datum/mind/cult_mind) - spawn(0) - for(var/datum/mind/cultist in cult) - if(cultist.current) - if(cultist.current.client) - for(var/image/I in cultist.current.client.images) - if(I.icon_state == "cult" && I.loc == cult_mind.current) - del(I) - - if(cult_mind.current) - if(cult_mind.current.client) - for(var/image/I in cult_mind.current.client.images) - if(I.icon_state == "cult") - del(I) - + var/datum/atom_hud/antag/culthud = huds[ANTAG_HUD_CULT] + culthud.leave_hud(cult_mind.current) + set_antag_hud(cult_mind.current, null) /datum/game_mode/cult/proc/get_unconvertables() var/list/ucs = list() diff --git a/code/game/gamemodes/gang/gang.dm b/code/game/gamemodes/gang/gang.dm index 9a4374959f7..718f9ad8d65 100644 --- a/code/game/gamemodes/gang/gang.dm +++ b/code/game/gamemodes/gang/gang.dm @@ -233,127 +233,41 @@ gangster_mind.current.visible_message("[gangster_mind.current] looks like they've given up the life of crime!") gangster_mind.current << "You have been reformed! You are no longer a gangster!" - update_gang_icons_removed(gangster_mind) + update_gang_icons_removed(gangster_mind, gang) +/////////////////////// +//Add/remove gang HUD// +/////////////////////// +/datum/game_mode/proc/get_gang_hud(var/gang) + var/datum/atom_hud/antag/ganghud = null + switch(gang) + if("A") ganghud = huds[ANTAG_HUD_GANG_A] + if("B") ganghud = huds[ANTAG_HUD_GANG_B] + return ganghud -///////////////////////////////////////////////////////////////////////////////////////////////// -//Keeps track of players having the correct icons//////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////// -/datum/game_mode/proc/update_all_gang_icons() - spawn(0) - var/list/all_gangsters = A_bosses + B_bosses + A_gangsters + B_gangsters +/datum/game_mode/proc/get_gang_bosses(var/gang) + var/bosses = null + switch(gang) + if("A") bosses = A_bosses + if("B") bosses = B_bosses + return bosses - //Delete all gang icons - for(var/datum/mind/gang_mind in all_gangsters) - if(gang_mind.current) - if(gang_mind.current.client) - for(var/image/I in gang_mind.current.client.images) - if(I.icon_state == "gangster" || I.icon_state == "gang_boss") - del(I) - - update_gang_icons("A") - update_gang_icons("B") - -/datum/game_mode/proc/update_gang_icons(var/gang) - var/list/bosses - var/list/gangsters - if(gang == "A") - bosses = A_bosses - gangsters = A_gangsters - else if(gang == "B") - bosses = B_bosses - gangsters = B_gangsters - else - world << "ERROR: Invalid gang in update_gang_icons()" - - //Update gang icons for boss' visions - for(var/datum/mind/boss_mind in bosses) - if(boss_mind.current) - if(boss_mind.current.client) - for(var/datum/mind/gangster_mind in gangsters) - if(gangster_mind.current) - var/I = image('icons/mob/mob.dmi', loc = gangster_mind.current, icon_state = "gangster") - boss_mind.current.client.images += I - for(var/datum/mind/boss2_mind in bosses) - if(boss2_mind.current) - var/I = image('icons/mob/mob.dmi', loc = boss2_mind.current, icon_state = "gang_boss") - boss_mind.current.client.images += I - - //Update boss and self icons for gangsters' visions - for(var/datum/mind/gangster_mind in gangsters) - if(gangster_mind.current) - if(gangster_mind.current.client) - for(var/datum/mind/boss_mind in bosses) - if(boss_mind.current) - var/I = image('icons/mob/mob.dmi', loc = boss_mind.current, icon_state = "gang_boss") - gangster_mind.current.client.images += I - //Tag themselves to see - var/K - if(gangster_mind in bosses) //If the new gangster is a boss himself - K = image('icons/mob/mob.dmi', loc = gangster_mind.current, icon_state = "gang_boss") - else - K = image('icons/mob/mob.dmi', loc = gangster_mind.current, icon_state = "gangster") - gangster_mind.current.client.images += K - -///////////////////////////////////////////////// -//Assigns icons when a new gangster is recruited// -///////////////////////////////////////////////// /datum/game_mode/proc/update_gang_icons_added(datum/mind/recruit_mind, var/gang) - var/list/bosses - if(gang == "A") - bosses = A_bosses - else if(gang == "B") - bosses = B_bosses - if(!gang) - world << "ERROR: Invalid gang in update_gang_icons_added()" + var/datum/atom_hud/antag/ganghud = get_gang_hud(gang) + var/bosses = get_gang_bosses(gang) + if(!ganghud) + ERROR("Invalid gang in update_gang_icons_added(): [gang]") - spawn(0) - for(var/datum/mind/boss_mind in bosses) - //Tagging the new gangster for the bosses to see - if(boss_mind.current) - if(boss_mind.current.client) - var/I - if(recruit_mind in bosses) //If the new gangster is a boss himself - I = image('icons/mob/mob.dmi', loc = recruit_mind.current, icon_state = "gang_boss") - else - I = image('icons/mob/mob.dmi', loc = recruit_mind.current, icon_state = "gangster") - boss_mind.current.client.images += I - //Tagging every boss for the new gangster to see - if(recruit_mind.current) - if(recruit_mind.current.client) - var/image/J = image('icons/mob/mob.dmi', loc = boss_mind.current, icon_state = "gang_boss") - recruit_mind.current.client.images += J - //Tag themselves to see - if(recruit_mind.current) - if(recruit_mind.current.client) - var/K - if(recruit_mind in bosses) //If the new gangster is a boss himself - K = image('icons/mob/mob.dmi', loc = recruit_mind.current, icon_state = "gang_boss") - else - K = image('icons/mob/mob.dmi', loc = recruit_mind.current, icon_state = "gangster") - recruit_mind.current.client.images += K + ganghud.join_hud(recruit_mind.current) + set_antag_hud(recruit_mind.current, ((recruit_mind in bosses) ? "gang_boss" : "gangster")) -//////////////////////////////////////// -//Keeps track of deconverted gangsters// -//////////////////////////////////////// -/datum/game_mode/proc/update_gang_icons_removed(datum/mind/defector_mind) - var/list/all_gangsters = A_bosses + B_bosses + A_gangsters + B_gangsters +/datum/game_mode/proc/update_gang_icons_removed(datum/mind/defector_mind, var/gang) + var/datum/atom_hud/antag/ganghud = get_gang_hud(gang) + if(!ganghud) + ERROR("Invalid gang in update_gang_icons_removed(): [gang]") - spawn(0) - //Remove defector's icon from gangsters' visions - for(var/datum/mind/boss_mind in all_gangsters) - if(boss_mind.current) - if(boss_mind.current.client) - for(var/image/I in boss_mind.current.client.images) - if((I.icon_state == "gangster" || I.icon_state == "gang_boss") && I.loc == defector_mind.current) - del(I) - - //Remove gang icons from defector's vision - if(defector_mind.current) - if(defector_mind.current.client) - for(var/image/I in defector_mind.current.client.images) - if(I.icon_state == "gangster" || I.icon_state == "gang_boss") - del(I) + ganghud.leave_hud(defector_mind.current) + set_antag_hud(defector_mind.current, null) /////////////////////////// //Checks for gang victory// diff --git a/code/game/gamemodes/nuclear/nuclear.dm b/code/game/gamemodes/nuclear/nuclear.dm index 913aaef67bd..ef02adb36ba 100644 --- a/code/game/gamemodes/nuclear/nuclear.dm +++ b/code/game/gamemodes/nuclear/nuclear.dm @@ -48,44 +48,15 @@ //////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////// -/datum/game_mode/proc/update_all_synd_icons() - spawn(0) - for(var/datum/mind/synd_mind in syndicates) - if(synd_mind.current) - if(synd_mind.current.client) - for(var/image/I in synd_mind.current.client.images) - if(I.icon_state == "synd") - del(I) - - for(var/datum/mind/synd_mind in syndicates) - if(synd_mind.current) - if(synd_mind.current.client) - for(var/datum/mind/synd_mind_1 in syndicates) - if(synd_mind_1.current) - var/I = image('icons/mob/mob.dmi', loc = synd_mind_1.current, icon_state = "synd") - synd_mind.current.client.images += I - /datum/game_mode/proc/update_synd_icons_added(datum/mind/synd_mind) - spawn(0) - if(synd_mind.current) - if(synd_mind.current.client) - var/I = image('icons/mob/mob.dmi', loc = synd_mind.current, icon_state = "synd") - synd_mind.current.client.images += I + var/datum/atom_hud/antag/opshud = huds[ANTAG_HUD_OPS] + opshud.join_hud(synd_mind.current) + set_antag_hud(synd_mind.current, "synd") /datum/game_mode/proc/update_synd_icons_removed(datum/mind/synd_mind) - spawn(0) - for(var/datum/mind/synd in syndicates) - if(synd.current) - if(synd.current.client) - for(var/image/I in synd.current.client.images) - if(I.icon_state == "synd" && I.loc == synd_mind.current) - del(I) - - if(synd_mind.current) - if(synd_mind.current.client) - for(var/image/I in synd_mind.current.client.images) - if(I.icon_state == "synd") - del(I) + var/datum/atom_hud/antag/opshud = huds[ANTAG_HUD_OPS] + opshud.leave_hud(synd_mind.current) + set_antag_hud(synd_mind.current, null) //////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////// @@ -129,8 +100,6 @@ spawnpos++ update_synd_icons_added(synd_mind) - update_all_synd_icons() - if(uplinklocker) new /obj/structure/closet/syndicate/nuclear(uplinklocker.loc) if(nuke_spawn && synd_spawn.len > 0) diff --git a/code/game/gamemodes/revolution/revolution.dm b/code/game/gamemodes/revolution/revolution.dm index b7dbbce85bc..3dc96cba6fb 100644 --- a/code/game/gamemodes/revolution/revolution.dm +++ b/code/game/gamemodes/revolution/revolution.dm @@ -4,7 +4,6 @@ // Just make sure the converter is a head before you call it! // To remove a rev (from brainwashing or w/e), call ticker.mode:remove_revolutionary(_THE_PLAYERS_MIND_), // this will also check they're not a head, so it can just be called freely -// If the rev icons start going wrong for some reason, ticker.mode:update_all_rev_icons() can be called to correct them. // If the game somtimes isn't registering a win properly, then ticker.mode.check_win() isn't being called somewhere. /datum/game_mode @@ -258,120 +257,21 @@ else M << "[rev_mind.current] looks like they just remembered their real allegiance!" - -///////////////////////////////////////////////////////////////////////////////////////////////// -//Keeps track of players having the correct icons//////////////////////////////////////////////// -//CURRENTLY CONTAINS BUGS://///////////////////////////////////////////////////////////////////// -//-PLAYERS THAT HAVE BEEN REVS FOR AWHILE OBTAIN THE BLUE ICON WHILE STILL NOT BEING A REV HEAD// -// -Possibly caused by cloning of a standard rev///////////////////////////////////////////////// -//-UNCONFIRMED: DECONVERTED REVS NOT LOSING THEIR ICON PROPERLY////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////// -/datum/game_mode/proc/update_all_rev_icons() - spawn(0) - for(var/datum/mind/head_rev_mind in head_revolutionaries) - if(head_rev_mind.current) - if(head_rev_mind.current.client) - for(var/image/I in head_rev_mind.current.client.images) - if(I.icon_state == "rev" || I.icon_state == "rev_head") - del(I) - - for(var/datum/mind/rev_mind in revolutionaries) - if(rev_mind.current) - if(rev_mind.current.client) - for(var/image/I in rev_mind.current.client.images) - if(I.icon_state == "rev" || I.icon_state == "rev_head") - del(I) - - for(var/datum/mind/head_rev in head_revolutionaries) - if(head_rev.current) - if(head_rev.current.client) - for(var/datum/mind/rev in revolutionaries) - if(rev.current) - var/I = image('icons/mob/mob.dmi', loc = rev.current, icon_state = "rev") - head_rev.current.client.images += I - for(var/datum/mind/head_rev_1 in head_revolutionaries) - if(head_rev_1.current) - var/I = image('icons/mob/mob.dmi', loc = head_rev_1.current, icon_state = "rev_head") - head_rev.current.client.images += I - - for(var/datum/mind/rev in revolutionaries) - if(rev.current) - if(rev.current.client) - for(var/datum/mind/head_rev in head_revolutionaries) - if(head_rev.current) - var/I = image('icons/mob/mob.dmi', loc = head_rev.current, icon_state = "rev_head") - rev.current.client.images += I - for(var/datum/mind/rev_1 in revolutionaries) - if(rev_1.current) - var/I = image('icons/mob/mob.dmi', loc = rev_1.current, icon_state = "rev") - rev.current.client.images += I - -//////////////////////////////////////////////////// -//Keeps track of converted revs icons/////////////// -//Refer to above bugs. They may apply here as well// -//////////////////////////////////////////////////// +///////////////////////////////////// +//Adds the rev hud to a new convert// +///////////////////////////////////// /datum/game_mode/proc/update_rev_icons_added(datum/mind/rev_mind) - spawn(0) - for(var/datum/mind/head_rev_mind in head_revolutionaries) + var/datum/atom_hud/antag/revhud = huds[ANTAG_HUD_REV] + revhud.join_hud(rev_mind.current) + set_antag_hud(rev_mind.current, ((rev_mind in head_revolutionaries) ? "rev_head" : "rev")) - //Tagging the new rev for revheads to see - if(head_rev_mind.current) - if(head_rev_mind.current.client) - var/I - if(rev_mind in head_revolutionaries) //If the new rev is a head rev - I = image('icons/mob/mob.dmi', loc = rev_mind.current, icon_state = "rev_head") - else - I = image('icons/mob/mob.dmi', loc = rev_mind.current, icon_state = "rev") - head_rev_mind.current.client.images += I - - //Tagging the revheads for new rev to see - if(rev_mind.current) - if(rev_mind.current.client) - var/image/J = image('icons/mob/mob.dmi', loc = head_rev_mind.current, icon_state = "rev_head") - rev_mind.current.client.images += J - - for(var/datum/mind/rev_mind_1 in revolutionaries) - - //Tagging the new rev for fellow revs to see - if(rev_mind_1.current) - if(rev_mind_1.current.client) - var/I - if(rev_mind in head_revolutionaries) //If the new rev is a head rev - I = image('icons/mob/mob.dmi', loc = rev_mind.current, icon_state = "rev_head") - else - I = image('icons/mob/mob.dmi', loc = rev_mind.current, icon_state = "rev") - rev_mind_1.current.client.images += I - - //Tagging fellow revs for the new rev to see - if(rev_mind.current) - if(rev_mind.current.client) - var/image/J = image('icons/mob/mob.dmi', loc = rev_mind_1.current, icon_state = "rev") - rev_mind.current.client.images += J - -/////////////////////////////////// -//Keeps track of deconverted revs// -/////////////////////////////////// +///////////////////////////////////////// +//Removes the hud from deconverted revs// +///////////////////////////////////////// /datum/game_mode/proc/update_rev_icons_removed(datum/mind/rev_mind) - spawn(0) - for(var/datum/mind/head_rev_mind in head_revolutionaries) - if(head_rev_mind.current) - if(head_rev_mind.current.client) - for(var/image/I in head_rev_mind.current.client.images) - if((I.icon_state == "rev" || I.icon_state == "rev_head") && I.loc == rev_mind.current) - del(I) - - for(var/datum/mind/rev_mind_1 in revolutionaries) - if(rev_mind_1.current) - if(rev_mind_1.current.client) - for(var/image/I in rev_mind_1.current.client.images) - if((I.icon_state == "rev" || I.icon_state == "rev_head") && I.loc == rev_mind.current) - del(I) - - if(rev_mind.current) - if(rev_mind.current.client) - for(var/image/I in rev_mind.current.client.images) - if(I.icon_state == "rev" || I.icon_state == "rev_head") - del(I) + var/datum/atom_hud/antag/revhud = huds[ANTAG_HUD_REV] + revhud.leave_hud(rev_mind.current) + set_antag_hud(rev_mind.current, null) ////////////////////////// //Checks for rev victory// diff --git a/code/game/machinery/cloning.dm b/code/game/machinery/cloning.dm index f971345f42f..bc18f0d9985 100644 --- a/code/game/machinery/cloning.dm +++ b/code/game/machinery/cloning.dm @@ -168,24 +168,11 @@ //Here let's calculate their health so the pod doesn't immediately eject them!!! H.updatehealth() + H.refresh_huds(clonemind.current) clonemind.transfer_to(H) H.ckey = ckey H << "Consciousness slowly creeps over you as your body regenerates.
So this is what cloning feels like?
" - // -- Mode/mind specific stuff goes here - - if((H.mind in ticker.mode.revolutionaries) || (H.mind in ticker.mode.head_revolutionaries)) - ticker.mode.update_all_rev_icons() //So the icon actually appears - if((H.mind in ticker.mode.A_bosses) || ((H.mind in ticker.mode.A_gangsters) || (H.mind in ticker.mode.B_bosses)) || (H.mind in ticker.mode.B_gangsters)) - ticker.mode.update_all_gang_icons() - if(H.mind in ticker.mode.syndicates) - ticker.mode.update_all_synd_icons() - if (H.mind in ticker.mode.cult) - ticker.mode.add_cultist(src.occupant.mind) - ticker.mode.update_all_cult_icons() //So the icon actually appears - - // -- End mode specific stuff - hardset_dna(H, ui, se, null, null, mrace, mcolor) if(efficiency > 2) diff --git a/code/game/mecha/medical/odysseus.dm b/code/game/mecha/medical/odysseus.dm index 4eb74496ddd..fa7d79e6113 100644 --- a/code/game/mecha/medical/odysseus.dm +++ b/code/game/mecha/medical/odysseus.dm @@ -16,7 +16,7 @@ if(H.glasses && istype(H.glasses, /obj/item/clothing/glasses/hud)) occupant_message("Your [H.glasses] prevent you from using the built-in medical hud.") else - var/datum/hud/data/medical/advanced/A = huds[DATA_HUD_MEDICAL_ADVANCED] + var/datum/atom_hud/data/medical/advanced/A = huds[DATA_HUD_MEDICAL_ADVANCED] A.add_hud_to(H) builtin_hud_user = 1 return 1 @@ -26,7 +26,7 @@ /obj/mecha/medical/odysseus/go_out() if(ishuman(occupant) && builtin_hud_user) var/mob/living/carbon/human/H = occupant - var/datum/hud/data/medical/advanced/A = huds[DATA_HUD_MEDICAL_ADVANCED] + var/datum/atom_hud/data/medical/advanced/A = huds[DATA_HUD_MEDICAL_ADVANCED] A.remove_hud_from(H) ..() return diff --git a/code/modules/admin/verbs/one_click_antag.dm b/code/modules/admin/verbs/one_click_antag.dm index 4a5110e6016..8b9e6e3ccf6 100644 --- a/code/modules/admin/verbs/one_click_antag.dm +++ b/code/modules/admin/verbs/one_click_antag.dm @@ -302,8 +302,6 @@ client/proc/one_click_antag() new_character.mind.make_Nuke(synd_spawn[spawnpos],nuke_code) spawnpos++ - ticker.mode.update_all_synd_icons() - return 1 diff --git a/code/modules/clothing/glasses/hud.dm b/code/modules/clothing/glasses/hud.dm index ca98414000f..9b6ab29fda5 100644 --- a/code/modules/clothing/glasses/hud.dm +++ b/code/modules/clothing/glasses/hud.dm @@ -7,11 +7,11 @@ /obj/item/clothing/glasses/hud/equipped(mob/living/carbon/human/user, slot) if(slot == slot_glasses) - var/datum/hud/H = huds[hud_type] + var/datum/atom_hud/H = huds[hud_type] H.add_hud_to(user) /obj/item/clothing/glasses/hud/dropped(mob/living/carbon/human/user) - var/datum/hud/H = huds[hud_type] + var/datum/atom_hud/H = huds[hud_type] H.remove_hud_from(user) /obj/item/clothing/glasses/hud/emp_act(severity) diff --git a/code/modules/hydroponics/hydroponics.dm b/code/modules/hydroponics/hydroponics.dm index 34bb9efa0c3..735480138c1 100644 --- a/code/modules/hydroponics/hydroponics.dm +++ b/code/modules/hydroponics/hydroponics.dm @@ -812,29 +812,12 @@ obj/machinery/hydroponics/attackby(var/obj/item/O as obj, var/mob/user as mob) podman.real_name = realName else podman.real_name = "Pod Person [rand(0,999)]" + podman.refresh_huds(mind.current) var/oldactive = mind.active mind.active = 1 mind.transfer_to(podman) mind.active = oldactive - // -- Mode/mind specific stuff goes here. TODO! Broken :( Should be merged into mob/living/Login - if((podman.mind in ticker.mode.A_bosses) || (podman.mind in ticker.mode.A_gangsters) || (podman.mind in ticker.mode.B_bosses) || (podman.mind in ticker.mode.B_gangsters)) - ticker.mode.update_all_gang_icons() - if(podman.mind in ticker.mode:revolutionaries) - ticker.mode.add_revolutionary(podman.mind) - ticker.mode.update_all_rev_icons() //So the icon actually appears - if(podman.mind in ticker.mode:head_revolutionaries) - ticker.mode.add_revolutionary(podman.mind) - ticker.mode.update_all_rev_icons() - if(podman.mind in ticker.mode:syndicates) - ticker.mode:update_all_synd_icons() - if(podman.mind in ticker.mode:cult) - ticker.mode:add_cultist(podman.mind) - ticker.mode:update_all_cult_icons() //So the icon actually appears - - // -- End mode specific stuff - podman.gender = ghost.gender - //dna stuff hardset_dna(podman, ui, se, null, null, null, !prob(potency) ? /datum/species/plant/pod : null, "#59CE00") //makes sure podman has dna and sets the dna's ui/se/mutantrace/real_name etc variables diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index f7da665c052..d8aac764edd 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -19,6 +19,7 @@ //Note that this is not a reliable way to determine if admins started as observers, since they change mobs a lot. var/atom/movable/following = null var/fun_verbs = 0 + var/list/datum/atom_hud/oldhuds = null //old antag hud, gets readded in cloning/plantpodding /mob/dead/observer/New(mob/body) sight |= SEE_TURFS | SEE_MOBS | SEE_OBJS | SEE_SELF @@ -69,6 +70,7 @@ Works together with spawning an observer, noted above. var/mob/dead/observer/ghost = new(src) //Transfer safety to observer spawning proc. ghost.can_reenter_corpse = can_reenter_corpse ghost.key = key + ghost.refresh_huds(src) //inherit the HUDs return ghost /* diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 83ede6120b3..0e4f3d8fe82 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -26,8 +26,6 @@ internal_organs += new /obj/item/organ/heart internal_organs += new /obj/item/organ/brain - prepare_data_huds() - // for spawned humans; overwritten by other code create_dna(src) ready_dna(src) @@ -35,23 +33,24 @@ ..() +/mob/living/carbon/human/prepare_huds() + ..() + prepare_data_huds() + /mob/living/carbon/human/proc/prepare_data_huds() - for(var/i=1;i<=7;i++) // 2 icons for medHUDs and 5 for secHUDs - hud_list += image('icons/mob/hud.dmi', src, "") - - //Update all our hud images... + //Update all our data hud images... med_hud_set_health() med_hud_set_status() sec_hud_set_ID() sec_hud_set_implants() sec_hud_set_security_status() //...and display them - add_to_all_huds() + add_to_all_data_huds() /mob/living/carbon/human/Destroy() for(var/atom/movable/organelle in organs) qdel(organelle) - remove_from_all_huds() + remove_from_all_data_huds() return ..() /mob/living/carbon/human/Bump(atom/movable/AM as mob|obj, yes) diff --git a/code/modules/mob/living/carbon/human/human_defines.dm b/code/modules/mob/living/carbon/human/human_defines.dm index 1cc63bab99c..09ac10b4d51 100644 --- a/code/modules/mob/living/carbon/human/human_defines.dm +++ b/code/modules/mob/living/carbon/human/human_defines.dm @@ -1,5 +1,6 @@ /mob/living/carbon/human languages = HUMAN + hud_possible = list(HEALTH_HUD,STATUS_HUD,ID_HUD,WANTED_HUD,IMPLOYAL_HUD,IMPCHEM_HUD,IMPTRACK_HUD, ANTAG_HUD) //Hair colour and style var/hair_color = "000" var/hair_style = "Bald" @@ -46,4 +47,4 @@ var/xylophone = 0 //For the spoooooooky xylophone cooldown - var/gender_ambiguous = 0 //if something goes wrong during gender reassignment this generates a line in examine \ No newline at end of file + var/gender_ambiguous = 0 //if something goes wrong during gender reassignment this generates a line in examine diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 93a04ade9ec..6985cf97e93 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -97,6 +97,7 @@ //Update our name based on whether our face is obscured/disfigured name = get_visible_name() + handle_regular_hud_updates() if(dna) dna.species.spec_life(src) // for mutantraces diff --git a/code/modules/mob/living/carbon/human/login.dm b/code/modules/mob/living/carbon/human/login.dm index 98ae4a6e6d3..7877b6f6072 100644 --- a/code/modules/mob/living/carbon/human/login.dm +++ b/code/modules/mob/living/carbon/human/login.dm @@ -1,6 +1,4 @@ /mob/living/carbon/human/Login() ..() update_hud() - if(ticker.mode) - ticker.mode.update_all_synd_icons() //This proc only sounds CPU-expensive on paper. It is O(n^2), but the outer for-loop only iterates through syndicates, which are only prsenet in nuke rounds and even when they exist, there's usually 6 of them. return diff --git a/code/modules/mob/living/login.dm b/code/modules/mob/living/login.dm index 0d2e5ad541b..889afd142a1 100644 --- a/code/modules/mob/living/login.dm +++ b/code/modules/mob/living/login.dm @@ -4,64 +4,16 @@ sync_mind() mind.show_memory(src, 0) - //Round specific stuff like hud updates + //Round specific stuff if(ticker && ticker.mode) switch(ticker.mode.name) if("sandbox") CanBuild() - if("revolution") - if((mind in ticker.mode.revolutionaries) || (src.mind in ticker.mode:head_revolutionaries)) - ticker.mode.update_rev_icons_added(src.mind) - if("gang") - if((mind in ticker.mode.A_bosses) || (mind in ticker.mode.A_gangsters)) - ticker.mode.update_gang_icons_added(src.mind,"A") - if((mind in ticker.mode.B_bosses) || (mind in ticker.mode.B_gangsters)) - ticker.mode.update_gang_icons_added(src.mind,"B") - if("cult") - if(mind in ticker.mode:cult) - ticker.mode.update_cult_icons_added(src.mind) - if("nuclear emergency") - if(mind in ticker.mode:syndicates) - ticker.mode.update_all_synd_icons() + + //HUD updates (antag hud, etc) + refresh_huds() if(ventcrawler) src << "You can ventcrawl! Use alt+click on vents to quickly travel about the station." update_interface() return . - -//This stuff needs to be merged from cloning.dm but I'm not in the mood to be shouted at for breaking all the things :< ~Carn - /* clones - switch(ticker.mode.name) - if("revolution") - if(src.occupant.mind in ticker.mode:revolutionaries) - ticker.mode:update_all_rev_icons() //So the icon actually appears - if(src.occupant.mind in ticker.mode:head_revolutionaries) - ticker.mode:update_all_rev_icons() - if("nuclear emergency") - if (src.occupant.mind in ticker.mode:syndicates) - ticker.mode:update_all_synd_icons() - if("cult") - if (src.occupant.mind in ticker.mode:cult) - ticker.mode:add_cultist(src.occupant.mind) - ticker.mode:update_all_cult_icons() //So the icon actually appears - */ - - /* Plantpeople - switch(ticker.mode.name) - if ("revolution") - if (podman.mind in ticker.mode:revolutionaries) - ticker.mode:add_revolutionary(podman.mind) - ticker.mode:update_all_rev_icons() //So the icon actually appears - if (podman.mind in ticker.mode:head_revolutionaries) - ticker.mode:update_all_rev_icons() - if ("nuclear emergency") - if (podman.mind in ticker.mode:syndicates) - ticker.mode:update_all_synd_icons() - if ("cult") - if (podman.mind in ticker.mode:cult) - ticker.mode:add_cultist(podman.mind) - ticker.mode:update_all_cult_icons() //So the icon actually appears - if ("changeling") - if (podman.mind in ticker.mode:changelings) - podman.make_changeling() - */ \ No newline at end of file diff --git a/code/modules/mob/living/silicon/silicon.dm b/code/modules/mob/living/silicon/silicon.dm index 36dbd64137f..a1d4cc93437 100644 --- a/code/modules/mob/living/silicon/silicon.dm +++ b/code/modules/mob/living/silicon/silicon.dm @@ -319,17 +319,17 @@ return -10 /mob/living/silicon/proc/remove_med_sec_hud() - var/datum/hud/secsensor = huds[sec_hud] - var/datum/hud/medsensor = huds[med_hud] + var/datum/atom_hud/secsensor = huds[sec_hud] + var/datum/atom_hud/medsensor = huds[med_hud] secsensor.remove_hud_from(src) medsensor.remove_hud_from(src) /mob/living/silicon/proc/add_sec_hud() - var/datum/hud/secsensor = huds[sec_hud] + var/datum/atom_hud/secsensor = huds[sec_hud] secsensor.add_hud_to(src) /mob/living/silicon/proc/add_med_hud() - var/datum/hud/medsensor = huds[med_hud] + var/datum/atom_hud/medsensor = huds[med_hud] medsensor.add_hud_to(src) /mob/living/silicon/verb/sensor_mode() diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 0ea87f92744..918437895bb 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -13,7 +13,6 @@ /mob/proc/sac_act(var/obj/effect/rune/R, var/mob/victim as mob) return - var/next_mob_id = 0 /mob/New() tag = "mob_[next_mob_id++]" @@ -22,8 +21,13 @@ var/next_mob_id = 0 dead_mob_list += src else living_mob_list += src + prepare_huds() ..() +/mob/proc/prepare_huds() + for(var/hud in hud_possible) + hud_list[hud] = image('icons/mob/hud.dmi', src, "") + /mob/proc/Cell() set category = "Admin" set hidden = 1 diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index f13d82a7c8e..6b66ca59f6e 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -3,6 +3,7 @@ layer = 4 animate_movement = 2 flags = NOREACT | HEAR + hud_possible = list(ANTAG_HUD) var/datum/mind/mind var/stat = 0 //Whether a mob is alive or dead. TODO: Move this to living - Nodrak diff --git a/icons/mob/hud.dmi b/icons/mob/hud.dmi index 648866f97d7..12fe2bf8812 100644 Binary files a/icons/mob/hud.dmi and b/icons/mob/hud.dmi differ diff --git a/icons/mob/mob.dmi b/icons/mob/mob.dmi index 2cfaf2b0015..390f3f00953 100644 Binary files a/icons/mob/mob.dmi and b/icons/mob/mob.dmi differ diff --git a/tgstation.dme b/tgstation.dme index 435daef1607..d6a94347384 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -23,6 +23,7 @@ #include "code\__DEFINES\combat.dm" #include "code\__DEFINES\flags.dm" #include "code\__DEFINES\genetics.dm" +#include "code\__DEFINES\hud.dm" #include "code\__DEFINES\machines.dm" #include "code\__DEFINES\math.dm" #include "code\__DEFINES\misc.dm" @@ -243,6 +244,7 @@ #include "code\game\area\ai_monitored.dm" #include "code\game\area\areas.dm" #include "code\game\area\Space Station 13 areas.dm" +#include "code\game\gamemodes\antag_hud.dm" #include "code\game\gamemodes\antag_spawner.dm" #include "code\game\gamemodes\events.dm" #include "code\game\gamemodes\factions.dm"