From 4097a3c76538dd893a067d5293cf33eec0fcfc15 Mon Sep 17 00:00:00 2001 From: Atermonera Date: Fri, 21 Aug 2020 22:40:52 -0700 Subject: [PATCH] Allows you to right click to lower job preference --- .../preference_setup/occupation/occupation.dm | 103 ++++++++++++------ .../shadowlarkens - job preferences.yml | 36 ++++++ 2 files changed, 103 insertions(+), 36 deletions(-) create mode 100644 html/changelogs/shadowlarkens - job preferences.yml diff --git a/code/modules/client/preference_setup/occupation/occupation.dm b/code/modules/client/preference_setup/occupation/occupation.dm index 59229c1d70..a42e93c727 100644 --- a/code/modules/client/preference_setup/occupation/occupation.dm +++ b/code/modules/client/preference_setup/occupation/occupation.dm @@ -76,6 +76,7 @@ . = list() . += "
" . += "Choose occupation chances
Unavailable occupations are crossed out.
" + . += "" . += "
" // Table within a table for alignment, also allows you to easily add more columns. . += "" var/index = -1 @@ -162,7 +163,32 @@ . += "" continue - if(pref.GetJobDepartment(job, 1) & job.flag) - . += " \[High]" - else if(pref.GetJobDepartment(job, 2) & job.flag) - . += " \[Medium]" - else if(pref.GetJobDepartment(job, 3) & job.flag) - . += " \[Low]" - else - . += " \[NEVER]" + . += " \[[prefLevelLabel]]" if(LAZYLEN(job.alt_titles)) . += "" . += "" @@ -222,8 +241,8 @@ return (pref.equip_preview_mob ? TOPIC_REFRESH_UPDATE_PREVIEW : TOPIC_REFRESH) else if(href_list["set_job"]) - if(SetJob(user, href_list["set_job"])) return (pref.equip_preview_mob ? TOPIC_REFRESH_UPDATE_PREVIEW : TOPIC_REFRESH) - + if(SetJob(user, href_list["set_job"], text2num(href_list["level"]))) + return (pref.equip_preview_mob ? TOPIC_REFRESH_UPDATE_PREVIEW : TOPIC_REFRESH) else if(href_list["job_info"]) var/rank = href_list["job_info"] @@ -272,7 +291,7 @@ if(job.title != new_title) pref.player_alt_titles[job.title] = new_title -/datum/category_item/player_setup_item/occupation/proc/SetJob(mob/user, role) +/datum/category_item/player_setup_item/occupation/proc/SetJob(mob/user, role, level) var/datum/job/job = job_master.GetJob(role) if(!job) return 0 @@ -284,18 +303,20 @@ pref.job_civilian_low |= job.flag return 1 - if(pref.GetJobDepartment(job, 1) & job.flag) - SetJobDepartment(job, 1) - else if(pref.GetJobDepartment(job, 2) & job.flag) - SetJobDepartment(job, 2) - else if(pref.GetJobDepartment(job, 3) & job.flag) - SetJobDepartment(job, 3) - else//job = Never - SetJobDepartment(job, 4) - + SetJobDepartment(job, level) return 1 +/datum/category_item/player_setup_item/occupation/proc/reset_jobhigh() + pref.job_civilian_med |= pref.job_civilian_high + pref.job_medsci_med |= pref.job_medsci_high + pref.job_engsec_med |= pref.job_engsec_high + pref.job_civilian_high = 0 + pref.job_medsci_high = 0 + pref.job_engsec_high = 0 + +// Level is equal to the desired new level of the job. So for a value of 4, we want to disable the job. /datum/category_item/player_setup_item/occupation/proc/SetJobDepartment(var/datum/job/job, var/level) +<<<<<<< HEAD if(!job || !level) return 0 switch(level) if(1)//Only one of these should ever be active at once so clear them all here @@ -313,37 +334,47 @@ pref.job_medsci_high = 0 pref.job_engsec_high = 0 pref.job_talon_high = 0 //VOREStation Add +======= + if(!job || !level) + return 0 +>>>>>>> d7df9f1... Merge pull request #7500 from ShadowLarkens/preferences_rightclick_to_lower switch(job.department_flag) if(CIVILIAN) + pref.job_civilian_low &= ~job.flag + pref.job_civilian_med &= ~job.flag + pref.job_civilian_high &= ~job.flag switch(level) - if(2) + if(1) + reset_jobhigh() pref.job_civilian_high = job.flag - pref.job_civilian_med &= ~job.flag - if(3) + if(2) pref.job_civilian_med |= job.flag - pref.job_civilian_low &= ~job.flag - else + if(3) pref.job_civilian_low |= job.flag if(MEDSCI) + pref.job_medsci_low &= ~job.flag + pref.job_medsci_med &= ~job.flag + pref.job_medsci_high &= ~job.flag switch(level) - if(2) + if(1) + reset_jobhigh() pref.job_medsci_high = job.flag - pref.job_medsci_med &= ~job.flag - if(3) + if(2) pref.job_medsci_med |= job.flag - pref.job_medsci_low &= ~job.flag - else + if(3) pref.job_medsci_low |= job.flag if(ENGSEC) + pref.job_engsec_low &= ~job.flag + pref.job_engsec_med &= ~job.flag + pref.job_engsec_high &= ~job.flag switch(level) - if(2) + if(1) + reset_jobhigh() pref.job_engsec_high = job.flag - pref.job_engsec_med &= ~job.flag - if(3) + if(2) pref.job_engsec_med |= job.flag - pref.job_engsec_low &= ~job.flag - else + if(3) pref.job_engsec_low |= job.flag //VOREStation Add if(TALON) diff --git a/html/changelogs/shadowlarkens - job preferences.yml b/html/changelogs/shadowlarkens - job preferences.yml new file mode 100644 index 0000000000..75a2fe7a28 --- /dev/null +++ b/html/changelogs/shadowlarkens - job preferences.yml @@ -0,0 +1,36 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +################################# + +# Your name. +author: Shadow Larkens + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - rscadd: "Added the ability to right click and lower preferences for jobs in the Occupation Menu."
" - . += "" + 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(pref.GetJobDepartment(job, 1) & job.flag) + prefLevelLabel = "High" + prefLevelColor = "55cc55" + prefUpperLevel = 4 + prefLowerLevel = 2 + else if(pref.GetJobDepartment(job, 2) & job.flag) + prefLevelLabel = "Medium" + prefLevelColor = "eecc22" + prefUpperLevel = 1 + prefLowerLevel = 3 + else if(pref.GetJobDepartment(job, 3) & job.flag) + prefLevelLabel = "Low" + prefLevelColor = "cc5555" + prefUpperLevel = 2 + prefLowerLevel = 4 + else + prefLevelLabel = "NEVER" + prefLevelColor = "black" + prefUpperLevel = 3 + prefLowerLevel = 1 + + . += "" if(job.type == /datum/job/assistant)//Assistant is special if(pref.job_civilian_low & ASSISTANT) @@ -174,14 +200,7 @@ . += "
 \[[pref.GetPlayerAltTitle(job)]\]