From 7811a45fe06aebca3330b1f7f5ba4b070feb040d Mon Sep 17 00:00:00 2001 From: celotajstg <81999976+celotajstg@users.noreply.github.com> Date: Sun, 11 Apr 2021 20:54:47 +0300 Subject: [PATCH] Prevent negative open positions in crew manifest (#58300) * Resolve open position issues in crew manifest * Use the classes helper for multiple classes Co-authored-by: celotajstg --- code/datums/datacore.dm | 4 +- code/modules/mob/dead/crew_manifest.dm | 35 ++++++---- tgui/packages/tgui/interfaces/CrewManifest.js | 65 ++++++++++++++----- .../tgui/styles/components/Tooltip.scss | 1 + .../tgui/styles/interfaces/CrewManifest.scss | 25 +++++-- 5 files changed, 95 insertions(+), 35 deletions(-) diff --git a/code/datums/datacore.dm b/code/datums/datacore.dm index 8ff5fe52ca7..e8717180d5f 100644 --- a/code/datums/datacore.dm +++ b/code/datums/datacore.dm @@ -160,6 +160,8 @@ "Service" = GLOB.service_positions, "Silicon" = GLOB.nonhuman_positions ) + var/list/heads = GLOB.command_positions + list("Quartermaster") + for(var/datum/data/record/t in GLOB.data_core.general) var/name = t.fields["name"] var/rank = t.fields["rank"] @@ -170,7 +172,7 @@ if(!manifest_out[department]) manifest_out[department] = list() // Append to beginning of list if captain or department head - if (rank == "Captain" || (department != "Command" && (rank in GLOB.command_positions))) + if (rank == "Captain" || (department != "Command" && (rank in heads))) manifest_out[department] = list(list( "name" = name, "rank" = rank diff --git a/code/modules/mob/dead/crew_manifest.dm b/code/modules/mob/dead/crew_manifest.dm index fafed6bfee3..44ad602067a 100644 --- a/code/modules/mob/dead/crew_manifest.dm +++ b/code/modules/mob/dead/crew_manifest.dm @@ -18,14 +18,15 @@ /datum/crew_manifest/ui_data(mob/user) var/list/positions = list( - "Command" = 0, - "Security" = 0, - "Engineering" = 0, - "Medical" = 0, - "Science" = 0, - "Supply" = 0, - "Service" = 0, - "Silicon" = 0 + "Command" = list("exceptions" = list(), "open" = 0), + "Security" = list("exceptions" = list(), "open" = 0), + "Engineering" = list("exceptions" = list(), "open" = 0), + "Medical" = list("exceptions" = list(), "open" = 0), + "Misc" = list("exceptions" = list(), "open" = 0), + "Science" = list("exceptions" = list(), "open" = 0), + "Supply" = list("exceptions" = list(), "open" = 0), + "Service" = list("exceptions" = list(), "open" = 0), + "Silicon" = list("exceptions" = list(), "open" = 0) ) var/list/departments = list( list("flag" = DEPARTMENT_COMMAND, "name" = "Command"), @@ -39,12 +40,18 @@ ) for(var/job in SSjob.occupations) - for(var/department in departments) - // Check if the job is part of a department using its flag - // Will return true for Research Director if the department is Science or Command, for example - if(job["departments"] & department["flag"]) - // Add open positions to current department - positions[department["name"]] += (job["total_positions"] - job["current_positions"]) + // Check if there are additional open positions or if there is no limit + if ((job["total_positions"] > 0 && job["total_positions"] > job["current_positions"]) || (job["total_positions"] == -1)) + for(var/department in departments) + // Check if the job is part of a department using its flag + // Will return true for Research Director if the department is Science or Command, for example + if(job["departments"] & department["flag"]) + if(job["total_positions"] == -1) + // Add job to list of exceptions, meaning it does not have a position limit + positions[department["name"]]["exceptions"] += list(job["title"]) + else + // Add open positions to current department + positions[department["name"]]["open"] += (job["total_positions"] - job["current_positions"]) return list( "manifest" = GLOB.data_core.get_manifest(), diff --git a/tgui/packages/tgui/interfaces/CrewManifest.js b/tgui/packages/tgui/interfaces/CrewManifest.js index fa109d90065..f9a2a88e719 100644 --- a/tgui/packages/tgui/interfaces/CrewManifest.js +++ b/tgui/packages/tgui/interfaces/CrewManifest.js @@ -1,9 +1,9 @@ +import { classes } from 'common/react'; import { useBackend } from "../backend"; -import { Icon, Section, Table } from "../components"; +import { Icon, Section, Table, Tooltip } from "../components"; import { Window } from "../layouts"; const commandJobs = [ - "Captain", "Head of Personnel", "Head of Security", "Chief Engineer", @@ -17,12 +17,13 @@ export const CrewManifest = (props, context) => { return ( - {Object.entries(manifest).map(([department, crew]) => ( + {Object.entries(manifest).map(([dept, crew]) => (
@@ -32,24 +33,56 @@ export const CrewManifest = (props, context) => { {crewMember.name} + {positions[dept].exceptions.includes(crewMember.rank) && ( + + + + )} + {crewMember.rank === "Captain" && ( + + + + )} {commandJobs.includes(crewMember.rank) && ( + className={classes([ + "CrewManifest__Icon", + "CrewManifest__Icon--Command", + "CrewManifest__Icon--Chevron", + ])} + name="chevron-up" + > + + )} {crewMember.rank} diff --git a/tgui/packages/tgui/styles/components/Tooltip.scss b/tgui/packages/tgui/styles/components/Tooltip.scss index a3fe79aefb1..217428c109c 100644 --- a/tgui/packages/tgui/styles/components/Tooltip.scss +++ b/tgui/packages/tgui/styles/components/Tooltip.scss @@ -16,6 +16,7 @@ $border-radius: base.$border-radius !default; left: 0; right: 0; bottom: 0; + font-family: Verdana, sans-serif; font-style: normal; font-weight: normal; diff --git a/tgui/packages/tgui/styles/interfaces/CrewManifest.scss b/tgui/packages/tgui/styles/interfaces/CrewManifest.scss index 8291cbbd50f..47c23ff1a29 100644 --- a/tgui/packages/tgui/styles/interfaces/CrewManifest.scss +++ b/tgui/packages/tgui/styles/interfaces/CrewManifest.scss @@ -5,6 +5,7 @@ $department_map: ( 'Security': colors.$red, 'Engineering': colors.$orange, 'Medical': colors.$teal, + 'Misc': colors.$white, 'Science': colors.$purple, 'Supply': colors.$brown, 'Service': colors.$green, @@ -28,14 +29,30 @@ $department_map: ( &__Cell { padding: 3px 0; - &--Captain { - color: colors.$yellow; - padding: 3px 8px; + &--Rank { + color: colors.$label; + } + } + + &__Icons { + padding: 3px 9px; + text-align: right; + } + + &__Icon { + color: colors.$label; + position: relative; + + &:not(:last-child) { + margin-right: 7px; + } + + &--Chevron { + padding-right: 2px; } &--Command { color: colors.$yellow; - padding: 3px 9px; } } }