diff --git a/code/modules/admin/player_panel2.dm b/code/modules/admin/player_panel2.dm
index 7dcb911952..599d1a0391 100644
--- a/code/modules/admin/player_panel2.dm
+++ b/code/modules/admin/player_panel2.dm
@@ -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("WARNING: NON-ADMIN [ADMIN_LOOKUPFLW(admin)] ACCESSING ADMIN PANEL. WARN Casper#3044.")
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, "You have been sent to Prison!")
+ to_chat(targetMob, "You have been sent to Prison!")
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)
diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm
index 7d42d8367e..dc1aefd746 100644
--- a/code/modules/client/client_procs.dm
+++ b/code/modules/client/client_procs.dm
@@ -519,7 +519,6 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
log_access("Logout: [key_name(src)]")
GLOB.ahelp_tickets.ClientLogout(src)
SSserver_maint.UpdateHubStatus()
- QDEL_NULL(jobban_panel)
if(credits)
QDEL_LIST(credits)
if(holder)
diff --git a/modular_splurt/code/modules/admin/JobBan.dm b/modular_splurt/code/modules/admin/JobBan.dm
index cf9292f519..8cb14fec1f 100644
--- a/modular_splurt/code/modules/admin/JobBan.dm
+++ b/modular_splurt/code/modules/admin/JobBan.dm
@@ -1,3 +1,5 @@
+// Stuff that helps the TGUI player panel jobban section to work
+
GLOBAL_LIST_INIT(jobban_panel_data, list(
list(
"name" = "Command",
@@ -50,13 +52,7 @@ GLOBAL_LIST_INIT(jobban_panel_data, list(
ROLE_LAVALAND,
ROLE_GHOSTCAFE,
ROLE_SENTIENCE,
- ROLE_MIND_TRANSFER
- )
- ),
- list(
- "name" = "Other",
- "color" = "grey",
- "roles" = list(
+ ROLE_MIND_TRANSFER,
ROLE_RESPAWN
)
),
@@ -81,136 +77,13 @@ GLOBAL_LIST_INIT(jobban_panel_data, list(
)
))
-/datum/admins/proc/show_jobban_panel(client/C)
- if(!istype(C, /client))
- to_chat(owner, "This client is no longer in the game.")
- return
-
- // this is stupid, thanks byond
- if(istype(src, /client))
- var/client/Cl = src
- src = Cl.holder
-
- if(!check_rights())
- to_chat(owner, "Error: you are not an admin!")
- return
-
- if(!C.jobban_panel)
- C.create_jobban_panel()
-
- C.jobban_panel.ui_interact(owner.mob)
-
-/datum/jobban_panel
- var/client/targetClient
- var/list/role_status // A list of each role and whether they are banned or not for this player.
-
-/datum/jobban_panel/New(client/target)
- . = ..()
- targetClient = target
-
-/datum/jobban_panel/Destroy(force, ...)
- targetClient = null
-
- SStgui.close_uis(src)
- return ..()
-
-/datum/jobban_panel/ui_interact(mob/user, datum/tgui/ui)
- if(!targetClient)
- return
-
- ui = SStgui.try_update_ui(user, src, ui)
- if (!ui)
- ui = new(user, src, "JobbanPanel", "[targetClient.ckey] Jobban Panel")
- ui.open()
-
-/datum/jobban_panel/ui_state(mob/user)
- return GLOB.admin_state
-
-/datum/jobban_panel/ui_data(mob/user)
- . = list()
- .["client_ckey"] = targetClient.ckey
- .["is_antag_banned"] = jobban_isbanned(targetClient.mob, ROLE_SYNDICATE)
-
- if (!role_status)
- updateJobbanStatus()
- .["roles"] = role_status
-
-// /datum/jobban_panel/ui_static_data()
-// . = list()
-
-/datum/jobban_panel/ui_act(action, params, datum/tgui/ui)
- if(..())
- return
-
+// notbannedlist is just a list of strings of the job titles you want to ban.
+/datum/admins/proc/Jobban(mob/M, list/notbannedlist)
+ to_chat(M, "ban start")
if (!check_rights(R_BAN))
to_chat(usr, "Error: You do not have sufficient admin rights to ban players.")
return
- 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 (params["is_category"])
- for(var/list/role_category in role_status) // For every department / antag category
- if (role_category["category_name"] == params["selected_role"]) // 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 += params["selected_role"]
-
- var/mode = params["want_to_ban"]
-
- 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 ((mode && !jobban_isbanned(M, role)) || (!mode && 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 (mode)
- 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/jobban_panel/proc/updateJobbanStatus()
- var/list/roles = list()
- var/mob/M = targetClient.mob
-
- 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(M, role)
- if(reason)
- roles_instance["is_banned"] = TRUE
- roles_instance["ban_reason"] = reason
-
- category_roles["category_roles"] += list(roles_instance)
-
- roles += list(category_roles)
-
- role_status = roles
-
-// notbannedlist is just a list of strings of the job titles you want to ban.
-/datum/admins/proc/Jobban(mob/M, list/notbannedlist)
var/severity = null
var/reason = null
@@ -271,9 +144,15 @@ GLOBAL_LIST_INIT(jobban_panel_data, list(
to_chat(M, "You have been [((msg == "ooc") || (msg == "appearance") || (msg == "pacifist")) ? "banned" : "jobbanned"] by [usr.client.key] from: [msg == "pacifist" ? "using violence" : msg].")
to_chat(M, "The reason is: [reason]")
to_chat(M, "This jobban can be lifted only upon request.")
+ to_chat(M, "ban end")
// notbannedlist is just a list of strings of the job titles you want to unban.
/datum/admins/proc/UnJobban(mob/M, list/bannedlist)
+
+ if (!check_rights(R_BAN))
+ to_chat(usr, "Error: You do not have sufficient admin rights to unban players.")
+ return
+
var/msg
for(var/job in bannedlist)
var/reason = jobban_isbanned(M, job)
@@ -290,7 +169,3 @@ GLOBAL_LIST_INIT(jobban_panel_data, list(
if(msg)
message_admins("[key_name_admin(usr)] unbanned [key_name_admin(M)] from [msg].")
to_chat(M, "You have been un-jobbanned by [usr.client.key] from [msg].")
-
-
-
-
diff --git a/modular_splurt/code/modules/client/client_defines.dm b/modular_splurt/code/modules/client/client_defines.dm
index 3111c09871..7149778f20 100644
--- a/modular_splurt/code/modules/client/client_defines.dm
+++ b/modular_splurt/code/modules/client/client_defines.dm
@@ -1,3 +1 @@
/client
- // Jobban panel for this client
- var/datum/jobban_panel/jobban_panel = null
diff --git a/modular_splurt/code/modules/client/client_procs.dm b/modular_splurt/code/modules/client/client_procs.dm
index 6b97b608b3..d62111d09d 100644
--- a/modular_splurt/code/modules/client/client_procs.dm
+++ b/modular_splurt/code/modules/client/client_procs.dm
@@ -2,8 +2,3 @@
. = ..()
if(ip_intel != initial(ip_intel) && ip_intel >= CONFIG_GET(number/ipintel_rating_bad))
uses_vpn = TRUE
-
-/client/proc/create_jobban_panel()
- QDEL_NULL(jobban_panel)
-
- jobban_panel = new(src)
diff --git a/tgui/packages/tgui/interfaces/PlayerPanel2.js b/tgui/packages/tgui/interfaces/PlayerPanel2.js
index bfdab70a3e..7d62ba0144 100644
--- a/tgui/packages/tgui/interfaces/PlayerPanel2.js
+++ b/tgui/packages/tgui/interfaces/PlayerPanel2.js
@@ -1,6 +1,6 @@
import { Fragment } from "inferno";
import { useBackend, useLocalState } from '../backend';
-import { Input, Button, Flex, Section, Tabs, Box, Dropdown, Slider, Tooltip } from '../components';
+import { Input, Button, Flex, Section, Tabs, Box, NoticeBox, Collapsible, Dropdown, Slider, Tooltip } from '../components';
import { Window } from '../layouts';
const PAGES = [
@@ -19,6 +19,15 @@ const PAGES = [
return data.client_ckey;
},
},
+ {
+ title: 'Job Bans',
+ component: () => Jobbans,
+ color: "red",
+ icon: "gavel",
+ canAccess: data => {
+ return data.client_ckey;
+ },
+ },
// {
// title: 'Physical',
// component: () => PhysicalActions,
@@ -60,9 +69,8 @@ const PAGES = [
export const PlayerPanel2 = (props, context) => {
const { act, data } = useBackend(context);
const [pageIndex, setPageIndex] = useLocalState(context, 'pageIndex', 0);
- const [canModifyCkey, setModifyCkey] = useLocalState(context, 'canModifyCkey', false);
- // const PageComponent = PAGES[pageIndex].component();
- const [tab, setTab] = useLocalState(context, 'tab', 0);
+ const PageComponent = PAGES[pageIndex].component();
+
const { mob_name, mob_type, client_key, client_ckey, client_rank,
playtimes_enabled, playtime } = data;
@@ -145,7 +153,7 @@ export const PlayerPanel2 = (props, context) => {
- {/* {PAGES.map((page, i) => {
+ {PAGES.map((page, i) => {
if (page.canAccess && !page.canAccess(data)) {
return;
}
@@ -160,51 +168,13 @@ export const PlayerPanel2 = (props, context) => {
{page.title}
);
- })} */}
- setTab(0)}>
- Tab title
-
- setTab(1)}>
- Tab title
-
- setTab(2)}>
- Tab title
-
+ })}
-
-
-
- {tab === 0 && (
-
- )}
- {tab === 1 && (
-
- )}
- {tab === 2 && (
-
- )}
- {/* */}
+
+
@@ -214,34 +184,23 @@ export const PlayerPanel2 = (props, context) => {
const Jobbans = (props, context) => {
const { act, data } = useBackend(context);
- const [tab2, setTab2] = useLocalState(context, 'tab2', 0);
- const { client_key, is_type_mob_living } = data;
+ const [jobbanTab, setJobbanTab] = useLocalState(context, 'jobbanTab', 0);
+ const { client_key, is_type_mob_living, roles } = data;
return (
- setTab2(0)}>
- Tab title
-
- setTab2(1)}>
- Tab title
-
- setTab2(2)}>
- Tab title
-
+ {roles.map((role_category, i) => { return (
+ setJobbanTab(i)}>
+ {role_category.category_name}
+
+ ); })}
@@ -255,42 +214,87 @@ const Jobbans = (props, context) => {
const Joban2 = (props, context) => {
const { act, data } = useBackend(context);
-
- const { client_key, is_type_mob_living } = data;
+ const [jobbanTab] = useLocalState(context, 'jobbanTab', 0);
+ const { roles, is_antag_banned } = data;
return (
-
-
-