Skip to content

Commit

Permalink
Feat: changeable colors for underclothing (#3256)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rerik007 authored Oct 10, 2023
1 parent 798a7e8 commit 1a3a7ec
Show file tree
Hide file tree
Showing 17 changed files with 230 additions and 210 deletions.
2 changes: 2 additions & 0 deletions SQL/paradise_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ CREATE TABLE `characters` (
`alt_head_name` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL,
`eye_colour` varchar(7) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '#000000',
`underwear` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`underwear_color` varchar(7) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '#ffffff',
`undershirt` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`undershirt_color` varchar(7) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '#ffffff',
`backbag` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`b_type` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL,
`alternate_option` smallint(4) NOT NULL,
Expand Down
3 changes: 3 additions & 0 deletions SQL/updates/30-31.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Adds colors for under clothing
ALTER TABLE `characters` ADD COLUMN `underwear_color` varchar(7) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '#ffffff' AFTER `underwear`;
ALTER TABLE `characters` ADD COLUMN `undershirt_color` varchar(7) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '#ffffff' AFTER `undershirt`;
2 changes: 1 addition & 1 deletion code/__DEFINES/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@
#define EXPLOSION_BLOCK_PROC -1

// The SQL version required by this version of the code
#define SQL_VERSION 30
#define SQL_VERSION 31

// Vending machine stuff
#define CAT_NORMAL 1
Expand Down
8 changes: 8 additions & 0 deletions code/game/objects/structures/dresser.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
valid_underwear[underwear] = GLOB.underwear_list[underwear]
var/new_underwear = input(user, "Choose your underwear:", "Changing") as null|anything in valid_underwear
if(new_underwear)
var/datum/sprite_accessory/underwear/uwear = GLOB.underwear_list[new_underwear]
if(uwear.allow_change_color)
var/new_underwear_color = input(user, "Choose your underwear color, else color will be white:", "Changing", "#ffffff") as color|null
H.color_underwear = new_underwear_color || "#ffffff"
H.underwear = new_underwear

if("Undershirt")
Expand All @@ -37,6 +41,10 @@
valid_undershirts[undershirt] = GLOB.undershirt_list[undershirt]
var/new_undershirt = input(user, "Choose your undershirt:", "Changing") as null|anything in valid_undershirts
if(new_undershirt)
var/datum/sprite_accessory/undershirt/ushirt = GLOB.undershirt_list[new_undershirt]
if(ushirt.allow_change_color)
var/new_undershirt_color = input(user, "Choose your undershirt color, else color will be white:", "Changing", "#ffffff") as color|null
H.color_undershirt = new_undershirt_color || "#ffffff"
H.undershirt = new_undershirt

if("Socks")
Expand Down
21 changes: 21 additions & 0 deletions code/modules/client/preference/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
var/spawnpoint = "Arrivals Shuttle" //where this character will spawn (0-2).
var/b_type = "A+" //blood type (not-chooseable)
var/underwear = "Nude" //underwear type
var/underwear_color = "#ffffff" //underwear color if underwear allows it
var/undershirt = "Nude" //undershirt type
var/undershirt_color = "#ffffff" //undershirt color if undershirt allows it
var/socks = "Nude" //socks type
var/backbag = GBACKPACK //backpack type
var/ha_style = "None" //Head accessory style
Expand Down Expand Up @@ -488,8 +490,14 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
dat += "<h2>Clothing</h2>"
if(S.clothing_flags & HAS_UNDERWEAR)
dat += "<b>Underwear:</b> <a href ='?_src_=prefs;preference=underwear;task=input'>[underwear]</a><BR>"
var/datum/sprite_accessory/underwear/uwear = GLOB.underwear_list[underwear]
if(uwear?.allow_change_color)
dat += "<b>Underwear Color:</b> <a href ='?_src_=prefs;preference=underwear_color;task=input'>Color</a> [color_square(underwear_color)]<BR>"
if(S.clothing_flags & HAS_UNDERSHIRT)
dat += "<b>Undershirt:</b> <a href ='?_src_=prefs;preference=undershirt;task=input'>[undershirt]</a><BR>"
var/datum/sprite_accessory/undershirt/ushirt = GLOB.undershirt_list[undershirt]
if(ushirt?.allow_change_color)
dat += "<b>Undershirt Color:</b> <a href ='?_src_=prefs;preference=undershirt_color;task=input'>Color</a> [color_square(undershirt_color)]<BR>"
if(S.clothing_flags & HAS_SOCKS)
dat += "<b>Socks:</b> <a href ='?_src_=prefs;preference=socks;task=input'>[socks]</a><BR>"
dat += "<b>Backpack Type:</b> <a href ='?_src_=prefs;preference=bag;task=input'>[backbag]</a><br>"
Expand Down Expand Up @@ -1906,6 +1914,12 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
ShowChoices(user)
if(new_underwear)
underwear = new_underwear

if("underwear_color")
var/new_uwear_color = input(user, "Choose your character's underwear colour:", "Character Preference", underwear_color) as color|null
if(new_uwear_color)
underwear_color = new_uwear_color

if("undershirt")
var/list/valid_undershirts = list()
for(var/undershirt in GLOB.undershirt_list)
Expand All @@ -1923,6 +1937,11 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
if(new_undershirt)
undershirt = new_undershirt

if("undershirt_color")
var/new_ushirt_color = input(user, "Choose your character's undershirt colour:", "Character Preference", undershirt_color) as color|null
if(new_ushirt_color)
undershirt_color = new_ushirt_color

if("socks")
var/list/valid_sockstyles = list()
for(var/sockstyle in GLOB.socks_list)
Expand Down Expand Up @@ -2609,7 +2628,9 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
W.buckle_mob(character, TRUE)

character.underwear = underwear
character.color_underwear = underwear_color
character.undershirt = undershirt
character.color_undershirt = undershirt_color
character.socks = socks

if(character.dna.species.bodyflags & HAS_HEAD_ACCESSORY)
Expand Down
90 changes: 51 additions & 39 deletions code/modules/client/preference/preferences_mysql.dm
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@
alt_head_name,
eye_colour,
underwear,
underwear_color,
undershirt,
undershirt_color,
backbag,
b_type,
alternate_option,
Expand Down Expand Up @@ -250,31 +252,33 @@
alt_head = query.item[20]
e_colour = query.item[21]
underwear = query.item[22]
undershirt = query.item[23]
backbag = query.item[24]
b_type = query.item[25]
underwear_color = query.item[23]
undershirt = query.item[24]
undershirt_color = query.item[25]
backbag = query.item[26]
b_type = query.item[27]


//Jobs
alternate_option = text2num(query.item[26])
job_support_high = text2num(query.item[27])
job_support_med = text2num(query.item[28])
job_support_low = text2num(query.item[29])
job_medsci_high = text2num(query.item[30])
job_medsci_med = text2num(query.item[31])
job_medsci_low = text2num(query.item[32])
job_engsec_high = text2num(query.item[33])
job_engsec_med = text2num(query.item[34])
job_engsec_low = text2num(query.item[35])
job_karma_high = text2num(query.item[36])
job_karma_med = text2num(query.item[37])
job_karma_low = text2num(query.item[38])
alternate_option = text2num(query.item[28])
job_support_high = text2num(query.item[29])
job_support_med = text2num(query.item[30])
job_support_low = text2num(query.item[31])
job_medsci_high = text2num(query.item[32])
job_medsci_med = text2num(query.item[33])
job_medsci_low = text2num(query.item[34])
job_engsec_high = text2num(query.item[35])
job_engsec_med = text2num(query.item[36])
job_engsec_low = text2num(query.item[37])
job_karma_high = text2num(query.item[38])
job_karma_med = text2num(query.item[39])
job_karma_low = text2num(query.item[40])

//Miscellaneous
flavor_text = query.item[39]
med_record = query.item[40]
sec_record = query.item[41]
gen_record = query.item[42]
flavor_text = query.item[41]
med_record = query.item[42]
sec_record = query.item[43]
gen_record = query.item[44]
// Apparently, the preceding vars weren't always encoded properly...
if(findtext(flavor_text, "<")) // ... so let's clumsily check for tags!
flavor_text = html_encode(flavor_text)
Expand All @@ -284,31 +288,31 @@
sec_record = html_encode(sec_record)
if(findtext(gen_record, "<"))
gen_record = html_encode(gen_record)
disabilities = text2num(query.item[43])
player_alt_titles = params2list(query.item[44])
organ_data = params2list(query.item[45])
rlimb_data = params2list(query.item[46])
nanotrasen_relation = query.item[47]
speciesprefs = text2num(query.item[48])
disabilities = text2num(query.item[45])
player_alt_titles = params2list(query.item[46])
organ_data = params2list(query.item[47])
rlimb_data = params2list(query.item[48])
nanotrasen_relation = query.item[49]
speciesprefs = text2num(query.item[50])

//socks
socks = query.item[49]
body_accessory = query.item[50]
loadout_gear = params2list(query.item[51])
autohiss_mode = text2num(query.item[52])
uplink_pref = query.item[53]
socks = query.item[51]
body_accessory = query.item[52]
loadout_gear = params2list(query.item[53])
autohiss_mode = text2num(query.item[54])
uplink_pref = query.item[55]

// TTS
tts_seed = query.item[54]
tts_seed = query.item[56]

//Emotes
custom_emotes_tmp = query.item[55]
custom_emotes_tmp = query.item[57]

// Gradient
h_grad_style = query.item[56]
h_grad_offset_x = query.item[57] // parsed down below
h_grad_colour = query.item[58]
h_grad_alpha = query.item[59]
h_grad_style = query.item[58]
h_grad_offset_x = query.item[59] // parsed down below
h_grad_colour = query.item[60]
h_grad_alpha = query.item[61]

saved = TRUE

Expand Down Expand Up @@ -342,7 +346,9 @@
alt_head = sanitize_inlist(alt_head, GLOB.alt_heads_list, initial(alt_head))
e_colour = sanitize_hexcolor(e_colour)
underwear = sanitize_text(underwear, initial(underwear))
underwear_color = sanitize_hexcolor(underwear_color)
undershirt = sanitize_text(undershirt, initial(undershirt))
undershirt_color= sanitize_hexcolor(undershirt_color)
backbag = sanitize_text(backbag, initial(backbag))
b_type = sanitize_text(b_type, initial(b_type))
autohiss_mode = sanitize_integer(autohiss_mode, 0, 2, initial(autohiss_mode))
Expand Down Expand Up @@ -437,7 +443,9 @@
alt_head_name=:alt_head,
eye_colour=:e_colour,
underwear=:underwear,
underwear_color=:underwear_color,
undershirt=:undershirt,
undershirt_color=:undershirt_color,
backbag=:backbag,
b_type=:b_type,
alternate_option=:alternate_option,
Expand Down Expand Up @@ -499,7 +507,9 @@
"alt_head" = alt_head || "",
"e_colour" = e_colour,
"underwear" = underwear,
"underwear_color" = underwear_color,
"undershirt" = undershirt,
"undershirt_color" = undershirt_color,
"backbag" = backbag,
"b_type" = b_type,
"alternate_option" = alternate_option,
Expand Down Expand Up @@ -565,7 +575,7 @@
head_accessory_style_name,
alt_head_name,
eye_colour,
underwear, undershirt,
underwear, underwear_color, undershirt, undershirt_color,
backbag, b_type, alternate_option,
job_support_high, job_support_med, job_support_low,
job_medsci_high, job_medsci_med, job_medsci_low,
Expand Down Expand Up @@ -593,7 +603,7 @@
:ha_style,
:alt_head,
:e_colour,
:underwear, :undershirt,
:underwear, :underwear_color, :undershirt, :undershirt_color,
:backbag, :b_type, :alternate_option,
:job_support_high, :job_support_med, :job_support_low,
:job_medsci_high, :job_medsci_med, :job_medsci_low,
Expand Down Expand Up @@ -633,7 +643,9 @@
"alt_head" = alt_head,
"e_colour" = e_colour,
"underwear" = underwear,
"underwear_color" = underwear_color,
"undershirt" = undershirt,
"undershirt_color" = undershirt_color,
"backbag" = backbag,
"b_type" = b_type,
"alternate_option" = alternate_option,
Expand Down
2 changes: 2 additions & 0 deletions code/modules/mob/living/carbon/human/human_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
var/age = 30 //Player's age (pure fluff)

var/underwear = "Nude" //Which underwear the player wants
var/color_underwear = "#ffffff"
var/undershirt = "Nude" //Which undershirt the player wants
var/color_undershirt = "#ffffff"
var/socks = "Nude" //Which socks the player wants
var/backbag = 2 //Which backpack type the player has chosen. Nothing, Satchel or Backpack.

Expand Down
10 changes: 8 additions & 2 deletions code/modules/mob/living/carbon/human/update_icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,19 @@ GLOBAL_LIST_EMPTY(damage_icon_parts)
var/datum/sprite_accessory/underwear/U = GLOB.underwear_list[underwear]
if(U)
var/u_icon = U.sprite_sheets && (dna.species.name in U.sprite_sheets) ? U.sprite_sheets[dna.species.name] : U.icon //Species-fit the undergarment.
underwear_standing.Blend(new /icon(u_icon, "uw_[U.icon_state]_s"), ICON_OVERLAY)
var/icon/underwear_icon = new (u_icon, "uw_[U.icon_state]_s")
if(U.allow_change_color)
underwear_icon.Blend(color_underwear, ICON_MULTIPLY)
underwear_standing.Blend(underwear_icon, ICON_OVERLAY)

if(undershirt && dna.species.clothing_flags & HAS_UNDERSHIRT)
var/datum/sprite_accessory/undershirt/U2 = GLOB.undershirt_list[undershirt]
if(U2)
var/u2_icon = U2.sprite_sheets && (dna.species.name in U2.sprite_sheets) ? U2.sprite_sheets[dna.species.name] : U2.icon
underwear_standing.Blend(new /icon(u2_icon, "us_[U2.icon_state]_s"), ICON_OVERLAY)
var/icon/undershirt_icon = new(u2_icon, "us_[U2.icon_state]_s")
if(U2.allow_change_color)
undershirt_icon.Blend(color_undershirt, ICON_MULTIPLY)
underwear_standing.Blend(undershirt_icon, ICON_OVERLAY)

if(socks && dna.species.clothing_flags & HAS_SOCKS)
var/datum/sprite_accessory/socks/U3 = GLOB.socks_list[socks]
Expand Down
4 changes: 4 additions & 0 deletions code/modules/mob/new_player/preferences_setup.dm
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,17 @@
if(U)
var/u_icon = U.sprite_sheets && (current_species.name in U.sprite_sheets) ? U.sprite_sheets[current_species.name] : U.icon //Species-fit the undergarment.
underwear_s = new/icon(u_icon, "uw_[U.icon_state]_s", ICON_OVERLAY)
if(U.allow_change_color)
underwear_s.Blend(underwear_color, ICON_MULTIPLY)

var/icon/undershirt_s = null
if(undershirt && (current_species.clothing_flags & HAS_UNDERSHIRT))
var/datum/sprite_accessory/undershirt/U2 = GLOB.undershirt_list[undershirt]
if(U2)
var/u2_icon = U2.sprite_sheets && (current_species.name in U2.sprite_sheets) ? U2.sprite_sheets[current_species.name] : U2.icon
undershirt_s = new/icon(u2_icon, "us_[U2.icon_state]_s", ICON_OVERLAY)
if(U2.allow_change_color)
undershirt_s.Blend(undershirt_color, ICON_MULTIPLY)

var/icon/socks_s = null
if(socks && (current_species.clothing_flags & HAS_SOCKS))
Expand Down
Loading

0 comments on commit 1a3a7ec

Please sign in to comment.