Merge pull request #7366 from KasparoVy/mob_rgb_to_hex

Converts Mob Colours to Hexadecimal
This commit is contained in:
tigercat2000
2017-08-16 12:52:13 -07:00
committed by GitHub
29 changed files with 392 additions and 665 deletions
@@ -210,19 +210,14 @@
H.ha_style = "None"
update_head_accessory()
/mob/living/carbon/human/proc/change_eye_color(var/red, var/green, var/blue, update_dna = 1)
/mob/living/carbon/human/proc/change_eye_color(var/colour = "#000000", update_dna = 1)
// Update the main DNA datum, then sync the change across the organs
var/obj/item/organ/internal/eyes/eyes_organ = get_int_organ(/obj/item/organ/internal/eyes)
if(eyes_organ)
var/eyes_red = eyes_organ.eye_colour[1]
var/eyes_green = eyes_organ.eye_colour[2]
var/eyes_blue = eyes_organ.eye_colour[3]
if(red == eyes_red && green == eyes_green && blue == eyes_blue)
if(colour == eyes_organ.eye_colour)
return
eyes_organ.eye_colour[1] = red
eyes_organ.eye_colour[2] = green
eyes_organ.eye_colour[3] = blue
eyes_organ.eye_colour = colour
dna.eye_color_to_dna(eyes_organ)
eyes_organ.set_dna(dna)
@@ -233,68 +228,58 @@
update_body()
return 1
/mob/living/carbon/human/proc/change_hair_color(var/red, var/green, var/blue, var/secondary)
/mob/living/carbon/human/proc/change_hair_color(var/colour = "#000000", var/secondary)
var/obj/item/organ/external/head/H = get_organ("head")
if(!H)
return
if(!secondary)
if(red == H.r_hair && green == H.g_hair && blue == H.b_hair)
if(colour == H.hair_colour)
return
H.r_hair = red
H.g_hair = green
H.b_hair = blue
H.hair_colour = colour
else
if(red == H.r_hair_sec && green == H.g_hair_sec && blue == H.b_hair_sec)
if(colour == H.sec_hair_colour)
return
H.r_hair_sec = red
H.g_hair_sec = green
H.b_hair_sec = blue
H.sec_hair_colour = colour
update_hair()
return 1
/mob/living/carbon/human/proc/change_facial_hair_color(var/red, var/green, var/blue, var/secondary)
/mob/living/carbon/human/proc/change_facial_hair_color(var/colour = "#000000", var/secondary)
var/obj/item/organ/external/head/H = get_organ("head")
if(!H)
return
if(!secondary)
if(red == H.r_facial && green == H.g_facial && blue == H.b_facial)
if(colour == H.facial_colour)
return
H.r_facial = red
H.g_facial = green
H.b_facial = blue
H.facial_colour = colour
else
if(red == H.r_facial_sec && green == H.g_facial_sec && blue == H.b_facial_sec)
if(colour == H.sec_facial_colour)
return
H.r_facial_sec = red
H.g_facial_sec = green
H.b_facial_sec = blue
H.sec_facial_colour = colour
update_fhair()
return 1
/mob/living/carbon/human/proc/change_head_accessory_color(var/red, var/green, var/blue)
/mob/living/carbon/human/proc/change_head_accessory_color(var/colour = "#000000")
var/obj/item/organ/external/head/H = get_organ("head")
if(!H)
return
if(red == H.r_headacc && green == H.g_headacc && blue == H.b_headacc)
if(colour == H.headacc_colour)
return
H.r_headacc = red
H.g_headacc = green
H.b_headacc = blue
H.headacc_colour = colour
update_head_accessory()
return 1
/mob/living/carbon/human/proc/change_marking_color(var/colour, var/location = "body")
/mob/living/carbon/human/proc/change_marking_color(var/colour = "#000000", var/location = "body")
if(colour == m_colours[location])
return
@@ -307,13 +292,11 @@
return 1
/mob/living/carbon/human/proc/change_skin_color(var/red, var/green, var/blue)
if(red == r_skin && green == g_skin && blue == b_skin || !(species.bodyflags & HAS_SKIN_COLOR))
/mob/living/carbon/human/proc/change_skin_color(var/colour = "#000000")
if(colour == skin_colour || !(species.bodyflags & HAS_SKIN_COLOR))
return
r_skin = red
g_skin = green
b_skin = blue
skin_colour = colour
force_update_limbs()
update_body()
+8 -24
View File
@@ -1431,13 +1431,9 @@
if(species.base_color && default_colour)
//Apply colour.
r_skin = color2R(species.base_color)
g_skin = color2G(species.base_color)
b_skin = color2B(species.base_color)
skin_colour = species.base_color
else
r_skin = 0
g_skin = 0
b_skin = 0
skin_colour = "#000000"
if(!(species.bodyflags & HAS_SKIN_TONE))
s_tone = 0
@@ -1461,29 +1457,17 @@
if(species.default_hair_colour)
//Apply colour.
H.r_hair = color2R(species.default_hair_colour)
H.g_hair = color2G(species.default_hair_colour)
H.b_hair = color2B(species.default_hair_colour)
H.hair_colour = species.default_hair_colour
else
H.r_hair = 0
H.g_hair = 0
H.b_hair = 0
H.hair_colour = "#000000"
if(species.default_fhair_colour)
H.r_facial = color2R(species.default_fhair_colour)
H.g_facial = color2G(species.default_fhair_colour)
H.b_facial = color2B(species.default_fhair_colour)
H.facial_colour = species.default_fhair_colour
else
H.r_facial = 0
H.g_facial = 0
H.b_facial = 0
H.facial_colour = "#000000"
if(species.default_headacc_colour)
H.r_headacc = color2R(species.default_headacc_colour)
H.g_headacc = color2G(species.default_headacc_colour)
H.b_headacc = color2B(species.default_headacc_colour)
H.headacc_colour = species.default_headacc_colour
else
H.r_headacc = 0
H.g_headacc = 0
H.b_headacc = 0
H.headacc_colour = "#000000"
m_styles = DEFAULT_MARKING_STYLES //Wipes out markings, setting them all to "None".
m_colours = DEFAULT_MARKING_COLOURS //Defaults colour to #00000 for all markings.
@@ -10,9 +10,7 @@ var/global/default_martial_art = new/datum/martial_art
var/s_tone = 0 //Skin tone
//Skin colour
var/r_skin = 0
var/g_skin = 0
var/b_skin = 0
var/skin_colour = "#000000"
var/lip_style = null //no lipstick by default- arguably misleading, as it could be used for general makeup
var/lip_color = "white"
@@ -584,11 +584,8 @@
if((H in recolor_list) && H.reagents.total_volume > SLIMEPERSON_COLOR_SHIFT_TRIGGER)
var/blood_amount = H.blood_volume
var/r_color = mix_color_from_reagents(H.reagents.reagent_list)
var/new_body_color = BlendRGB(r_color, rgb(H.r_skin, H.g_skin, H.b_skin), (blood_amount*SLIMEPERSON_BLOOD_SCALING_FACTOR)/((blood_amount*SLIMEPERSON_BLOOD_SCALING_FACTOR)+(H.reagents.total_volume)))
var/list/new_color_list = ReadRGB(new_body_color)
H.r_skin = new_color_list[1]
H.g_skin = new_color_list[2]
H.b_skin = new_color_list[3]
var/new_body_color = BlendRGB(r_color, H.skin_colour, (blood_amount*SLIMEPERSON_BLOOD_SCALING_FACTOR)/((blood_amount*SLIMEPERSON_BLOOD_SCALING_FACTOR)+(H.reagents.total_volume)))
H.skin_colour = new_body_color
if(world.time % SLIMEPERSON_ICON_UPDATE_PERIOD > SLIMEPERSON_ICON_UPDATE_PERIOD - 20) // The 20 is because this gets called every 2 seconds, from the mob controller
for(var/organname in H.bodyparts_by_name)
var/obj/item/organ/external/E = H.bodyparts_by_name[organname]
@@ -228,7 +228,7 @@ var/global/list/damage_icon_parts = list()
var/obj/item/organ/internal/eyes/eyes = get_int_organ(/obj/item/organ/internal/eyes)
if(eyes)
icon_key += "[rgb(eyes.eye_colour[1], eyes.eye_colour[2], eyes.eye_colour[3])]"
icon_key += "[eyes.eye_colour]"
else
icon_key += "#000000"
@@ -248,7 +248,7 @@ var/global/list/damage_icon_parts = list()
icon_key += "[part.dna.GetUIState(DNA_UI_GENDER)]"
icon_key += "[part.dna.GetUIValue(DNA_UI_SKIN_TONE)]"
if(part.s_col)
icon_key += "[rgb(part.s_col[1], part.s_col[2], part.s_col[3])]"
icon_key += "[part.s_col]"
if(part.s_tone)
icon_key += "[part.s_tone]"
@@ -408,7 +408,7 @@ var/global/list/damage_icon_parts = list()
if(head_organ.species.name in head_accessory_style.species_allowed)
var/icon/head_accessory_s = new/icon("icon" = head_accessory_style.icon, "icon_state" = "[head_accessory_style.icon_state]_s")
if(head_accessory_style.do_colouration)
head_accessory_s.Blend(rgb(head_organ.r_headacc, head_organ.g_headacc, head_organ.b_headacc), ICON_ADD)
head_accessory_s.Blend(head_organ.headacc_colour, ICON_ADD)
head_accessory_standing = head_accessory_s //head_accessory_standing.Blend(head_accessory_s, ICON_OVERLAY)
//Having it this way preserves animations. Useful for animated antennae.
@@ -449,14 +449,14 @@ var/global/list/damage_icon_parts = list()
if((head_organ.species.name in hair_style.species_allowed) || (head_organ.species.bodyflags & ALL_RPARTS)) //If the head's species is in the list of allowed species for the hairstyle, or the head's species is one flagged to have bodies comprised wholly of cybernetics...
var/icon/hair_s = new/icon("icon" = hair_style.icon, "icon_state" = "[hair_style.icon_state]_s")
if(head_organ.species.name == "Slime People") // I am el worstos
hair_s.Blend(rgb(r_skin, g_skin, b_skin, 160), ICON_AND)
hair_s.Blend("[skin_colour]A0", ICON_AND)
else if(hair_style.do_colouration)
hair_s.Blend(rgb(head_organ.r_hair, head_organ.g_hair, head_organ.b_hair), ICON_ADD)
hair_s.Blend(head_organ.hair_colour, ICON_ADD)
if(hair_style.secondary_theme)
var/icon/hair_secondary_s = new/icon("icon" = hair_style.icon, "icon_state" = "[hair_style.icon_state]_[hair_style.secondary_theme]_s")
if(!hair_style.no_sec_colour)
hair_secondary_s.Blend(rgb(head_organ.r_hair_sec, head_organ.g_hair_sec, head_organ.b_hair_sec), ICON_ADD)
hair_secondary_s.Blend(head_organ.sec_hair_colour, ICON_ADD)
hair_s.Blend(hair_secondary_s, ICON_OVERLAY)
hair_standing = hair_s //hair_standing.Blend(hair_s, ICON_OVERLAY)
@@ -495,14 +495,14 @@ var/global/list/damage_icon_parts = list()
if((head_organ.species.name in facial_hair_style.species_allowed) || (head_organ.species.bodyflags & ALL_RPARTS)) //If the head's species is in the list of allowed species for the hairstyle, or the head's species is one flagged to have bodies comprised wholly of cybernetics...
var/icon/facial_s = new/icon("icon" = facial_hair_style.icon, "icon_state" = "[facial_hair_style.icon_state]_s")
if(head_organ.species.name == "Slime People") // I am el worstos
facial_s.Blend(rgb(r_skin, g_skin, b_skin, 160), ICON_AND)
facial_s.Blend("[skin_colour]A0", ICON_AND)
else if(facial_hair_style.do_colouration)
facial_s.Blend(rgb(head_organ.r_facial, head_organ.g_facial, head_organ.b_facial), ICON_ADD)
facial_s.Blend(head_organ.facial_colour, ICON_ADD)
if(facial_hair_style.secondary_theme)
var/icon/facial_secondary_s = new/icon("icon" = facial_hair_style.icon, "icon_state" = "[facial_hair_style.icon_state]_[facial_hair_style.secondary_theme]_s")
if(!facial_hair_style.no_sec_colour)
facial_secondary_s.Blend(rgb(head_organ.r_facial_sec, head_organ.g_facial_sec, head_organ.b_facial_sec), ICON_ADD)
facial_secondary_s.Blend(head_organ.sec_facial_colour, ICON_ADD)
facial_s.Blend(facial_secondary_s, ICON_OVERLAY)
face_standing.Blend(facial_s, ICON_OVERLAY)
@@ -1168,7 +1168,7 @@ var/global/list/damage_icon_parts = list()
if(body_accessory.try_restrictions(src))
var/icon/accessory_s = new/icon("icon" = body_accessory.icon, "icon_state" = body_accessory.icon_state)
if(species.bodyflags & HAS_SKIN_COLOR)
accessory_s.Blend(rgb(r_skin, g_skin, b_skin), body_accessory.blend_mode)
accessory_s.Blend(skin_colour, body_accessory.blend_mode)
if(tail_marking_icon && (body_accessory.name in tail_marking_style.tails_allowed))
accessory_s.Blend(tail_marking_icon, ICON_OVERLAY)
if((!body_accessory || istype(body_accessory, /datum/body_accessory/tail)) && species.bodyflags & TAIL_OVERLAPPED) // If the player has a species whose tail is overlapped by limbs... (having a non-tail body accessory like the snake body will override this)
@@ -1193,7 +1193,7 @@ var/global/list/damage_icon_parts = list()
if(!wear_suit || !(wear_suit.flags_inv & HIDETAIL) && !istype(wear_suit, /obj/item/clothing/suit/space))
var/icon/tail_s = new/icon("icon" = 'icons/effects/species.dmi', "icon_state" = "[tail]_s")
if(species.bodyflags & HAS_SKIN_COLOR)
tail_s.Blend(rgb(r_skin, g_skin, b_skin), ICON_ADD)
tail_s.Blend(skin_colour, ICON_ADD)
if(tail_marking_icon && !tail_marking_style.tails_allowed)
tail_s.Blend(tail_marking_icon, ICON_OVERLAY)
if((!body_accessory || istype(body_accessory, /datum/body_accessory/tail)) && species.bodyflags & TAIL_OVERLAPPED) // If the player has a species whose tail is overlapped by limbs... (having a non-tail body accessory like the snake body will override this)
@@ -1234,7 +1234,7 @@ var/global/list/damage_icon_parts = list()
if(body_accessory)
var/icon/accessory_s = new/icon("icon" = body_accessory.get_animated_icon(), "icon_state" = body_accessory.get_animated_icon_state())
if(species.bodyflags & HAS_SKIN_COLOR)
accessory_s.Blend(rgb(r_skin, g_skin, b_skin), body_accessory.blend_mode)
accessory_s.Blend(skin_colour, body_accessory.blend_mode)
if(tail_marking_icon && (body_accessory.name in tail_marking_style.tails_allowed))
accessory_s.Blend(tail_marking_icon, ICON_OVERLAY)
if((!body_accessory || istype(body_accessory, /datum/body_accessory/tail)) && species.bodyflags & TAIL_OVERLAPPED) // If the player has a species whose tail is overlapped by limbs... (having a non-tail body accessory like the snake body will override this)
@@ -1261,7 +1261,7 @@ var/global/list/damage_icon_parts = list()
else if(tail && species.bodyflags & HAS_TAIL)
var/icon/tailw_s = new/icon("icon" = 'icons/effects/species.dmi', "icon_state" = "[tail]w_s")
if(species.bodyflags & HAS_SKIN_COLOR)
tailw_s.Blend(rgb(r_skin, g_skin, b_skin), ICON_ADD)
tailw_s.Blend(skin_colour, ICON_ADD)
if(tail_marking_icon && !tail_marking_style.tails_allowed)
tailw_s.Blend(tail_marking_icon, ICON_OVERLAY)
if((!body_accessory || istype(body_accessory, /datum/body_accessory/tail)) && species.bodyflags & TAIL_OVERLAPPED) // If the player has a species whose tail is overlapped by limbs... (having a non-tail body accessory like the snake body will override this)
@@ -30,22 +30,16 @@
randomize_hair_color("facial")
if(S.bodyflags & HAS_HEAD_ACCESSORY)
ha_style = random_head_accessory(species)
var/list/colours = randomize_skin_color(1)
r_headacc = colours["red"]
g_headacc = colours["green"]
b_headacc = colours["blue"]
hacc_colour = randomize_skin_color(1)
if(S.bodyflags & HAS_HEAD_MARKINGS)
m_styles["head"] = random_marking_style("head", species, robohead, null, alt_head)
var/list/colours = randomize_skin_color(1)
m_colours["head"] = rgb(colours["red"], colours["green"], colours["blue"])
m_colours["head"] = randomize_skin_color(1)
if(S.bodyflags & HAS_BODY_MARKINGS)
m_styles["body"] = random_marking_style("body", species)
var/list/colours = randomize_skin_color(1)
m_colours["body"] = rgb(colours["red"], colours["green"], colours["blue"])
m_colours["body"] = randomize_skin_color(1)
if(S.bodyflags & HAS_TAIL_MARKINGS) //Species with tail markings.
m_styles["tail"] = random_marking_style("tail", species, null, body_accessory)
var/list/colours = randomize_skin_color(1)
m_colours["tail"] = rgb(colours["red"], colours["green"], colours["blue"])
m_colours["tail"] = randomize_skin_color(1)
if(!(S.bodyflags & ALL_RPARTS))
randomize_eyes_color()
if(S.bodyflags & HAS_SKIN_COLOR)
@@ -56,9 +50,7 @@
/datum/preferences/proc/randomize_hair_color(var/target = "hair")
if(prob (75) && target == "facial") // Chance to inherit hair color
r_facial = r_hair
g_facial = g_hair
b_facial = b_hair
f_colour = h_colour
return
var/red
@@ -106,13 +98,9 @@
switch(target)
if("hair")
r_hair = red
g_hair = green
b_hair = blue
h_colour = rgb(red, green, blue)
if("facial")
r_facial = red
g_facial = green
b_facial = blue
f_colour = rgb(red, green, blue)
/datum/preferences/proc/randomize_eyes_color()
var/red
@@ -158,11 +146,9 @@
green = max(min(green + rand (-25, 25), 255), 0)
blue = max(min(blue + rand (-25, 25), 255), 0)
r_eyes = red
g_eyes = green
b_eyes = blue
e_colour = rgb(red, green, blue)
/datum/preferences/proc/randomize_skin_color(var/pass_to_list)
/datum/preferences/proc/randomize_skin_color(var/pass_on)
var/red
var/green
var/blue
@@ -206,17 +192,10 @@
green = max(min(green + rand (-25, 25), 255), 0)
blue = max(min(blue + rand (-25, 25), 255), 0)
if(pass_to_list)
var/list/colours = list(
"red" = red,
"blue" = blue,
"green" = green
)
return colours
if(pass_on)
return rgb(red, green, blue)
else
r_skin = red
g_skin = green
b_skin = blue
s_colour = rgb(red, green, blue)
/datum/preferences/proc/blend_backpack(var/icon/clothes_s,var/backbag,var/satchel,var/backpack="backpack")
switch(backbag)
@@ -284,7 +263,7 @@
// Skin color
if(current_species && (current_species.bodyflags & HAS_SKIN_COLOR))
preview_icon.Blend(rgb(r_skin, g_skin, b_skin), ICON_ADD)
preview_icon.Blend(s_colour, ICON_ADD)
// Skin tone
if(current_species && (current_species.bodyflags & HAS_SKIN_TONE))
@@ -325,7 +304,7 @@
temp.Shift(NORTH, tail_shift_y)
if(current_species && (current_species.bodyflags & HAS_SKIN_COLOR))
temp.Blend(rgb(r_skin, g_skin, b_skin), blend_mode)
temp.Blend(s_colour, blend_mode)
if(current_species && (current_species.bodyflags & HAS_TAIL_MARKINGS))
var/tail_marking = m_styles["tail"]
@@ -358,7 +337,7 @@
var/icon/face_s = new/icon("icon" = 'icons/mob/human_face.dmi', "icon_state" = "bald_s")
if(!(current_species.bodyflags & NO_EYES))
var/icon/eyes_s = new/icon("icon" = 'icons/mob/human_face.dmi', "icon_state" = current_species ? current_species.eyes : "eyes_s")
eyes_s.Blend(rgb(r_eyes, g_eyes, b_eyes), ICON_ADD)
eyes_s.Blend(e_colour, ICON_ADD)
face_s.Blend(eyes_s, ICON_OVERLAY)
@@ -366,14 +345,14 @@
if(hair_style)
var/icon/hair_s = new/icon("icon" = hair_style.icon, "icon_state" = "[hair_style.icon_state]_s")
if(current_species.name == "Slime People") // whee I am part of the problem
hair_s.Blend(rgb(r_skin, g_skin, b_skin, 160), ICON_ADD)
hair_s.Blend("[s_colour]A0", ICON_ADD)
else
hair_s.Blend(rgb(r_hair, g_hair, b_hair), ICON_ADD)
hair_s.Blend(h_colour, ICON_ADD)
if(hair_style.secondary_theme)
var/icon/hair_secondary_s = new/icon("icon" = hair_style.icon, "icon_state" = "[hair_style.icon_state]_[hair_style.secondary_theme]_s")
if(!hair_style.no_sec_colour)
hair_secondary_s.Blend(rgb(r_hair_sec, g_hair_sec, b_hair_sec), ICON_ADD)
hair_secondary_s.Blend(h_sec_colour, ICON_ADD)
hair_s.Blend(hair_secondary_s, ICON_OVERLAY)
face_s.Blend(hair_s, ICON_OVERLAY)
@@ -383,21 +362,21 @@
var/datum/sprite_accessory/head_accessory_style = head_accessory_styles_list[ha_style]
if(head_accessory_style && head_accessory_style.species_allowed)
var/icon/head_accessory_s = new/icon("icon" = head_accessory_style.icon, "icon_state" = "[head_accessory_style.icon_state]_s")
head_accessory_s.Blend(rgb(r_headacc, g_headacc, b_headacc), ICON_ADD)
head_accessory_s.Blend(hacc_colour, ICON_ADD)
face_s.Blend(head_accessory_s, ICON_OVERLAY)
var/datum/sprite_accessory/facial_hair_style = facial_hair_styles_list[f_style]
if(facial_hair_style && facial_hair_style.species_allowed)
var/icon/facial_s = new/icon("icon" = facial_hair_style.icon, "icon_state" = "[facial_hair_style.icon_state]_s")
if(current_species.name == "Slime People") // whee I am part of the problem
facial_s.Blend(rgb(r_skin, g_skin, b_skin, 160), ICON_ADD)
facial_s.Blend("[s_colour]A0", ICON_ADD)
else
facial_s.Blend(rgb(r_facial, g_facial, b_facial), ICON_ADD)
facial_s.Blend(f_colour, ICON_ADD)
if(facial_hair_style.secondary_theme)
var/icon/facial_secondary_s = new/icon("icon" = facial_hair_style.icon, "icon_state" = "[facial_hair_style.icon_state]_[facial_hair_style.secondary_theme]_s")
if(!facial_hair_style.no_sec_colour)
facial_secondary_s.Blend(rgb(r_facial_sec, g_facial_sec, b_facial_sec), ICON_ADD)
facial_secondary_s.Blend(f_sec_colour, ICON_ADD)
facial_s.Blend(facial_secondary_s, ICON_OVERLAY)
face_s.Blend(facial_s, ICON_OVERLAY)