[MIRROR] Adds a second ear slot. (#9329)

Co-authored-by: silicons <2003111+silicons@users.noreply.github.com>
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
This commit is contained in:
CHOMPStation2StaffMirrorBot
2024-10-27 08:38:03 -07:00
committed by GitHub
parent ab2f0cc3d3
commit 38b0939ad4
24 changed files with 385 additions and 66 deletions

View File

@@ -17,6 +17,15 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
var/r_ears3 = 30 // Ear tertiary color.
var/g_ears3 = 30 // Ear tertiary color
var/b_ears3 = 30 // Ear tertiary color
/// The typepath of the character's selected secondary ears.
var/ear_secondary_style
/// The color channels for the character's selected secondary ears
///
/// * This is a lazy list. Its length, when populated, should but cannot be assumed
/// to be the number of color channels supported by the secondary ear style.
var/list/ear_secondary_colors = list()
var/tail_style // Type of selected tail style
var/r_tail = 30 // Tail/Taur color
var/g_tail = 30 // Tail/Taur color
@@ -27,6 +36,7 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
var/r_tail3 = 30 // For tertiary overlay.
var/g_tail3 = 30 // For tertiary overlay.
var/b_tail3 = 30 // For tertiary overlay.
var/wing_style // Type of selected wing style
var/r_wing = 30 // Wing color
var/g_wing = 30 // Wing color
@@ -37,6 +47,7 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
var/r_wing3 = 30 // Wing tertiary color
var/g_wing3 = 30 // Wing tertiary color
var/b_wing3 = 30 // Wing tertiary color
var/datum/browser/markings_subwindow = null
// Sanitize ear/wing/tail styles
@@ -59,6 +70,8 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
// Sanitize for non-existent keys.
if(ear_style && !(ear_style in get_available_styles(global.ear_styles_list)))
ear_style = null
if(ear_secondary_style && !(ear_secondary_style in get_available_styles(global.ear_styles_list)))
ear_secondary_style = null
if(wing_style && !(wing_style in get_available_styles(global.wing_styles_list)))
wing_style = null
if(tail_style && !(tail_style in get_available_styles(global.tail_styles_list)))
@@ -144,6 +157,8 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
pref.r_ears3 = save_data["r_ears3"]
pref.g_ears3 = save_data["g_ears3"]
pref.b_ears3 = save_data["b_ears3"]
pref.ear_secondary_style = save_data["ear_secondary_style"]
pref.ear_secondary_colors = save_data["ear_secondary_colors"]
pref.tail_style = save_data["tail_style"]
pref.r_tail = save_data["r_tail"]
pref.g_tail = save_data["g_tail"]
@@ -221,6 +236,8 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
save_data["r_ears3"] = pref.r_ears3
save_data["g_ears3"] = pref.g_ears3
save_data["b_ears3"] = pref.b_ears3
save_data["ear_secondary_style"] = pref.ear_secondary_style
save_data["ear_secondary_colors"] = pref.ear_secondary_colors
save_data["tail_style"] = pref.tail_style
save_data["r_tail"] = pref.r_tail
save_data["g_tail"] = pref.g_tail
@@ -289,6 +306,14 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
pref.r_ears3 = sanitize_integer(pref.r_ears3, 0, 255, initial(pref.r_ears3))
pref.g_ears3 = sanitize_integer(pref.g_ears3, 0, 255, initial(pref.g_ears3))
pref.b_ears3 = sanitize_integer(pref.b_ears3, 0, 255, initial(pref.b_ears3))
// sanitize secondary ears
pref.ear_secondary_colors = SANITIZE_LIST(pref.ear_secondary_colors)
if(length(pref.ear_secondary_colors) > length(GLOB.fancy_sprite_accessory_color_channel_names))
pref.ear_secondary_colors.len = length(GLOB.fancy_sprite_accessory_color_channel_names)
for(var/i in 1 to length(pref.ear_secondary_colors))
pref.ear_secondary_colors[i] = sanitize_hexcolor(pref.ear_secondary_colors[i], "#ffffff")
pref.r_tail = sanitize_integer(pref.r_tail, 0, 255, initial(pref.r_tail))
pref.g_tail = sanitize_integer(pref.g_tail, 0, 255, initial(pref.g_tail))
pref.b_tail = sanitize_integer(pref.b_tail, 0, 255, initial(pref.b_tail))
@@ -364,6 +389,10 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
character.b_ears3 = pref.b_ears3
character.g_ears3 = pref.g_ears3
// apply secondary ears; sanitize again to prevent runtimes in rendering
character.ear_secondary_style = ear_styles[pref.ear_secondary_style]
character.ear_secondary_colors = SANITIZE_LIST(pref.ear_secondary_colors)
var/list/tail_styles = pref.get_available_styles(global.tail_styles_list)
character.tail_style = tail_styles[pref.tail_style]
character.r_tail = pref.r_tail
@@ -655,6 +684,15 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
else
. += " Style: <a href='?src=\ref[src];ear_style=1'>Select</a><br>"
var/datum/sprite_accessory/ears/ears_secondary = ear_styles[pref.ear_secondary_style]
. += span_bold("Horns") + "<br>"
if(istype(ears_secondary))
. += " Style: <a href='?src=\ref[src];ear_secondary_style=1'>[ears_secondary.name]</a><br>"
for(var/channel in 1 to min(ears_secondary.get_color_channel_count(), length(GLOB.fancy_sprite_accessory_color_channel_names)))
. += "<a href='?src=\ref[src];ear_secondary_color=[channel]'>Change [GLOB.fancy_sprite_accessory_color_channel_names[channel]] Color</a> [color_square(hex = LAZYACCESS(pref.ear_secondary_colors, channel) || "#ffffff")]<br>"
else
. += " Style: <a href='?src=\ref[src];ear_secondary_style=1'>Select</a><br>"
var/list/tail_styles = pref.get_available_styles(global.tail_styles_list)
var/datum/sprite_accessory/tail/tail = tail_styles[pref.tail_style]
. += span_bold("Tail") + "<br>"
@@ -1349,6 +1387,32 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
pref.b_ears3 = hex2num(copytext(new_earc3, 6, 8))
return TOPIC_REFRESH_UPDATE_PREVIEW
else if(href_list["ear_secondary_style"])
var/new_style = tgui_input_list(user, "Select an ear style for this character:", "Character Preference", pref.get_available_styles(global.ear_styles_list), pref.ear_secondary_style)
if(!new_style)
return TOPIC_NOACTION
pref.ear_secondary_style = new_style
return TOPIC_REFRESH_UPDATE_PREVIEW
else if(href_list["ear_secondary_color"])
var/channel = text2num(href_list["ear_secondary_color"])
// very important sanity check; this makes sure someone can't crash the server by setting channel to some insanely high value
if(channel > GLOB.fancy_sprite_accessory_color_channel_names.len)
return TOPIC_NOACTION
// this would say 'secondary ears' but you'd get 'choose your character's primary secondary ear colour' which sounds silly
var/new_color = input(
user,
"Choose your character's [lowertext(GLOB.fancy_sprite_accessory_color_channel_names[channel])] ear colour:",
"Secondary Ear Coloration",
LAZYACCESS(pref.ear_secondary_colors, channel) || "#ffffff",
) as color | null
if(!new_color)
return TOPIC_NOACTION
// ensures color channel list is at least that long
// the upper bound is to have a secondary safety check because list index set is a dangerous call
pref.ear_secondary_colors.len = clamp(length(pref.ear_secondary_colors), channel, length(GLOB.fancy_sprite_accessory_color_channel_names))
pref.ear_secondary_colors[channel] = new_color
return TOPIC_REFRESH_UPDATE_PREVIEW
else if(href_list["tail_style"])
var/new_tail_style = tgui_input_list(user, "Select a tail style for this character:", "Character Preference", pref.get_available_styles(global.tail_styles_list), pref.tail_style)
if(new_tail_style)