From 3ac5a32e39771bbf38a56d9fa663ad03bf4fc157 Mon Sep 17 00:00:00 2001 From: Atermonera Date: Sun, 15 Mar 2020 11:34:30 -0700 Subject: [PATCH] Fixes the occupation screen. --- code/controllers/subsystems/job.dm | 34 +++++++++++++ code/game/jobs/job/captain.dm | 8 +-- code/game/jobs/job/civilian.dm | 8 +-- code/game/jobs/job/department.dm | 1 + .../preference_setup/occupation/occupation.dm | 49 ++++++++++++++++++- maps/southern_cross/southern_cross_jobs.dm | 2 +- 6 files changed, 91 insertions(+), 11 deletions(-) diff --git a/code/controllers/subsystems/job.dm b/code/controllers/subsystems/job.dm index 97af46fa34..f265f39955 100644 --- a/code/controllers/subsystems/job.dm +++ b/code/controllers/subsystems/job.dm @@ -41,10 +41,12 @@ SUBSYSTEM_DEF(job) for(var/D in department_datums) var/datum/department/dept = department_datums[D] sortTim(dept.jobs, /proc/cmp_job_datums, TRUE) + sortTim(dept.primary_jobs, /proc/cmp_job_datums, TRUE) return TRUE /datum/controller/subsystem/job/proc/add_to_departments(datum/job/J) + // Adds to the regular job lists in the departments, which allow multiple departments for a job. for(var/D in J.departments) var/datum/department/dept = LAZYACCESS(department_datums, D) if(!istype(dept)) @@ -52,6 +54,16 @@ SUBSYSTEM_DEF(job) continue dept.jobs[J.title] = J + // Now for the 'primary' department for a job, which is defined as being the first department in the list for a job. + // This results in no duplicates, which can be useful in some situations. + if(LAZYLEN(J.departments)) + var/primary_department = J.departments[1] + var/datum/department/dept = LAZYACCESS(department_datums, primary_department) + if(!istype(dept)) + job_debug_message("Job '[J.title]' has their primary department be '[primary_department]', but it does not exist.") + else + dept.primary_jobs[J.title] = J + /datum/controller/subsystem/job/proc/setup_departments() for(var/t in subtypesof(/datum/department)) var/datum/department/D = new t() @@ -95,7 +107,29 @@ SUBSYSTEM_DEF(job) job_debug_message("Was asked to get job titles for a non-existant department '[target_department_name]'.") return list() +// Returns a reference to the primary department datum that a job is in. +// Can receive job datum refs, typepaths, or job title strings. +/datum/controller/subsystem/job/proc/get_primary_department_of_job(datum/job/J) + if(!istype(J, /datum/job)) + if(ispath(J)) + J = get_job_type(J) + else if(istext(J)) + J = get_job(J) + if(!istype(J)) + job_debug_message("Was asked to get department for job '[J]', but input could not be resolved into a job datum.") + return + + if(!LAZYLEN(J.departments)) + return + + var/primary_department = J.departments[1] + var/datum/department/dept = LAZYACCESS(department_datums, primary_department) + if(!istype(dept)) + job_debug_message("Job '[J.title]' has their primary department be '[primary_department]', but it does not exist.") + return + + return department_datums[primary_department] // Someday it might be good to port code/game/jobs/job_controller.dm to here and clean it up. diff --git a/code/game/jobs/job/captain.dm b/code/game/jobs/job/captain.dm index bd4336506c..5c4740e732 100644 --- a/code/game/jobs/job/captain.dm +++ b/code/game/jobs/job/captain.dm @@ -15,7 +15,7 @@ var/datum/announcement/minor/captain_announcement = new(do_newscast = 1) total_positions = 1 spawn_positions = 1 supervisors = "company officials and Corporate Regulations" - selection_color = "#1D1D4F" + selection_color = "#2F2F7F" req_admin_notify = 1 access = list() //See get_access() minimal_access = list() //See get_access() @@ -59,7 +59,7 @@ var/datum/announcement/minor/captain_announcement = new(do_newscast = 1) /datum/job/hop title = "Head of Personnel" flag = HOP - departments = list(DEPARTMENT_CIVILIAN, DEPARTMENT_CARGO, DEPARTMENT_COMMAND) + departments = list(DEPARTMENT_COMMAND, DEPARTMENT_CIVILIAN, DEPARTMENT_CARGO) sorting_order = 2 // Above the QM, below captain. departments_managed = list(DEPARTMENT_CIVILIAN, DEPARTMENT_CARGO) department_flag = CIVILIAN @@ -67,7 +67,7 @@ var/datum/announcement/minor/captain_announcement = new(do_newscast = 1) total_positions = 1 spawn_positions = 1 supervisors = "the Colony Director" - selection_color = "#2F2F7F" + selection_color = "#1D1D4F" req_admin_notify = 1 minimal_player_age = 10 economic_modifier = 10 @@ -115,7 +115,7 @@ var/datum/announcement/minor/captain_announcement = new(do_newscast = 1) total_positions = 2 spawn_positions = 2 supervisors = "command staff" - selection_color = "#2F2F7F" + selection_color = "#1D1D4F" minimal_player_age = 5 economic_modifier = 7 diff --git a/code/game/jobs/job/civilian.dm b/code/game/jobs/job/civilian.dm index 571ef67efd..d667d2bc2c 100644 --- a/code/game/jobs/job/civilian.dm +++ b/code/game/jobs/job/civilian.dm @@ -104,7 +104,7 @@ total_positions = 1 spawn_positions = 1 supervisors = "the Head of Personnel" - selection_color = "#7a4f33" + selection_color = "#9b633e" economic_modifier = 5 access = list(access_maint_tunnels, access_mailsorting, access_cargo, access_cargo_bot, access_qm, access_mining, access_mining_station) minimal_access = list(access_maint_tunnels, access_mailsorting, access_cargo, access_cargo_bot, access_qm, access_mining, access_mining_station) @@ -134,7 +134,7 @@ total_positions = 2 spawn_positions = 2 supervisors = "the Quartermaster and the Head of Personnel" - selection_color = "#9b633e" + selection_color = "#7a4f33" access = list(access_maint_tunnels, access_mailsorting, access_cargo, access_cargo_bot, access_mining, access_mining_station) minimal_access = list(access_maint_tunnels, access_cargo, access_cargo_bot, access_mailsorting) @@ -159,7 +159,7 @@ total_positions = 3 spawn_positions = 3 supervisors = "the Quartermaster and the Head of Personnel" - selection_color = "#9b633e" + selection_color = "#7a4f33" economic_modifier = 5 access = list(access_maint_tunnels, access_mailsorting, access_cargo, access_cargo_bot, access_mining, access_mining_station) minimal_access = list(access_mining, access_mining_station, access_mailsorting) @@ -271,4 +271,4 @@ // IAA Alt Titles /datum/alt_title/iaa - title = "Internal Affairs Agent" \ No newline at end of file + title = "Internal Affairs Agent" diff --git a/code/game/jobs/job/department.dm b/code/game/jobs/job/department.dm index 914f8e5a03..39bbc1c38c 100644 --- a/code/game/jobs/job/department.dm +++ b/code/game/jobs/job/department.dm @@ -7,6 +7,7 @@ var/short_name = "NO" // Shorter name, used for things like external Topic() responses. var/color = "#000000" // Color to use in UIs to represent this department. var/list/jobs = list() // Assoc list. Key is the job title, and the value is a reference to the job datum. Populated by SSjob subsystem. + var/list/primary_jobs = list() // Same as above, but only jobs with their 'primary' department are put here. Primary being the first department in their list. var/sorting_order = 0 // Used to sort departments, e.g. Command always being on top. var/visible = TRUE // If false, it should not show up on things like the manifest or ID computer. var/assignable = TRUE // Similar for above, but only for ID computers and such. Used for silicon department. diff --git a/code/modules/client/preference_setup/occupation/occupation.dm b/code/modules/client/preference_setup/occupation/occupation.dm index ade5260989..6e1af2f0ac 100644 --- a/code/modules/client/preference_setup/occupation/occupation.dm +++ b/code/modules/client/preference_setup/occupation/occupation.dm @@ -54,23 +54,67 @@ if(alt_title && !(alt_title in job.alt_titles)) pref.player_alt_titles -= job.title +<<<<<<< HEAD /datum/category_item/player_setup_item/occupation/content(mob/user, limit = 20, list/splitJobs = list("Pathfinder")) //VOREStation Edit +======= +/datum/category_item/player_setup_item/occupation/content(mob/user, limit = 20, list/splitJobs = list()) +>>>>>>> 920e495... Merge pull request #6813 from Neerti/occupation_screen_fix if(!job_master) return . = list() . += "
" . += "Choose occupation chances
Unavailable occupations are crossed out.
" - . += "
" // Table within a table for alignment, also allows you to easily add more columns. + . += "
" // Table within a table for alignment, also allows you to easily add more columns. . += "" var/index = -1 //The job before the current job. I only use this to get the previous jobs color when I'm filling in blank rows. var/datum/job/lastJob +<<<<<<< HEAD if (!job_master) return for(var/datum/job/job in job_master.occupations) if(job.latejoin_only) continue //VOREStation Code if((++index >= limit) || (job.title in splitJobs)) +======= + var/datum/department/last_department = null // Used to avoid repeating the look-ahead check for if a whole department can fit. + + var/list/all_valid_jobs = list() + // If the occupation window gets opened before SSJob initializes, then it'll just be blank, with no runtimes. + // It will work once init is finished. + + for(var/D in SSjob.department_datums) + var/datum/department/department = SSjob.department_datums[D] + if(department.centcom_only) // No joining as a centcom role, if any are ever added. + continue + + for(var/J in department.primary_jobs) + all_valid_jobs += department.jobs[J] + + for(var/datum/job/job in all_valid_jobs) + var/datum/department/current_department = SSjob.get_primary_department_of_job(job) + + // Should we add a new column? + var/make_new_column = FALSE + if(++index > limit) + // Ran out of rows, make a new column. + make_new_column = TRUE + + else if(job.title in splitJobs) + // Is hardcoded to split at this job title. + make_new_column = TRUE + + else if(current_department != last_department) + // If the department is bigger than the limit then we have to split. + if(limit >= current_department.primary_jobs.len) + // Look ahead to see if we would need to split, and if so, avoid it. + if(index + current_department.primary_jobs.len > limit) + // Looked ahead, and determined that a new column is needed to avoid splitting the department into two. + make_new_column = TRUE + + + if(make_new_column) +>>>>>>> 920e495... Merge pull request #6813 from Neerti/occupation_screen_fix /******* if((index < limit) && (lastJob != null)) //If the cells were broken up by a job in the splitJob list then it will fill in the rest of the cells with @@ -78,8 +122,9 @@ for(var/i = 0, i < (limit - index), i++) . += "" *******/ - . += "
//>  
" + . += "
" index = 0 + last_department = current_department . += "
" diff --git a/maps/southern_cross/southern_cross_jobs.dm b/maps/southern_cross/southern_cross_jobs.dm index 1fa6b308b6..9d7988dd22 100644 --- a/maps/southern_cross/southern_cross_jobs.dm +++ b/maps/southern_cross/southern_cross_jobs.dm @@ -98,7 +98,7 @@ var/const/access_explorer = 43 /datum/job/sar title = "Search and Rescue" flag = SAR - departments = list(DEPARTMENT_MEDICAL, DEPARTMENT_PLANET) + departments = list(DEPARTMENT_PLANET, DEPARTMENT_MEDICAL) department_flag = MEDSCI faction = "Station" total_positions = 2