From 53a185f838ebccea566ed5d23ba8d3d583e8c1ab Mon Sep 17 00:00:00 2001 From: Arokha Sieyes Date: Wed, 7 Mar 2018 23:39:52 -0500 Subject: [PATCH] U_I Phase 2.0: Code cleanup Removing calls to update_icons_layers and the like, stubbing them to help track down future calls. --- code/__defines/items_clothing.dm | 42 +- code/__defines/mobs.dm | 2 - code/_helpers/icons.dm | 4 +- code/_onclick/hud/hud.dm | 1 + code/_onclick/hud/human.dm | 5 +- code/game/antagonist/outsider/mercenary.dm | 2 - code/game/antagonist/outsider/technomancer.dm | 2 - code/game/antagonist/outsider/wizard.dm | 1 - .../changeling/generic_equip_procs.dm | 19 +- .../changeling/powers/fabricate_clothing.dm | 12 - .../computer3/computers/HolodeckControl.dm | 1 - code/game/objects/items.dm | 3 +- code/game/objects/items/devices/defib.dm | 1 - code/game/objects/items/weapons/handcuffs.dm | 15 + code/modules/admin/topic.dm | 7 - code/modules/admin/verbs/possess.dm | 1 - code/modules/client/preferences.dm | 8 +- code/modules/clothing/suits/miscellaneous.dm | 9 + code/modules/holodeck/HolodeckControl.dm | 1 - code/modules/mob/dead/observer/observer.dm | 1 - code/modules/mob/holder.dm | 2 - code/modules/mob/inventory.dm | 1 - code/modules/mob/living/carbon/carbon.dm | 2 - code/modules/mob/living/carbon/human/human.dm | 13 +- .../mob/living/carbon/human/human_defines.dm | 2 - .../mob/living/carbon/human/human_helpers.dm | 2 +- .../mob/living/carbon/human/human_organs.dm | 3 +- .../mob/living/carbon/human/inventory.dm | 55 +- code/modules/mob/living/carbon/human/life.dm | 46 +- .../mob/living/carbon/human/update_icons.dm | 603 ++++++------------ code/modules/mob/living/inventory.dm | 8 +- code/modules/mob/living/living.dm | 28 + code/modules/mob/living/living_defines.dm | 3 + code/modules/mob/living/silicon/silicon.dm | 2 +- .../mob/living/simple_animal/simple_hud.dm | 5 +- code/modules/mob/mob.dm | 3 + code/modules/mob/mob_helpers.dm | 23 +- .../mob/new_player/preferences_setup.dm | 4 +- code/modules/mob/update_icons.dm | 25 +- code/modules/organs/organ_external.dm | 2 +- code/modules/paperwork/paper.dm | 4 +- 41 files changed, 396 insertions(+), 577 deletions(-) diff --git a/code/__defines/items_clothing.dm b/code/__defines/items_clothing.dm index 8cb0d04bab..3b89072f19 100644 --- a/code/__defines/items_clothing.dm +++ b/code/__defines/items_clothing.dm @@ -80,29 +80,33 @@ #define BLOCKHEADHAIR 0x20 // Hides the user's hair overlay. Leaves facial hair. #define BLOCKHAIR 0x40 // Hides the user's hair, facial and otherwise. -// Slots. -#define slot_back 1 -#define slot_wear_mask 2 -#define slot_handcuffed 3 -#define slot_l_hand 4 -#define slot_r_hand 5 -#define slot_belt 6 -#define slot_wear_id 7 -#define slot_l_ear 8 -#define slot_glasses 9 +// Slots as numbers // +//Hands +#define slot_l_hand 1 +#define slot_r_hand 2 //Some things may reference this, try to keep it here +//Shown unless F12 pressed +#define slot_back 3 +#define slot_belt 4 +#define slot_wear_id 5 +#define slot_l_store 6 +#define slot_r_store 7 //Some things may reference this, try to keep it here +//Shown when inventory unhidden +#define slot_glasses 8 +#define slot_wear_mask 9 #define slot_gloves 10 #define slot_head 11 #define slot_shoes 12 #define slot_wear_suit 13 #define slot_w_uniform 14 -#define slot_l_store 15 -#define slot_r_store 16 -#define slot_s_store 17 -#define slot_in_backpack 18 -#define slot_legcuffed 19 -#define slot_r_ear 20 -#define slot_legs 21 -#define slot_tie 22 +#define slot_s_store 15 +#define slot_l_ear 16 +#define slot_r_ear 17 +//Secret slots +#define slot_legs 18 +#define slot_tie 19 +#define slot_handcuffed 20 +#define slot_legcuffed 21 +#define slot_in_backpack 22 // Inventory slot strings. // since numbers cannot be used as associative list keys. @@ -120,7 +124,7 @@ #define slot_head_str "slot_head" #define slot_wear_mask_str "slot_wear_mask" #define slot_handcuffed_str "slot_handcuffed" -#define slot_legcuffed_str "slot_legcuffed" +#define slot_legcuffed_str "slot_legcuffed" #define slot_wear_mask_str "slot_wear_mask" #define slot_wear_id_str "slot_wear_id" #define slot_gloves_str "slot_gloves" diff --git a/code/__defines/mobs.dm b/code/__defines/mobs.dm index ef5b5838be..7a4563f6db 100644 --- a/code/__defines/mobs.dm +++ b/code/__defines/mobs.dm @@ -267,5 +267,3 @@ //Some mob icon layering defines #define BODY_LAYER -100 -#define BACKPLANE_LAYER -101 -#define HUD_LAYER -105 diff --git a/code/_helpers/icons.dm b/code/_helpers/icons.dm index d3c2f7ef85..3c8988d0b4 100644 --- a/code/_helpers/icons.dm +++ b/code/_helpers/icons.dm @@ -922,8 +922,8 @@ proc/sort_atoms_by_layer(var/list/atoms) /proc/gen_hud_image(var/file, var/person, var/state, var/plane) var/image/img = image(file, person, state) img.plane = plane //Thanks Byond. - img.layer = HUD_LAYER - img.appearance_flags = APPEARANCE_UI|KEEP_APART + img.layer = MOB_LAYER-0.02 + img.appearance_flags = APPEARANCE_UI return img /** diff --git a/code/_onclick/hud/hud.dm b/code/_onclick/hud/hud.dm index 786c7cdd04..3a251f71fa 100644 --- a/code/_onclick/hud/hud.dm +++ b/code/_onclick/hud/hud.dm @@ -164,6 +164,7 @@ var/list/global_huds = list( var/obj/screen/movable/action_button/hide_toggle/hide_actions_toggle var/action_buttons_hidden = 0 + var/list/slot_info datum/hud/New(mob/owner) mymob = owner diff --git a/code/_onclick/hud/human.dm b/code/_onclick/hud/human.dm index e1b141ecb7..1c903700b0 100644 --- a/code/_onclick/hud/human.dm +++ b/code/_onclick/hud/human.dm @@ -14,6 +14,7 @@ src.adding = list() src.other = list() src.hotkeybuttons = list() //These can be disabled for hotkey users + src.slot_info = list() var/list/hud_elements = list() var/obj/screen/using @@ -33,6 +34,7 @@ inv_box.screen_loc = slot_data["loc"] inv_box.slot_id = slot_data["slot"] inv_box.icon_state = slot_data["state"] + slot_info["[inv_box.slot_id]"] = inv_box.screen_loc if(slot_data["dir"]) inv_box.set_dir(slot_data["dir"]) @@ -164,9 +166,9 @@ inv_box.slot_id = slot_r_hand inv_box.color = ui_color inv_box.alpha = ui_alpha - src.r_hand_hud_object = inv_box src.adding += inv_box + slot_info["[slot_r_hand]"] = inv_box.screen_loc inv_box = new /obj/screen/inventory/hand() inv_box.hud = src @@ -181,6 +183,7 @@ inv_box.alpha = ui_alpha src.l_hand_hud_object = inv_box src.adding += inv_box + slot_info["[slot_l_hand]"] = inv_box.screen_loc using = new /obj/screen/inventory() using.name = "hand" diff --git a/code/game/antagonist/outsider/mercenary.dm b/code/game/antagonist/outsider/mercenary.dm index 157d590b78..94b362fca8 100644 --- a/code/game/antagonist/outsider/mercenary.dm +++ b/code/game/antagonist/outsider/mercenary.dm @@ -50,8 +50,6 @@ var/datum/antagonist/mercenary/mercs var/obj/item/device/radio/uplink/U = new(player.loc, player.mind, DEFAULT_TELECRYSTAL_AMOUNT) player.put_in_hands(U) - player.update_icons_layers() - create_id("Mercenary", player) create_radio(SYND_FREQ, player) return 1 diff --git a/code/game/antagonist/outsider/technomancer.dm b/code/game/antagonist/outsider/technomancer.dm index 33dc33b5e8..2cb7532308 100644 --- a/code/game/antagonist/outsider/technomancer.dm +++ b/code/game/antagonist/outsider/technomancer.dm @@ -47,7 +47,6 @@ var/datum/antagonist/technomancer/technomancers technomancer_mob.equip_to_slot_or_del(new /obj/item/device/flashlight(technomancer_mob), slot_belt) technomancer_mob.equip_to_slot_or_del(new /obj/item/clothing/shoes/laceup(technomancer_mob), slot_shoes) technomancer_mob.equip_to_slot_or_del(new /obj/item/clothing/head/technomancer/master(technomancer_mob), slot_head) - technomancer_mob.update_icons_layers() return 1 /datum/antagonist/technomancer/proc/equip_apprentice(var/mob/living/carbon/human/technomancer_mob) @@ -67,7 +66,6 @@ var/datum/antagonist/technomancer/technomancers technomancer_mob.equip_to_slot_or_del(new /obj/item/device/flashlight(technomancer_mob), slot_belt) technomancer_mob.equip_to_slot_or_del(new /obj/item/clothing/shoes/laceup(technomancer_mob), slot_shoes) technomancer_mob.equip_to_slot_or_del(new /obj/item/clothing/head/technomancer/apprentice(technomancer_mob), slot_head) - technomancer_mob.update_icons() return 1 /datum/antagonist/technomancer/check_victory() diff --git a/code/game/antagonist/outsider/wizard.dm b/code/game/antagonist/outsider/wizard.dm index ad5cc10479..feaf8857ba 100644 --- a/code/game/antagonist/outsider/wizard.dm +++ b/code/game/antagonist/outsider/wizard.dm @@ -87,7 +87,6 @@ var/datum/antagonist/wizard/wizards wizard_mob.equip_to_slot_or_del(new /obj/item/weapon/storage/box(wizard_mob), slot_in_backpack) wizard_mob.equip_to_slot_or_del(new /obj/item/weapon/teleportation_scroll(wizard_mob), slot_r_store) wizard_mob.equip_to_slot_or_del(new /obj/item/weapon/spellbook(wizard_mob), slot_r_hand) - wizard_mob.update_icons_layers() return 1 /datum/antagonist/wizard/check_victory() diff --git a/code/game/gamemodes/changeling/generic_equip_procs.dm b/code/game/gamemodes/changeling/generic_equip_procs.dm index 7ff76ff9f6..ef1ab650a1 100644 --- a/code/game/gamemodes/changeling/generic_equip_procs.dm +++ b/code/game/gamemodes/changeling/generic_equip_procs.dm @@ -122,7 +122,6 @@ playsound(src, 'sound/effects/splat.ogg', 30, 1) visible_message("[src] pulls on their clothes, peeling it off along with parts of their skin attached!", "We remove and deform our equipment.") - M.update_icons_layers() M.mind.changeling.armor_deployed = 0 return success @@ -138,7 +137,6 @@ M.equip_to_slot_or_del(I, slot_head) grown_items_list.Add("a helmet") playsound(src, 'sound/effects/blobattack.ogg', 30, 1) - M.update_icons_layers() success = 1 sleep(1 SECOND) @@ -148,7 +146,6 @@ M.equip_to_slot_or_del(I, slot_w_uniform) grown_items_list.Add("a uniform") playsound(src, 'sound/effects/blobattack.ogg', 30, 1) - M.update_icons_layers() success = 1 sleep(1 SECOND) @@ -158,7 +155,6 @@ M.equip_to_slot_or_del(I, slot_gloves) grown_items_list.Add("some gloves") playsound(src, 'sound/effects/splat.ogg', 30, 1) - M.update_icons_layers() success = 1 sleep(1 SECOND) @@ -168,7 +164,6 @@ M.equip_to_slot_or_del(I, slot_shoes) grown_items_list.Add("shoes") playsound(src, 'sound/effects/splat.ogg', 30, 1) - M.update_icons_layers() success = 1 sleep(1 SECOND) @@ -178,7 +173,6 @@ M.equip_to_slot_or_del(I, slot_belt) grown_items_list.Add("a belt") playsound(src, 'sound/effects/splat.ogg', 30, 1) - M.update_icons_layers() success = 1 sleep(1 SECOND) @@ -188,7 +182,6 @@ M.equip_to_slot_or_del(I, slot_glasses) grown_items_list.Add("some glasses") playsound(src, 'sound/effects/splat.ogg', 30, 1) - M.update_icons_layers() success = 1 sleep(1 SECOND) @@ -198,7 +191,6 @@ M.equip_to_slot_or_del(I, slot_wear_mask) grown_items_list.Add("a mask") playsound(src, 'sound/effects/splat.ogg', 30, 1) - M.update_icons_layers() success = 1 sleep(1 SECOND) @@ -208,7 +200,6 @@ M.equip_to_slot_or_del(I, slot_back) grown_items_list.Add("a backpack") playsound(src, 'sound/effects/blobattack.ogg', 30, 1) - M.update_icons_layers() success = 1 sleep(1 SECOND) @@ -218,7 +209,6 @@ M.equip_to_slot_or_del(I, slot_wear_suit) grown_items_list.Add("an exosuit") playsound(src, 'sound/effects/blobattack.ogg', 30, 1) - M.update_icons_layers() success = 1 sleep(1 SECOND) @@ -228,20 +218,13 @@ M.equip_to_slot_or_del(I, slot_wear_id) grown_items_list.Add("an ID card") playsound(src, 'sound/effects/splat.ogg', 30, 1) - M.update_icons_layers() success = 1 sleep(1 SECOND) var/feedback = english_list(grown_items_list, nothing_text = "nothing", and_text = " and ", comma_text = ", ", final_comma_text = "" ) M << "We have grown [feedback]." - /* - for(var/I in stuff_to_equip) - world << I - world << stuff_to_equip - world << "Proc ended." - */ - M.update_icons() + if(success) M.mind.changeling.armor_deployed = 1 M.mind.changeling.chem_charges -= 10 diff --git a/code/game/gamemodes/changeling/powers/fabricate_clothing.dm b/code/game/gamemodes/changeling/powers/fabricate_clothing.dm index aad702ea49..d79af62b4c 100644 --- a/code/game/gamemodes/changeling/powers/fabricate_clothing.dm +++ b/code/game/gamemodes/changeling/powers/fabricate_clothing.dm @@ -56,7 +56,6 @@ var/global/list/changeling_fabricated_clothing = list( visible_message("[H] tears off [src]!", "We remove [src].") qdel(src) - H.update_icons_layers() /obj/item/clothing/head/chameleon/changeling name = "malformed head" @@ -78,7 +77,6 @@ var/global/list/changeling_fabricated_clothing = list( visible_message("[H] tears off [src]!", "We remove [src].") qdel(src) - H.update_icons_layers() /obj/item/clothing/suit/chameleon/changeling name = "chitinous chest" @@ -104,7 +102,6 @@ var/global/list/changeling_fabricated_clothing = list( visible_message("[H] tears off [src]!", "We remove [src].") qdel(src) - H.update_icons_layers() /obj/item/clothing/shoes/chameleon/changeling name = "malformed feet" @@ -130,7 +127,6 @@ var/global/list/changeling_fabricated_clothing = list( visible_message("[H] tears off [src]!", "We remove [src].") qdel(src) - H.update_icons_layers() /obj/item/weapon/storage/backpack/chameleon/changeling name = "backpack" @@ -158,7 +154,6 @@ var/global/list/changeling_fabricated_clothing = list( for(var/atom/movable/AM in src.contents) //Dump whatever's in the bag before deleting. AM.forceMove(get_turf(loc)) qdel(src) - H.update_icons_layers() /obj/item/clothing/gloves/chameleon/changeling name = "malformed hands" @@ -185,8 +180,6 @@ var/global/list/changeling_fabricated_clothing = list( visible_message("[H] tears off [src]!", "We remove [src].") qdel(src) - H.update_icons_layers() - /obj/item/clothing/mask/chameleon/changeling name = "chitin visor" @@ -213,7 +206,6 @@ var/global/list/changeling_fabricated_clothing = list( visible_message("[H] tears off [src]!", "We remove [src].") qdel(src) - H.update_icons_layers() /obj/item/clothing/glasses/chameleon/changeling name = "chitin goggles" @@ -235,7 +227,6 @@ var/global/list/changeling_fabricated_clothing = list( visible_message("[H] tears off [src]!", "We remove [src].") qdel(src) - H.update_icons_layers() /obj/item/weapon/storage/belt/chameleon/changeling name = "waist pouch" @@ -261,7 +252,6 @@ var/global/list/changeling_fabricated_clothing = list( visible_message("[H] tears off [src]!", "We remove [src].") qdel(src) - H.update_icons_layers() /obj/item/weapon/card/id/syndicate/changeling name = "chitinous card" @@ -291,8 +281,6 @@ var/global/list/changeling_fabricated_clothing = list( visible_message("[H] tears off [src]!", "We remove [src].") qdel(src) - H.update_icons_layers() - /obj/item/weapon/card/id/syndicate/changeling/Click() //Since we can't hold it in our hands, and attack_hand() doesn't work if it in inventory... if(!registered_user) diff --git a/code/game/machinery/computer3/computers/HolodeckControl.dm b/code/game/machinery/computer3/computers/HolodeckControl.dm index 4d63b95673..a629354d7b 100644 --- a/code/game/machinery/computer3/computers/HolodeckControl.dm +++ b/code/game/machinery/computer3/computers/HolodeckControl.dm @@ -155,7 +155,6 @@ var/mob/M = obj.loc if(ismob(M)) M.remove_from_mob(obj) - M.update_icons_layers() //so their overlays update if(!silent) var/obj/oldobj = obj diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 2504da2d06..5952e13d73 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -283,6 +283,7 @@ // note this isn't called during the initial dressing of a player /obj/item/proc/equipped(var/mob/user, var/slot) hud_layerise() + user.position_hud_item(src,slot) if(user.client) user.client.screen |= src if(user.pulling == src) user.stop_pulling() return @@ -698,7 +699,7 @@ modules/mob/living/carbon/human/life.dm if you die, you will be zoomed out. if(slot_l_hand_str) state2use += "_l" - testing("[src] (\ref[src]) - Worn Icon:[icon2use], Worn State:[state2use], Worn Layer:[layer2use]") + // testing("[src] (\ref[src]) - Slot: [slot_name], Inhands: [inhands], Worn Icon:[icon2use], Worn State:[state2use], Worn Layer:[layer2use]") //Generate the base onmob icon var/icon/standing_icon = icon(icon = icon2use, icon_state = state2use) diff --git a/code/game/objects/items/devices/defib.dm b/code/game/objects/items/devices/defib.dm index 9eb4991f69..4b9ea5137a 100644 --- a/code/game/objects/items/devices/defib.dm +++ b/code/game/objects/items/devices/defib.dm @@ -487,7 +487,6 @@ M.timeofdeath = 0 M.stat = UNCONSCIOUS //Life() can bring them back to consciousness if it needs to. - M.regenerate_icons() M.failed_last_breath = 0 //So mobs that died of oxyloss don't revive and have perpetual out of breath. M.reload_fullscreen() diff --git a/code/game/objects/items/weapons/handcuffs.dm b/code/game/objects/items/weapons/handcuffs.dm index e5f8043d43..344387f8cd 100644 --- a/code/game/objects/items/weapons/handcuffs.dm +++ b/code/game/objects/items/weapons/handcuffs.dm @@ -103,6 +103,13 @@ target.update_inv_handcuffed() return 1 +/obj/item/weapon/handcuffs/equipped(var/mob/living/user,var/slot) + . = ..() + if(slot == slot_handcuffed) + user.drop_r_hand() + user.drop_l_hand() + user.stop_pulling() + var/last_chew = 0 /mob/living/carbon/human/RestrainedClickOn(var/atom/A) if (A != src) return ..() @@ -315,3 +322,11 @@ var/last_chew = 0 target.legcuffed = lcuffs target.update_inv_legcuffed() return 1 + +/obj/item/weapon/handcuffs/legcuffs/equipped(var/mob/living/user,var/slot) + . = ..() + if(slot == slot_legcuffed) + if(user.m_intent != "walk") + user.m_intent = "walk" + if(user.hud_used && user.hud_used.move_intent) + user.hud_used.move_intent.icon_state = "walking" diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 502461cd69..358df91af6 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -1001,11 +1001,6 @@ //strip their stuff and stick it in the crate for(var/obj/item/I in M) M.drop_from_inventory(I, locker) - if(ishuman(M)) - var/mob/living/carbon/human/H = M - H.update_icons_layers() //Cheaper - else - M.update_icons() //so they black out before warping M.Paralyse(5) @@ -1188,10 +1183,8 @@ usr << "This can only be used on instances of type /mob/living/carbon/human" return var/block=text2num(href_list["block"]) - //testing("togmutate([href_list["block"]] -> [block])") usr.client.cmd_admin_toggle_block(H,block) show_player_panel(H) - //H.regenerate_icons() else if(href_list["adminplayeropts"]) var/mob/M = locate(href_list["adminplayeropts"]) diff --git a/code/modules/admin/verbs/possess.dm b/code/modules/admin/verbs/possess.dm index 6de30853ce..aa100623ff 100644 --- a/code/modules/admin/verbs/possess.dm +++ b/code/modules/admin/verbs/possess.dm @@ -37,7 +37,6 @@ if(ishuman(usr)) var/mob/living/carbon/human/H = usr H.name = H.get_visible_name() -// usr.regenerate_icons() //So the name is updated properly usr.loc = O.loc // Appear where the object you were controlling is -- TLE usr.client.eye = usr diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 915ea1758d..db297cde3f 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -287,10 +287,10 @@ datum/preferences if(icon_updates) character.force_update_limbs() - character.update_mutations(0) - character.update_underwear(0) - character.update_hair(0) - character.update_icons_all() + character.update_icons_body() + character.update_mutations() + character.update_underwear() + character.update_hair() /datum/preferences/proc/open_load_dialog(mob/user) var/dat = "" diff --git a/code/modules/clothing/suits/miscellaneous.dm b/code/modules/clothing/suits/miscellaneous.dm index 1392da3e46..9e0c0a0196 100644 --- a/code/modules/clothing/suits/miscellaneous.dm +++ b/code/modules/clothing/suits/miscellaneous.dm @@ -265,6 +265,15 @@ return ..() +/obj/item/clothing/suit/straight_jacket/equipped(var/mob/living/user,var/slot) + . = ..() + if(slot == slot_wear_suit) + user.drop_l_hand() + user.drop_r_hand() + if(ishuman(user)) + var/mob/living/carbon/human/H = user + H.drop_from_inventory(H.handcuffed) + /obj/item/clothing/suit/ianshirt name = "worn shirt" desc = "A worn out, curiously comfortable t-shirt with a picture of Ian. You wouldn't go so far as to say it feels like being hugged when you wear it but it's pretty close. Good for sleeping in." diff --git a/code/modules/holodeck/HolodeckControl.dm b/code/modules/holodeck/HolodeckControl.dm index 8560e71f34..59575eb603 100644 --- a/code/modules/holodeck/HolodeckControl.dm +++ b/code/modules/holodeck/HolodeckControl.dm @@ -247,7 +247,6 @@ var/mob/M = obj.loc if(ismob(M)) M.remove_from_mob(obj) - M.update_icons_layers() //so their overlays update if(!silent) var/obj/oldobj = obj diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index 13cd4d4c36..ac4e71c592 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -103,7 +103,6 @@ if (ishuman(body)) var/mob/living/carbon/human/H = body icon = H.icon - LAZYCLEARLIST(H.list_huds) H.update_icons() overlays = H.overlays else diff --git a/code/modules/mob/holder.dm b/code/modules/mob/holder.dm index 53945ce8a8..8815a6a176 100644 --- a/code/modules/mob/holder.dm +++ b/code/modules/mob/holder.dm @@ -83,8 +83,6 @@ var/list/holder_mob_icon_cache = list() H.update_inv_l_hand() else if(H.r_hand == src) H.update_inv_r_hand() - //else - //H.regenerate_icons() //Basically just too expensive. Probably also not necessary. //Mob specific holders. /obj/item/weapon/holder/diona diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index 439aed4ec7..41f2a724bd 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -138,7 +138,6 @@ var/list/slot_equipment_priority = list( \ remove_from_mob(W, target) if(!(W && W.loc)) return 1 // self destroying objects (tk, grabs) - update_icons_layers() return 1 return 0 diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index dfa385f43c..b22fdcabc8 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -290,10 +290,8 @@ H.bloody_hands = 0 H.update_inv_gloves(0) H.germ_level = 0 - update_icons_layers(FALSE) //apply the now updated overlays to the mob update_icons_body() - /mob/living/carbon/fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume) ..() var/temp_inc = max(min(BODYTEMP_HEATING_MAX*(1-get_heat_protection()), exposed_temperature - bodytemperature), 0) diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index decd4bd8d4..6a6da1534b 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -5,7 +5,8 @@ icon = 'icons/effects/effects.dmi' //We have an ultra-complex update icons that overlays everything, don't load some stupid random male human icon_state = "nothing" - var/list/hud_list[TOTAL_HUDS] + has_huds = TRUE //We do have HUDs (like health, wanted, status, not inventory slots) + var/embedded_flag //To check if we've need to roll for damage on movement while an item is imbedded in us. var/obj/item/weapon/rig/wearing_rig // This is very not good, but it's much much better than calling get_rig() every update_canmove() call. var/last_push_time //For human_attackhand.dm, keeps track of the last use of disarm @@ -40,9 +41,8 @@ nutrition = rand(200,400) - make_hud_overlays() - human_mob_list |= src + ..() hide_underwear.Cut() @@ -59,13 +59,6 @@ for(var/organ in organs) qdel(organ) - LAZYCLEARLIST(list_layers) - list_layers = null //Be free! - LAZYCLEARLIST(list_body) - list_body = null - LAZYCLEARLIST(list_huds) - list_huds = null - return ..() /mob/living/carbon/human/Stat() diff --git a/code/modules/mob/living/carbon/human/human_defines.dm b/code/modules/mob/living/carbon/human/human_defines.dm index 8439df5398..244c22e80b 100644 --- a/code/modules/mob/living/carbon/human/human_defines.dm +++ b/code/modules/mob/living/carbon/human/human_defines.dm @@ -102,8 +102,6 @@ can_be_antagged = TRUE - var/has_huds = TRUE //Do they have all the fancy life huds? Not for mannequins. - // Used by mobs in virtual reality to point back to the "real" mob the client belongs to. var/mob/living/carbon/human/vr_holder = null // Used by "real" mobs after they leave a VR session diff --git a/code/modules/mob/living/carbon/human/human_helpers.dm b/code/modules/mob/living/carbon/human/human_helpers.dm index 5ad867a156..553c62ce13 100644 --- a/code/modules/mob/living/carbon/human/human_helpers.dm +++ b/code/modules/mob/living/carbon/human/human_helpers.dm @@ -108,7 +108,7 @@ return FBP_NONE -/mob/living/carbon/human/proc/make_hud_overlays() +/mob/living/carbon/human/make_hud_overlays() hud_list[HEALTH_HUD] = gen_hud_image(ingame_hud_med, src, "100", plane = PLANE_CH_HEALTH) if(isSynthetic()) hud_list[STATUS_HUD] = gen_hud_image(ingame_hud, src, "hudrobo", plane = PLANE_CH_STATUS) diff --git a/code/modules/mob/living/carbon/human/human_organs.dm b/code/modules/mob/living/carbon/human/human_organs.dm index 7c4e38730f..0e1c5cfda6 100644 --- a/code/modules/mob/living/carbon/human/human_organs.dm +++ b/code/modules/mob/living/carbon/human/human_organs.dm @@ -2,7 +2,8 @@ var/obj/item/organ/internal/eyes/eyes = internal_organs_by_name[O_EYES] if(eyes) eyes.update_colour() - regenerate_icons() + update_icons_body() //Body handles eyes + update_eyes() //For floating eyes only /mob/living/carbon/var/list/internal_organs = list() /mob/living/carbon/human/var/list/organs = list() diff --git a/code/modules/mob/living/carbon/human/inventory.dm b/code/modules/mob/living/carbon/human/inventory.dm index 947b844ad2..9319893175 100644 --- a/code/modules/mob/living/carbon/human/inventory.dm +++ b/code/modules/mob/living/carbon/human/inventory.dm @@ -152,12 +152,14 @@ This saves us from having to call add_fingerprint() any time something is put in else if (W == wear_id) wear_id = null update_inv_wear_id() + BITSET(hud_updateflag, ID_HUD) + BITSET(hud_updateflag, WANTED_HUD) else if (W == r_store) r_store = null - update_inv_pockets() + //update_inv_pockets() //Doesn't do anything. else if (W == l_store) l_store = null - update_inv_pockets() + //update_inv_pockets() //Doesn't do anything. else if (W == s_store) s_store = null update_inv_s_store() @@ -195,8 +197,7 @@ This saves us from having to call add_fingerprint() any time something is put in //This is an UNSAFE proc. Use mob_can_equip() before calling this one! Or rather use equip_to_slot_if_possible() or advanced_equip_to_slot_if_possible() -//set redraw_mob to 0 if you don't wish the hud to be updated - if you're doing it manually in your own proc. -/mob/living/carbon/human/equip_to_slot(obj/item/W as obj, slot, redraw_mob = 1) +/mob/living/carbon/human/equip_to_slot(obj/item/W as obj, slot) if(!slot) return @@ -213,39 +214,41 @@ This saves us from having to call add_fingerprint() any time something is put in src.back = W W.equipped(src, slot) worn_clothing += back - update_inv_back(redraw_mob) + update_inv_back() if(slot_wear_mask) src.wear_mask = W if(wear_mask.flags_inv & (BLOCKHAIR|BLOCKHEADHAIR)) - update_hair(redraw_mob) //rebuild hair - update_inv_ears(0) + update_hair() //rebuild hair + update_inv_ears() W.equipped(src, slot) worn_clothing += wear_mask - update_inv_wear_mask(redraw_mob) + update_inv_wear_mask() if(slot_handcuffed) src.handcuffed = W - update_inv_handcuffed(redraw_mob) + update_inv_handcuffed() if(slot_legcuffed) src.legcuffed = W W.equipped(src, slot) - update_inv_legcuffed(redraw_mob) + update_inv_legcuffed() if(slot_l_hand) src.l_hand = W W.equipped(src, slot) - update_inv_l_hand(redraw_mob) + update_inv_l_hand() if(slot_r_hand) src.r_hand = W W.equipped(src, slot) - update_inv_r_hand(redraw_mob) + update_inv_r_hand() if(slot_belt) src.belt = W W.equipped(src, slot) worn_clothing += belt - update_inv_belt(redraw_mob) + update_inv_belt() if(slot_wear_id) src.wear_id = W W.equipped(src, slot) - update_inv_wear_id(redraw_mob) + update_inv_wear_id() + BITSET(hud_updateflag, ID_HUD) + BITSET(hud_updateflag, WANTED_HUD) if(slot_l_ear) src.l_ear = W if(l_ear.slot_flags & SLOT_TWOEARS) @@ -254,7 +257,7 @@ This saves us from having to call add_fingerprint() any time something is put in src.r_ear = O O.hud_layerise() W.equipped(src, slot) - update_inv_ears(redraw_mob) + update_inv_ears() if(slot_r_ear) src.r_ear = W if(r_ear.slot_flags & SLOT_TWOEARS) @@ -263,54 +266,54 @@ This saves us from having to call add_fingerprint() any time something is put in src.l_ear = O O.hud_layerise() W.equipped(src, slot) - update_inv_ears(redraw_mob) + update_inv_ears() if(slot_glasses) src.glasses = W W.equipped(src, slot) - update_inv_glasses(redraw_mob) + update_inv_glasses() if(slot_gloves) src.gloves = W W.equipped(src, slot) worn_clothing += glasses - update_inv_gloves(redraw_mob) + update_inv_gloves() if(slot_head) src.head = W if(head.flags_inv & (BLOCKHAIR|BLOCKHEADHAIR|HIDEMASK)) - update_hair(redraw_mob) //rebuild hair + update_hair() //rebuild hair update_inv_ears(0) update_inv_wear_mask(0) if(istype(W,/obj/item/clothing/head/kitty)) W.update_icon(src) W.equipped(src, slot) worn_clothing += head - update_inv_head(redraw_mob) + update_inv_head() if(slot_shoes) src.shoes = W W.equipped(src, slot) worn_clothing += shoes - update_inv_shoes(redraw_mob) + update_inv_shoes() if(slot_wear_suit) src.wear_suit = W W.equipped(src, slot) worn_clothing += wear_suit - update_inv_wear_suit(redraw_mob) + update_inv_wear_suit() if(slot_w_uniform) src.w_uniform = W W.equipped(src, slot) worn_clothing += w_uniform - update_inv_w_uniform(redraw_mob) + update_inv_w_uniform() if(slot_l_store) src.l_store = W W.equipped(src, slot) - update_inv_pockets(redraw_mob) + //update_inv_pockets() //Doesn't do anything if(slot_r_store) src.r_store = W W.equipped(src, slot) - update_inv_pockets(redraw_mob) + //update_inv_pockets() //Doesn't do anything if(slot_s_store) src.s_store = W W.equipped(src, slot) - update_inv_s_store(redraw_mob) + update_inv_s_store() if(slot_in_backpack) if(src.get_active_hand() == W) src.remove_from_mob(W) diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index e643ee24b1..a79808a0a9 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -1582,26 +1582,24 @@ we only set those statuses and icons upon changes. Then those HUD items will simply add those pre-made images. This proc below is only called when those HUD elements need to change as determined by the mobs hud_updateflag. */ - - /mob/living/carbon/human/proc/handle_hud_list() if (BITTEST(hud_updateflag, HEALTH_HUD)) - var/image/holder = hud_list[HEALTH_HUD] + var/image/holder = grab_hud(HEALTH_HUD) if(stat == DEAD) holder.icon_state = "-100" // X_X else holder.icon_state = RoundHealth((health-config.health_threshold_crit)/(getMaxHealth()-config.health_threshold_crit)*100) - hud_list[HEALTH_HUD] = holder + apply_hud(HEALTH_HUD, holder) if (BITTEST(hud_updateflag, LIFE_HUD)) - var/image/holder = hud_list[LIFE_HUD] + var/image/holder = grab_hud(LIFE_HUD) if(isSynthetic()) holder.icon_state = "hudrobo" else if(stat == DEAD) holder.icon_state = "huddead" else holder.icon_state = "hudhealthy" - hud_list[LIFE_HUD] = holder + apply_hud(LIFE_HUD, holder) if (BITTEST(hud_updateflag, STATUS_HUD)) var/foundVirus = 0 @@ -1610,8 +1608,8 @@ foundVirus = 1 break - var/image/holder = hud_list[STATUS_HUD] - var/image/holder2 = hud_list[STATUS_HUD_OOC] + var/image/holder = grab_hud(STATUS_HUD) + var/image/holder2 = grab_hud(STATUS_HUD_OOC) if (isSynthetic()) holder.icon_state = "hudrobo" else if(stat == DEAD) @@ -1633,11 +1631,11 @@ else holder2.icon_state = "hudhealthy" - hud_list[STATUS_HUD] = holder - hud_list[STATUS_HUD_OOC] = holder2 + apply_hud(STATUS_HUD, holder) + apply_hud(STATUS_HUD_OOC, holder2) if (BITTEST(hud_updateflag, ID_HUD)) - var/image/holder = hud_list[ID_HUD] + var/image/holder = grab_hud(ID_HUD) if(wear_id) var/obj/item/weapon/card/id/I = wear_id.GetID() if(I) @@ -1647,11 +1645,10 @@ else holder.icon_state = "hudunknown" - - hud_list[ID_HUD] = holder + apply_hud(ID_HUD, holder) if (BITTEST(hud_updateflag, WANTED_HUD)) - var/image/holder = hud_list[WANTED_HUD] + var/image/holder = grab_hud(WANTED_HUD) holder.icon_state = "hudblank" var/perpname = name if(wear_id) @@ -1674,15 +1671,16 @@ else if((R.fields["id"] == E.fields["id"]) && (R.fields["criminal"] == "Released")) holder.icon_state = "hudreleased" break - hud_list[WANTED_HUD] = holder + + apply_hud(WANTED_HUD, holder) if ( BITTEST(hud_updateflag, IMPLOYAL_HUD) \ || BITTEST(hud_updateflag, IMPCHEM_HUD) \ || BITTEST(hud_updateflag, IMPTRACK_HUD)) - var/image/holder1 = hud_list[IMPTRACK_HUD] - var/image/holder2 = hud_list[IMPLOYAL_HUD] - var/image/holder3 = hud_list[IMPCHEM_HUD] + var/image/holder1 = grab_hud(IMPTRACK_HUD) + var/image/holder2 = grab_hud(IMPLOYAL_HUD) + var/image/holder3 = grab_hud(IMPCHEM_HUD) holder1.icon_state = "hudblank" holder2.icon_state = "hudblank" @@ -1698,21 +1696,21 @@ if(istype(I,/obj/item/weapon/implant/chem)) holder3.icon_state = "hud_imp_chem" - hud_list[IMPTRACK_HUD] = holder1 - hud_list[IMPLOYAL_HUD] = holder2 - hud_list[IMPCHEM_HUD] = holder3 + apply_hud(IMPTRACK_HUD, holder1) + apply_hud(IMPLOYAL_HUD, holder2) + apply_hud(IMPCHEM_HUD, holder3) if (BITTEST(hud_updateflag, SPECIALROLE_HUD)) - var/image/holder = hud_list[SPECIALROLE_HUD] + var/image/holder = grab_hud(SPECIALROLE_HUD) holder.icon_state = "hudblank" if(mind && mind.special_role) if(hud_icon_reference[mind.special_role]) holder.icon_state = hud_icon_reference[mind.special_role] else holder.icon_state = "hudsyndicate" - hud_list[SPECIALROLE_HUD] = holder + apply_hud(SPECIALROLE_HUD, holder) + hud_updateflag = 0 - update_icons_huds() /mob/living/carbon/human/handle_stunned() if(!can_feel_pain()) diff --git a/code/modules/mob/living/carbon/human/update_icons.dm b/code/modules/mob/living/carbon/human/update_icons.dm index 41eb37d07f..28ca224b18 100644 --- a/code/modules/mob/living/carbon/human/update_icons.dm +++ b/code/modules/mob/living/carbon/human/update_icons.dm @@ -1,142 +1,62 @@ /* Global associative list for caching humanoid icons. Index format m or f, followed by a string of 0 and 1 to represent bodyparts followed by husk fat hulk skeleton 1 or 0. - TODO: Proper documentation - icon_key is [species.race_key][g][husk][fat][hulk][skeleton][s_tone] */ -var/global/list/human_icon_cache = list() +var/global/list/human_icon_cache = list() //key is incredibly complex, see update_icons_body() var/global/list/tail_icon_cache = list() //key is [species.race_key][r_skin][g_skin][b_skin] -var/global/list/light_overlay_cache = list() +var/global/list/light_overlay_cache = list() //see make_worn_icon() on helmets +var/global/list/damage_icon_parts = list() //see UpdateDamageIcon() +//Add an entry to overlays, assuming it exists /mob/living/carbon/human/proc/apply_layer(cache_index) if((. = overlays_standing[cache_index])) add_overlay(.) +//Remove an entry from overlays, and from the list /mob/living/carbon/human/proc/remove_layer(cache_index) var/I = overlays_standing[cache_index] if(I) cut_overlay(I) overlays_standing[cache_index] = null - /////////////////////// - //UPDATE_ICONS SYSTEM// - /////////////////////// -/* -Calling this a system is perhaps a bit trumped up. It is essentially update_clothing dismantled into its -core parts. The key difference is that when we generate overlays we do not generate either lying or standing -versions. Instead, we generate both and store them in two fixed-length lists, both using the same list-index -(The indexes are in update_icons.dm): Each list for humans is (at the time of writing) of length 19. -This will hopefully be reduced as the system is refined. - var/overlays_lying[19] //For the lying down stance - var/overlays_standing[19] //For the standing stance -When we call update_icons, the 'lying' variable is checked and then the appropriate list is assigned to our overlays! -That in itself uses a tiny bit more memory (no more than all the ridiculous lists the game has already mind you). -On the other-hand, it should be very CPU cheap in comparison to the old system. -In the old system, we updated all our overlays every life() call, even if we were standing still inside a crate! -or dead!. 25ish overlays, all generated from scratch every second for every xeno/human/monkey and then applied. -More often than not update_clothing was being called a few times in addition to that! CPU was not the only issue, -all those icons had to be sent to every client. So really the cost was extremely cumulative. To the point where -update_clothing would frequently appear in the top 10 most CPU intensive procs during profiling. -Another feature of this new system is that our lists are indexed. This means we can update specific overlays! -So we only regenerate icons when we need them to be updated! This is the main saving for this system. -In practice this means that: - everytime you fall over, we just switch between precompiled lists. Which is fast and cheap. - Everytime you do something minor like take a pen out of your pocket, we only update the in-hand overlay - etc... -There are several things that need to be remembered: -> Whenever we do something that should cause an overlay to update (which doesn't use standard procs - ( i.e. you do something like l_hand = /obj/item/something new(src) ) - You will need to call the relevant update_inv_* proc: - update_inv_head() - update_inv_wear_suit() - update_inv_gloves() - update_inv_shoes() - update_inv_w_uniform() - update_inv_glasse() - update_inv_l_hand() - update_inv_r_hand() - update_inv_belt() - update_inv_wear_id() - update_inv_ears() - update_inv_s_store() - update_inv_pockets() - update_inv_back() - update_inv_handcuffed() - update_inv_wear_mask() - All of these are named after the variable they update from. They are defined at the mob/ level like - update_clothing was, so you won't cause undefined proc runtimes with usr.update_inv_wear_id() if the usr is a - slime etc. Instead, it'll just return without doing any work. So no harm in calling it for slimes and such. -> There are also these special cases: - update_mutations() //handles updating your appearance for certain mutations. e.g TK head-glows - UpdateDamageIcon() //handles damage overlays for brute/burn damage //(will rename this when I geta round to it) - update_icons_body() //Handles updating your mob's icon to reflect their gender/race/complexion etc - update_hair() //Handles updating your hair overlay (used to be update_face, but mouth and - ...eyes were merged into update_body) - update_targeted() // Updates the target overlay when someone points a gun at you -> All of these procs update our overlays_lying and overlays_standing, and then call update_icons() by default. - If you wish to update several overlays at once, you can set the argument to 0 to disable the update and call - it manually: - e.g. - update_inv_head(0) - update_inv_l_hand(0) - update_inv_r_hand() //<---calls update_icons() - or equivillantly: - update_inv_head(0) - update_inv_l_hand(0) - update_inv_r_hand(0) - update_icons() -> If you need to update all overlays you can use regenerate_icons(). it works exactly like update_clothing used to. -> I reimplimented an old unused variable which was in the code called (coincidentally) var/update_icon - It can be used as another method of triggering regenerate_icons(). It's basically a flag that when set to non-zero - will call regenerate_icons() at the next life() call and then reset itself to 0. - The idea behind it is icons are regenerated only once, even if multiple events requested it. -This system is confusing and is still a WIP. It's primary goal is speeding up the controls of the game whilst -reducing processing costs. So please bear with me while I iron out the kinks. It will be worth it, I promise. -If I can eventually free var/lying stuff from the life() process altogether, stuns/death/status stuff -will become less affected by lag-spikes and will be instantaneous! :3 -If you have any questions/constructive-comments/bugs-to-report/or have a massivly devestated butt... -Please contact me on #coderbus IRC. ~Carn x -*/ - +// These are used as the layers for the icons, as well as indexes in a list that holds onto them. +// Technically the layers used are all -100+layer to make them FLOAT_LAYER overlays. //Human Overlays Indexes///////// #define MUTATIONS_LAYER 1 //Mutations like fat, and lasereyes #define SKIN_LAYER 2 //Skin things added by a call on species -#define DAMAGE_LAYER 3 //Injury overlay sprites like open wounds -#define SURGERY_LEVEL 4 //Overlays for open surgical sites -#define UNDERWEAR_LAYER 5 //Underwear/bras/etc -#define SHOES_LAYER_ALT 6 //Shoe-slot item (when set to be under uniform via verb) -#define UNIFORM_LAYER 7 //Uniform-slot item -#define ID_LAYER 8 //ID-slot item -#define SHOES_LAYER 9 //Shoe-slot item -#define GLOVES_LAYER 10 //Glove-slot item -#define BELT_LAYER 11 //Belt-slot item -#define SUIT_LAYER 12 //Suit-slot item -#define TAIL_LAYER 13 //Some species have tails to render -#define GLASSES_LAYER 14 //Eye-slot item -#define BELT_LAYER_ALT 15 //Belt-slot item (when set to be above suit via verb) -#define SUIT_STORE_LAYER 16 //Suit storage-slot item -#define BACK_LAYER 17 //Back-slot item -#define HAIR_LAYER 18 //The human's hair -#define EARS_LAYER 19 //Both ear-slot items (combined image) -#define EYES_LAYER 20 //Mob's eyes (used for glowing eyes) -#define FACEMASK_LAYER 21 //Mask-slot item -#define HEAD_LAYER 22 //Head-slot item -#define HANDCUFF_LAYER 23 //Handcuffs, if the human is handcuffed, in a secret inv slot -#define LEGCUFF_LAYER 24 //Same as handcuffs, for legcuffs -#define L_HAND_LAYER 25 //Left-hand item -#define R_HAND_LAYER 26 //Right-hand item -#define MODIFIER_EFFECTS_LAYER 27 //Effects drawn by modifiers -#define FIRE_LAYER 28 //'Mob on fire' overlay layer -#define WATER_LAYER 29 //'Mob submerged' overlay layer -#define TARGETED_LAYER 30 //'Aimed at' overlay layer -#define TOTAL_LAYERS 30//<---- KEEP THIS UPDATED, should always equal the highest number here, used to initialize a list. +#define BLOOD_LAYER 3 //Bloodied hands/feet/anything else +#define DAMAGE_LAYER 4 //Injury overlay sprites like open wounds +#define SURGERY_LAYER 5 //Overlays for open surgical sites +#define UNDERWEAR_LAYER 6 //Underwear/bras/etc +#define SHOES_LAYER_ALT 7 //Shoe-slot item (when set to be under uniform via verb) +#define UNIFORM_LAYER 8 //Uniform-slot item +#define ID_LAYER 9 //ID-slot item +#define SHOES_LAYER 10 //Shoe-slot item +#define GLOVES_LAYER 11 //Glove-slot item +#define BELT_LAYER 12 //Belt-slot item +#define SUIT_LAYER 13 //Suit-slot item +#define TAIL_LAYER 14 //Some species have tails to render +#define GLASSES_LAYER 15 //Eye-slot item +#define BELT_LAYER_ALT 16 //Belt-slot item (when set to be above suit via verb) +#define SUIT_STORE_LAYER 17 //Suit storage-slot item +#define BACK_LAYER 18 //Back-slot item +#define HAIR_LAYER 19 //The human's hair +#define EARS_LAYER 20 //Both ear-slot items (combined image) +#define EYES_LAYER 21 //Mob's eyes (used for glowing eyes) +#define FACEMASK_LAYER 22 //Mask-slot item +#define HEAD_LAYER 23 //Head-slot item +#define HANDCUFF_LAYER 24 //Handcuffs, if the human is handcuffed, in a secret inv slot +#define LEGCUFF_LAYER 25 //Same as handcuffs, for legcuffs +#define L_HAND_LAYER 26 //Left-hand item +#define R_HAND_LAYER 27 //Right-hand item +#define MODIFIER_EFFECTS_LAYER 28 //Effects drawn by modifiers +#define FIRE_LAYER 29 //'Mob on fire' overlay layer +#define WATER_LAYER 30 //'Mob submerged' overlay layer +#define TARGETED_LAYER 31 //'Aimed at' overlay layer +#define TOTAL_LAYERS 32//<---- KEEP THIS UPDATED, should always equal the highest number here, used to initialize a list. ////////////////////////////////// /mob/living/carbon/human - var/list/list_huds = list() - var/list/list_body = list() - var/list/list_layers = list() - var/list/overlays_standing[TOTAL_LAYERS] var/previous_damage_appearance // store what the body last looked like, so we only have to update it if something changed @@ -146,31 +66,23 @@ Please contact me on #coderbus IRC. ~Carn x if(QDESTROYING(src)) return - lying_prev = lying //so we don't update overlays for lying/standing unless our stance changes again + crash_with("CANARY: Old human update_icons was called.") + update_hud() //TODO: remove the need for this - //1: HUDs because these are hidden behind a backplane. See update_icons_huds() - //add_underlay(list_huds) //The first one can set instead of add + //Do any species specific layering updates, such as when hiding. + update_icon_special() - //2: The 'layers' list (overlays_standing), from the defines above - //add_overlay(list_layers) +/mob/living/carbon/human/update_icons_layers() + crash_with("CANARY: Old human update_icons was called.") - //3: Apply transforms based on situation - update_transform() +/mob/living/carbon/human/update_icons_all() + crash_with("CANARY: Old human update_icons_all was called.") - //4: Do any species specific layering updates, such as when hiding. - update_icon_special(FALSE) - -/mob/living/carbon/human/update_transform(var/mutable_appearance/passed_ma) - if(QDESTROYING(src)) - return - - var/mutable_appearance/ma - if(passed_ma) - ma = passed_ma - else - ma = new(src) +/mob/living/carbon/human/update_icons_huds() + crash_with("CANARY: Old human update_icons_huds was called.") +/mob/living/carbon/human/update_transform() // First, get the correct size. var/desired_scale = icon_scale @@ -181,90 +93,23 @@ Please contact me on #coderbus IRC. ~Carn x desired_scale *= M.icon_scale_percent // Regular stuff again. + var/matrix/M = matrix() if(lying && !species.prone_icon) //Only rotate them if we're not drawing a specific icon for being prone. - var/matrix/M = matrix() M.Turn(90) M.Scale(desired_scale) M.Translate(1,-6) - ma.transform = M - ma.layer = MOB_LAYER -0.01 // Fix for a byond bug where turf entry order no longer matters + layer = MOB_LAYER -0.01 // Fix for a byond bug where turf entry order no longer matters else - var/matrix/M = matrix() M.Scale(desired_scale) M.Translate(0, 16*(desired_scale-1)) - ma.transform = M - ma.layer = MOB_LAYER // Fix for a byond bug where turf entry order no longer matters + layer = MOB_LAYER // Fix for a byond bug where turf entry order no longer matters - if(!passed_ma) - update_icon_special(ma) - appearance = ma + animate(src, transform = M, time = 0.5 SECONDS) + update_icon_special() //May contain transform-altering things -//Update the layers from the defines above -/mob/living/carbon/human/update_icons_layers(var/update_icons = 1) - if(QDESTROYING(src)) - return - - list_layers.Cut() - - for(var/entry in overlays_standing) - if(istype(entry, /image)) - list_layers += entry - else if(istype(entry, /list)) - for(var/inner_entry in entry) - list_layers += inner_entry - - if(species && species.has_floating_eyes) - list_layers += species.get_eyes(src) - - if(update_icons) - update_icons() - -//HUD Icons (ingame huds, not the user interface) -//Update things like med/sec hud icons -/mob/living/carbon/human/update_icons_huds(var/update_icons = 1) - if(QDESTROYING(src)) - return - - cut_overlay(list_huds) - - list_huds.Cut() - - if(has_huds) - list_huds = hud_list.Copy() - list_huds += backplane // Required to mask HUDs in context menus: http://www.byond.com/forum/?post=2336679 - - //Typing indicator code - if(client && !stat) //They have a client & aren't dead/KO'd? Continue on! - if(typing_indicator && hud_typing) //They already have the indicator and are still typing - list_huds += typing_indicator - typing_indicator.invisibility = invisibility - - else if(!typing_indicator && hud_typing) //Are they in their body, NOT dead, have hud_typing, do NOT have a typing indicator. and have it enabled? - typing_indicator = image(icon = 'icons/mob/talk.dmi', icon_state = "[speech_bubble_appearance()]_typing") - list_huds += typing_indicator - - else if(typing_indicator && !hud_typing) //Did they stop typing? - typing = FALSE - hud_typing = FALSE - - add_overlay(list_huds) - -//A full, crunchy reprocess of all three cached lists -/mob/living/carbon/human/update_icons_all(var/update_icons = 1) - if(QDESTROYING(src)) - return - - update_icons_huds(FALSE) - update_icons_body(FALSE) - update_icons_layers(FALSE) - - if(update_icons) - update_icons() - -var/global/list/damage_icon_parts = list() //DAMAGE OVERLAYS //constructs damage icon for each organ from mask * damage field and saves it in our overlays_ lists -/mob/living/carbon/human/UpdateDamageIcon(var/update_icons=1) +/mob/living/carbon/human/UpdateDamageIcon() if(QDESTROYING(src)) return @@ -309,7 +154,7 @@ var/global/list/damage_icon_parts = list() apply_layer(DAMAGE_LAYER) //BASE MOB SPRITE -/mob/living/carbon/human/update_icons_body(var/update_icons=1) +/mob/living/carbon/human/update_icons_body() if(QDESTROYING(src)) return @@ -321,7 +166,7 @@ var/global/list/damage_icon_parts = list() var/hulk = (HULK in src.mutations) var/skeleton = (SKELETON in src.mutations) - robolimb_count = 0 + robolimb_count = 0 //TODO, here, really tho? robobody_count = 0 //CACHING: Generate an index key from visible bodyparts. @@ -330,9 +175,6 @@ var/global/list/damage_icon_parts = list() //Create a new, blank icon for our mob to use. var/icon/stand_icon = new(species.icon_template ? species.icon_template : 'icons/mob/human.dmi', icon_state = "blank") - //Clean old list_body - list_body.Cut() - var/g = "male" if(gender == FEMALE) g = "female" @@ -433,13 +275,10 @@ var/global/list/damage_icon_parts = list() stand_icon.Blend(base_icon,ICON_OVERLAY) icon = stand_icon - if(update_icons) - update_icons() - //tail - update_tail_showing(0) + update_tail_showing() -/mob/living/carbon/human/proc/update_skin(var/update_icons=1) +/mob/living/carbon/human/proc/update_skin() if(QDESTROYING(src)) return @@ -451,8 +290,34 @@ var/global/list/damage_icon_parts = list() overlays_standing[SKIN_LAYER] = skin apply_layer(SKIN_LAYER) +/mob/living/carbon/human/proc/update_bloodied() + if(QDESTROYING(src)) + return + + remove_layer(BLOOD_LAYER) + if(!blood_DNA && !feet_blood_DNA) + return + + var/image/both = image(icon = 'icons/effects/effects.dmi', icon_state = "nothing", layer = BODY_LAYER+BLOOD_LAYER) + + //Bloody hands + if(blood_DNA) + var/image/bloodsies = image(icon = species.get_blood_mask(src), icon_state = "bloodyhands", layer = BODY_LAYER+BLOOD_LAYER) + bloodsies.color = hand_blood_color + both.add_overlay(bloodsies) + + //Bloody feet + if(feet_blood_DNA) + var/image/bloodsies = image(icon = species.get_blood_mask(src), icon_state = "shoeblood", layer = BODY_LAYER+BLOOD_LAYER) + bloodsies.color = feet_blood_color + both.add_overlay(bloodsies) + + overlays_standing[BLOOD_LAYER] = both + + apply_layer(BLOOD_LAYER) + //UNDERWEAR OVERLAY -/mob/living/carbon/human/proc/update_underwear(var/update_icons=1) +/mob/living/carbon/human/proc/update_underwear() if(QDESTROYING(src)) return @@ -470,13 +335,13 @@ var/global/list/damage_icon_parts = list() apply_layer(UNDERWEAR_LAYER) //HAIR OVERLAY -/mob/living/carbon/human/proc/update_hair(var/update_icons=1) +/mob/living/carbon/human/proc/update_hair() if(QDESTROYING(src)) return //Reset our hair remove_layer(HAIR_LAYER) - update_eyes(0) //Pirated out of here, for glowing eyes. + update_eyes() //Pirated out of here, for glowing eyes. var/obj/item/organ/external/head/head_organ = get_organ(BP_HEAD) if(!head_organ || head_organ.is_stump() ) @@ -484,7 +349,6 @@ var/global/list/damage_icon_parts = list() //masks and helmets can obscure our hair. if( (head && (head.flags_inv & BLOCKHAIR)) || (wear_mask && (wear_mask.flags_inv & BLOCKHAIR))) - if(update_icons) update_icons_layers() return //base icons @@ -516,7 +380,7 @@ var/global/list/damage_icon_parts = list() overlays_standing[HAIR_LAYER] = image(face_standing, layer = BODY_LAYER+HAIR_LAYER) apply_layer(HAIR_LAYER) -/mob/living/carbon/human/update_eyes(var/update_icons=1) +/mob/living/carbon/human/update_eyes() if(QDESTROYING(src)) return @@ -555,7 +419,7 @@ var/global/list/damage_icon_parts = list() overlays_standing[EYES_LAYER] = eyes_image apply_layer(EYES_LAYER) -/mob/living/carbon/human/update_mutations(var/update_icons=1) +/mob/living/carbon/human/update_mutations() if(QDESTROYING(src)) return @@ -588,54 +452,52 @@ var/global/list/damage_icon_parts = list() apply_layer(MUTATIONS_LAYER) /* --------------------------------------- */ -//For legacy support. +//Recomputes every icon on the mob. Expensive. +//Useful if the species changed, or there's some +//other drastic body-shape change, but otherwise avoid. /mob/living/carbon/human/regenerate_icons() ..() - if(transforming || QDELETED(src)) return + if(transforming || QDELETED(src)) + return - update_mutations(0) - update_skin(0) - update_icons_body(0) - update_underwear(0) - update_hair(0) - update_inv_w_uniform(0) - update_inv_wear_id(0) - update_inv_gloves(0) - update_inv_glasses(0) - update_inv_ears(0) - update_inv_shoes(0) - update_inv_s_store(0) - update_inv_wear_mask(0) - update_inv_head(0) - update_inv_belt(0) - update_inv_back(0) - update_inv_wear_suit(0) - update_inv_r_hand(0) - update_inv_l_hand(0) - update_inv_handcuffed(0) - update_inv_legcuffed(0) - update_inv_pockets(0) - update_fire(0) - update_water(0) - update_surgery(0) - UpdateDamageIcon(0) - update_icons_layers(0) - update_icons_huds(0) - update_icons() - //Hud Stuff - update_hud() + update_icons_body() + UpdateDamageIcon() + update_mutations() + update_skin() + update_underwear() + update_hair() + update_inv_w_uniform() + update_inv_wear_id() + update_inv_gloves() + update_inv_glasses() + update_inv_ears() + update_inv_shoes() + update_inv_s_store() + update_inv_wear_mask() + update_inv_head() + update_inv_belt() + update_inv_back() + update_inv_wear_suit() + update_inv_r_hand() + update_inv_l_hand() + update_inv_handcuffed() + update_inv_legcuffed() + //update_inv_pockets() //Doesn't do anything + update_fire() + update_water() + update_surgery() /* --------------------------------------- */ //vvvvvv UPDATE_INV PROCS vvvvvv -/mob/living/carbon/human/update_inv_w_uniform(var/update_icons=1) +/mob/living/carbon/human/update_inv_w_uniform() if(QDESTROYING(src)) return remove_layer(UNIFORM_LAYER) //Shoes can be affected by uniform being drawn onto them - update_inv_shoes(FALSE) + update_inv_shoes() if(!w_uniform) return @@ -643,60 +505,41 @@ var/global/list/damage_icon_parts = list() if(wear_suit && (wear_suit.flags_inv & HIDEJUMPSUIT) && !istype(wear_suit, /obj/item/clothing/suit/space/rig)) return //Wearing a suit that prevents uniform rendering - //Align this item on the inventory screen TODO: Move this elsewhere - w_uniform.screen_loc = ui_iclothing - //Build a uniform sprite overlays_standing[UNIFORM_LAYER] = w_uniform.make_worn_icon(body_type = species.get_bodytype(), slot_name = slot_w_uniform_str, default_icon = INV_W_UNIFORM_DEF_ICON, default_layer = UNIFORM_LAYER) apply_layer(UNIFORM_LAYER) -/mob/living/carbon/human/update_inv_wear_id(var/update_icons=1) +/mob/living/carbon/human/update_inv_wear_id() if(QDESTROYING(src)) return - overlays_standing[ID_LAYER] = null - - //Set the bits to update the ID hud since they put something in this slot (or removed it) - //TODO: Move elsewhere, update icons is not the place. - BITSET(hud_updateflag, ID_HUD) - BITSET(hud_updateflag, WANTED_HUD) - + remove_layer(ID_LAYER) + if(!wear_id) return //Not wearing an ID - - //Align this item on the inventory screen TODO: Move this elsewhere - wear_id.screen_loc = ui_id //Only draw the ID on the mob if the uniform allows for it if(w_uniform && istype(w_uniform, /obj/item/clothing/under)) var/obj/item/clothing/under/U = w_uniform if(U.displays_id) overlays_standing[ID_LAYER] = wear_id.make_worn_icon(body_type = species.get_bodytype(), slot_name = slot_wear_id_str, default_icon = INV_WEAR_ID_DEF_ICON, default_layer = ID_LAYER) - apply_layer(ID_LAYER) + + apply_layer(ID_LAYER) -/mob/living/carbon/human/update_inv_gloves(var/update_icons=1) +/mob/living/carbon/human/update_inv_gloves() if(QDESTROYING(src)) return remove_layer(GLOVES_LAYER) - if(!gloves && !blood_DNA) - return //No gloves, no bloody hands, no reason to be here. + if(!gloves) + return //No gloves, no reason to be here. - //Draw gloves if they have gloves - if(gloves) - gloves.screen_loc = ui_gloves //TODO - - overlays_standing[GLOVES_LAYER] = gloves.make_worn_icon(body_type = species.get_bodytype(), slot_name = slot_gloves_str, default_icon = INV_GLOVES_DEF_ICON, default_layer = GLOVES_LAYER) + overlays_standing[GLOVES_LAYER] = gloves.make_worn_icon(body_type = species.get_bodytype(), slot_name = slot_gloves_str, default_icon = INV_GLOVES_DEF_ICON, default_layer = GLOVES_LAYER) - else if(blood_DNA) //TODO: Make this proc generic - var/image/bloodsies = image(icon = species.get_blood_mask(src), icon_state = "bloodyhands") - bloodsies.color = hand_blood_color - overlays_standing[GLOVES_LAYER] = bloodsies - apply_layer(GLOVES_LAYER) -/mob/living/carbon/human/update_inv_glasses(var/update_icons=1) +/mob/living/carbon/human/update_inv_glasses() if(QDESTROYING(src)) return @@ -705,12 +548,11 @@ var/global/list/damage_icon_parts = list() if(!glasses) return //Not wearing glasses, no need to update anything. - glasses.screen_loc = ui_glasses //TODO - overlays_standing[GLASSES_LAYER] = glasses.make_worn_icon(body_type = species.get_bodytype(), slot_name = slot_gloves_str, default_icon = INV_EYES_DEF_ICON, default_layer = GLASSES_LAYER) + apply_layer(GLASSES_LAYER) -/mob/living/carbon/human/update_inv_ears(var/update_icons=1) +/mob/living/carbon/human/update_inv_ears() if(QDESTROYING(src)) return @@ -726,49 +568,40 @@ var/global/list/damage_icon_parts = list() var/image/both = image(icon = 'icons/effects/effects.dmi', icon_state = "nothing", layer = BODY_LAYER+EARS_LAYER) if(l_ear) - l_ear.screen_loc = ui_l_ear //TODO var/image/standing = l_ear.make_worn_icon(body_type = species.get_bodytype(), slot_name = slot_l_ear_str, default_icon = INV_EARS_DEF_ICON, default_layer = EARS_LAYER) both.add_overlay(standing) if(r_ear) - r_ear.screen_loc = ui_r_ear //TODO var/image/standing = r_ear.make_worn_icon(body_type = species.get_bodytype(), slot_name = slot_r_ear_str, default_icon = INV_EARS_DEF_ICON, default_layer = EARS_LAYER) both.add_overlay(standing) overlays_standing[EARS_LAYER] = both apply_layer(EARS_LAYER) -/mob/living/carbon/human/update_inv_shoes(var/update_icons=1) +/mob/living/carbon/human/update_inv_shoes() if(QDESTROYING(src)) return remove_layer(SHOES_LAYER) remove_layer(SHOES_LAYER_ALT) //Dumb alternate layer for shoes being under the uniform. - if((!shoes && !feet_blood_DNA) || (wear_suit && wear_suit.flags_inv & HIDESHOES) || (w_uniform && w_uniform.flags_inv & HIDESHOES)) + if(!shoes || (wear_suit && wear_suit.flags_inv & HIDESHOES) || (w_uniform && w_uniform.flags_inv & HIDESHOES)) return //Either nothing to draw, or it'd be hidden. - if(shoes) - //Allow for shoe layer toggle nonsense - shoes.screen_loc = ui_shoes //TODO - var/shoe_layer = SHOES_LAYER - if(istype(shoes, /obj/item/clothing/shoes)) - var/obj/item/clothing/shoes/ushoes = shoes - if(ushoes.shoes_under_pants == 1) - shoe_layer = SHOES_LAYER_ALT + //Allow for shoe layer toggle nonsense + var/shoe_layer = SHOES_LAYER + if(istype(shoes, /obj/item/clothing/shoes)) + var/obj/item/clothing/shoes/ushoes = shoes + if(ushoes.shoes_under_pants == 1) + shoe_layer = SHOES_LAYER_ALT - //NB: the use of a var for the layer on this one - overlays_standing[shoe_layer] = shoes.make_worn_icon(body_type = species.get_bodytype(), slot_name = slot_shoes_str, default_icon = INV_FEET_DEF_ICON, default_layer = shoe_layer) - apply_layer(shoe_layer) - - //Bloody feet, but not wearing shoes TODO - else if(feet_blood_DNA) - var/image/bloodsies = image(icon = species.get_blood_mask(src), icon_state = "shoeblood") - bloodsies.color = feet_blood_color - overlays_standing[SHOES_LAYER] = bloodsies - apply_layer(SHOES_LAYER) + //NB: the use of a var for the layer on this one + overlays_standing[shoe_layer] = shoes.make_worn_icon(body_type = species.get_bodytype(), slot_name = slot_shoes_str, default_icon = INV_FEET_DEF_ICON, default_layer = shoe_layer) -/mob/living/carbon/human/update_inv_s_store(var/update_icons=1) + apply_layer(SHOES_LAYER) + apply_layer(SHOES_LAYER_ALT) + +/mob/living/carbon/human/update_inv_s_store() if(QDESTROYING(src)) return @@ -776,8 +609,6 @@ var/global/list/damage_icon_parts = list() if(!s_store) return //Why bother, nothing there. - - s_store.screen_loc = ui_sstore1 //TODO //TODO, this is unlike the rest of the things //Basically has no variety in slot icon choices at all. WHY SPECIES ONLY?? @@ -785,9 +616,10 @@ var/global/list/damage_icon_parts = list() if(!t_state) t_state = s_store.icon_state overlays_standing[SUIT_STORE_LAYER] = image(icon = species.suit_storage_icon, icon_state = t_state, layer = BODY_LAYER+SUIT_STORE_LAYER) + apply_layer(SUIT_STORE_LAYER) -/mob/living/carbon/human/update_inv_head(var/update_icons=1) +/mob/living/carbon/human/update_inv_head() if(QDESTROYING(src)) return @@ -795,13 +627,12 @@ var/global/list/damage_icon_parts = list() if(!head) return //No head item, why bother. - - head.screen_loc = ui_head //TODO overlays_standing[HEAD_LAYER] = head.make_worn_icon(body_type = species.get_bodytype(), slot_name = slot_head_str, default_icon = INV_HEAD_DEF_ICON, default_layer = HEAD_LAYER) + apply_layer(HEAD_LAYER) -/mob/living/carbon/human/update_inv_belt(var/update_icons=1) +/mob/living/carbon/human/update_inv_belt() if(QDESTROYING(src)) return @@ -810,8 +641,6 @@ var/global/list/damage_icon_parts = list() if(!belt) return //No belt, why bother. - - belt.screen_loc = ui_belt //TODO - Distant screaming. //Toggle for belt layering with uniform var/belt_layer = BELT_LAYER @@ -822,43 +651,31 @@ var/global/list/damage_icon_parts = list() //NB: this uses a var from above overlays_standing[belt_layer] = belt.make_worn_icon(body_type = species.get_bodytype(), slot_name = slot_belt_str, default_icon = INV_BELT_DEF_ICON, default_layer = belt_layer) + apply_layer(belt_layer) -/mob/living/carbon/human/update_inv_wear_suit(var/update_icons=1) +/mob/living/carbon/human/update_inv_wear_suit() if(QDESTROYING(src)) return remove_layer(SUIT_LAYER) - //Hide/show other layers if necessary (AAAAA) TODO - update_inv_w_uniform(FALSE) - update_inv_shoes(FALSE) - update_tail_showing(FALSE) + //Hide/show other layers if necessary + update_inv_w_uniform() + update_inv_shoes() + update_tail_showing() if(!wear_suit) return //No point, no suit. - wear_suit.screen_loc = ui_oclothing //TODO - overlays_standing[SUIT_LAYER] = wear_suit.make_worn_icon(body_type = species.get_bodytype(), slot_name = slot_wear_suit_str, default_icon = INV_SUIT_DEF_ICON, default_layer = SUIT_LAYER) + apply_layer(SUIT_LAYER) - //REALLY? REAAAAAAALLY???? UPDATE ICONS??? TODO - if( istype(wear_suit, /obj/item/clothing/suit/straight_jacket) ) - drop_from_inventory(handcuffed) - drop_l_hand() - drop_r_hand() +/mob/living/carbon/human/update_inv_pockets() + crash_with("Someone called update_inv_pockets even though it's dumb") -/mob/living/carbon/human/update_inv_pockets(var/update_icons=1) - if(QDESTROYING(src)) - return - - //Wow, this can probably go away, huh. - if(l_store) l_store.screen_loc = ui_storage1 //TODO - if(r_store) r_store.screen_loc = ui_storage2 //TODO - if(update_icons) update_icons_layers() - -/mob/living/carbon/human/update_inv_wear_mask(var/update_icons=1) +/mob/living/carbon/human/update_inv_wear_mask() if(QDESTROYING(src)) return @@ -866,13 +683,12 @@ var/global/list/damage_icon_parts = list() if(!wear_mask || (head && head.flags_inv & HIDEMASK)) return //Why bother, nothing in mask slot. - - wear_mask.screen_loc = ui_mask //TODO overlays_standing[FACEMASK_LAYER] = wear_mask.make_worn_icon(body_type = species.get_bodytype(), slot_name = slot_wear_mask_str, default_icon = INV_MASK_DEF_ICON, default_layer = FACEMASK_LAYER) + apply_layer(FACEMASK_LAYER) -/mob/living/carbon/human/update_inv_back(var/update_icons=1) +/mob/living/carbon/human/update_inv_back() if(QDESTROYING(src)) return @@ -881,9 +697,8 @@ var/global/list/damage_icon_parts = list() if(!back) return //Why do anything - back.screen_loc = ui_back //TODO - overlays_standing[BACK_LAYER] = back.make_worn_icon(body_type = species.get_bodytype(), slot_name = slot_back_str, default_icon = INV_BACK_DEF_ICON, default_layer = BACK_LAYER) + apply_layer(BACK_LAYER) //TODO: Carbon procs in my human update_icons?? @@ -902,7 +717,7 @@ var/global/list/damage_icon_parts = list() hud_used.l_hand_hud_object.update_icon() hud_used.r_hand_hud_object.update_icon() -/mob/living/carbon/human/update_inv_handcuffed(var/update_icons=1) +/mob/living/carbon/human/update_inv_handcuffed() if(QDESTROYING(src)) return @@ -912,14 +727,11 @@ var/global/list/damage_icon_parts = list() if(!handcuffed) return //Not cuffed, why bother - drop_r_hand() - drop_l_hand() - stop_pulling() //TODO: should be handled elsewhere - overlays_standing[HANDCUFF_LAYER] = handcuffed.make_worn_icon(body_type = species.get_bodytype(), slot_name = slot_handcuffed_str, default_icon = INV_HCUFF_DEF_ICON, default_layer = HANDCUFF_LAYER) + apply_layer(HANDCUFF_LAYER) -/mob/living/carbon/human/update_inv_legcuffed(var/update_icons=1) +/mob/living/carbon/human/update_inv_legcuffed() if(QDESTROYING(src)) return @@ -929,15 +741,10 @@ var/global/list/damage_icon_parts = list() return //Not legcuffed, why bother. overlays_standing[LEGCUFF_LAYER] = handcuffed.make_worn_icon(body_type = species.get_bodytype(), slot_name = slot_legcuffed_str, default_icon = INV_LCUFF_DEF_ICON, default_layer = LEGCUFF_LAYER) + apply_layer(LEGCUFF_LAYER) - //TODO: Not in my update_icons - if(m_intent != "walk") - m_intent = "walk" - if(hud_used && src.hud_used.move_intent) - hud_used.move_intent.icon_state = "walking" - -/mob/living/carbon/human/update_inv_r_hand(var/update_icons=1) +/mob/living/carbon/human/update_inv_r_hand() if(QDESTROYING(src)) return @@ -946,15 +753,11 @@ var/global/list/damage_icon_parts = list() if(!r_hand) return //No hand, no bother. - r_hand.screen_loc = ui_rhand //TODO - overlays_standing[R_HAND_LAYER] = r_hand.make_worn_icon(body_type = species.get_bodytype(), inhands = TRUE, slot_name = slot_r_hand_str, default_icon = INV_R_HAND_DEF_ICON, default_layer = R_HAND_LAYER) + apply_layer(R_HAND_LAYER) - if(handcuffed) - drop_r_hand() //TODO: EXCUSE ME - -/mob/living/carbon/human/update_inv_l_hand(var/update_icons=1) +/mob/living/carbon/human/update_inv_l_hand() if(QDESTROYING(src)) return @@ -963,15 +766,11 @@ var/global/list/damage_icon_parts = list() if(!l_hand) return //No hand, no bother. - l_hand.screen_loc = ui_lhand //TODO - overlays_standing[L_HAND_LAYER] = l_hand.make_worn_icon(body_type = species.get_bodytype(), inhands = TRUE, slot_name = slot_l_hand_str, default_icon = INV_L_HAND_DEF_ICON, default_layer = L_HAND_LAYER) + apply_layer(L_HAND_LAYER) - if(handcuffed) - drop_l_hand() //TODO: AAAAAAAAAAa - -/mob/living/carbon/human/proc/update_tail_showing(var/update_icons=1) +/mob/living/carbon/human/proc/update_tail_showing() if(QDESTROYING(src)) return @@ -983,7 +782,7 @@ var/global/list/damage_icon_parts = list() if(species_tail && !(wear_suit && wear_suit.flags_inv & HIDETAIL)) var/icon/tail_s = get_tail_icon() overlays_standing[TAIL_LAYER] = image(tail_s, icon_state = "[species_tail]_s") - animate_tail_reset(0) + animate_tail_reset() apply_layer(TAIL_LAYER) @@ -1009,16 +808,17 @@ var/global/list/damage_icon_parts = list() /mob/living/carbon/human/proc/set_tail_state(var/t_state) var/image/tail_overlay = overlays_standing[TAIL_LAYER] - + remove_layer(TAIL_LAYER) if(tail_overlay && species.get_tail_animation(src)) tail_overlay.icon_state = t_state + apply_layer(TAIL_LAYER) return tail_overlay return null //Not really once, since BYOND can't do that. //Update this if the ability to flick() images or make looping animation start at the first frame is ever added. //You can sort of flick images now with flick_overlay -Aro -/mob/living/carbon/human/proc/animate_tail_once(var/update_icons=1) +/mob/living/carbon/human/proc/animate_tail_once() if(QDESTROYING(src)) return @@ -1027,33 +827,29 @@ var/global/list/damage_icon_parts = list() var/image/tail_overlay = overlays_standing[TAIL_LAYER] if(tail_overlay && tail_overlay.icon_state == t_state) return //let the existing animation finish - + remove_layer(TAIL_LAYER) tail_overlay = set_tail_state(t_state) if(tail_overlay) spawn(20) //check that the animation hasn't changed in the meantime if(overlays_standing[TAIL_LAYER] == tail_overlay && tail_overlay.icon_state == t_state) animate_tail_stop() + + apply_layer(TAIL_LAYER) - if(update_icons) update_icons_layers() - -/mob/living/carbon/human/proc/animate_tail_start(var/update_icons=1) +/mob/living/carbon/human/proc/animate_tail_start() if(QDESTROYING(src)) return set_tail_state("[species.get_tail(src)]_slow[rand(0,9)]") - if(update_icons) update_icons_layers() - -/mob/living/carbon/human/proc/animate_tail_fast(var/update_icons=1) +/mob/living/carbon/human/proc/animate_tail_fast() if(QDESTROYING(src)) return set_tail_state("[species.get_tail(src)]_loop[rand(0,9)]") - if(update_icons) update_icons_layers() - -/mob/living/carbon/human/proc/animate_tail_reset(var/update_icons=1) +/mob/living/carbon/human/proc/animate_tail_reset() if(QDESTROYING(src)) return @@ -1062,17 +858,13 @@ var/global/list/damage_icon_parts = list() else set_tail_state("[species.get_tail(src)]_static") - if(update_icons) update_icons_layers() - -/mob/living/carbon/human/proc/animate_tail_stop(var/update_icons=1) +/mob/living/carbon/human/proc/animate_tail_stop() if(QDESTROYING(src)) return set_tail_state("[species.get_tail(src)]_static") - if(update_icons) update_icons_layers() - -/mob/living/carbon/human/update_modifier_visuals(var/update_icons=1) +/mob/living/carbon/human/update_modifier_visuals() if(QDESTROYING(src)) return @@ -1088,9 +880,10 @@ var/global/list/damage_icon_parts = list() effects.overlays += I //TODO, this compositing is annoying. overlays_standing[MODIFIER_EFFECTS_LAYER] = effects + apply_layer(MODIFIER_EFFECTS_LAYER) -/mob/living/carbon/human/update_fire(var/update_icons=1) +/mob/living/carbon/human/update_fire() if(QDESTROYING(src)) return @@ -1099,10 +892,11 @@ var/global/list/damage_icon_parts = list() if(!on_fire) return - overlays_standing[FIRE_LAYER] = image(icon = 'icons/mob/OnFire.dmi', icon_state = get_fire_icon_state()) + overlays_standing[FIRE_LAYER] = image(icon = 'icons/mob/OnFire.dmi', icon_state = get_fire_icon_state(), layer = BODY_LAYER+FIRE_LAYER) + apply_layer(FIRE_LAYER) -/mob/living/carbon/human/update_water(var/update_icons=1) +/mob/living/carbon/human/update_water() if(QDESTROYING(src)) return @@ -1112,30 +906,31 @@ var/global/list/damage_icon_parts = list() if(!depth || lying) return - overlays_standing[WATER_LAYER] = image(icon = 'icons/mob/submerged.dmi', icon_state = "human_swimming_[depth]") //TODO: Improve + overlays_standing[WATER_LAYER] = image(icon = 'icons/mob/submerged.dmi', icon_state = "human_swimming_[depth]", layer = BODY_LAYER+WATER_LAYER) //TODO: Improve + apply_layer(WATER_LAYER) -/mob/living/carbon/human/proc/update_surgery(var/update_icons=1) +/mob/living/carbon/human/proc/update_surgery() if(QDESTROYING(src)) return - remove_layer(SURGERY_LEVEL) + remove_layer(SURGERY_LAYER) var/image/total = new for(var/obj/item/organ/external/E in organs) if(E.open) - var/image/I = image(icon = 'icons/mob/surgery.dmi', icon_state = "[E.icon_name][round(E.open)]", layer = -SURGERY_LEVEL) + var/image/I = image(icon = 'icons/mob/surgery.dmi', icon_state = "[E.icon_name][round(E.open)]", layer = BODY_LAYER+SURGERY_LAYER) total.overlays += I //TODO: This compositing is annoying if(total.overlays.len) - overlays_standing[SURGERY_LEVEL] = total - apply_layer(SURGERY_LEVEL) + overlays_standing[SURGERY_LAYER] = total + apply_layer(SURGERY_LAYER) //Human Overlays Indexes///////// #undef MUTATIONS_LAYER #undef SKIN_LAYER #undef DAMAGE_LAYER -#undef SURGERY_LEVEL +#undef SURGERY_LAYER #undef UNDERWEAR_LAYER #undef SHOES_LAYER_ALT #undef UNIFORM_LAYER diff --git a/code/modules/mob/living/inventory.dm b/code/modules/mob/living/inventory.dm index 60be7fb8b5..4a651af999 100644 --- a/code/modules/mob/living/inventory.dm +++ b/code/modules/mob/living/inventory.dm @@ -72,16 +72,16 @@ /mob/living/u_equip(obj/W as obj) if (W == r_hand) r_hand = null - update_inv_r_hand(0) + update_inv_r_hand() else if (W == l_hand) l_hand = null - update_inv_l_hand(0) + update_inv_l_hand() else if (W == back) back = null - update_inv_back(0) + update_inv_back() else if (W == wear_mask) wear_mask = null - update_inv_wear_mask(0) + update_inv_wear_mask() return /mob/living/get_equipped_item(var/slot) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index fae7cba4ba..39520be29d 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -1,6 +1,13 @@ /mob/living/New() ..() + //Prime this list if we need it. + if(has_huds) + add_overlay(backplane,TRUE) //Strap this on here, to block HUDs from appearing in rightclick menus: http://www.byond.com/forum/?post=2336679 + hud_list = list() + hud_list.len = TOTAL_HUDS + make_hud_overlays() + //I'll just hang my coat up over here dsoverlay = image('icons/mob/darksight.dmi',global_hud.darksight) //This is a secret overlay! Go look at the file, you'll see. var/mutable_appearance/dsma = new(dsoverlay) //Changing like ten things, might as well. @@ -855,6 +862,7 @@ default behaviour is: resting = !resting to_chat(src, "You are now [resting ? "resting" : "getting up"]") + update_canmove() /mob/living/proc/cannot_use_vents() if(mob_size > MOB_SMALL) @@ -1003,6 +1011,7 @@ default behaviour is: break if(lying != lying_prev) + lying_prev = lying update_transform() return canmove @@ -1157,3 +1166,22 @@ default behaviour is: item.throw_at(target, throw_range, item.throw_speed, src) + +//Add an entry to overlays, assuming it exists +/mob/living/proc/apply_hud(cache_index, var/image/I) + hud_list[cache_index] = I + if((. = hud_list[cache_index])) + //underlays += . + add_overlay(.) + +//Remove an entry from overlays, and from the list +/mob/living/proc/grab_hud(cache_index) + var/I = hud_list[cache_index] + if(I) + //underlays -= I + cut_overlay(I) + hud_list[cache_index] = null + return I + +/mob/living/proc/make_hud_overlays() + return \ No newline at end of file diff --git a/code/modules/mob/living/living_defines.dm b/code/modules/mob/living/living_defines.dm index b36cd29d21..23dbb6fc09 100644 --- a/code/modules/mob/living/living_defines.dm +++ b/code/modules/mob/living/living_defines.dm @@ -54,3 +54,6 @@ var/glow_range = 2 var/glow_intensity = null var/glow_color = "#FFFFFF" // The color they're glowing! + + var/list/hud_list //Holder for health hud, status hud, wanted hud, etc (not like inventory slots) + var/has_huds = FALSE //Whether or not we should bother initializing the above list diff --git a/code/modules/mob/living/silicon/silicon.dm b/code/modules/mob/living/silicon/silicon.dm index 09321af981..0d88e0c96f 100644 --- a/code/modules/mob/living/silicon/silicon.dm +++ b/code/modules/mob/living/silicon/silicon.dm @@ -7,7 +7,7 @@ var/list/stating_laws = list()// Channels laws are currently being stated on var/obj/item/device/radio/common_radio - var/list/hud_list[10] + has_huds = TRUE var/list/speech_synthesizer_langs = list() //which languages can be vocalized by the speech synthesizer //Used in say.dm. diff --git a/code/modules/mob/living/simple_animal/simple_hud.dm b/code/modules/mob/living/simple_animal/simple_hud.dm index cd3ed61355..5da7e8a696 100644 --- a/code/modules/mob/living/simple_animal/simple_hud.dm +++ b/code/modules/mob/living/simple_animal/simple_hud.dm @@ -12,6 +12,7 @@ var/list/adding = list() var/list/other = list() var/list/hotkeybuttons = list() + var/list/slot_info = list() hud.adding = adding hud.other = other @@ -34,6 +35,7 @@ inv_box.screen_loc = slot_data["loc"] inv_box.slot_id = slot_data["slot"] inv_box.icon_state = slot_data["state"] + slot_info["[inv_box.slot_id]"] = inv_box.screen_loc if(slot_data["dir"]) inv_box.set_dir(slot_data["dir"]) @@ -249,9 +251,9 @@ inv_box.slot_id = slot_r_hand inv_box.color = ui_color inv_box.alpha = ui_alpha - hud.r_hand_hud_object = inv_box hud.adding += inv_box + slot_info["[slot_r_hand]"] = inv_box.screen_loc inv_box = new /obj/screen/inventory/hand() inv_box.hud = src @@ -266,6 +268,7 @@ inv_box.alpha = ui_alpha hud.l_hand_hud_object = inv_box hud.adding += inv_box + slot_info["[slot_l_hand]"] = inv_box.screen_loc //Swaphand titlebar using = new /obj/screen/inventory() diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 062b950b97..00864d0a04 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -858,14 +858,17 @@ /mob/proc/Resting(amount) facing_dir = null resting = max(max(resting,amount),0) + update_canmove() return /mob/proc/SetResting(amount) resting = max(amount,0) + update_canmove() return /mob/proc/AdjustResting(amount) resting = max(resting + amount,0) + update_canmove() return /mob/proc/AdjustLosebreath(amount) diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index dc7e568bd5..54c2283a2d 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -624,7 +624,28 @@ var/global/image/backplane backplane = image('icons/misc/win32.dmi') backplane.alpha = 0 backplane.plane = -100 - backplane.layer = BACKPLANE_LAYER + backplane.layer = MOB_LAYER-0.01 backplane.mouse_opacity = 0 return TRUE + +/mob/proc/position_hud_item(var/obj/item/item, var/slot) + if(!istype(hud_used) || !slot || !LAZYLEN(hud_used.slot_info)) + return + + //They may have hidden their entire hud but the hands + if(!hud_used.hud_shown && slot > slot_r_hand) + item.screen_loc = null + return + + //They may have hidden the icons in the bottom left with the hide button + if(!hud_used.inventory_shown && slot > slot_r_store) + item.screen_loc = null + return + + var/screen_place = hud_used.slot_info["[slot]"] + if(!screen_place) + item.screen_loc = null + return + + item.screen_loc = screen_place diff --git a/code/modules/mob/new_player/preferences_setup.dm b/code/modules/mob/new_player/preferences_setup.dm index a81a7334fc..108a316840 100644 --- a/code/modules/mob/new_player/preferences_setup.dm +++ b/code/modules/mob/new_player/preferences_setup.dm @@ -247,8 +247,6 @@ mannequin.job = previewJob.title previewJob.equip_preview(mannequin, player_alt_titles[previewJob.title]) - mannequin.regenerate_icons() - /datum/preferences/proc/update_preview_icon() var/mob/living/carbon/human/dummy/mannequin/mannequin = get_mannequin(client_ckey) mannequin.delete_inventory(TRUE) @@ -266,4 +264,4 @@ stamp = getFlatIcon(mannequin, defdir=SOUTH) preview_icon.Blend(stamp, ICON_OVERLAY, 49, 1) - preview_icon.Scale(preview_icon.Width() * 2, preview_icon.Height() * 2) // Scaling here to prevent blurring in the browser. \ No newline at end of file + preview_icon.Scale(preview_icon.Width() * 2, preview_icon.Height() * 2) // Scaling here to prevent blurring in the browser. diff --git a/code/modules/mob/update_icons.dm b/code/modules/mob/update_icons.dm index ae6e01a249..6004ca3e4c 100644 --- a/code/modules/mob/update_icons.dm +++ b/code/modules/mob/update_icons.dm @@ -1,31 +1,26 @@ //Most of these are defined at this level to reduce on checks elsewhere in the code. //Having them here also makes for a nice reference list of the various overlay-updating procs available -/mob/proc/regenerate_icons() //TODO: phase this out completely if possible +/mob/proc/regenerate_icons() //Update every aspect of the mob's icons (expensive, resist the urge to use unless you need it) return /mob/proc/update_icons() update_icon() //Ugh. return -/mob/proc/update_icons_layers(var/update_icons = TRUE) - if(update_icons) - update_icons() +// Obsolete +/mob/proc/update_icons_layers() + return -/mob/proc/update_icons_huds(var/update_icons = TRUE) - if(update_icons) - update_icons() +/mob/proc/update_icons_huds() + return -/mob/proc/update_icons_body(var/update_icons = TRUE) - if(update_icons) - update_icons() +/mob/proc/update_icons_body() + return /mob/proc/update_icons_all() - update_icons_huds(FALSE) - update_icons_body(FALSE) - update_icons_layers(FALSE) - - update_icons() + return +// End obsolete /mob/proc/update_hud() return diff --git a/code/modules/organs/organ_external.dm b/code/modules/organs/organ_external.dm index 7253d35049..86a9f589e4 100644 --- a/code/modules/organs/organ_external.dm +++ b/code/modules/organs/organ_external.dm @@ -873,7 +873,7 @@ Note that amputating the affected organ does in fact remove the infection from t spawn(1) victim.updatehealth() victim.UpdateDamageIcon() - victim.regenerate_icons() + victim.update_icons_body() dir = 2 switch(disintegrate) diff --git a/code/modules/paperwork/paper.dm b/code/modules/paperwork/paper.dm index c57f5de2c5..9e090c2095 100644 --- a/code/modules/paperwork/paper.dm +++ b/code/modules/paperwork/paper.dm @@ -499,13 +499,13 @@ B.loc = h_user B.hud_layerise() h_user.l_store = B - h_user.update_inv_pockets() + //h_user.update_inv_pockets() //Doesn't do anything else if (h_user.r_store == src) h_user.drop_from_inventory(src) B.loc = h_user B.hud_layerise() h_user.r_store = B - h_user.update_inv_pockets() + //h_user.update_inv_pockets() //Doesn't do anything else if (h_user.head == src) h_user.u_equip(src) h_user.put_in_hands(B)