Merge pull request #16172 from dearmochi/hair-gradients

[READY] Port hair gradient customization
This commit is contained in:
Fox McCloud
2021-11-11 15:40:21 -05:00
committed by GitHub
21 changed files with 260 additions and 41 deletions
@@ -56,7 +56,11 @@
body_accessory,
gear,
autohiss,
slot
slot,
hair_gradient,
hair_gradient_offset,
hair_gradient_colour,
hair_gradient_alpha
FROM characters WHERE ckey=:ckey"}, list(
"ckey" = C.ckey
))
+55 -4
View File
@@ -95,6 +95,13 @@
/// Character slot number, used for saves and stuff.
var/slot_number = 0
// Hair gradient
var/h_grad_style = "None"
var/h_grad_offset_x = 0
var/h_grad_offset_y = 0
var/h_grad_colour = "#000000"
var/h_grad_alpha = 255
// Fuckery to prevent null characters
/datum/character_save/New()
randomise()
@@ -178,7 +185,11 @@
socks=:socks,
body_accessory=:body_accessory,
gear=:gearlist,
autohiss=:autohiss_mode
autohiss=:autohiss_mode,
hair_gradient=:h_grad_style,
hair_gradient_offset=:h_grad_offset,
hair_gradient_colour=:h_grad_colour,
hair_gradient_alpha=:h_grad_alpha
WHERE ckey=:ckey
AND slot=:slot"}, list(
// OH GOD SO MANY PARAMETERS
@@ -234,6 +245,10 @@
"body_accessory" = (body_accessory ? body_accessory : ""),
"gearlist" = (gearlist ? gearlist : ""),
"autohiss_mode" = autohiss_mode,
"h_grad_style" = h_grad_style,
"h_grad_offset" = "[h_grad_offset_x],[h_grad_offset_y]",
"h_grad_colour" = h_grad_colour,
"h_grad_alpha" = h_grad_alpha,
"ckey" = C.ckey,
"slot" = slot_number
))
@@ -274,7 +289,8 @@
gen_record,
player_alt_titles,
disabilities, organ_data, rlimb_data, nanotrasen_relation, speciesprefs,
socks, body_accessory, gear, autohiss)
socks, body_accessory, gear, autohiss,
hair_gradient, hair_gradient_offset, hair_gradient_colour, hair_gradient_alpha)
VALUES
(:ckey, :slot, :metadata, :name, :be_random_name, :gender,
:age, :species, :language,
@@ -301,7 +317,8 @@
:gen_record,
:playertitlelist,
:disabilities, :organlist, :rlimblist, :nanotrasen_relation, :speciesprefs,
:socks, :body_accessory, :gearlist, :autohiss_mode)
:socks, :body_accessory, :gearlist, :autohiss_mode,
:h_grad_style, :h_grad_offset, :h_grad_colour, :h_grad_alpha)
"}, list(
// This has too many params for anyone to look at this without going insae
"ckey" = C.ckey,
@@ -357,7 +374,11 @@
"socks" = socks,
"body_accessory" = (body_accessory ? body_accessory : ""),
"gearlist" = (gearlist ? gearlist : ""),
"autohiss_mode" = autohiss_mode
"autohiss_mode" = autohiss_mode,
"h_grad_style" = h_grad_style,
"h_grad_offset" = "[h_grad_offset_x],[h_grad_offset_y]",
"h_grad_colour" = h_grad_colour,
"h_grad_alpha" = h_grad_alpha
))
if(!query.warn_execute())
@@ -441,6 +462,11 @@
loadout_gear = query.item[51]
autohiss_mode = text2num(query.item[52])
h_grad_style = query.item[54]
h_grad_offset_x = query.item[55] // parsed down below
h_grad_colour = query.item[56]
h_grad_alpha = query.item[57]
//Sanitize
var/datum/species/SP = GLOB.all_species[species]
metadata = sanitize_text(metadata, initial(metadata))
@@ -507,6 +533,13 @@
socks = sanitize_text(socks, initial(socks))
body_accessory = sanitize_text(body_accessory, initial(body_accessory))
h_grad_style = sanitize_text(length(h_grad_style) ? h_grad_style : null, "None")
var/list/expl = splittext(h_grad_offset_x, ",")
if(length(expl) == 2)
h_grad_offset_x = text2num(expl[1]) || 0
h_grad_offset_y = text2num(expl[2]) || 0
h_grad_colour = sanitize_hexcolor(h_grad_colour)
h_grad_alpha = sanitize_integer(h_grad_alpha, 0, 255, initial(h_grad_alpha))
loadout_gear = sanitize_json(loadout_gear)
if(!player_alt_titles)
@@ -874,6 +907,18 @@
else if(hair_style.do_colouration)
hair_s.Blend(h_colour, ICON_ADD)
var/datum/sprite_accessory/hair_gradient/gradient = GLOB.hair_gradients_list[h_grad_style]
if(gradient)
var/icon/grad_s = new/icon("icon" = gradient.icon, "icon_state" = gradient.icon_state)
if(h_grad_offset_x)
grad_s.Shift(EAST, h_grad_offset_x)
if(h_grad_offset_y)
grad_s.Shift(NORTH, h_grad_offset_y)
grad_s.Blend(hair_s, ICON_ADD)
grad_s.MapColors(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK, h_grad_colour)
grad_s.ChangeOpacity(h_grad_alpha / 255)
hair_s.Blend(grad_s, ICON_OVERLAY)
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_style.do_colouration )
@@ -1781,6 +1826,12 @@
H.f_style = f_style
H.alt_head = alt_head
H.h_grad_style = h_grad_style
H.h_grad_offset_x = h_grad_offset_x
H.h_grad_offset_y = h_grad_offset_y
H.h_grad_colour = h_grad_colour
H.h_grad_alpha = h_grad_alpha
//End of head-specific.
character.skin_colour = s_colour
@@ -372,6 +372,29 @@
var/new_h_style = input(user, "Choose your character's hair style:", "Character Preference") as null|anything in valid_hairstyles
if(new_h_style)
active_character.h_style = new_h_style
if("h_grad_style")
var/result = input(user, "Choose your character's hair gradient style:", "Character Preference") as null|anything in GLOB.hair_gradients_list
if(result)
active_character.h_grad_style = result
if("h_grad_offset")
var/result = input(user, "Enter your character's hair gradient offset as a comma-separated value (x,y). Example:\n0,0 (no offset)\n5,0 (5 pixels to the right)", "Character Preference") as null|text
if(result)
var/list/expl = splittext(result, ",")
if(length(expl) == 2)
active_character.h_grad_offset_x = clamp(text2num(expl[1]) || 0, -16, 16)
active_character.h_grad_offset_y = clamp(text2num(expl[2]) || 0, -16, 16)
if("h_grad_colour")
var/result = input(user, "Choose your character's hair gradient colour:", "Character Preference", active_character.h_grad_colour) as color|null
if(result)
active_character.h_grad_colour = result
if("h_grad_alpha")
var/result = input(user, "Choose your character's hair gradient alpha (0-255):", "Character Preference", active_character.h_grad_alpha) as num|null
if(!isnull(result))
active_character.h_grad_alpha = clamp(result, 0, 255)
if("headaccessory")
if(S.bodyflags & HAS_HEAD_ACCESSORY) //Species with head accessories.
@@ -233,6 +233,14 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
var/datum/sprite_accessory/temp_hair_style = GLOB.hair_styles_public_list[active_character.h_style]
if(temp_hair_style && temp_hair_style.secondary_theme && !temp_hair_style.no_sec_colour)
dat += " <a href='?_src_=prefs;preference=secondary_hair;task=input'>Color #2</a> [color_square(active_character.h_sec_colour)]"
// Hair gradient
dat += "<br>"
dat += "- <b>Gradient:</b>"
dat += " <a href='?_src_=prefs;preference=h_grad_style;task=input'>[active_character.h_grad_style]</a>"
dat += " <a href='?_src_=prefs;preference=h_grad_colour;task=input'>Color</a> [color_square(active_character.h_grad_colour)]"
dat += " <a href='?_src_=prefs;preference=h_grad_alpha;task=input'>[active_character.h_grad_alpha]</a>"
dat += "<br>"
dat += "- <b>Gradient Offset:</b> <a href='?_src_=prefs;preference=h_grad_offset;task=input'>[active_character.h_grad_offset_x],[active_character.h_grad_offset_y]</a>"
dat += "<br>"
dat += "<b>Facial Hair:</b> "
@@ -98,7 +98,6 @@
qdel(query)
return 1
/datum/preferences/proc/load_random_character_slot(client/C)
var/list/datum/character_save/valid_slots = list()
for(var/datum/character_save/CS in character_saves)