diff --git a/code/__HELPERS/lists.dm b/code/__HELPERS/lists.dm index 09081948d13..007e54dac2b 100644 --- a/code/__HELPERS/lists.dm +++ b/code/__HELPERS/lists.dm @@ -144,6 +144,26 @@ proc/listclearnulls(list/list) pos-- L.Insert(pos+1, thing) +// Returns the next item in a list +/proc/next_list_item(var/item, var/list/L) + var/i + i = L.Find(item) + if(i == L.len) + i = 1 + else + i++ + return L[i] + +// Returns the previous item in a list +/proc/previous_list_item(var/item, var/list/L) + var/i + i = L.Find(item) + if(i == 1) + i = L.len + else + i-- + return L[i] + /* * Sorting */ diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 583d2769276..300972e8b5e 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -174,6 +174,7 @@ datum/preferences dat += "

Hair Style

" dat += "[hair_style]
" + dat += "< >
" dat += "    Change
" @@ -182,6 +183,7 @@ datum/preferences dat += "

Facial Hair Style

" dat += "[facial_hair_style]
" + dat += "< >
" dat += "    Change
" @@ -580,6 +582,18 @@ datum/preferences if(new_hair_style) hair_style = new_hair_style + if("next_hair_style") + if (gender == MALE) + hair_style = next_list_item(hair_style, hair_styles_male_list) + else + hair_style = next_list_item(hair_style, hair_styles_female_list) + + if("previous_hair_style") + if (gender == MALE) + hair_style = previous_list_item(hair_style, hair_styles_male_list) + else + hair_style = previous_list_item(hair_style, hair_styles_female_list) + if("facial") var/new_facial = input(user, "Choose your character's facial-hair colour:", "Character Preference") as null|color if(new_facial) @@ -594,6 +608,18 @@ datum/preferences if(new_facial_hair_style) facial_hair_style = new_facial_hair_style + if("next_facehair_style") + if (gender == MALE) + facial_hair_style = next_list_item(facial_hair_style, facial_hair_styles_male_list) + else + facial_hair_style = next_list_item(facial_hair_style, facial_hair_styles_female_list) + + if("previous_facehair_style") + if (gender == MALE) + facial_hair_style = previous_list_item(facial_hair_style, facial_hair_styles_male_list) + else + facial_hair_style = previous_list_item(facial_hair_style, facial_hair_styles_female_list) + if("underwear") var/new_underwear if(gender == MALE)