Remove job .tsx files from preferences menu, use compiled data instead (#63200)

Removes every job .tsx file, and moves their necessary data over to the job datums themselves. This lowers the burden of both adding and removing jobs, and allows for jobs to be removed without touching any internal code (I'm specifically doing this for events)
This commit is contained in:
Mothblocks
2021-12-06 03:56:46 +02:00
committed by GitHub
parent 252e203e47
commit 0989ce2d6f
80 changed files with 232 additions and 563 deletions
-24
View File
@@ -363,30 +363,6 @@ Middleware can inject its own data at several points, such as providing new UI a
---
## Jobs
Every job must have an associated `.ts` file so that the UI knows where to place it.
Create a file in `tgui/packages/tgui/interfaces/PreferencesMenu/jobs/jobs/`.
This will specify the description and department of the job. Here is the details for the medical doctor:
```ts
import { Job } from "../base";
import { Service } from "../departments";
const Cook: Job = {
name: "Cook",
// If you need more room, use `multiline`
description: "Serve food, cook meat, keep the crew fed.",
department: Service,
};
export default Cook;
```
---
## Antagonists
In order to make an antagonist selectable, you must do a few things:
@@ -25,6 +25,40 @@
return TRUE
/datum/preference_middleware/jobs/get_constant_data()
var/list/data = list()
var/list/departments = list()
var/list/jobs = list()
for (var/datum/job/job as anything in SSjob.joinable_occupations)
var/datum/job_department/department_type = job.department_for_prefs || job.departments_list?[1]
if (isnull(department_type))
stack_trace("[job] does not have a department set, yet is a joinable occupation!")
continue
if (isnull(job.description))
stack_trace("[job] does not have a description set, yet is a joinable occupation!")
continue
var/department_name = initial(department_type.department_name)
if (isnull(departments[department_name]))
var/datum/job/department_head_type = initial(department_type.department_head)
departments[department_name] = list(
"head" = department_head_type && initial(department_head_type.title),
)
jobs[job.title] = list(
"description" = job.description,
"department" = department_name,
)
data["departments"] = departments
data["jobs"] = jobs
return data
/datum/preference_middleware/jobs/get_ui_data(mob/user)
var/list/data = list()