diff --git a/code/controllers/subsystem/who.dm b/code/controllers/subsystem/who.dm new file mode 100644 index 000000000000..1264cccdb444 --- /dev/null +++ b/code/controllers/subsystem/who.dm @@ -0,0 +1,325 @@ +SUBSYSTEM_DEF(who) + name = "Who" + flags = SS_NO_INIT|SS_BACKGROUND + runlevels = RUNLEVELS_DEFAULT|RUNLEVEL_LOBBY + wait = 5 SECONDS //smooth update + + //make it global, good for CPU, no per player UI update + var/datum/player_list/who = new + var/datum/player_list/staff/staff_who = new + +/datum/controller/subsystem/who/fire(resumed = TRUE) + who.update_data() + staff_who.update_data() + +//datum +/datum/player_list + var/tgui_name = "Who" + var/tgui_interface_name = "Who" + var/list/mobs_ckey = list() + var/list/list_data = list() + +/datum/player_list/proc/update_data() + var/list/new_list_data = list() + var/list/new_mobs_ckey = list() + var/list/additiona_data = list( + "lobby" = 0, + "admin_observers" = 0, + "observers" = 0, + "yautja" = 0, + "infected_preds" = 0, + "humans" = 0, + "infected_humans" = 0, + "uscm" = 0, + "uscm_marines" = 0, + ) + var/list/mobs_by_faction = list() + new_list_data["additional_info"] = list() + + for(var/client/client in GLOB.clients) + new_list_data["all_clients"]++ + var/list/client_payload = list() + client_payload["ckey"] = "[client.key]" + client_payload["text"] = "[client.key]" + client_payload["ckey_color"] = "white"// change it if want! for byond supporters maybe? (client.player_data?.donator_info.patreon_function_available("ooc_color") ? "#D4AF37" : "white") + var/mob/client_mob = client.mob + new_mobs_ckey[client.key] = client_mob + if(client_mob) + if(istype(client_mob, /mob/new_player)) + client_payload["text"] += " - in Lobby" + additiona_data["lobby"]++ + new_list_data["total_players"] += list(client_payload) + continue + + if(isobserver(client_mob)) + client_payload["text"] += " - Playing as [client_mob.real_name]" + if(CLIENT_IS_STAFF(client)) + additiona_data["admin_observers"]++ + else + additiona_data["observers"]++ + + var/mob/dead/observer/observer = client_mob + if(observer.started_as_observer) + client_payload["color"] += "#808080" + client_payload["text"] += " - Spectating" + else + client_payload["color"] += "#A000D0" + client_payload["text"] += " - DEAD" + + else + client_payload["text"] += " - Playing as [client_mob.real_name]" + + switch(client_mob.stat) + if(UNCONSCIOUS) + client_payload["color"] += "#B0B0B0" + client_payload["text"] += " - Unconscious" + if(DEAD) + client_payload["color"] += "#A000D0" + client_payload["text"] += " - DEAD" + + if(client_mob.stat != DEAD) + if(isxeno(client_mob)) + client_payload["color"] += "#f00" + client_payload["text"] += " - Xenomorph" + + else if(ishuman(client_mob)) + if(client_mob.faction == FACTION_ZOMBIE) + client_payload["color"] += "#2DACB1" + client_payload["text"] += " - Zombie" + else if(client_mob.faction == FACTION_YAUTJA) + client_payload["color"] += "#7ABA19" + client_payload["text"] += " - Yautja" + additiona_data["yautja"]++ + if(client_mob.status_flags & XENO_HOST) + additiona_data["infected_preds"]++ + else + additiona_data["humans"]++ + if(client_mob.status_flags & XENO_HOST) + additiona_data["infected_humans"]++ + if(client_mob.faction == FACTION_MARINE) + additiona_data["uscm"]++ + if(client_mob.job in (ROLES_MARINES)) + additiona_data["uscm_marines"]++ + + mobs_by_faction[client_mob.faction]++ + + new_list_data["total_players"] += list(client_payload) + +// Case - no shit code in UI... backend... + new_list_data["additional_info"] += list(list( + "content" = "in Lobby: [additiona_data["lobby"]]", + "color" = "#777", + "text" = "Player in lobby", + )) + + new_list_data["additional_info"] += list(list( + "content" = "Spectators: [additiona_data["observers"]] Players", + "color" = "#777", + "text" = "Spectating players", + )) + + new_list_data["additional_info"] += list(list( + "content" = "Spectators: [additiona_data["admin_observers"]] Administrators", + "color" = "#777", + "text" = "Spectating administrators", + )) + + new_list_data["additional_info"] += list(list( + "content" = "Humans: [additiona_data["humans"]]", + "color" = "#2C7EFF", + "text" = "Players playing as Human", + )) + + new_list_data["additional_info"] += list(list( + "content" = "Infected Humans: [additiona_data["infected_humans"]]", + "color" = "#F00", + "text" = "Players playing as Infected Human", + )) + + new_list_data["additional_info"] += list(list( + "content" = "USS `Almayer` Personnel: [additiona_data["uscm"]]", + "color" = "#2d199b", + "text" = "Players playing as USS `Almayer` Personnel", + )) + + new_list_data["additional_info"] += list(list( + "content" = "Marines: [additiona_data["uscm_marines"]]", + "color" = "#2d199b", + "text" = "Players playing as Marines", + )) + + new_list_data["additional_info"] += list(list( + "content" = "Yautjes: [additiona_data["yautja"]]", + "color" = "#7ABA19", + "text" = "Players playing as Yautja", + )) + + new_list_data["additional_info"] += list(list( + "content" = "Infected Yautjes: [additiona_data["infected_preds"]])", + "color" = "#7ABA19", + "text" = "Players playing as Infected Yautja", + )) + + for(var/faction_to_get in FACTION_LIST_HUMANOID - FACTION_YAUTJA - FACTION_MARINE) + var/datum/faction/faction = GLOB.faction_datums[faction_to_get] + if(!length(mobs_by_faction[faction_to_get])) + continue + new_list_data["factions"] += list(list( + "content" = "[faction.name]: [length(mobs_by_faction[faction_to_get])]", + "color" = "#43397b",//https://cdn.discordapp.com/attachments/972351753691484260/1125177717751554068/video_2023-03-23_21-38-07.mov + "text" = "",//NO ~~NUKES~~ DESCRIPTIONS? https://cdn.discordapp.com/attachments/800784806383976508/1125146089759195146/trim.13BC96E2-6A10-40AA-B0B1-3D22024D1E8F.mp4 + )) + for(var/faction_to_get in FACTION_LIST_XENOMORPH) + var/datum/hive_status/faction = GLOB.hive_datum[faction_to_get] + if(!length(mobs_by_faction[faction_to_get])) + continue + new_list_data["xenomorphs"] += list(list( + "content" = "[faction.name]: [length(mobs_by_faction[faction_to_get])]", + "color" = faction.color, + "text" = "Queen: [faction.living_xeno_queen ? "Alive" : "Dead"]", + )) + +/* in future... + for(var/faction_to_get in FACTION_LIST_HUMANOID - FACTION_YAUTJA - FACTION_MARINE) + var/datum/faction/faction = GLOB.faction_datum[faction_to_get] + if(!length(faction.totalMobs)) + continue + new_list_data["factions"] += list(list( + "content" = "[faction.name]: [length(faction.totalMobs)]", + "color" = faction.color, + "text" = "[faction.desc]", + )) + for(var/faction_to_get in FACTION_LIST_XENOMORPH) + var/datum/faction/faction = GLOB.faction_datum[faction_to_get] + if(!length(faction.totalMobs)) + continue + new_list_data["xenomorphs"] += list(list( + "content" = "[faction.name]: [length(faction.totalMobs)]", + "color" = faction.color, + "text" = "Queen: [faction.living_xeno_queen ? "Alive" : "Dead"] [faction.desc]", + )) +*/ + + list_data = new_list_data + mobs_ckey = new_mobs_ckey + +/datum/player_list/tgui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, tgui_name, tgui_interface_name) + ui.open() + ui.set_autoupdate(TRUE) + +/datum/player_list/ui_data(mob/user) + . = list_data + +/datum/player_list/ui_static_data(mob/user) + . = list() + + .["admin"] = CLIENT_IS_STAFF(user.client) + +/datum/player_list/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) + . = ..() + if(.) + return + + switch(action) + if("get_player_panel") + admin_datums[usr.client.ckey].show_player_panel(mobs_ckey[params["ckey"]]) + +/datum/player_list/ui_status(mob/user, datum/ui_state/state) + return UI_INTERACTIVE + + +/datum/player_list/staff + tgui_name = "StaffWho" + tgui_interface_name = "Staff Who" + + var/list/category_colors = list( + "Management" = "purple", + "Maintainers" = "blue", + "Administrators" = "red", + "Moderators" = "orange", + "Mentors" = "green" + ) + +/datum/player_list/staff/update_data() + var/list/new_list_data = list() + mobs_ckey = list() + + var/list/listings + var/list/mappings + if(CONFIG_GET(flag/show_manager)) + LAZYSET(mappings, "Management", R_HOST) + if(CONFIG_GET(flag/show_devs)) + LAZYSET(mappings, "Maintainers", R_PROFILER) + LAZYSET(mappings, "Administrators", R_ADMIN) + if(CONFIG_GET(flag/show_mods)) + LAZYSET(mappings, "Moderators", R_MOD && R_BAN) + if(CONFIG_GET(flag/show_mentors)) + LAZYSET(mappings, "Mentors", R_MENTOR) + + for(var/category in mappings) + LAZYSET(listings, category, list()) + + for(var/client/client in GLOB.admins) + if(client.admin_holder?.fakekey && !CLIENT_IS_STAFF(client)) + continue + + for(var/category in mappings) + if(CLIENT_HAS_RIGHTS(client, mappings[category])) + LAZYADD(listings[category], client) + break + + for(var/category in listings) + var/list/admins = list() + for(var/client/entry in listings[category]) + var/list/admin = list() + var/rank = entry.admin_holder.rank + if(entry.admin_holder.extra_titles?.len) + for(var/srank in entry.admin_holder.extra_titles) + rank += " & [srank]" + + admin["content"] = "[entry.key] ([rank])" + admin["text"] = "" + + if(entry.admin_holder?.fakekey) + admin["text"] += " (HIDDEN)" + + if(istype(entry.mob, /mob/dead/observer)) + admin["color"] = "#808080" + admin["text"] += " Spectating" + + else if(istype(entry.mob, /mob/new_player)) + admin["color"] = "#688944" + admin["text"] += " in Lobby" + else + admin["color"] = "#688944" + admin["text"] += " Playing" + + if(entry.is_afk()) + admin["color"] = "#A040D0" + admin["text"] += " (AFK)" + + admins += list(admin) + + new_list_data["administrators"] += list(list( + "category" = category, + "category_color" = category_colors[category], + "category_administrators" = length(listings[category]), + "admins" = admins, + )) + + list_data = new_list_data + +/mob/verb/who() + set category = "OOC" + set name = "Who" + + SSwho.who.tgui_interact(src) + +/mob/verb/staffwho() + set category = "Admin" + set name = "Staff Who" + + SSwho.staff_who.tgui_interact(src) diff --git a/code/game/verbs/who.dm b/code/game/verbs/who.dm deleted file mode 100644 index bb0e53a012cb..000000000000 --- a/code/game/verbs/who.dm +++ /dev/null @@ -1,202 +0,0 @@ -/client/verb/who()//likely don't touch any... this is easy can die. (:troll_fale:) - set name = "Who" - set category = "OOC" - - var/list/counted_humanoids = list( - "Observers" = 0, - "Admin observers" = 0, - "Humans" = 0, - "Infected humans" = 0, - FACTION_MARINE = 0, - "USCM Marines" = 0, - "Lobby" = 0, - - FACTION_YAUTJA = 0, - "Infected preds" = 0, - - FACTION_PMC = 0, - FACTION_CLF = 0, - FACTION_UPP = 0, - FACTION_FREELANCER = 0, - FACTION_SURVIVOR = 0, - FACTION_WY_DEATHSQUAD = 0, - FACTION_COLONIST = 0, - FACTION_MERCENARY = 0, - FACTION_DUTCH = 0, - FACTION_HEFA = 0, - FACTION_GLADIATOR = 0, - FACTION_PIRATE = 0, - FACTION_PIZZA = 0, - FACTION_SOUTO = 0, - - FACTION_NEUTRAL = 0, - - FACTION_ZOMBIE = 0 - ) - - var/list/counted_xenos = list() - - var/players = length(GLOB.clients) - - var/dat = "Current Players:
" - var/list/Lines = list() - if(admin_holder && ((R_ADMIN & admin_holder.rights) || (R_MOD & admin_holder.rights))) - for(var/client/C in GLOB.clients) - var/entry = "[C.key]" - if(C.mob) //Juuuust in case - if(istype(C.mob, /mob/new_player)) - entry += " - In Lobby" - counted_humanoids["Lobby"]++ - else - entry += " - Playing as [C.mob.real_name]" - - if(isobserver(C.mob)) - counted_humanoids["Observers"]++ - if(C.admin_holder?.rights & R_MOD) - counted_humanoids["Admin observers"]++ - counted_humanoids["Observers"]-- - var/mob/dead/observer/O = C.mob - if(O.started_as_observer) - entry += " - Observing" - else - entry += " - DEAD" - else - switch(C.mob.stat) - if(UNCONSCIOUS) - entry += " - Unconscious" - if(DEAD) - entry += " - DEAD" - - if(C.mob && C.mob.stat != DEAD) - if(ishuman(C.mob)) - if(C.mob.faction == FACTION_ZOMBIE) - counted_humanoids[FACTION_ZOMBIE]++ - entry += " - Zombie" - else if(C.mob.faction == FACTION_YAUTJA) - counted_humanoids[FACTION_YAUTJA]++ - entry += " - Predator" - if(C.mob.status_flags & XENO_HOST) - counted_humanoids["Infected preds"]++ - else - counted_humanoids["Humans"]++ - if(C.mob.status_flags & XENO_HOST) - counted_humanoids["Infected humans"]++ - if(C.mob.faction == FACTION_MARINE) - counted_humanoids[FACTION_MARINE]++ - if(C.mob.job in (ROLES_MARINES)) - counted_humanoids["USCM Marines"]++ - else - counted_humanoids[C.mob.faction]++ - else if(isxeno(C.mob)) - var/mob/living/carbon/xenomorph/X = C.mob - counted_xenos[X.hivenumber]++ - if(X.faction == FACTION_PREDALIEN) - counted_xenos[FACTION_PREDALIEN]++ - entry += " - Xenomorph" - entry += " (?)" - Lines += entry - - for(var/line in sortList(Lines)) - dat += "[line]
" - dat += "Total Players: [players]" - dat += "
In Lobby: [counted_humanoids["Lobby"]]" - dat += "
Observers: [counted_humanoids["Observers"]] players and [counted_humanoids["Admin observers"]] staff members" - dat += "
Humans: [counted_humanoids["Humans"]] (Infected: [counted_humanoids["Infected humans"]])" - if(counted_humanoids[FACTION_MARINE]) - dat += "
USCM personnel: [counted_humanoids[FACTION_MARINE]] (Marines: [counted_humanoids["USCM Marines"]])" - if(counted_humanoids[FACTION_YAUTJA]) - dat += "
Predators: [counted_humanoids[FACTION_YAUTJA]] [counted_humanoids["Infected preds"] ? "(Infected: [counted_humanoids["Infected preds"]])" : ""]" - if(counted_humanoids[FACTION_ZOMBIE]) - dat += "
Zombies: [counted_humanoids[FACTION_ZOMBIE]]" - - var/show_fact = TRUE - for(var/i in 10 to LAZYLEN(counted_humanoids) - 2) - if(counted_humanoids[counted_humanoids[i]]) - if(show_fact) - dat += "

Other factions:" - show_fact = FALSE - dat += "
[counted_humanoids[i]]: [counted_humanoids[counted_humanoids[i]]]" - if(counted_humanoids[FACTION_NEUTRAL]) - dat += "
[FACTION_NEUTRAL] Humans: [counted_humanoids[FACTION_NEUTRAL]]" - - show_fact = TRUE - var/datum/hive_status/hive - for(var/hivenumber in counted_xenos) - // Print predalien counts last - if(hivenumber == FACTION_PREDALIEN) - continue - if(show_fact) - dat += "

Xenomorphs:" - show_fact = FALSE - hive = GLOB.hive_datum[hivenumber] - if(hive) - dat += "
[hive.name]: [counted_xenos[hivenumber]] (Queen: [hive.living_xeno_queen ? "Alive" : "Dead"])" - else - dat += "
Error: no hive datum detected for [hivenumber]." - hive = null - if(counted_xenos[FACTION_PREDALIEN]) - dat += "
Predaliens: [counted_xenos[FACTION_PREDALIEN]]" - - else - for(var/client/C in GLOB.clients) - if(C.admin_holder && C.admin_holder.fakekey) - continue - - Lines += C.key - for(var/line in sortList(Lines)) - dat += "[line]
" - dat += "Total Players: [players]
" - - dat += "" - show_browser(usr, dat, "Who", "who", "size=600x800") - - -/client/verb/staffwho() - set name = "Staffwho" - set category = "Admin" - - var/dat = "" - var/list/mappings - if(CONFIG_GET(flag/show_manager)) - LAZYSET(mappings, "Management", R_HOST) - if(CONFIG_GET(flag/show_devs)) - LAZYSET(mappings, "Maintainers", R_PROFILER) - LAZYSET(mappings, "Admins", R_ADMIN) - if(CONFIG_GET(flag/show_mods)) - LAZYSET(mappings, "Moderators", R_MOD) - if(CONFIG_GET(flag/show_mentors)) - LAZYSET(mappings, "Mentors", R_MENTOR) - - var/list/listings - for(var/category in mappings) - LAZYSET(listings, category, list()) - - for(var/client/C in GLOB.admins) - if(C.admin_holder?.fakekey && !CLIENT_IS_STAFF(src)) - continue - for(var/category in mappings) - if(CLIENT_HAS_RIGHTS(C, mappings[category])) - LAZYADD(listings[category], C) - break - - for(var/category in listings) - dat += "
Current [category] ([length(listings[category])]):
\n" - for(var/client/entry in listings[category]) - dat += "\t[entry.key] is a [entry.admin_holder.rank]" - if(entry.admin_holder.extra_titles?.len) - for(var/srank in entry.admin_holder.extra_titles) - dat += " & [srank]" - if(CLIENT_IS_STAFF(src)) - if(entry.admin_holder?.fakekey) - dat += " (HIDDEN)" - if(istype(entry.mob, /mob/dead/observer)) - dat += " - Observing" - else if(istype(entry.mob, /mob/new_player)) - dat += " - Lobby" - else - dat += " - Playing" - if(entry.is_afk()) - dat += " (AFK)" - dat += "
" - dat += "" - show_browser(usr, dat, "Staffwho", "staffwho", "size=600x800") diff --git a/colonialmarines.dme b/colonialmarines.dme index 204c144c8916..d9b99e62ac56 100644 --- a/colonialmarines.dme +++ b/colonialmarines.dme @@ -286,6 +286,7 @@ #include "code\controllers\subsystem\tracking.dm" #include "code\controllers\subsystem\vote.dm" #include "code\controllers\subsystem\weather.dm" +#include "code\controllers\subsystem\who.dm" #include "code\controllers\subsystem\x_evolution.dm" #include "code\controllers\subsystem\xeno.dm" #include "code\controllers\subsystem\xenocon.dm" @@ -1279,7 +1280,6 @@ #include "code\game\verbs\ooc.dm" #include "code\game\verbs\preferences.dm" #include "code\game\verbs\records.dm" -#include "code\game\verbs\who.dm" #include "code\js\byjax.dm" #include "code\js\menus.dm" #include "code\modules\trigger.dm" diff --git a/tgui/packages/tgui/interfaces/StaffWho.js b/tgui/packages/tgui/interfaces/StaffWho.js new file mode 100644 index 000000000000..99f1e4e549c3 --- /dev/null +++ b/tgui/packages/tgui/interfaces/StaffWho.js @@ -0,0 +1,75 @@ +import { useBackend } from '../backend'; +import { Button, Stack, Collapsible } from '../components'; +import { Window } from '../layouts'; + +export const StaffWho = (props, context) => { + const { data } = useBackend(context); + const { admin, administrators } = data; + + return ( + + + {administrators !== undefined && ( + + + {administrators.map((x, index) => ( + + {x.admins.map((x, index) => ( + + ))} + + ))} + + + )} + + + ); +}; + +const StaffWhoCollapsible = (props, context) => { + const { title, color, children } = props; + return ( + + {children} + + ); +}; + +const GetAdminInfo = (props, context) => { + const { admin, content, color, text } = props; + return admin ? ( + + ) : ( + + ); +}; diff --git a/tgui/packages/tgui/interfaces/Who.js b/tgui/packages/tgui/interfaces/Who.js new file mode 100644 index 000000000000..8c694f7151d2 --- /dev/null +++ b/tgui/packages/tgui/interfaces/Who.js @@ -0,0 +1,140 @@ +import { useBackend } from '../backend'; +import { Button, Collapsible, Box, Section, Stack } from '../components'; +import { Window } from '../layouts'; + +export const Who = (props, context) => { + const { act, data } = useBackend(context); + const { + admin, + all_clients, + total_players, + additional_info, + factions, + xenomorphs, + } = data; + + return ( + + + + {total_players !== undefined && ( + +
+ + {total_players.map((x, index) => ( + + ))} + +
+
+ )} + + {admin && ( + +
+ + + {additional_info !== undefined && + additional_info.map((x, index) => ( + + ))} + {factions !== undefined && + factions.map((x, index) => ( + + ))} + {xenomorphs !== undefined && + xenomorphs.map((x, index) => ( + + ))} + + +
+
+ )} +
+
+
+ ); +}; + +const WhoCollapsible = (props, context) => { + const { title, color, children } = props; + return ( + + {children} + + ); +}; + +const GetAddInfo = (props, context) => { + const { act } = useBackend(context); + const { content, color, text } = props; + + return ( + + ); +}; + +const GetPlayerInfo = (props, context) => { + const { act } = useBackend(context); + const { admin, ckey, ckey_color, color, text } = props; + return admin ? ( + + ) : ( + + ); +};