Files
nevimer 00ccf0c6b5 Merge remote-tracking branch 'tgstation/master' into upstream-feb12-2026
# Conflicts:
#	.github/CODEOWNERS
#	.github/workflows/compile_changelogs.yml
#	.github/workflows/stale.yml
#	SQL/database_changelog.md
#	_maps/map_files/CatwalkStation/CatwalkStation_2023.dmm
#	code/__DEFINES/atom_hud.dm
#	code/__DEFINES/inventory.dm
#	code/__DEFINES/mobs.dm
#	code/__DEFINES/species_clothing_paths.dm
#	code/__DEFINES/subsystems.dm
#	code/__DEFINES/surgery.dm
#	code/__HELPERS/global_lists.dm
#	code/_globalvars/lists/maintenance_loot.dm
#	code/_globalvars/traits/_traits.dm
#	code/controllers/subsystem/minor_mapping.dm
#	code/controllers/subsystem/processing/quirks.dm
#	code/controllers/subsystem/shuttle.dm
#	code/datums/components/palette.dm
#	code/datums/components/surgery_initiator.dm
#	code/datums/diseases/advance/advance.dm
#	code/datums/hud.dm
#	code/datums/mood.dm
#	code/datums/mutations/chameleon.dm
#	code/datums/quirks/negative_quirks/nyctophobia.dm
#	code/datums/status_effects/debuffs/debuffs.dm
#	code/datums/status_effects/debuffs/drunk.dm
#	code/datums/status_effects/debuffs/slime/slime_leech.dm
#	code/datums/weather/weather.dm
#	code/game/data_huds.dm
#	code/game/objects/items.dm
#	code/game/objects/items/devices/scanners/health_analyzer.dm
#	code/game/objects/items/frog_statue.dm
#	code/game/objects/items/rcd/RLD.dm
#	code/game/objects/items/robot/items/hypo.dm
#	code/game/objects/items/stacks/medical.dm
#	code/game/objects/items/stacks/wrap.dm
#	code/game/objects/items/storage/garment.dm
#	code/game/objects/items/tools/medical/defib.dm
#	code/game/objects/items/weaponry.dm
#	code/game/objects/items/weaponry/melee/misc.dm
#	code/game/objects/structures/crates_lockers/closets/secure/security.dm
#	code/game/objects/structures/curtains.dm
#	code/game/objects/structures/dresser.dm
#	code/game/objects/structures/girders.dm
#	code/game/objects/structures/maintenance.dm
#	code/game/objects/structures/mirror.dm
#	code/modules/admin/greyscale_modify_menu.dm
#	code/modules/admin/verbs/light_debug.dm
#	code/modules/antagonists/ashwalker/ashwalker.dm
#	code/modules/antagonists/heretic/knowledge/starting_lore.dm
#	code/modules/antagonists/ninja/ninjaDrainAct.dm
#	code/modules/art/paintings.dm
#	code/modules/client/preferences.dm
#	code/modules/client/verbs/ooc.dm
#	code/modules/clothing/head/wig.dm
#	code/modules/events/disease_outbreak.dm
#	code/modules/holodeck/holo_effect.dm
#	code/modules/jobs/job_types/head_of_security.dm
#	code/modules/jobs/job_types/security_officer.dm
#	code/modules/library/skill_learning/generic_skillchips/point.dm
#	code/modules/mining/lavaland/ash_flora.dm
#	code/modules/mining/lavaland/mining_loot/megafauna/ash_drake.dm
#	code/modules/mob/dead/new_player/new_player.dm
#	code/modules/mob/living/basic/guardian/guardian.dm
#	code/modules/mob/living/basic/space_fauna/space_dragon/space_dragon.dm
#	code/modules/mob/living/carbon/carbon.dm
#	code/modules/mob/living/carbon/human/human.dm
#	code/modules/mob/living/carbon/human/human_defines.dm
#	code/modules/mob/living/carbon/life.dm
#	code/modules/mob/living/living.dm
#	code/modules/mob/living/living_defines.dm
#	code/modules/mob/mob.dm
#	code/modules/mob_spawn/ghost_roles/mining_roles.dm
#	code/modules/mod/mod_control.dm
#	code/modules/mod/modules/modules_general.dm
#	code/modules/modular_computers/computers/item/computer_ui.dm
#	code/modules/paperwork/paper.dm
#	code/modules/paperwork/paperbin.dm
#	code/modules/power/lighting/light.dm
#	code/modules/projectiles/guns/energy/kinetic_accelerator.dm
#	code/modules/projectiles/projectile.dm
#	code/modules/reagents/chemistry/reagents/drinks/alcohol_reagents.dm
#	code/modules/reagents/chemistry/reagents/food_reagents.dm
#	code/modules/reagents/chemistry/reagents/other_reagents.dm
#	code/modules/reagents/chemistry/reagents/pyrotechnic_reagents.dm
#	code/modules/research/xenobiology/crossbreeding/_clothing.dm
#	code/modules/research/xenobiology/crossbreeding/prismatic.dm
#	code/modules/surgery/advanced/brainwashing.dm
#	code/modules/surgery/advanced/lobotomy.dm
#	code/modules/surgery/amputation.dm
#	code/modules/surgery/blood_filter.dm
#	code/modules/surgery/bodyparts/_bodyparts.dm
#	code/modules/surgery/brain_surgery.dm
#	code/modules/surgery/cavity_implant.dm
#	code/modules/surgery/coronary_bypass.dm
#	code/modules/surgery/gastrectomy.dm
#	code/modules/surgery/healing.dm
#	code/modules/surgery/limb_augmentation.dm
#	code/modules/surgery/organ_manipulation.dm
#	code/modules/surgery/revival.dm
#	code/modules/surgery/sleeper_protocol.dm
#	code/modules/surgery/surgery_helpers.dm
#	code/modules/surgery/surgery_step.dm
#	code/modules/unit_tests/_unit_tests.dm
#	code/modules/unit_tests/designs.dm
#	code/modules/unit_tests/icon_state_worn.dm
#	code/modules/unit_tests/screenshots/screenshot_antag_icons_cultist.png
#	code/modules/unit_tests/screenshots/screenshot_antag_icons_headrevolutionary.png
#	code/modules/unit_tests/screenshots/screenshot_antag_icons_provocateur.png
#	code/modules/unit_tests/screenshots/screenshot_husk_body.png
#	code/modules/unit_tests/screenshots/screenshot_husk_body_missing_limbs.png
#	icons/map_icons/clothing/head/_head.dmi
#	icons/map_icons/clothing/shoes.dmi
#	icons/map_icons/items/_item.dmi
#	icons/mob/huds/hud.dmi
#	icons/mob/inhands/64x64_lefthand.dmi
#	icons/mob/inhands/64x64_righthand.dmi
#	icons/obj/machines/computer.dmi
#	tgui/packages/tgui/interfaces/OperatingComputer.jsx
#	tgui/packages/tgui/interfaces/PreferencesMenu/CharacterPreferences/MainPage.tsx
#	tgui/packages/tgui/interfaces/PreferencesMenu/types.ts
#	tgui/packages/tgui/interfaces/SurgeryInitiator.tsx
#	tools/icon_cutter/check.py
2026-02-12 23:50:09 -05:00

229 lines
8.5 KiB
Plaintext

#define JOB_CHOICE_YES "Yes"
#define JOB_CHOICE_REROLL "Reroll"
#define JOB_CHOICE_CANCEL "Cancel"
GLOBAL_DATUM_INIT(latejoin_menu, /datum/latejoin_menu, new)
/// Makes a list of jobs and pushes them to a DM list selector. Just in case someone did a special kind of fucky-wucky with TGUI.
/datum/latejoin_menu/proc/fallback_ui(mob/dead/new_player/user)
var/list/jobs = list()
for(var/datum/job/job as anything in SSjob.joinable_occupations)
jobs += job.title
var/input_contents = input(user, "Pick a job to join as:", "Latejoin Job Selection") as null|anything in jobs
if(!input_contents)
return
user.AttemptLateSpawn(input_contents)
/datum/latejoin_menu/ui_close(mob/dead/new_player/user)
. = ..()
if(istype(user))
user.jobs_menu_mounted = TRUE // Don't flood a user's chat if they open and close the UI.
/datum/latejoin_menu/ui_interact(mob/dead/new_player/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
// In case they reopen the GUI
// FIXME: this can cause a runtime since user can be a living mob
if(istype(user))
user.jobs_menu_mounted = FALSE
addtimer(CALLBACK(src, PROC_REF(scream_at_player), user), 5 SECONDS)
ui = new(user, src, "JobSelection", "Latejoin Menu")
ui.open()
/datum/latejoin_menu/proc/scream_at_player(mob/dead/new_player/player)
if(!player.jobs_menu_mounted)
to_chat(player, span_notice("If the late join menu isn't showing, hold CTRL while clicking the join button!"))
/datum/latejoin_menu/ui_data(mob/user)
var/mob/dead/new_player/owner = user
var/list/departments = list()
var/list/data = list(
"disable_jobs_for_non_observers" = SSlag_switch.measures[DISABLE_NON_OBSJOBS],
"round_duration" = DisplayTimeText(world.time - SSticker.round_start_time, round_seconds_to = 1),
"departments" = departments,
)
if(SSshuttle.emergency)
switch(SSshuttle.emergency.mode)
if(SHUTTLE_ESCAPE)
data["shuttle_status"] = "The station has been evacuated."
if(SHUTTLE_CALL, SHUTTLE_DOCKED, SHUTTLE_IGNITING, SHUTTLE_ESCAPE)
data["shuttle_status"] = "The station is currently undergoing evacuation procedures."
for(var/datum/job/prioritized_job in SSjob.prioritized_jobs)
if(prioritized_job.current_positions >= prioritized_job.total_positions)
SSjob.prioritized_jobs -= prioritized_job
for(var/datum/job_department/department as anything in SSjob.joinable_departments)
var/list/department_jobs = list()
var/list/department_data = list(
"jobs" = department_jobs,
"open_slots" = 0,
)
departments[department.department_name] = department_data
for(var/datum/job/job_datum as anything in department.department_jobs)
//Jobs under multiple departments should only be displayed if this is their first department or the command department
if(LAZYLEN(job_datum.departments_list) > 1 && job_datum.departments_list[1] != department.type && !(job_datum.departments_bitflags & DEPARTMENT_BITFLAG_COMMAND))
continue
var/job_availability = owner.IsJobUnavailable(job_datum.title, latejoin = TRUE)
var/list/job_data = list(
"prioritized" = (job_datum in SSjob.prioritized_jobs),
"used_slots" = job_datum.current_positions,
"open_slots" = job_datum.total_positions < 0 ? "∞" : job_datum.total_positions,
)
if(job_availability != JOB_AVAILABLE)
if (job_datum.job_flags & JOB_HIDE_WHEN_EMPTY)
continue
job_data["unavailable_reason"] = get_job_unavailable_error_message(job_availability, job_datum.title)
if(job_datum.total_positions < 0)
department_data["open_slots"] = "∞"
if(department_data["open_slots"] != "∞")
if(job_datum.total_positions - job_datum.current_positions > 0)
department_data["open_slots"] += job_datum.total_positions - job_datum.current_positions
department_jobs[job_datum.title] = job_data
return data
/datum/latejoin_menu/ui_static_data(mob/user)
var/list/departments = list()
var/mob/dead/new_player/owner = user
for(var/datum/job_department/department as anything in SSjob.joinable_departments)
var/list/department_jobs = list()
var/list/department_data = list(
"jobs" = department_jobs,
"color" = department.ui_color,
)
departments[department.department_name] = department_data
for(var/datum/job/job_datum as anything in department.department_jobs)
//Jobs under multiple departments should only be displayed if this is their first department or the command department
if(LAZYLEN(job_datum.departments_list) > 1 && job_datum.departments_list[1] != department.type && !(job_datum.departments_bitflags & DEPARTMENT_BITFLAG_COMMAND))
continue
if((job_datum.job_flags & JOB_HIDE_WHEN_EMPTY) && owner.IsJobUnavailable(job_datum.title, latejoin = TRUE) != JOB_AVAILABLE)
continue
var/list/job_data = list(
"command" = !!(job_datum.departments_bitflags & DEPARTMENT_BITFLAG_COMMAND),
"description" = job_datum.description,
)
department_jobs[job_datum.title] = job_data
return list("departments_static" = departments)
/datum/latejoin_menu/ui_state(mob/user)
return GLOB.new_player_state
/datum/latejoin_menu/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if(!ui.user.client || ui.user.client.interviewee || !isnewplayer(ui.user))
return TRUE
var/mob/dead/new_player/owner = ui.user
switch(action)
if("ui_mounted_with_no_bluescreen")
owner.jobs_menu_mounted = TRUE
if("select_job")
if(params["job"] == "Random")
var/job = get_random_job(owner)
if(!job)
return TRUE
params["job"] = job
if(!SSticker?.IsRoundInProgress())
tgui_alert(owner, "The round is either not ready, or has already finished...", "Oh No!")
return TRUE
if(SSlag_switch.measures[DISABLE_NON_OBSJOBS])
tgui_alert(owner, "There is an administrative lock on entering the game for non-observers!", "Oh No!")
return TRUE
// SKYRAT EDIT ADDITION START - Flavourtext requirement
if(CONFIG_GET(flag/min_flavor_text))
if(length_char(owner.client.prefs.read_preference(/datum/preference/text/flavor_text)) < CONFIG_GET(number/flavor_text_character_requirement))
to_chat(owner, span_notice("You need at least [CONFIG_GET(number/flavor_text_character_requirement)] characters of flavor text to join the round. You have [length_char(owner.client.prefs.read_preference(/datum/preference/text/flavor_text))] characters."))
return
// SKYRAT EDIT END
//Determines Relevent Population Cap
var/relevant_cap
var/hard_popcap = CONFIG_GET(number/hard_popcap)
var/extreme_popcap = CONFIG_GET(number/extreme_popcap)
if(hard_popcap && extreme_popcap)
relevant_cap = min(hard_popcap, extreme_popcap)
else
relevant_cap = max(hard_popcap, extreme_popcap)
if(SSticker.queued_players.len && !(ckey(owner.key) in GLOB.admin_datums))
if((living_player_count() >= relevant_cap) || (owner != SSticker.queued_players[1]))
tgui_alert(owner, "The server is full!", "Oh No!")
return TRUE
// SAFETY: AttemptLateSpawn has it's own sanity checks. This is perfectly safe.
owner.AttemptLateSpawn(params["job"])
if("viewpoll")
var/datum/poll_question/poll = locate(params["viewpoll"]) in GLOB.polls
if(!poll)
return TRUE
owner.poll_player(poll)
return TRUE
if("votepollref")
var/datum/poll_question/poll = locate(params["votepollref"]) in GLOB.polls
if(!poll)
return TRUE
owner.vote_on_poll_handler(poll, params)
return TRUE
/// Gives the user a random job that they can join as, and prompts them if they'd actually like to keep it, rerolling if not. Cancellable by the user.
/// WARNING: BLOCKS THREAD!
/datum/latejoin_menu/proc/get_random_job(mob/dead/new_player/owner)
var/list/dept_data = list()
for(var/datum/job_department/department as anything in SSjob.joinable_departments)
for(var/datum/job/job_datum as anything in department.department_jobs)
if(owner.IsJobUnavailable(job_datum.title, latejoin = TRUE) != JOB_AVAILABLE)
continue
dept_data += job_datum.title
if(dept_data.len <= 0) //Congratufuckinglations
tgui_alert(owner, "There are literally no random jobs available for you on this server, ahelp for assistance.", "Oh No!")
return
var/random_job
while(random_job != JOB_CHOICE_YES)
if(dept_data.len <= 0)
tgui_alert(owner, "It seems that there are no more random jobs available for you!", "Oh No!")
return
var/random = pick_n_take(dept_data)
var/list/random_job_options = list(JOB_CHOICE_YES, JOB_CHOICE_REROLL, JOB_CHOICE_CANCEL)
random_job = tgui_alert(owner, "[random]?", "Random Job", random_job_options)
if(random_job == JOB_CHOICE_CANCEL)
return
if(random_job == JOB_CHOICE_YES)
return random
#undef JOB_CHOICE_YES
#undef JOB_CHOICE_REROLL
#undef JOB_CHOICE_CANCEL