Files
Bubberstation/code/modules/client/verbs/who.dm
SkyratBot b5c01f9342 [MIRROR] Prettifies Adminwho into an Examine Block [MDB IGNORE] (#24514)
* Prettifies Adminwho into an Examine Block (#79137)

## About The Pull Request

Same vein of #71170 (2d3e7f2383) / #69845
(61d49cb11a) in an attempt to lessen the
number of cruddy "system messages" that just print straight text to
chat.

This could be improved CSS wise but I think a standard examine block
helps a lot while maintaing clarity, see below:

![image](https://github.com/tgstation/tgstation/assets/34697715/7c08fac0-bd10-4297-ac82-c85d02d7d792)

I also heavily refactored adminwho code to not have so much copypasta
while using more `jointext()` and keeping everything a bit more readable
than what it previously was. User-facing stuff should all be the same
(with the addition of an examine block) except in two spots

* Custom header message when no admins are online. I think this is a far
clearer message than having `Current Admins:` and then the message about
adminhelps being relayed to Discord
* There's no tabs per each entry. This was replaced by a bullet point. I
think it's better to read.
## Why It's Good For The Game

As time goes on, I'm more and more peeved by these pretty critical
messages constantly blending in with output from the rest of the game.
This is why balloon_alerts and whatever became so popular to my eyes,
there's just constant junk. I figure that we may as well just keep the
systematic stuff that _must_ live in the chat box looking as neat as
possible.
## Changelog
🆑
qol: Adminwho messages are now in an examine block for heightened
clarity.
/🆑

* Prettifies Adminwho into an Examine Block

---------

Co-authored-by: san7890 <the@san7890.com>
2023-10-22 10:24:18 -07:00

173 lines
5.9 KiB
Plaintext

#define DEFAULT_WHO_CELLS_PER_ROW 4
#define NO_ADMINS_ONLINE_MESSAGE "Adminhelps are also sent through TGS to services like IRC and Discord. If no admins are available in game, sending an adminhelp might still be noticed and responded to."
/client/verb/who()
set name = "Who"
set category = "OOC"
var/msg = "<b>Current Players:</b>\n"
var/list/Lines = list()
var/columns_per_row = DEFAULT_WHO_CELLS_PER_ROW
if(holder)
if (check_rights(R_ADMIN,0) && isobserver(src.mob))//If they have +ADMIN and are a ghost they can see players IC names and statuses.
columns_per_row = 1
var/mob/dead/observer/G = src.mob
if(!G.started_as_observer)//If you aghost to do this, KorPhaeron will deadmin you in your sleep.
log_admin("[key_name(usr)] checked advanced who in-round")
for(var/client/client in GLOB.clients)
var/entry = "\t[client.key]"
if(client.holder && client.holder.fakekey)
entry += " <i>(as [client.holder.fakekey])</i>"
if (isnewplayer(client.mob))
entry += " - <font color='darkgray'><b>In Lobby</b></font>"
else
entry += " - Playing as [client.mob.real_name]"
switch(client.mob.stat)
if(UNCONSCIOUS, HARD_CRIT)
entry += " - <font color='darkgray'><b>Unconscious</b></font>"
if(DEAD)
if(isobserver(client.mob))
var/mob/dead/observer/O = client.mob
if(O.started_as_observer)
entry += " - <font color='gray'>Observing</font>"
else
entry += " - <font color='black'><b>DEAD</b></font>"
else
entry += " - <font color='black'><b>DEAD</b></font>"
if(is_special_character(client.mob))
entry += " - <b><font color='red'>Antagonist</font></b>"
entry += " [ADMIN_QUE(client.mob)]"
entry += " ([round(client.avgping, 1)]ms)"
Lines += entry
else//If they don't have +ADMIN, only show hidden admins
for(var/client/client in GLOB.clients)
var/entry = "[client.key]"
if(client.holder && client.holder.fakekey)
entry += " <i>(as [client.holder.fakekey])</i>"
entry += " ([round(client.avgping, 1)]ms)"
Lines += entry
else
for(var/client/client in GLOB.clients)
if(client.holder && client.holder.fakekey)
Lines += "[client.holder.fakekey] ([round(client.avgping, 1)]ms)"
else
Lines += "[client.key] ([round(client.avgping, 1)]ms)"
var/num_lines = 0
msg += "<table style='width: 100%; table-layout: fixed'><tr>"
for(var/line in sort_list(Lines))
msg += "<td>[line]</td>"
num_lines += 1
if (num_lines == columns_per_row)
num_lines = 0
msg += "</tr><tr>"
msg += "</tr></table>"
msg += "<b>Total Players: [length(Lines)]</b>"
to_chat(src, "<span class='infoplain'>[msg]</span>")
/client/verb/adminwho()
set category = "Admin"
set name = "Adminwho"
var/list/lines = list()
var/payload_string = generate_adminwho_string()
var/header
if(payload_string == NO_ADMINS_ONLINE_MESSAGE)
header = "No Admins Currently Online"
else
header = "Current Admins:"
lines += span_bold(header)
lines += payload_string
var/finalized_string = examine_block(jointext(lines, "\n"))
to_chat(src, finalized_string)
/// Proc that generates the applicable string to dispatch to the client for adminwho.
/client/proc/generate_adminwho_string()
var/list/list_of_admins = get_list_of_admins()
if(isnull(list_of_admins))
return NO_ADMINS_ONLINE_MESSAGE
var/list/message_strings = list()
if(isnull(holder))
message_strings += get_general_adminwho_information(list_of_admins)
message_strings += NO_ADMINS_ONLINE_MESSAGE
else
message_strings += get_sensitive_adminwho_information(list_of_admins)
return jointext(message_strings, "\n")
/// Proc that returns a list of cliented admins. Remember that this list can contain nulls!
/// Also, will return null if we don't have any admins.
/proc/get_list_of_admins()
var/returnable_list = list()
for(var/client/admin in GLOB.admins)
returnable_list += admin
if(length(returnable_list) == 0)
return null
return returnable_list
/// Proc that will return the applicable display name, linkified or not, based on the input client reference.
/proc/get_linked_admin_name(client/admin)
var/feedback_link = admin.holder.feedback_link()
return isnull(feedback_link) ? admin : "<a href=[feedback_link]>[admin]</a>"
/// Proc that gathers adminwho information for a general player, which will only give information if an admin isn't AFK, and handles potential fakekeying.
/// Will return a list of strings.
/proc/get_general_adminwho_information(list/checkable_admins)
var/returnable_list = list()
for(var/client/admin in checkable_admins)
if(admin.is_afk() || !isnull(admin.holder.fakekey))
continue //Don't show afk or fakekeyed admins to adminwho
returnable_list += "• [get_linked_admin_name(admin)] is a [admin.holder.rank_names()]"
return returnable_list
/// Proc that gathers adminwho information for admins, which will contain information on if the admin is AFK, readied to join, etc. Only arg is a list of clients to use.
/// Will return a list of strings.
/proc/get_sensitive_adminwho_information(list/checkable_admins)
var/returnable_list = list()
for(var/client/admin in checkable_admins)
var/list/admin_strings = list()
admin_strings += "• [get_linked_admin_name(admin)] is a [admin.holder.rank_names()]"
if(admin.holder.fakekey)
admin_strings += "<i>(as [admin.holder.fakekey])</i>"
if(isobserver(admin.mob))
admin_strings += "- Observing"
else if(isnewplayer(admin.mob))
if(SSticker.current_state <= GAME_STATE_PREGAME)
var/mob/dead/new_player/lobbied_admin = admin.mob
if(lobbied_admin.ready == PLAYER_READY_TO_PLAY)
admin_strings += "- Lobby (Readied)"
else
admin_strings += "- Lobby (Not Readied)"
else
admin_strings += "- Lobby"
else
admin_strings += "- Playing"
if(admin.is_afk())
admin_strings += "(AFK)"
returnable_list += jointext(admin_strings, " ")
return returnable_list
#undef DEFAULT_WHO_CELLS_PER_ROW
#undef NO_ADMINS_ONLINE_MESSAGE