Add species sorting

This commit is contained in:
Aronai Sieyes
2021-06-26 11:13:57 -04:00
parent bb219fb11d
commit ec09ddd547
6 changed files with 34 additions and 4 deletions
+5
View File
@@ -472,3 +472,8 @@ GLOBAL_LIST_INIT(all_volume_channels, list(
#define TRAIT_SORT_NORMAL 1
#define TRAIT_SORT_BODYTYPE 2
#define TRAIT_SORT_SPECIES 3
#define SPECIES_SORT_NORMAL 1
#define SPECIES_SORT_WHITELISTED 2
#define SPECIES_SORT_RESTRICTED 3
#define SPECIES_SORT_CUSTOM 4
+3 -4
View File
@@ -1,10 +1,9 @@
//Languages/species/whitelist.
GLOBAL_LIST_EMPTY_TYPED(all_species, /datum/species)
GLOBAL_LIST_EMPTY_TYPED(whitelisted_species, /datum/species) // Species that require a whitelist check.
GLOBAL_LIST_EMPTY_TYPED(playable_species, /datum/species) // A list of ALL playable species, whitelisted, latejoin or otherwise.
GLOBAL_LIST_EMPTY_TYPED(all_languages, /datum/language)
GLOBAL_LIST_INIT(language_name_conflicts, list())
GLOBAL_LIST_INIT(language_keys, list()) // Table of say codes for all languages
GLOBAL_LIST_INIT(language_key_conflicts, list())
GLOBAL_LIST_INIT(whitelisted_species, list(SPECIES_HUMAN)) // Species that require a whitelist check.
// VOREStation edit - include custom species
GLOBAL_LIST_INIT(playable_species, list(SPECIES_HUMAN, SPECIES_CUSTOM)) // A list of ALL playable species, whitelisted, latejoin or otherwise.
// VOREStation edit end
+6
View File
@@ -201,6 +201,12 @@ GLOBAL_LIST_EMPTY(mannequins)
S.race_key = rkey //Used in mob icon caching.
GLOB.all_species[S.name] = S
//Shakey shakey shake
sortTim(GLOB.all_species, /proc/cmp_species, associative = TRUE)
//Split up the rest
for(var/speciesname in GLOB.all_species)
var/datum/species/S = GLOB.all_species[speciesname]
if(!(S.spawn_flags & SPECIES_IS_RESTRICTED))
GLOB.playable_species += S.name
if(S.spawn_flags & SPECIES_IS_WHITELISTED)
+7
View File
@@ -79,12 +79,19 @@
/proc/cmp_text_asc(a,b)
return sorttext(b,a)
///Tracks are sorted by genre then by title inside that.
/proc/cmp_media_track_asc(datum/track/A, datum/track/B)
var/genre_sort = sorttext(B.genre || "Uncategorized", A.genre || "Uncategorized")
return genre_sort || sorttext(B.title, A.title)
///Filters have a numerical priority.
/proc/cmp_filter_data_priority(list/A, list/B)
return A["priority"] - B["priority"]
///Traits have sort they have defined on them to categorize themselves into groups. After that, alphabetical.
/proc/cmp_trait_datums_name(datum/trait/A, datum/trait/B)
return A.sort == B.sort ? sorttext("[B.name]","[A.name]") : A.sort - B.sort
///Species have sort_hint they self-generate to hint themselves into groups. After that, alphabetical.
/proc/cmp_species(datum/species/A, datum/species/B)
return A.sort_hint == B.sort_hint ? sorttext("[B.name]","[A.name]") : A.sort_hint - B.sort_hint
@@ -272,6 +272,8 @@
var/icon_height = 32
var/agility = 20 //prob() to do agile things
var/sort_hint = SPECIES_SORT_NORMAL
/datum/species/proc/update_attack_types()
unarmed_attacks = list()
for(var/u_type in unarmed_types)
@@ -305,6 +307,14 @@
inherent_verbs = list()
inherent_verbs |= /mob/living/carbon/human/proc/regurgitate
update_sort_hint()
/datum/species/proc/update_sort_hint()
if(spawn_flags & SPECIES_IS_RESTRICTED)
sort_hint = SPECIES_SORT_RESTRICTED
else if(spawn_flags & SPECIES_IS_WHITELISTED)
sort_hint = SPECIES_SORT_WHITELISTED
/datum/species/proc/sanitize_name(var/name, var/robot = 0)
return sanitizeName(name, MAX_NAME_LEN, robot)
@@ -42,6 +42,9 @@
BP_R_FOOT = list("path" = /obj/item/organ/external/foot/right, "descriptor" = "right foot")
)
/datum/species/custom/update_sort_hint()
sort_hint = SPECIES_SORT_CUSTOM
/datum/species/custom/get_race_key()
var/datum/species/real = GLOB.all_species[base_species]
return real.race_key