mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-19 13:35:10 +00:00
## About The Pull Request `init_possible_values()` now only ever returns a list of values instead of both values and icons. The responsibility of icon generation has moved from this proc to a new `icon_for(value)` proc, which returns the icon/typepath of an atom. A runtime is thrown if any value does not have an icon. This boosts production initialization times by 3+ seconds, but is primarily done to allow for further optimizations of this process. As an example, it is a mapping of value -> icon so that in the code that executes this we can have more fine grained control over tick overrun. As a bonus, fixes #67092.
186 lines
6.5 KiB
Plaintext
186 lines
6.5 KiB
Plaintext
/proc/generate_icon_with_head_accessory(datum/sprite_accessory/sprite_accessory)
|
|
var/static/icon/head_icon
|
|
if (isnull(head_icon))
|
|
head_icon = icon('icons/mob/human/bodyparts_greyscale.dmi', "human_head_m")
|
|
head_icon.Blend(skintone2hex("caucasian1"), ICON_MULTIPLY)
|
|
|
|
if (isnull(sprite_accessory))
|
|
return head_icon
|
|
|
|
ASSERT(istype(sprite_accessory))
|
|
|
|
var/icon/final_icon = new(head_icon)
|
|
|
|
var/icon/head_accessory_icon = icon(sprite_accessory.icon, sprite_accessory.icon_state)
|
|
head_accessory_icon.Blend(COLOR_DARK_BROWN, ICON_MULTIPLY)
|
|
final_icon.Blend(head_accessory_icon, ICON_OVERLAY)
|
|
|
|
final_icon.Crop(10, 19, 22, 31)
|
|
final_icon.Scale(32, 32)
|
|
|
|
return final_icon
|
|
|
|
/datum/preference/color/eye_color
|
|
priority = PREFERENCE_PRIORITY_BODYPARTS
|
|
savefile_key = "eye_color"
|
|
savefile_identifier = PREFERENCE_CHARACTER
|
|
category = PREFERENCE_CATEGORY_SECONDARY_FEATURES
|
|
relevant_head_flag = HEAD_EYECOLOR
|
|
|
|
/datum/preference/color/eye_color/apply_to_human(mob/living/carbon/human/target, value)
|
|
var/hetero = target.eye_color_heterochromatic
|
|
target.eye_color_left = value
|
|
if(!hetero)
|
|
target.eye_color_right = value
|
|
|
|
var/obj/item/organ/internal/eyes/eyes_organ = target.get_organ_by_type(/obj/item/organ/internal/eyes)
|
|
if (!eyes_organ || !istype(eyes_organ))
|
|
return
|
|
|
|
if (!initial(eyes_organ.eye_color_left))
|
|
eyes_organ.eye_color_left = value
|
|
eyes_organ.old_eye_color_left = value
|
|
|
|
if(hetero) // Don't override the snowflakes please
|
|
return
|
|
|
|
if (!initial(eyes_organ.eye_color_right))
|
|
eyes_organ.eye_color_right = value
|
|
eyes_organ.old_eye_color_right = value
|
|
eyes_organ.refresh()
|
|
|
|
/datum/preference/color/eye_color/create_default_value()
|
|
return random_eye_color()
|
|
|
|
/datum/preference/choiced/facial_hairstyle
|
|
priority = PREFERENCE_PRIORITY_BODYPARTS
|
|
savefile_key = "facial_style_name"
|
|
savefile_identifier = PREFERENCE_CHARACTER
|
|
category = PREFERENCE_CATEGORY_FEATURES
|
|
main_feature_name = "Facial hair"
|
|
should_generate_icons = TRUE
|
|
relevant_head_flag = HEAD_FACIAL_HAIR
|
|
|
|
/datum/preference/choiced/facial_hairstyle/init_possible_values()
|
|
return assoc_to_keys_features(GLOB.facial_hairstyles_list)
|
|
|
|
/datum/preference/choiced/facial_hairstyle/icon_for(value)
|
|
return generate_icon_with_head_accessory(GLOB.facial_hairstyles_list[value])
|
|
|
|
/datum/preference/choiced/facial_hairstyle/apply_to_human(mob/living/carbon/human/target, value)
|
|
target.set_facial_hairstyle(value, update = FALSE)
|
|
|
|
/datum/preference/choiced/facial_hairstyle/compile_constant_data()
|
|
var/list/data = ..()
|
|
|
|
data[SUPPLEMENTAL_FEATURE_KEY] = "facial_hair_color"
|
|
|
|
return data
|
|
|
|
/datum/preference/color/facial_hair_color
|
|
priority = PREFERENCE_PRIORITY_BODYPARTS
|
|
savefile_key = "facial_hair_color"
|
|
savefile_identifier = PREFERENCE_CHARACTER
|
|
category = PREFERENCE_CATEGORY_SUPPLEMENTAL_FEATURES
|
|
relevant_head_flag = HEAD_FACIAL_HAIR
|
|
|
|
/datum/preference/color/facial_hair_color/apply_to_human(mob/living/carbon/human/target, value)
|
|
target.set_facial_haircolor(value, update = FALSE)
|
|
|
|
/datum/preference/choiced/facial_hair_gradient
|
|
priority = PREFERENCE_PRIORITY_BODYPARTS
|
|
category = PREFERENCE_CATEGORY_SECONDARY_FEATURES
|
|
savefile_identifier = PREFERENCE_CHARACTER
|
|
savefile_key = "facial_hair_gradient"
|
|
relevant_head_flag = HEAD_FACIAL_HAIR
|
|
|
|
/datum/preference/choiced/facial_hair_gradient/init_possible_values()
|
|
return assoc_to_keys_features(GLOB.facial_hair_gradients_list)
|
|
|
|
/datum/preference/choiced/facial_hair_gradient/apply_to_human(mob/living/carbon/human/target, value)
|
|
target.set_facial_hair_gradient_style(new_style = value, update = FALSE)
|
|
|
|
/datum/preference/choiced/facial_hair_gradient/create_default_value()
|
|
return "None"
|
|
|
|
/datum/preference/color/facial_hair_gradient
|
|
priority = PREFERENCE_PRIORITY_BODYPARTS
|
|
category = PREFERENCE_CATEGORY_SECONDARY_FEATURES
|
|
savefile_identifier = PREFERENCE_CHARACTER
|
|
savefile_key = "facial_hair_gradient_color"
|
|
relevant_head_flag = HEAD_FACIAL_HAIR
|
|
|
|
/datum/preference/color/facial_hair_gradient/apply_to_human(mob/living/carbon/human/target, value)
|
|
target.set_facial_hair_gradient_color(new_color = value, update = FALSE)
|
|
|
|
/datum/preference/color/facial_hair_gradient/is_accessible(datum/preferences/preferences)
|
|
if (!..(preferences))
|
|
return FALSE
|
|
return preferences.read_preference(/datum/preference/choiced/facial_hair_gradient) != "None"
|
|
|
|
/datum/preference/color/hair_color
|
|
priority = PREFERENCE_PRIORITY_BODYPARTS
|
|
savefile_key = "hair_color"
|
|
savefile_identifier = PREFERENCE_CHARACTER
|
|
category = PREFERENCE_CATEGORY_SUPPLEMENTAL_FEATURES
|
|
relevant_head_flag = HEAD_HAIR
|
|
|
|
/datum/preference/color/hair_color/apply_to_human(mob/living/carbon/human/target, value)
|
|
target.set_haircolor(value, update = FALSE)
|
|
|
|
/datum/preference/choiced/hairstyle
|
|
priority = PREFERENCE_PRIORITY_BODYPARTS
|
|
savefile_key = "hairstyle_name"
|
|
savefile_identifier = PREFERENCE_CHARACTER
|
|
category = PREFERENCE_CATEGORY_FEATURES
|
|
main_feature_name = "Hairstyle"
|
|
should_generate_icons = TRUE
|
|
relevant_head_flag = HEAD_HAIR
|
|
|
|
/datum/preference/choiced/hairstyle/init_possible_values()
|
|
return assoc_to_keys_features(GLOB.hairstyles_list)
|
|
|
|
/datum/preference/choiced/hairstyle/icon_for(value)
|
|
return generate_icon_with_head_accessory(GLOB.hairstyles_list[value])
|
|
|
|
/datum/preference/choiced/hairstyle/apply_to_human(mob/living/carbon/human/target, value)
|
|
target.set_hairstyle(value, update = FALSE)
|
|
|
|
/datum/preference/choiced/hairstyle/compile_constant_data()
|
|
var/list/data = ..()
|
|
|
|
data[SUPPLEMENTAL_FEATURE_KEY] = "hair_color"
|
|
|
|
return data
|
|
|
|
/datum/preference/choiced/hair_gradient
|
|
priority = PREFERENCE_PRIORITY_BODYPARTS
|
|
category = PREFERENCE_CATEGORY_SECONDARY_FEATURES
|
|
savefile_identifier = PREFERENCE_CHARACTER
|
|
savefile_key = "hair_gradient"
|
|
relevant_head_flag = HEAD_HAIR
|
|
|
|
/datum/preference/choiced/hair_gradient/init_possible_values()
|
|
return assoc_to_keys_features(GLOB.hair_gradients_list)
|
|
|
|
/datum/preference/choiced/hair_gradient/apply_to_human(mob/living/carbon/human/target, value)
|
|
target.set_hair_gradient_style(new_style = value, update = FALSE)
|
|
|
|
/datum/preference/choiced/hair_gradient/create_default_value()
|
|
return "None"
|
|
|
|
/datum/preference/color/hair_gradient
|
|
priority = PREFERENCE_PRIORITY_BODYPARTS
|
|
category = PREFERENCE_CATEGORY_SECONDARY_FEATURES
|
|
savefile_identifier = PREFERENCE_CHARACTER
|
|
savefile_key = "hair_gradient_color"
|
|
relevant_head_flag = HEAD_HAIR
|
|
|
|
/datum/preference/color/hair_gradient/apply_to_human(mob/living/carbon/human/target, value)
|
|
target.set_hair_gradient_color(new_color = value, update = FALSE)
|
|
|
|
/datum/preference/color/hair_gradient/is_accessible(datum/preferences/preferences)
|
|
if (!..(preferences))
|
|
return FALSE
|
|
return preferences.read_preference(/datum/preference/choiced/hair_gradient) != "None"
|