[MIRROR] Convert late spawn UI to TGUI (#9272)

Co-authored-by: ShadowLarkens <shadowlarkens@gmail.com>
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
This commit is contained in:
CHOMPStation2
2024-10-20 14:08:39 -07:00
committed by GitHub
parent 45025bd128
commit a0379d1b79
5 changed files with 415 additions and 84 deletions

View File

@@ -93,3 +93,6 @@ Code is pretty much ripped verbatim from nano modules, but with un-needed stuff
/datum/tgui_module/proc/relaymove(mob/user, direction)
return FALSE
/datum/tgui_module/proc/close_ui()
SStgui.close_uis(src)

View File

@@ -0,0 +1,140 @@
/datum/tgui_module/late_choices
name = "Late Join"
tgui_id = "LateChoices"
/datum/tgui_module/late_choices/tgui_status(mob/user, datum/tgui_state/state)
if(!isnewplayer(user))
return STATUS_CLOSE
return STATUS_INTERACTIVE
/proc/get_user_job_priority(mob/user, datum/job/job)
. = 0
if(!user?.client?.prefs)
return
if(user.client.prefs.GetJobDepartment(job, 1) & job.flag)
. = 1
else if(user.client.prefs.GetJobDepartment(job, 2) & job.flag)
. = 2
else if(user.client.prefs.GetJobDepartment(job, 3) & job.flag)
. = 3
/proc/department_flag_to_name(department)
switch(department)
if(DEPARTMENT_COMMAND)
. = "Command"
if(DEPARTMENT_SECURITY)
. = "Security"
if(DEPARTMENT_ENGINEERING)
. = "Engineering"
if(DEPARTMENT_MEDICAL)
. = "Medical"
if(DEPARTMENT_RESEARCH)
. = "Research"
if(DEPARTMENT_CARGO)
. = "Supply"
if(DEPARTMENT_CIVILIAN)
. = "Service"
if(DEPARTMENT_PLANET)
. = "Expedition"
if(DEPARTMENT_SYNTHETIC)
. = "Silicon"
if(DEPARTMENT_TALON)
. = "Offmap"
else
. = "Unknown"
/proc/character_old_enough_for_job(datum/preferences/prefs, datum/job/job)
if(!job.minimum_character_age && !job.min_age_by_species)
return TRUE
var/min_age = job.get_min_age(prefs.species, prefs.organ_data["brain"])
if(prefs.age >= min_age)
return TRUE
return FALSE
/datum/tgui_module/late_choices/tgui_data(mob/new_player/user)
var/list/data = ..()
var/name = user.client.prefs.be_random_name ? "friend" : user.client.prefs.real_name
data["name"] = name
data["duration"] = roundduration2text()
if(emergency_shuttle?.going_to_centcom())
data["evac"] = "Gone"
else if(emergency_shuttle?.online())
if(emergency_shuttle.evac)
data["evac"] = "Emergency"
else
data["evac"] = "Crew Transfer"
else
data["evac"] = "None"
var/list/jobs = list()
for(var/datum/job/job in job_master.occupations)
if(job && user.IsJobAvailable(job.title))
// Check for jobs with minimum age requirements
if(!character_old_enough_for_job(user.client.prefs, job))
continue
//CHOMPEdit Begin - Check species job bans... (Only used for shadekin)
if(job.is_species_banned(user.client.prefs.species, user.client.prefs.organ_data["brain"]))
continue
//CHOMPEdit End
var/active = 0
// Only players with the job assigned and AFK for less than 10 minutes count as active
for(var/mob/M in player_list)
if(M.mind?.assigned_role == job.title && M.client?.inactivity <= 10 MINUTES)
active++
// Figure out departments
var/list/departments = list()
for(var/department in job.departments)
departments += department_flag_to_name(department)
UNTYPED_LIST_ADD(jobs, list(
"title" = job.title,
"priority" = get_user_job_priority(user, job),
"departments" = departments,
"current_positions" = job.current_positions,
"active" = active,
"offmap" = job.offmap_spawn,
))
data["jobs"] = jobs
return data
/datum/tgui_module/late_choices/tgui_act(action, params)
. = ..()
if(.)
return
var/mob/new_player/user = usr
switch(action)
if("join")
var/job = params["job"]
if(!CONFIG_GET(flag/enter_allowed)) // CHOMPEdit
to_chat(user, span_notice("There is an administrative lock on entering the game!"))
return
else if(ticker && ticker.mode && ticker.mode.explosion_in_progress)
to_chat(user, span_danger("The station is currently exploding. Joining would go poorly."))
return
var/datum/species/S = GLOB.all_species[user.client.prefs.species]
if(!is_alien_whitelisted(user, S))
tgui_alert(user, "You are currently not whitelisted to play [user.client.prefs.species].")
return 0
if(!(S.spawn_flags & SPECIES_CAN_JOIN))
tgui_alert_async(user,"Your current species, [user.client.prefs.species], is not available for play on the station.")
return 0
user.AttemptLateSpawn(job, user.client.prefs.spawnpoint)