Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
AndroBetel committed Jun 7, 2024
1 parent 85ca166 commit 05f1a56
Show file tree
Hide file tree
Showing 30 changed files with 374 additions and 315 deletions.
3 changes: 2 additions & 1 deletion code/__HELPERS/icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -920,8 +920,9 @@ world
// From /datum/preferences/proc/copy_appearance_to
body.age = original.age
body.gender = original.gender
body.ethnicity = original.ethnicity
body.skin_color = original.skin_color
body.body_type = original.body_type
body.body_size = original.body_size

body.r_eyes = original.r_eyes
body.g_eyes = original.g_eyes
Expand Down
9 changes: 6 additions & 3 deletions code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#define isdeaf(A) (ismob(A) && ((A?:sdisabilities & DISABILITY_DEAF) || A?:ear_deaf))
#define xeno_hivenumber(A) (isxeno(A) ? A?:hivenumber : FALSE)

/proc/random_ethnicity()
return pick(GLOB.ethnicities_list)
/proc/random_skin_color()
return pick(GLOB.skin_color_list)

/proc/random_body_type()
return pick(GLOB.body_types_list)
return pick(GLOB.body_type_list)

/proc/random_body_size()
return pick(GLOB.body_size_list)

/proc/random_hair_style(gender, species = "Human")
var/h_style = "Crewcut"
Expand Down
16 changes: 11 additions & 5 deletions code/__HELPERS/sanitize_values.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,24 @@
else return default
return default

/proc/sanitize_ethnicity(ethnicity, default = "Western")
if (ethnicity in GLOB.ethnicities_list)
return ethnicity
/proc/sanitize_skin_color(skin_color, default = "Pale 2")
if(skin_color in GLOB.skin_color_list)
return skin_color

return default

/proc/sanitize_body_type(body_type, default = "Mesomorphic (Average)")
if (body_type in GLOB.body_types_list)
/proc/sanitize_body_type(body_type, default = "Lean")
if(body_type in GLOB.body_type_list)
return body_type

return default

/proc/sanitize_body_size(body_size, default = "Average")
if(body_size in GLOB.body_size_list)
return body_size

return default

/proc/sanitize_hexcolor(color, default="#000000")
if(!istext(color)) return default
var/len = length(color)
Expand Down
9 changes: 5 additions & 4 deletions code/_globalvars/global_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,11 @@ GLOBAL_LIST_INIT(custom_event_info_list, setup_custom_event_info())
GLOBAL_LIST_INIT(poster_designs, subtypesof(/datum/poster))

//Preferences stuff
// Ethnicities
GLOBAL_REFERENCE_LIST_INDEXED(ethnicities_list, /datum/ethnicity, name) // Stores /datum/ethnicity indexed by name
// Body Types
GLOBAL_REFERENCE_LIST_INDEXED(body_types_list, /datum/body_type, name) // Stores /datum/body_type indexed by name
// Skin colors
GLOBAL_REFERENCE_LIST_INDEXED(skin_color_list, /datum/skin_color, name) // Stores /datum/skin_color indexed by name
// Body
GLOBAL_REFERENCE_LIST_INDEXED(body_type_list, /datum/body_type, name) // Stores /datum/body_type indexed by name
GLOBAL_REFERENCE_LIST_INDEXED(body_size_list, /datum/body_size, name) // Stores /datum/body_size indexed by name
//Hairstyles
GLOBAL_REFERENCE_LIST_INDEXED(hair_styles_list, /datum/sprite_accessory/hair, name) //stores /datum/sprite_accessory/hair indexed by name
GLOBAL_REFERENCE_LIST_INDEXED(facial_hair_styles_list, /datum/sprite_accessory/facial_hair, name) //stores /datum/sprite_accessory/facial_hair indexed by name
Expand Down
35 changes: 21 additions & 14 deletions code/datums/datacore.dm
Original file line number Diff line number Diff line change
Expand Up @@ -355,31 +355,38 @@ GLOBAL_DATUM_INIT(data_core, /datum/datacore, new)
var/icon/icobase = H.species.icobase
var/icon/temp

var/datum/ethnicity/ET = GLOB.ethnicities_list[H.ethnicity]
var/datum/body_type/B = GLOB.body_types_list[H.body_type]
var/datum/skin_color/set_skin_color = GLOB.skin_color_list[H.skin_color]
var/datum/body_type/set_body_type = GLOB.body_type_list[H.body_type]
var/datum/body_size/set_body_size = GLOB.body_size_list[H.body_size]

var/e_icon
var/b_icon
var/skin_color_icon
var/body_type_icon
var/body_size_icon

if (!ET)
e_icon = "western"
if(!set_skin_color)
skin_color_icon = "pale2"
else
e_icon = ET.icon_name
skin_color_icon = set_skin_color.icon_name

if (!B)
b_icon = "mesomorphic"
if(!set_body_type)
body_type_icon = "lean"
else
b_icon = B.icon_name
body_type_icon = set_body_type.icon_name

preview_icon = new /icon(icobase, get_limb_icon_name(H.species, b_icon, H.gender, "torso", e_icon))
temp = new /icon(icobase, get_limb_icon_name(H.species, b_icon, H.gender, "groin", e_icon))
if(!set_body_size)
body_size_icon = "avg"
else
body_size_icon = set_body_size.icon_name

preview_icon = new /icon(icobase, get_limb_icon_name(H.species, body_size_icon, body_type_icon, H.gender, "torso", skin_color_icon))
temp = new /icon(icobase, get_limb_icon_name(H.species, body_size_icon, body_type_icon, H.gender, "groin", skin_color_icon))
preview_icon.Blend(temp, ICON_OVERLAY)
temp = new /icon(icobase, get_limb_icon_name(H.species, b_icon, H.gender, "head", e_icon))
temp = new /icon(icobase, get_limb_icon_name(H.species, body_size_icon, body_type_icon, H.gender, "head", skin_color_icon))
preview_icon.Blend(temp, ICON_OVERLAY)

for(var/obj/limb/E in H.limbs)
if(E.status & LIMB_DESTROYED) continue
temp = new /icon(icobase, get_limb_icon_name(H.species, b_icon, H.gender, E.name, e_icon))
temp = new /icon(icobase, get_limb_icon_name(H.species, body_size_icon, body_type_icon, H.gender, E.name, skin_color_icon))
if(E.status & LIMB_ROBOT)
temp.MapColors(rgb(77,77,77), rgb(150,150,150), rgb(28,28,28), rgb(0,0,0))
preview_icon.Blend(temp, ICON_OVERLAY)
Expand Down
2 changes: 1 addition & 1 deletion code/defines/procs/records.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
G.fields["real_rank"] = "Unassigned"
G.fields["sex"] = "Male"
G.fields["age"] = "Unknown"
G.fields["ethnicity"] = "Unknown"
G.fields["skin_color"] = "Unknown"
G.fields["p_stat"] = "Active"
G.fields["m_stat"] = "Stable"
G.fields["species"] = "Human"
Expand Down
41 changes: 27 additions & 14 deletions code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,10 @@ var/const/MAX_SAVE_SLOTS = 10
var/g_eyes = 0 //Eye color
var/b_eyes = 0 //Eye color
var/species = "Human" //Species datum to use.
var/ethnicity = "Western" // Ethnicity
var/body_type = "Mesomorphic (Average)" // Body Type
var/ethnicity = "Western" //Legacy, kept to update save files
var/skin_color = "Pale 2" // Skin color
var/body_size = "Average" // Body Size
var/body_type = "Lean" // Body Type
var/language = "None" //Secondary language
var/list/gear //Custom/fluff item loadout.
var/preferred_squad = "None"
Expand Down Expand Up @@ -333,8 +335,9 @@ var/const/MAX_SAVE_SLOTS = 10
dat += "<a href='?_src_=prefs;preference=all;task=random'>&reg;</A></h2>"
dat += "<b>Age:</b> <a href='?_src_=prefs;preference=age;task=input'><b>[age]</b></a><br>"
dat += "<b>Gender:</b> <a href='?_src_=prefs;preference=gender'><b>[gender == MALE ? "Male" : "Female"]</b></a><br>"
dat += "<b>Ethnicity:</b> <a href='?_src_=prefs;preference=ethnicity;task=input'><b>[ethnicity]</b></a><br>"
dat += "<b>Body Type:</b> <a href='?_src_=prefs;preference=body_type;task=input'><b>[body_type]</b></a><br>"
dat += "<b>Skin Color:</b> <a href='?_src_=prefs;preference=skin_color;task=input'><b>[skin_color]</b></a><br>"
dat += "<b>Body Size:</b> <a href='?_src_=prefs;preference=body_size;task=input'><b>[body_size]</b></a><br>"
dat += "<b>Body Muscularity:</b> <a href='?_src_=prefs;preference=body_type;task=input'><b>[body_type]</b></a><br>"
dat += "<b>Traits:</b> <a href='byond://?src=\ref[user];preference=traits;task=open'><b>Character Traits</b></a>"
dat += "<br>"

Expand Down Expand Up @@ -1183,10 +1186,12 @@ var/const/MAX_SAVE_SLOTS = 10
real_name = character_origin.generate_human_name(gender)
if ("age")
age = rand(AGE_MIN, AGE_MAX)
if ("ethnicity")
ethnicity = random_ethnicity()
if ("skin_color")
skin_color = random_skin_color()
if ("body_type")
body_type = random_body_type()
if ("body_size")
body_size = random_body_size()
if ("hair")
r_hair = rand(0,255)
g_hair = rand(0,255)
Expand Down Expand Up @@ -1545,18 +1550,24 @@ var/const/MAX_SAVE_SLOTS = 10
if(new_h_gradient_style)
grad_style = new_h_gradient_style

if ("ethnicity")
var/new_ethnicity = tgui_input_list(user, "Choose your character's ethnicity:", "Character Preferences", GLOB.ethnicities_list)
if ("skin_color")
var/new_skin_color = tgui_input_list(user, "Choose your character's skin color:", "Character Preferences", GLOB.skin_color_list)

if (new_ethnicity)
ethnicity = new_ethnicity
if (new_skin_color)
skin_color = new_skin_color

if ("body_type")
var/new_body_type = tgui_input_list(user, "Choose your character's body type:", "Character Preferences", GLOB.body_types_list)
var/new_body_type = tgui_input_list(user, "Choose your character's body type:", "Character Preferences", GLOB.body_type_list)

if (new_body_type)
body_type = new_body_type

if ("body_size")
var/new_body_size = tgui_input_list(user, "Choose your character's body size:", "Character Preferences", GLOB.body_size_list)

if (new_body_size)
body_size = new_body_size

if("facial")
var/new_facial = input(user, "Choose your character's facial-hair color:", "Character Preference", rgb(r_facial, g_facial, b_facial)) as color|null
if(new_facial)
Expand Down Expand Up @@ -2047,8 +2058,9 @@ var/const/MAX_SAVE_SLOTS = 10

character.age = age
character.gender = gender
character.ethnicity = ethnicity
character.skin_color = skin_color
character.body_type = body_type
character.body_size = body_size

character.r_eyes = r_eyes
character.g_eyes = g_eyes
Expand Down Expand Up @@ -2120,15 +2132,16 @@ var/const/MAX_SAVE_SLOTS = 10
message_admins("[character] ([character.ckey]) has spawned with their gender as plural or neuter. Please notify coders.")
character.gender = MALE

// Transfers the character's physical characteristics (age, gender, ethnicity, etc) to the mob
// Transfers the character's physical characteristics (age, gender, skin color, etc) to the mob
/datum/preferences/proc/copy_appearance_to(mob/living/carbon/human/character, safety = 0)
if(!istype(character))
return

character.age = age
character.gender = gender
character.ethnicity = ethnicity
character.skin_color = skin_color
character.body_type = body_type
character.body_size = body_size

character.r_eyes = r_eyes
character.g_eyes = g_eyes
Expand Down
56 changes: 54 additions & 2 deletions code/modules/client/preferences_savefile.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define SAVEFILE_VERSION_MIN 8
#define SAVEFILE_VERSION_MAX 24
#define SAVEFILE_VERSION_MAX 25

//handles converting savefiles to new formats
//MAKE SURE YOU KEEP THIS UP TO DATE!
Expand Down Expand Up @@ -110,6 +110,53 @@

S.cd = "/"

if(savefile_version < 25)
var/ethnicity
var/skin_color = "pale2"
S["ethnicity"] >> ethnicity
switch(ethnicity)
if("anglo")
skin_color = "pale2"
if("western")
skin_color = "tan2"
if("germanic")
skin_color = "pale2"
if("scandinavian")
skin_color = "pale3"
if("baltic")
skin_color = "pale3"
if("sinoorient")
skin_color = "pale1"
if("southorient")
skin_color = "tan1"
if("indian")
skin_color = "tan3"
if("sino")
skin_color = "tan1"
if("mesoamerican")
skin_color = "tan3"
if("northamerican")
skin_color = "tan3"
if("southamerican")
skin_color = "tan2"
if("circumpolar")
skin_color = "tan1"
if("northafrican")
skin_color = "tan3"
if("centralafrican")
skin_color = "dark1"
if("costalafrican")
skin_color = "dark3"
if("persian")
skin_color = "tan3"
if("levant")
skin_color = "tan3"
if("australasian")
skin_color = "dark2"
if("polynesian")
skin_color = "tan3"
S["skin_color"] << skin_color

savefile_version = SAVEFILE_VERSION_MAX
return 1

Expand Down Expand Up @@ -472,7 +519,9 @@
S["gender"] >> gender
S["age"] >> age
S["ethnicity"] >> ethnicity
S["skin_color"] >> skin_color
S["body_type"] >> body_type
S["body_size"] >> body_size
S["language"] >> language
S["spawnpoint"] >> spawnpoint

Expand Down Expand Up @@ -549,8 +598,9 @@
be_random_body = sanitize_integer(be_random_body, 0, 1, initial(be_random_body))
gender = sanitize_gender(gender)
age = sanitize_integer(age, AGE_MIN, AGE_MAX, initial(age))
ethnicity = sanitize_ethnicity(ethnicity)
skin_color = sanitize_skin_color(skin_color)
body_type = sanitize_body_type(body_type)
body_size = sanitize_body_size(body_size)
r_hair = sanitize_integer(r_hair, 0, 255, initial(r_hair))
g_hair = sanitize_integer(g_hair, 0, 255, initial(g_hair))
b_hair = sanitize_integer(b_hair, 0, 255, initial(b_hair))
Expand Down Expand Up @@ -628,7 +678,9 @@
S["gender"] << gender
S["age"] << age
S["ethnicity"] << ethnicity
S["skin_color"] << skin_color
S["body_type"] << body_type
S["body_size"] << body_size
S["language"] << language
S["hair_red"] << r_hair
S["hair_green"] << g_hair
Expand Down
4 changes: 2 additions & 2 deletions code/modules/gear_presets/fun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@
new_human.change_real_name(new_human, "Ivan")
new_human.f_style = "Shaved"
new_human.h_style = "Shaved Head"
new_human.ethnicity = "Scandinavian"
new_human.skin_color = "pale3"
new_human.r_hair = 165
new_human.g_hair = 42
new_human.b_hair = 42
Expand Down Expand Up @@ -362,7 +362,7 @@
new_human.b_facial = 51
new_human.h_style = "Mullet"
new_human.f_style = "Full English"
new_human.ethnicity = "Anglo"
new_human.skin_color = "pale2"
new_human.r_eyes = 102 //Brown eyes.
new_human.g_eyes = 51
new_human.b_eyes = 0
Expand Down
4 changes: 2 additions & 2 deletions code/modules/gear_presets/yautja.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@

/datum/equipment_preset/yautja/load_race(mob/living/carbon/human/new_human, client/mob_client)
new_human.set_species(SPECIES_YAUTJA)
new_human.ethnicity = "tan"
new_human.skin_color = "tan"
new_human.body_type = "pred" //can be removed in future for body types
if(!mob_client)
mob_client = new_human.client
if(mob_client?.prefs)
new_human.h_style = mob_client.prefs.predator_h_style
new_human.ethnicity = mob_client.prefs.predator_skin_color
new_human.skin_color = mob_client.prefs.predator_skin_color

/datum/equipment_preset/yautja/load_id(mob/living/carbon/human/new_human)
new_human.job = rank
Expand Down
5 changes: 3 additions & 2 deletions code/modules/mob/living/carbon/human/human_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
var/g_eyes = 0
var/b_eyes = 0

var/ethnicity = "Western" // Ethnicity
var/body_type = "Mesomorphic (Average)" // Body Type
var/skin_color = "Pale 2" // Skin color
var/body_size = "Average" // Body Size
var/body_type = "Lean" // Body Buffness

//Skin color
var/r_skin = 0
Expand Down
Loading

0 comments on commit 05f1a56

Please sign in to comment.