Skip to content

Commit

Permalink
Add playtime support for removed jobs (#9893)
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmeow authored Oct 20, 2023
1 parent 0db821f commit ffd31ed
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
9 changes: 9 additions & 0 deletions code/modules/jobs/job_exp.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ GLOBAL_PROTECT(exp_to_update)
for(var/job in typelist["titles"])
if(job in explist)
amount += explist[job]
// Removed job support
typelist = GLOB.exp_removed_jobsmap[exptype]
if(typelist)
for(var/job in typelist["titles"])
if(job in explist)
amount += explist[job]
return amount

/client/proc/get_exp_living(pure_numeric = FALSE)
Expand Down Expand Up @@ -107,6 +113,9 @@ GLOBAL_PROTECT(exp_to_update)
for(var/rtype in SSjob.name_occupations)
if(!play_records[rtype])
play_records[rtype] = 0
for(var/rtype in GLOB.exp_removed_jobs)
if(!play_records[rtype])
play_records[rtype] = 0
for(var/rtype in GLOB.exp_specialmap)
if(!play_records[rtype])
play_records[rtype] = 0
Expand Down
5 changes: 5 additions & 0 deletions code/modules/jobs/job_report.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@

var/list/data = list()
data["jobPlaytimes"] = list()
data["jobRemovedPlaytimes"] = list()
data["specialPlaytimes"] = list()

for (var/job_name in SSjob.name_occupations)
var/playtime = play_records[job_name] ? text2num(play_records[job_name]) : 0
data["jobPlaytimes"][job_name] = playtime

for (var/job_name in GLOB.exp_removed_jobs)
var/playtime = play_records[job_name] ? text2num(play_records[job_name]) : 0
data["jobRemovedPlaytimes"][job_name] = playtime

for (var/special_name in GLOB.exp_specialmap[EXP_TYPE_SPECIAL])
var/playtime = play_records[special_name] ? text2num(play_records[special_name]) : 0
data["specialPlaytimes"][special_name] = playtime
Expand Down
11 changes: 11 additions & 0 deletions code/modules/jobs/jobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,18 @@ GLOBAL_LIST_INIT(security_positions_hud, list(
JOB_HUD_DEPUTY,
JOB_HUD_RAWSECURITY))

/// Put any removed jobs here so they can still show in playtime listings.
GLOBAL_LIST_INIT(exp_removed_jobs, list(
// "Virologist",
))
GLOBAL_PROTECT(exp_removed_jobs)

/// Put any removed jobs here so they can still show in playtime listings.
GLOBAL_LIST_INIT(exp_removed_jobsmap, list(
// EXP_TYPE_CREW = list("titles" = list("Virologist")),
// EXP_TYPE_MEDICAL = list("titles" = list("Virologist")),
))
GLOBAL_PROTECT(exp_removed_jobsmap)

GLOBAL_LIST_INIT(exp_jobsmap, list(
EXP_TYPE_CREW = list("titles" = command_positions | engineering_positions | medical_positions | science_positions | supply_positions | security_positions | civilian_positions | gimmick_positions | list(JOB_NAME_AI,JOB_NAME_CYBORG)), // crew positions
Expand Down
11 changes: 7 additions & 4 deletions tgui/packages/tgui/interfaces/TrackedPlaytime.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const JOB_REPORT_MENU_FAIL_REASON_NO_RECORDS = 2;
const sortByPlaytime = sortBy(([_, playtime]) => -playtime);

const PlaytimeSection = (props) => {
const { playtimes } = props;
const { playtimes, removedJobs } = props;
const sortedPlaytimes = sortByPlaytime(Object.entries(playtimes));
const mostPlayed = sortedPlaytimes[0][1];
return (
Expand All @@ -24,7 +24,7 @@ const PlaytimeSection = (props) => {
style={{
'vertical-align': 'middle',
}}>
<Box align="right">{jobName}</Box>
<Box align="right">{jobName + (removedJobs?.includes(jobName) ? ' (Removed)' : '')}</Box>
</Table.Cell>
<Table.Cell>
<ProgressBar maxValue={mostPlayed} value={playtime}>
Expand All @@ -49,7 +49,7 @@ const PlaytimeSection = (props) => {

export const TrackedPlaytime = (props, context) => {
const { data } = useBackend(context);
const { failReason, jobPlaytimes, specialPlaytimes, livingTime, ghostTime } = data;
const { failReason, jobPlaytimes = {}, jobRemovedPlaytimes = {}, specialPlaytimes, livingTime, ghostTime } = data;
return (
<Window title="Tracked Playtime" width={550} height={650}>
<Window.Content scrollable>
Expand All @@ -66,7 +66,10 @@ export const TrackedPlaytime = (props, context) => {
/>
</Section>
<Section title="Jobs">
<PlaytimeSection playtimes={jobPlaytimes} />
<PlaytimeSection
playtimes={{ ...jobPlaytimes, ...jobRemovedPlaytimes }}
removedJobs={Object.keys(jobRemovedPlaytimes)}
/>
</Section>
<Section title="Special">
<PlaytimeSection playtimes={specialPlaytimes} />
Expand Down

0 comments on commit ffd31ed

Please sign in to comment.