Fixes the occupation screen.

This commit is contained in:
Atermonera
2020-03-15 11:34:30 -07:00
committed by VirgoBot
parent 08a9fcf0f2
commit 3ac5a32e39
6 changed files with 91 additions and 11 deletions

View File

@@ -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.

View File

@@ -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

View File

@@ -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"
title = "Internal Affairs Agent"

View File

@@ -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.

View File

@@ -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()
. += "<tt><center>"
. += "<b>Choose occupation chances</b><br>Unavailable occupations are crossed out.<br>"
. += "<table width='100%' cellpadding='1' cellspacing='0'><tr><td width='20%'>" // Table within a table for alignment, also allows you to easily add more columns.
. += "<table width='100%' cellpadding='1' cellspacing='0'><tr><td width='20%' valign='top'>" // Table within a table for alignment, also allows you to easily add more columns.
. += "<table width='100%' cellpadding='1' cellspacing='0'>"
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++)
. += "<tr bgcolor='[lastJob.selection_color]'><td width='60%' align='right'>//>&nbsp</a></td><td><a>&nbsp</a></td></tr>"
*******/
. += "</table></td><td width='20%'><table width='100%' cellpadding='1' cellspacing='0'>"
. += "</table></td><td width='20%' valign='top'><table width='100%' cellpadding='1' cellspacing='0'>"
index = 0
last_department = current_department
. += "<tr bgcolor='[job.selection_color]'><td width='60%' align='right'>"

View File

@@ -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