From ecbb37ee11b3150991aac4eef4516c5484d4bb85 Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Sun, 25 Oct 2020 18:05:36 +0000 Subject: [PATCH] Job Menu Redesign (#13881) * Job Menu Redesign * Tweaks * Steel Tweaks * I once wrote a list * Farie Tweaks --- code/modules/client/preference/preferences.dm | 270 +++++++++--------- 1 file changed, 142 insertions(+), 128 deletions(-) diff --git a/code/modules/client/preference/preferences.dm b/code/modules/client/preference/preferences.dm index ef5565ee599..e216ad6f5d1 100644 --- a/code/modules/client/preference/preferences.dm +++ b/code/modules/client/preference/preferences.dm @@ -588,159 +588,167 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts metadata["[tweak]"] = new_metadata -/datum/preferences/proc/SetChoices(mob/user, limit = 13, list/splitJobs = list("Civilian","Research Director","AI","Bartender"), width = 760, height = 790) +/datum/preferences/proc/SetChoices(mob/user, limit = 17, list/splitJobs = list("Head of Security", "Bartender"), widthPerColumn = 400, height = 700) if(!SSjobs) return - //limit - The amount of jobs allowed per column. Defaults to 17 to make it look nice. + //limit - The amount of jobs allowed per column. Defaults to 17 to make it look nice. //splitJobs - Allows you split the table by job. You can make different tables for each department by including their heads. Defaults to CE to make it look nice. - //width - Screen' width. Defaults to 550 to make it look nice. - //height - Screen's height. Defaults to 500 to make it look nice. + //widthPerColumn - Screen's width for every column. + //height - Screen's height. + var/width = widthPerColumn - var/HTML = "" - HTML += "
" - HTML += "Choose occupation chances
Unavailable occupations are crossed out.

" - HTML += "
\[Done\]

" // Easier to press up here. - HTML += "
Left-click to raise an occupation preference, right-click to lower it.
" - HTML += "" - HTML += "" - switch(alternate_option) - if(GET_RANDOM_JOB) - HTML += "

Get random job if preferences unavailable

" - if(BE_ASSISTANT) - HTML += "

Be a civilian if preferences unavailable

" - if(RETURN_TO_LOBBY) - HTML += "

Return to lobby if preferences unavailable

" + for(var/i in 1 to limit - index) // Finish the column so it is even + html += "" - HTML += "
\[Reset\]
" - HTML += "" + html += "
" // Table within a table for alignment, also allows you to easily add more colomns. - HTML += "" - var/index = -1 + var/list/html = list() + html += "" + if(!length(SSjobs.occupations)) + html += "The Jobs subsystem is not yet finished creating jobs, please try again later" + html += "
Done

" // Easier to press up here. + else + html += "
" + html += "Choose occupation chances
Unavailable occupations are crossed out.

" + html += "
Save

" // Easier to press up here. + html += "
Left-click to raise an occupation preference, right-click to lower it.
" + html += "" + html += "
" + continue + /* + if(GetJobDepartment(job, 1) & job.flag) + HTML += " \[High]" + else if(GetJobDepartment(job, 2) & job.flag) + HTML += " \[Medium]" + else if(GetJobDepartment(job, 3) & job.flag) + HTML += " \[Low]" + else + HTML += " \[NEVER]" + */ + html += "[prefLevelLabel]" - HTML += "
" // Table within a table for alignment, also allows you to easily add more colomns. + html += "" + 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 - if(!SSjobs) - return - for(var/datum/job/job in SSjobs.occupations) + //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 + if(!SSjobs) + return + for(var/J in SSjobs.occupations) + var/datum/job/job = J - if(job.admin_only) - continue + if(job.admin_only) + continue - if(job.hidden_from_job_prefs) - continue + if(job.hidden_from_job_prefs) + continue - index += 1 - if((index >= limit) || (job.title in splitJobs)) - 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 - //the last job's selection color. Creating a rather nice effect. - for(var/i = 0, i < (limit - index), i += 1) - HTML += "" - HTML += "
  
" - index = 0 + index += 1 + if((index >= limit) || (job.title in splitJobs)) + if((index < limit) && (lastJob != null)) + // Dynamic window width + width += widthPerColumn + //If the cells were broken up by a job in the splitJob list then it will fill in the rest of the cells with + //the last job's selection color. Creating a rather nice effect. + for(var/i in 1 to limit - index) + html += "" + html += "
  
" + index = 0 - HTML += "" - continue - if(jobban_isbanned(user, rank)) - HTML += "[rank]" - continue - var/available_in_playtime = job.available_in_playtime(user.client) - if(available_in_playtime) - HTML += "[rank]" - continue - if(job.barred_by_disability(user.client)) - HTML += "[rank]" - continue - if(!job.player_old_enough(user.client)) - var/available_in_days = job.available_in_days(user.client) - HTML += "[rank]" - continue - if((job_support_low & JOB_CIVILIAN) && (rank != "Civilian")) - HTML += "[rank]" - continue - if((rank in GLOB.command_positions) || (rank == "AI"))//Bold head jobs - HTML += "[rank]" - else - HTML += "[rank]" - - HTML += "" - HTML += "" - continue -/* - if(GetJobDepartment(job, 1) & job.flag) - HTML += " \[High]" - else if(GetJobDepartment(job, 2) & job.flag) - HTML += " \[Medium]" - else if(GetJobDepartment(job, 3) & job.flag) - HTML += " \[Low]" - else - HTML += " \[NEVER]" - */ - HTML += "[prefLevelLabel]" + rank = "[GetPlayerAltTitle(job)]" + else + rank = job.title + lastJob = job + if(!is_job_whitelisted(user, job.title)) + html += "[rank]" + continue + if(jobban_isbanned(user, job.title)) + html += "[rank]" + continue + var/available_in_playtime = job.available_in_playtime(user.client) + if(available_in_playtime) + html += "[rank]" + continue + if(job.barred_by_disability(user.client)) + html += "[rank]" + continue + if(!job.player_old_enough(user.client)) + var/available_in_days = job.available_in_days(user.client) + html += "[rank]" + continue + if((job_support_low & JOB_CIVILIAN) && (job.title != "Civilian")) + html += "[rank]" + continue + if((job.title in GLOB.command_positions) || (job.title == "AI"))//Bold head jobs + html += "[rank]" + else + html += "[rank]" - if(job.alt_titles) - HTML += "
\[[GetPlayerAltTitle(job)]\]" + html += "" + html += "" - for(var/i = 1, i < (limit - index), i += 1) // Finish the column so it is even - HTML += "" + // HTML += "" - HTML += "
" - var/rank = job.title - lastJob = job - if(!is_job_whitelisted(user, rank)) - HTML += "[rank] \[KARMA]
\[BANNED]
\[ " + get_exp_format(available_in_playtime) + " as " + job.get_exp_req_type() + " \]
\[ DISABILITY \]
\[IN [(available_in_days)] DAYS]
" - - var/prefLevelLabel = "ERROR" - var/prefLevelColor = "pink" - var/prefUpperLevel = -1 // level to assign on left click - var/prefLowerLevel = -1 // level to assign on right click - - if(GetJobDepartment(job, 1) & job.flag) - prefLevelLabel = "High" - prefLevelColor = "slateblue" - prefUpperLevel = 4 - prefLowerLevel = 2 - else if(GetJobDepartment(job, 2) & job.flag) - prefLevelLabel = "Medium" - prefLevelColor = "green" - prefUpperLevel = 1 - prefLowerLevel = 3 - else if(GetJobDepartment(job, 3) & job.flag) - prefLevelLabel = "Low" - prefLevelColor = "orange" - prefUpperLevel = 2 - prefLowerLevel = 4 - else - prefLevelLabel = "NEVER" - prefLevelColor = "red" - prefUpperLevel = 3 - prefLowerLevel = 1 - - - HTML += "" - -// HTML += "" - - if(rank == "Civilian")//Civilian is special - if(job_support_low & JOB_CIVILIAN) - HTML += " \[Yes]" - else - HTML += " \[No]" + html += "
" + var/rank if(job.alt_titles) - HTML += "
\[[GetPlayerAltTitle(job)]\]
\[KARMA]
\[BANNED]
\[" + get_exp_format(available_in_playtime) + " as " + job.get_exp_req_type() + "\]
\[DISABILITY\]
\[IN [(available_in_days)] DAYS]
" + + var/prefLevelLabel = "ERROR" + var/prefLevelColor = "pink" + var/prefUpperLevel = -1 // level to assign on left click + var/prefLowerLevel = -1 // level to assign on right click + + if(GetJobDepartment(job, 1) & job.flag) + prefLevelLabel = "High" + prefLevelColor = "slateblue" + prefUpperLevel = 4 + prefLowerLevel = 2 + else if(GetJobDepartment(job, 2) & job.flag) + prefLevelLabel = "Medium" + prefLevelColor = "green" + prefUpperLevel = 1 + prefLowerLevel = 3 + else if(GetJobDepartment(job, 3) & job.flag) + prefLevelLabel = "Low" + prefLevelColor = "orange" + prefUpperLevel = 2 + prefLowerLevel = 4 + else + prefLevelLabel = "NEVER" + prefLevelColor = "red" + prefUpperLevel = 3 + prefLowerLevel = 1 - HTML += "
  
" + if(job.title == "Civilian")//Civilian is special + if(job_support_low & JOB_CIVILIAN) + html += " Yes" + else + html += " No" + html += "
" + html += "
  
" + html += "
" + + switch(alternate_option) + if(GET_RANDOM_JOB) + html += "

Get random job if preferences unavailable

" + if(BE_ASSISTANT) + html += "

Be a civilian if preferences unavailable

" + if(RETURN_TO_LOBBY) + html += "

Return to lobby if preferences unavailable

" + + html += "
Reset
" + html += "

Learn About Job Selection
" + html += "
" user << browse(null, "window=preferences") // user << browse(HTML, "window=mob_occupation;size=[width]x[height]") var/datum/browser/popup = new(user, "mob_occupation", "
Occupation Preferences
", width, height) popup.set_window_options("can_close=0") - popup.set_content(HTML) + var/html_string = html.Join() + popup.set_content(html_string) popup.open(0) return @@ -1077,6 +1085,12 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts if("reset") ResetJobs() SetChoices(user) + if("learnaboutselection") + if(config.wikiurl) + if(alert("Would you like to open the Job selection info in your browser?", "Open Job Selection", "Yes", "No") == "Yes") + user << link("[config.wikiurl]/index.php/Job_Selection_and_Assignment") + else + to_chat(user, "The Wiki URL is not set in the server configuration.") if("random") if(alternate_option == GET_RANDOM_JOB || alternate_option == BE_ASSISTANT) alternate_option += 1