Human icon tweaks (#3131)

Mostly efficiency changes to human icons, little bit of code deduplication in head icons.
The human overlay list has been changed to accept /list so that multiple items can be added to a layer without having to resort to adding overlays to an intermediary object like an /image.

changes:

Human skin color (not tone) is now stored as a hex string instead of a 3-value list.
Human body hair color (resomi only) is now stored as a hex string instead of a 3-value list.
Body markings now play nice with the human icon cache (Fixes #3110)
Hair properly uses its cache now in all cases.
Merged head organs and human icon's implementations of hair icon gen into a proc on human.
Replaced the individual hair and beard caches with a shared composited hair cache used by both head icon and mob icons.
Lists in the human overlay list are now flattened out onto the human, allowing for multiple objects within a single human icon layer without using an intermediary image.
Removed some unused caching lists.
Damage overlays no longer utilize overlays on a blank image for drawing, instead using a list in the human overlay list.
Shoe overlays no longer utilize overlays on the shoe image, instead using a list in the human overlay list.
Surgery overlays no longer utilize overlays on a blank image, instead using a list in the human overlay list.
This commit is contained in:
Lohikar
2017-07-23 01:03:00 +03:00
committed by Erki
parent 67e07d0b9e
commit 64e33fab83
6 changed files with 121 additions and 119 deletions
-2
View File
@@ -1,5 +1,3 @@
var/list/organ_cache = list()
/obj/item/organ
name = "organ"
icon = 'icons/obj/surgery.dmi'
+2 -2
View File
@@ -34,8 +34,8 @@
var/cannot_amputate
var/cannot_break
var/s_tone
var/list/s_col
var/list/h_col
var/skin_color
var/hair_color
var/list/wounds = list()
var/number_wounds = 0 // cache the number of wounds, which is NOT wounds.len!
var/perma_injury = 0
+16 -52
View File
@@ -13,8 +13,8 @@
/obj/item/organ/external/proc/sync_colour_to_human(var/mob/living/carbon/human/human)
s_tone = null
s_col = null
h_col = null
skin_color = null
hair_color = null
if(status & ORGAN_ROBOT && !(isipc(human)))
return
if(species && human.species && species.name != human.species.name)
@@ -22,20 +22,20 @@
if(!isnull(human.s_tone) && (human.species.appearance_flags & HAS_SKIN_TONE))
s_tone = human.s_tone
if(human.species.appearance_flags & HAS_SKIN_COLOR)
s_col = list(human.r_skin, human.g_skin, human.b_skin)
h_col = list(human.r_hair, human.g_hair, human.b_hair)
skin_color = rgb(human.r_skin, human.g_skin, human.b_skin)
hair_color = rgb(human.r_hair, human.g_hair, human.b_hair)
/obj/item/organ/external/proc/sync_colour_to_dna()
s_tone = null
s_col = null
h_col = null
skin_color = null
hair_color = null
if(status & ORGAN_ROBOT && !force_skintone)
return
if(!isnull(dna.GetUIValue(DNA_UI_SKIN_TONE)) && (species.appearance_flags & HAS_SKIN_TONE))
s_tone = dna.GetUIValue(DNA_UI_SKIN_TONE)
if(species.appearance_flags & HAS_SKIN_COLOR)
s_col = list(dna.GetUIValue(DNA_UI_SKIN_R), dna.GetUIValue(DNA_UI_SKIN_G), dna.GetUIValue(DNA_UI_SKIN_B))
h_col = list(dna.GetUIValue(DNA_UI_HAIR_R),dna.GetUIValue(DNA_UI_HAIR_G),dna.GetUIValue(DNA_UI_HAIR_B))
skin_color = rgb(dna.GetUIValue(DNA_UI_SKIN_R), dna.GetUIValue(DNA_UI_SKIN_G), dna.GetUIValue(DNA_UI_SKIN_B))
hair_color = rgb(dna.GetUIValue(DNA_UI_HAIR_R),dna.GetUIValue(DNA_UI_HAIR_G),dna.GetUIValue(DNA_UI_HAIR_B))
/obj/item/organ/external/head/sync_colour_to_human(var/mob/living/carbon/human/human)
..()
@@ -102,41 +102,7 @@
add_overlay(finished_icon) //So when it's not on your body, it has icons
mob_icon.Blend(finished_icon, ICON_OVERLAY) //So when it's on your body, it has icons
if(owner.f_style)
var/datum/sprite_accessory/facial_hair_style = facial_hair_styles_list[owner.f_style]
if(facial_hair_style && facial_hair_style.species_allowed && (species.get_bodytype() in facial_hair_style.species_allowed))
var/facialcolor
if (facial_hair_style.do_colouration)
facialcolor = rgb(owner.r_facial, owner.g_facial, owner.b_facial)
var/cache_key = "[facial_hair_style.icon]_[facial_hair_style.icon_state]_[facialcolor || "nocolor"]"
var/icon/facial_s = SSicon_cache.human_beard_cache[cache_key]
if (!facial_s)
facial_s = new/icon("icon" = facial_hair_style.icon, "icon_state" = "[facial_hair_style.icon_state]_s")
if(facial_hair_style.do_colouration)
facial_s.Blend(facialcolor, ICON_ADD)
SSicon_cache.human_beard_cache[cache_key] = facial_s
add_overlay(facial_s)
if(owner.h_style && !(owner.head && (owner.head.flags_inv & BLOCKHEADHAIR)))
var/datum/sprite_accessory/hair_style = hair_styles_list[owner.h_style]
if(hair_style && (species.get_bodytype() in hair_style.species_allowed))
var/haircolor
if (hair_style.do_colouration && istype(h_col) && h_col.len >= 3)
haircolor = rgb(h_col[1], h_col[2], h_col[3])
var/cache_key = "[hair_style.icon]_[hair_style.icon_state]_[haircolor || "nocolor"]"
var/icon/hair_s = SSicon_cache.human_hair_cache[cache_key]
if (!hair_s)
hair_s = new/icon("icon" = hair_style.icon, "icon_state" = "[hair_style.icon_state]_s")
if(hair_style.do_colouration && islist(h_col) && h_col.len >= 3)
hair_s.Blend(haircolor, ICON_ADD)
SSicon_cache.human_hair_cache[cache_key] = hair_s
add_overlay(hair_s)
add_overlay(owner.generate_hair_icon())
compile_overlays()
@@ -150,14 +116,12 @@
if(force_icon)
mob_icon = new /icon(force_icon, "[icon_name][gendered_icon ? "_[gender]" : ""]")
if(painted)
if(s_col && s_col.len >= 3)
mob_icon.Blend(rgb(s_col[1], s_col[2], s_col[3]), ICON_ADD)
if(painted && skin_color)
mob_icon.Blend(skin_color, ICON_ADD)
else
if(!dna)
mob_icon = new /icon('icons/mob/human_races/r_human.dmi', "[icon_name][gendered_icon ? "_[gender]" : ""]")
else
if(!gendered_icon)
gender = null
else
@@ -185,8 +149,8 @@
mob_icon.Blend(rgb(s_tone, s_tone, s_tone), ICON_ADD)
else
mob_icon.Blend(rgb(-s_tone, -s_tone, -s_tone), ICON_SUBTRACT)
else if(s_col && s_col.len >= 3)
mob_icon.Blend(rgb(s_col[1], s_col[2], s_col[3]), ICON_ADD)
else if(skin_color)
mob_icon.Blend(skin_color, ICON_ADD)
//Body markings, does not include head, duplicated (sadly) above.
for(var/M in markings)
@@ -203,12 +167,12 @@
add_overlay(finished_icon) //So when it's not on your body, it has icons
mob_icon.Blend(finished_icon, ICON_OVERLAY) //So when it's on your body, it has icons
if(body_hair && islist(h_col) && h_col.len >= 3)
if(body_hair && hair_color)
var/list/limb_icon_cache = SSicon_cache.body_hair_cache
var/cache_key = "[body_hair]-[icon_name]-[h_col[1]][h_col[2]][h_col[3]]"
var/cache_key = "[body_hair]-[icon_name]-[hair_color]"
if(!limb_icon_cache[cache_key])
var/icon/I = icon(species.icobase, "[icon_name]_[body_hair]")
I.Blend(rgb(h_col[1],h_col[2],h_col[3]), ICON_ADD)
I.Blend(hair_color, ICON_ADD)
limb_icon_cache[cache_key] = I
mob_icon.Blend(limb_icon_cache[cache_key], ICON_OVERLAY)