mirror of
https://github.com/SPLURT-Station/S.P.L.U.R.T-Station-13.git
synced 2026-08-25 13:46:46 +01:00
Jobban panel merged with player panel
This commit is contained in:
@@ -27,6 +27,9 @@ GLOBAL_LIST_INIT(mute_bits, list(
|
||||
|
||||
/datum/player_panel
|
||||
var/mob/targetMob
|
||||
var/client/targetClient
|
||||
var/list/roleStatus // A list of each role and whether they are banned or not for this player.
|
||||
var/isAntagBanned
|
||||
|
||||
/datum/player_panel/New(mob/target)
|
||||
. = ..()
|
||||
@@ -34,6 +37,9 @@ GLOBAL_LIST_INIT(mute_bits, list(
|
||||
|
||||
/datum/player_panel/Destroy(force, ...)
|
||||
targetMob = null
|
||||
targetClient = null
|
||||
roleStatus = null
|
||||
isAntagBanned = null
|
||||
|
||||
SStgui.close_uis(src)
|
||||
return ..()
|
||||
@@ -66,16 +72,22 @@ GLOBAL_LIST_INIT(mute_bits, list(
|
||||
.["is_slept"] = L.admin_sleeping
|
||||
|
||||
if(targetMob.client)
|
||||
var/client/targetClient = targetMob.client
|
||||
.["client_key"] = targetClient.key
|
||||
targetClient = targetMob.client
|
||||
.["client_ckey"] = targetClient.ckey
|
||||
.["client_muted"] = targetClient.prefs.muted
|
||||
.["client_rank"] = targetClient.holder ? targetClient.holder.rank : "Player"
|
||||
|
||||
|
||||
if (!roleStatus)
|
||||
updateJobbanStatus()
|
||||
.["roles"] = roleStatus
|
||||
.["is_antag_banned"] = isAntagBanned
|
||||
|
||||
else
|
||||
.["client_key"] = null
|
||||
targetClient = null
|
||||
roleStatus = null
|
||||
isAntagBanned = null
|
||||
.["client_ckey"] = null
|
||||
.["client_muted"] = null
|
||||
.["client_rank"] = null
|
||||
|
||||
/datum/player_panel/ui_static_data()
|
||||
. = list()
|
||||
@@ -91,8 +103,6 @@ GLOBAL_LIST_INIT(mute_bits, list(
|
||||
|
||||
var/client/admin = ui.user.client
|
||||
|
||||
to_chat(admin, "Easdasdasdadmin!")
|
||||
|
||||
if (!check_rights(R_ADMIN))
|
||||
message_admins("<span class='adminhelp'>WARNING: NON-ADMIN [ADMIN_LOOKUPFLW(admin)] ACCESSING ADMIN PANEL. WARN Casper#3044.</span>")
|
||||
to_chat(admin, "Error: you are not an admin!")
|
||||
@@ -198,7 +208,7 @@ GLOBAL_LIST_INIT(mute_bits, list(
|
||||
return
|
||||
|
||||
targetMob.forceMove(pick(GLOB.prisonwarp))
|
||||
to_chat(targetMob, "<span class='adminnotice'>You have been sent to Prison!</span>")
|
||||
to_chat(targetMob, "<span class='userdanger'>You have been sent to Prison!</span>")
|
||||
|
||||
log_admin("[key_name(admin)] has sent [key_name(targetMob)] to Prison!")
|
||||
message_admins("[key_name_admin(admin)] has sent [key_name_admin(targetMob)] to Prison!")
|
||||
@@ -211,7 +221,7 @@ GLOBAL_LIST_INIT(mute_bits, list(
|
||||
|
||||
if ("job_ban")
|
||||
if(targetMob.client)
|
||||
admin.holder.show_jobban_panel(targetMob.client)
|
||||
process_banlist(params["selected_role"], params["is_category"], params["want_to_ban"])
|
||||
|
||||
if ("mute")
|
||||
if(!targetMob.client)
|
||||
@@ -219,3 +229,72 @@ GLOBAL_LIST_INIT(mute_bits, list(
|
||||
|
||||
targetMob.client.prefs.muted = text2num(params["mute_flag"])
|
||||
log_admin("[key_name(admin)] set the mute flags for [key_name(targetMob)] to [targetMob.client.prefs.muted].")
|
||||
|
||||
// process_banlist: Gets all jobs in a job category
|
||||
// Input:
|
||||
// query (string): The name of the role / department you want to jobban.
|
||||
// is_category (boolean): Is the query a department / role category? e.g. query "Engineering" needs TRUE
|
||||
// want_to_ban (boolean): Should we ban or should we unban the job we just supplied.
|
||||
//
|
||||
// Output:A list of strings with the names of each role the INPUT covers.
|
||||
/datum/player_panel/proc/process_banlist(query, is_category, want_to_ban)
|
||||
if(!SSjob)
|
||||
to_chat(usr, "Jobs subsystem not initialized yet!")
|
||||
return
|
||||
|
||||
var/mob/M = targetClient.mob
|
||||
var/list/jobs_to_set = list() // All the roles relating to the clicked button
|
||||
|
||||
if (is_category)
|
||||
for(var/list/role_category in roleStatus) // For every department / antag category
|
||||
if (role_category["category_name"] == query) // If this is the selected category
|
||||
|
||||
for(var/list/role in role_category["category_roles"])
|
||||
jobs_to_set += role["name"]
|
||||
break
|
||||
|
||||
else
|
||||
jobs_to_set += query
|
||||
|
||||
var/list/jobs_to_set_trimmed = list() // The roles from jobs_to_set that aren't already banned / unbanned
|
||||
for(var/role in jobs_to_set)
|
||||
|
||||
// If we are in ban mode and this role is unbanned OR if we are in unban mode and this role is banned
|
||||
// (We don't want to ban / unban roles that are already banned / unbanned)
|
||||
if ((want_to_ban && !jobban_isbanned(M, role)) || (!want_to_ban && jobban_isbanned(M, role)))
|
||||
jobs_to_set_trimmed += role
|
||||
|
||||
for(var/role in jobs_to_set_trimmed)
|
||||
|
||||
if (jobs_to_set_trimmed.len) // At least one role to get banned / unbanned
|
||||
if (want_to_ban)
|
||||
usr.client.holder.Jobban(targetClient.mob, jobs_to_set_trimmed)
|
||||
else
|
||||
usr.client.holder.UnJobban(targetClient.mob, jobs_to_set_trimmed)
|
||||
|
||||
updateJobbanStatus() // Update TGUI data to reflect new ban statuses
|
||||
|
||||
// Updates the jobban status of this client's jobban panel.
|
||||
/datum/player_panel/proc/updateJobbanStatus()
|
||||
var/list/roles = list()
|
||||
|
||||
for(var/list/role_category in GLOB.jobban_panel_data) // For every department / antag category
|
||||
var/list/category_roles = list()
|
||||
category_roles["category_name"] = role_category["name"]
|
||||
category_roles["category_color"] = role_category["color"]
|
||||
category_roles["category_roles"] = list()
|
||||
|
||||
for(var/role in role_category["roles"]) // For every job / antag
|
||||
var/list/roles_instance = list()
|
||||
roles_instance["name"] = role
|
||||
var/reason = jobban_isbanned(targetMob, role)
|
||||
if(reason)
|
||||
roles_instance["ban_reason"] = reason
|
||||
|
||||
category_roles["category_roles"] += list(roles_instance)
|
||||
|
||||
roles += list(category_roles)
|
||||
|
||||
roleStatus = roles
|
||||
|
||||
isAntagBanned = jobban_isbanned(targetMob, ROLE_SYNDICATE)
|
||||
|
||||
Reference in New Issue
Block a user