From d6c24f11c40f0e927e33e17869921515e88618a5 Mon Sep 17 00:00:00 2001 From: Llywelwyn <82828093+Llywelwyn@users.noreply.github.com> Date: Sun, 5 May 2024 15:08:09 +0100 Subject: [PATCH] Adds gradient style/colour selection to the appearance changer (#19020) now the ghostspawner and augs and stuff can change gradient style/colour too where applicable ![image](https://github.com/Aurorastation/Aurora.3/assets/82828093/3c6a7f54-3ec4-447d-a46d-c22ca9cc5a55) changes: - rscadd: "Added gradient style/colour selection to the appearance changer." - bugfix: "Fixed hair colour being unable to be the same as eye colour." --- .../mob/living/carbon/human/appearance.dm | 52 +++++++++++++++- code/modules/nano/modules/human_appearance.dm | 24 ++++++++ html/changelogs/lly-hairstuff.yml | 59 +++++++++++++++++++ .../tgui/interfaces/AppearanceChanger.tsx | 23 ++++++++ 4 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 html/changelogs/lly-hairstuff.yml diff --git a/code/modules/mob/living/carbon/human/appearance.dm b/code/modules/mob/living/carbon/human/appearance.dm index bec615079cc..947755e244a 100644 --- a/code/modules/mob/living/carbon/human/appearance.dm +++ b/code/modules/mob/living/carbon/human/appearance.dm @@ -48,6 +48,24 @@ update_hair() return 1 +/** + * Sets gradient style and updates hair overlay + */ +/mob/living/carbon/human/proc/change_gradient(var/gradient) + if(!gradient) + return + + if(g_style == gradient) + return + + if(!(gradient in GLOB.hair_gradient_styles_list)) + return + + g_style = gradient + + update_hair() + return TRUE + /mob/living/carbon/human/proc/change_facial_hair(var/facial_hair_style) if(!facial_hair_style) return @@ -94,7 +112,7 @@ return 1 /mob/living/carbon/human/proc/change_hair_color(var/red, var/green, var/blue) - if(red == r_eyes && green == g_eyes && blue == b_eyes) + if(red == r_hair && green == g_hair && blue == b_hair) return r_hair = red @@ -106,6 +124,22 @@ update_hair() return 1 +/** + * Sets gradient colour and updates sprite + */ +/mob/living/carbon/human/proc/change_gradient_color(var/red, var/green, var/blue) + if(red == r_grad && green == g_grad && blue == b_grad) + return + + r_grad = red + g_grad = green + b_grad = blue + + force_update_limbs() + update_body() + update_hair() + return TRUE + /mob/living/carbon/human/proc/change_facial_hair_color(var/red, var/green, var/blue) if(red == r_facial && green == g_facial && blue == b_facial) return @@ -236,6 +270,22 @@ return valid_hairstyles +/** + * Returns a list of all valid gradient styles for this mob + */ +/mob/living/carbon/human/proc/generate_valid_gradients() + var/list/valid_gradient_styles = list() + if(species.bald) + return valid_gradient_styles + for(var/gradient in GLOB.hair_gradient_styles_list) + var/datum/sprite_accessory/S = GLOB.hair_gradient_styles_list[gradient] + + if(!(species.type in S.species_allowed)) + continue + + valid_gradient_styles += gradient + return valid_gradient_styles + /mob/living/carbon/human/proc/generate_valid_facial_hairstyles() var/list/valid_facial_hairstyles = new() if(species.bald) diff --git a/code/modules/nano/modules/human_appearance.dm b/code/modules/nano/modules/human_appearance.dm index 57abcea138e..f1cb72dcc6c 100644 --- a/code/modules/nano/modules/human_appearance.dm +++ b/code/modules/nano/modules/human_appearance.dm @@ -12,6 +12,7 @@ var/list/valid_genders = list() var/list/valid_pronouns = list() var/list/valid_hairstyles = list() + var/list/valid_gradient_styles = list() var/list/valid_facial_hairstyles = list() var/list/valid_cultures = list() var/list/valid_origins = list() @@ -115,6 +116,21 @@ if(owner.change_hair_color(r_hair, g_hair, b_hair)) update_dna() . = TRUE + if("gradient") + if(can_change(APPEARANCE_HAIR) && (params["gradient"] in valid_gradient_styles)) + if(owner.change_gradient(params["gradient"])) + update_dna() + . = TRUE + if("gradient_color") + if(can_change(APPEARANCE_HAIR_COLOR)) + var/new_gradient = input("Please select gradient color.", "Gradient Color", rgb(owner.r_grad, owner.g_grad, owner.b_grad)) as color|null + if(new_gradient) + var/r_grad = hex2num(copytext(new_gradient, 2, 4)) + var/g_grad = hex2num(copytext(new_gradient, 4, 6)) + var/b_grad = hex2num(copytext(new_gradient, 6, 8)) + if(owner.change_gradient_color(r_grad, g_grad, b_grad)) + update_dna() + . = TRUE if("facial_hair") if(can_change(APPEARANCE_FACIAL_HAIR) && (params["facial_hair"] in valid_facial_hairstyles)) if(owner.change_facial_hair(params["facial_hair"])) @@ -261,11 +277,16 @@ data["owner_hair_style"] = owner.h_style data["valid_hair_styles"] = valid_hairstyles + data["change_gradient"] = can_change(APPEARANCE_HAIR) + data["owner_gradient_style"] = owner.g_style + data["valid_gradient_styles"] = valid_gradient_styles + data["change_facial_hair"] = can_change(APPEARANCE_FACIAL_HAIR) data["owner_facial_hair_style"] = owner.f_style data["valid_facial_hair_styles"] = valid_facial_hairstyles data["change_hair_color"] = can_change(APPEARANCE_HAIR_COLOR) + data["change_gradient_color"] = can_change(APPEARANCE_HAIR_COLOR) data["change_facial_hair_color"] = can_change(APPEARANCE_FACIAL_HAIR_COLOR) return data @@ -315,6 +336,7 @@ valid_genders = list() valid_pronouns = list() valid_hairstyles = list() + valid_gradient_styles = list() valid_facial_hairstyles = list() valid_cultures = list() valid_origins = list() @@ -338,6 +360,8 @@ valid_pronouns = owner.species.selectable_pronouns.Copy() if(!length(valid_hairstyles) || !length(valid_facial_hairstyles)) valid_hairstyles = owner.generate_valid_hairstyles(check_gender = 1) + if(!length(valid_gradient_styles)) + valid_gradient_styles = owner.generate_valid_gradients() if(!length(valid_facial_hairstyles)) valid_facial_hairstyles = owner.generate_valid_facial_hairstyles() if(!length(valid_cultures)) diff --git a/html/changelogs/lly-hairstuff.yml b/html/changelogs/lly-hairstuff.yml new file mode 100644 index 00000000000..adf644b3bac --- /dev/null +++ b/html/changelogs/lly-hairstuff.yml @@ -0,0 +1,59 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# - (fixes bugs) +# wip +# - (work in progress) +# qol +# - (quality of life) +# soundadd +# - (adds a sound) +# sounddel +# - (removes a sound) +# rscadd +# - (adds a feature) +# rscdel +# - (removes a feature) +# imageadd +# - (adds an image or sprite) +# imagedel +# - (removes an image or sprite) +# spellcheck +# - (fixes spelling or grammar) +# experiment +# - (experimental change) +# balance +# - (balance changes) +# code_imp +# - (misc internal code change) +# refactor +# - (refactors code) +# config +# - (makes a change to the config files) +# admin +# - (makes changes to administrator tools) +# server +# - (miscellaneous changes to server) +################################# + +# Your name. +author: Llywelwyn + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, this gets changed to [] after reading. Just remove the brackets when you add new shit. +# Please surround your changes in double quotes ("). It works without them, but if you use certain characters it screws up compiling. The quotes will not show up in the changelog. +changes: + - rscadd: "Added gradient style/colour selection to the appearance changer." + - bugfix: "Fixed hair colour being unable to be the same as eye colour." diff --git a/tgui/packages/tgui/interfaces/AppearanceChanger.tsx b/tgui/packages/tgui/interfaces/AppearanceChanger.tsx index a909d2e1bdc..c0e81984b30 100644 --- a/tgui/packages/tgui/interfaces/AppearanceChanger.tsx +++ b/tgui/packages/tgui/interfaces/AppearanceChanger.tsx @@ -43,11 +43,16 @@ export type ChangerData = { owner_hair_style: string; valid_hair_styles: string[]; + change_gradient: BooleanLike; + owner_gradient_style: string; + valid_gradient_styles: string[]; + change_facial_hair: BooleanLike; owner_facial_hair_style: string; valid_facial_hair_styles: string[]; change_hair_color: BooleanLike; + change_gradient_color: BooleanLike; change_facial_hair_color: BooleanLike; change_prosthetics: BooleanLike; @@ -256,6 +261,14 @@ export const ColorsWindow = (props, context) => { ) : ( '' )} + {data.change_gradient_color ? ( +