Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorts the ready panel further #1

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions code/__HELPERS/cmp.dm
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@
/proc/cmp_pdajob_asc(datum/computer_file/program/messenger/A, datum/computer_file/program/messenger/B)
return sorttext(B?.computer?.saved_job, A?.computer?.saved_job)

/proc/cmp_jobestimate_asc(list/A, list/B) // TODO: Move this to a modular file.
return B["estimate"] - A["estimate"]

/proc/cmp_num_string_asc(A, B)
return text2num(A) - text2num(B)

Expand Down
23 changes: 16 additions & 7 deletions modular_zubbers/code/modules/mob/dead/dead.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

sortTim(players, GLOBAL_PROC_REF(cmp_text_asc))

var/list/collected_players = list() //Assoc list for sorting - display name is the key, job value from crewmonitor is the value
for(var/ckey in players)
var/mob/dead/new_player/player = players[ckey]
var/datum/preferences/prefs = player.client?.prefs
Expand All @@ -37,15 +38,23 @@
else
display = prefs.read_preference(/datum/preference/name/real_name)

var/title = J.title
if(player.ready == PLAYER_READY_TO_PLAY && J.title != JOB_ASSISTANT||JOB_PRISONER)
if(J.departments_bitflags & (DEPARTMENT_BITFLAG_COMMAND | DEPARTMENT_BITFLAG_SILICON))
player_ready_data.Insert(1, "[display] as [title]")
else
player_ready_data += "* [display] as [title]"
var/list/entry
entry["character_name"] = display
entry["job_title"] = J.title
entry["job_title_id"] = GLOB.crewmonitor.jobs[J.title]
OUT << entry
collected_players[++collected_players.len] = entry
// TODO: This ^ isn't working, no entries are being added to it. Need to debug.
// TODO: Also need to see if I have to add exceptions for AI/Cyborg for sorting purposes.

collected_players = sort_list(collected_players, GLOBAL_PROC_REF(cmp_jobestimate_asc)) // Sort list by job ID.

for(var/entry in collected_players)
player_ready_data += "* [entry["character_name"]] as [entry["job_title"]]"

if(length(player_ready_data))
player_ready_data.Insert(1, "------------------")
player_ready_data.Insert(1, "Job Estimation:")
player_ready_data.Insert(1, "")
player_ready_data.Insert(2, "Job Estimation:")
player_ready_data.Insert(3, "------------------")
return player_ready_data