Who & Adminwho improvements (#15855)

* Who & Adminwho improvements

* Mochi tweaks

* Sabre tweaks
This commit is contained in:
AffectedArc07
2021-05-04 21:43:05 -04:00
committed by GitHub
parent f3fe73501d
commit 281c72fbcc
7 changed files with 168 additions and 48 deletions
+19
View File
@@ -652,3 +652,22 @@
// return the split html object to the caller
return s
/**
* Proc to generate a "rank colour" from a client
*
* This takes the client and looks at various factors in order, such as patreon status, staff rank, and more
* Arguments:
* * C - The client were looking up
*/
/proc/client2rankcolour(client/C)
// First check if end user is an admin
if(C.holder)
if(C.holder.rank in GLOB.rank_colour_map)
// Return their rank colour if they are in here
return GLOB.rank_colour_map[C.holder.rank]
// If they arent an admin, see if they are a patreon. Just accept any level
if(C.donator_level)
return "#e67e22" // Patreon orange
return null
+3
View File
@@ -54,4 +54,7 @@ GLOBAL_LIST_INIT(cooking_recipes, list(RECIPE_MICROWAVE = list(), RECIPE_OVEN =
GLOBAL_LIST_INIT(cooking_ingredients, list(RECIPE_MICROWAVE = list(), RECIPE_OVEN = list(), RECIPE_GRILL = list(), RECIPE_CANDY = list()))
GLOBAL_LIST_INIT(cooking_reagents, list(RECIPE_MICROWAVE = list(), RECIPE_OVEN = list(), RECIPE_GRILL = list(), RECIPE_CANDY = list()))
/// Associative list of admin rank to colour. Set in config/rank_colours.txt
GLOBAL_LIST_EMPTY(rank_colour_map)
#define EGG_LAYING_MESSAGES list("lays an egg.", "squats down and croons.", "begins making a huge racket.", "begins clucking raucously.")
+31
View File
@@ -925,3 +925,34 @@
runnable_modes[M] = probabilities[M.config_tag]
// to_chat(world, "DEBUG: runnable_mode\[[runnable_modes.len]\] = [M.config_tag]")
return runnable_modes
/datum/configuration/proc/load_rank_colour_map()
var/list/lines = file2list("config/rank_colours.txt")
for(var/line in lines)
// Skip newlines
if(!length(line))
continue
// Skip comments
if(line[1] == "#")
continue
//Split the line at every " - "
var/list/split_holder = splittext(line, " - ")
if(!length(split_holder))
continue
// Rank is before the " - "
var/rank = split_holder[1]
if(!rank)
continue
// Color is after the " - "
var/colour = ""
if(length(split_holder) >= 2)
colour = split_holder[2]
if(rank && colour)
GLOB.rank_colour_map[rank] = colour
else
stack_trace("Invalid colour for rank '[rank]' in config/rank_colours.txt")
+101 -48
View File
@@ -1,63 +1,98 @@
/client/verb/who()
set name = "Who"
set category = "OOC"
var/msg = "<b>Current Players:</b>\n"
var/list/lines = list()
var/list/temp = list()
for(var/client/C in GLOB.clients)
if(C.holder && C.holder.big_brother) // BB doesn't show up at all
continue
if(C.holder && C.holder.fakekey)
temp += C.holder.fakekey
else
temp += C.key
temp = sortList(temp) // Sort it. We dont do this above because fake keys would be out of order, which would be a giveaway
var/list/output_players = list()
// Now go over it again to apply colours.
for(var/p in temp)
var/client/C = GLOB.directory[ckey(p)]
if(!C)
// This should NEVER happen, but better to be safe
continue
// Get the colour
var/colour = client2rankcolour(C)
var/out = "[p]"
if(C.holder)
out = "<b>[out]</b>"
if(colour)
out = "<font color='[colour]'>[out]</font>"
output_players += out
lines += "<b>Current Players ([length(output_players)]): </b>"
lines += output_players.Join(", ") // Turn players into a comma separated list
if(check_rights(R_ADMIN, FALSE))
lines += "Click <a href='?_src_=holder;who_advanced=1'>here</a> for detailed (old) who."
var/msg = lines.Join("\n")
to_chat(src, msg)
// Advanced version of `who` to show player age, antag status and more. Lags the chat when loading, so its in its own proc
/client/proc/who_advanced()
if(!check_rights(R_ADMIN))
return
var/list/Lines = list()
if(check_rights(R_ADMIN,0))
for(var/client/C in GLOB.clients)
if(C.holder && C.holder.big_brother && !check_rights(R_PERMISSIONS, 0)) // need PERMISSIONS to see BB
continue
for(var/client/C in GLOB.clients)
if(C.holder && C.holder.big_brother && !check_rights(R_PERMISSIONS, FALSE)) // need PERMISSIONS to see BB
continue
var/entry = "\t[C.key]"
if(C.holder && C.holder.fakekey)
entry += " <i>(as [C.holder.fakekey])</i>"
entry += " - Playing as [C.mob.real_name]"
switch(C.mob.stat)
if(UNCONSCIOUS)
entry += " - <font color='darkgray'><b>Unconscious</b></font>"
if(DEAD)
if(isobserver(C.mob))
var/mob/dead/observer/O = C.mob
if(O.started_as_observer)
entry += " - <font color='gray'>Observing</font>"
else
entry += " - <font color='black'><b>DEAD</b></font>"
else if(isnewplayer(C.mob))
entry += " - <font color='green'>New Player</font>"
var/entry = "\t[C.key]"
if(C.holder && C.holder.fakekey)
entry += " <i>(as [C.holder.fakekey])</i>"
entry += " - Playing as [C.mob.real_name]"
switch(C.mob.stat)
if(UNCONSCIOUS)
entry += " - <font color='darkgray'><b>Unconscious</b></font>"
if(DEAD)
if(isobserver(C.mob))
var/mob/dead/observer/O = C.mob
if(O.started_as_observer)
entry += " - <font color='gray'>Observing</font>"
else
entry += " - <font color='black'><b>DEAD</b></font>"
else if(isnewplayer(C.mob))
entry += " - <font color='green'>New Player</font>"
else
entry += " - <font color='black'><b>DEAD</b></font>"
var/age
if(isnum(C.player_age))
age = C.player_age
else
age = 0
var/age
if(isnum(C.player_age))
age = C.player_age
else
age = 0
if(age <= 1)
age = "<font color='#ff0000'><b>[age]</b></font>"
else if(age < 10)
age = "<font color='#ff8c00'><b>[age]</b></font>"
if(age <= 1)
age = "<font color='#ff0000'><b>[age]</b></font>"
else if(age < 10)
age = "<font color='#ff8c00'><b>[age]</b></font>"
entry += " - [age]"
entry += " - [age]"
if(is_special_character(C.mob))
entry += " - <b><font color='red'>Antagonist</font></b>"
entry += " ([ADMIN_QUE(C.mob,"?")])"
Lines += entry
else
for(var/client/C in GLOB.clients)
if(C.holder && C.holder.big_brother) // BB doesn't show up at all
continue
if(is_special_character(C.mob))
entry += " - <b><font color='red'>Antagonist</font></b>"
entry += " ([ADMIN_QUE(C.mob, "?")])"
Lines += entry
if(C.holder && C.holder.fakekey)
Lines += C.holder.fakekey
else
Lines += C.key
var/msg = ""
for(var/line in sortList(Lines))
msg += "[line]\n"
@@ -83,7 +118,12 @@
if(C.holder.big_brother && !check_rights(R_PERMISSIONS, 0)) // normal admins can't see BB
continue
msg += "\t[C] is a [C.holder.rank]"
// Their rank may not have a defined colour, only set colour if so
var/rank_colour = client2rankcolour(C)
if(rank_colour)
msg += "<font color='[rank_colour]'><b>[C]</b></font> is a [C.holder.rank]"
else
msg += "<b>[C]</b> is a [C.holder.rank]"
if(C.holder.fakekey)
msg += " <i>(as [C.holder.fakekey])</i>"
@@ -102,7 +142,12 @@
num_admins_online++
else if(check_rights(R_MENTOR|R_MOD, 0, C.mob))
modmsg += "\t[C] is a [C.holder.rank]"
// Their rank may not have a defined colour, only set colour if so
var/rank_colour = client2rankcolour(C)
if(rank_colour)
modmsg += "<font color='[rank_colour]'><b>[C]</b></font> is a [C.holder.rank]"
else
modmsg += "<b>[C]</b> is a [C.holder.rank]"
if(isobserver(C.mob))
modmsg += " - Observing"
@@ -120,10 +165,18 @@
if(check_rights(R_ADMIN, 0, C.mob))
if(!C.holder.fakekey)
msg += "\t[C] is a [C.holder.rank]\n"
var/rank_colour = client2rankcolour(C)
if(rank_colour)
msg += "<font color='[rank_colour]'><b>[C]</b></font> is a [C.holder.rank]"
else
msg += "<b>[C]</b> is a [C.holder.rank]"
num_admins_online++
else if(check_rights(R_MOD|R_MENTOR, 0, C.mob) && !check_rights(R_ADMIN, 0, C.mob))
modmsg += "\t[C] is a [C.holder.rank]\n"
var/rank_colour = client2rankcolour(C)
if(rank_colour)
modmsg += "<font color='[rank_colour]'><b>[C]</b></font> is a [C.holder.rank]"
else
modmsg += "<b>[C]</b> is a [C.holder.rank]"
num_mods_online++
var/noadmins_info = "\n<span class='notice'><small>If no admins or mentors are online, make a ticket anyways. Adminhelps and mentorhelps will be relayed to discord, and staff will still be informed.<small></span>"
+1
View File
@@ -190,6 +190,7 @@ GLOBAL_LIST_EMPTY(world_topic_handlers)
config.load("config/game_options.txt","game_options")
config.loadsql("config/dbconfig.txt")
config.loadoverflowwhitelist("config/ofwhitelist.txt")
config.load_rank_colour_map()
// apply some settings from config..
/world/proc/update_status()
+2
View File
@@ -3556,6 +3556,8 @@
var/datum/browser/popup = new(usr, "view_karma", "Karma stats for [target_ckey]", 600, 300)
popup.set_content(dat)
popup.open(FALSE)
else if(href_list["who_advanced"])
usr.client.who_advanced()
/client/proc/create_eventmob_for(mob/living/carbon/human/H, killthem = 0)
if(!check_rights(R_EVENT))
+11
View File
@@ -0,0 +1,11 @@
# Use this file to denote colours for ingame admin ranks, using the following format
# Rankname - #12A5F4
# Colours dont have to be in hex, since this colour string is thrown into the style -aa
Head of Staff - #e74c3c
Maintainer - #992d22
Server Dev - #1abc9c
Community Manager - #e91e63
Game Admin - #238afa
Trial Admin - #7fb6fc
PR Reviewer - #c27c0e
Mentor - #f1c40f