Allows you to mute soundfiles from specific admins (#20576)

* Allows you to mute soundfiles from specific admins

* me no spello

* Wording tweak
This commit is contained in:
AffectedArc07
2023-03-11 19:10:23 +00:00
committed by GitHub
parent 42c807b08a
commit 90e8ec7948
10 changed files with 61 additions and 4 deletions
+10
View File
@@ -26,14 +26,24 @@ GLOBAL_LIST_EMPTY(sounds_cache)
if(alert("Are you sure?\nSong: [S]\nNow you can also play this sound using \"Play Server Sound\".", "Confirmation request" ,"Play", "Cancel") == "Cancel")
return
if(holder.fakekey)
if(alert("Playing this sound will expose your real ckey despite being in stealth mode. You sure?", "Double check" ,"Play", "Cancel") == "Cancel")
return
log_admin("[key_name(src)] played sound [S]")
message_admins("[key_name_admin(src)] played sound [S]", 1)
for(var/mob/M in GLOB.player_list)
if(M.client.prefs.sound & SOUND_MIDI)
if(ckey in M.client.prefs.admin_sound_ckey_ignore)
continue // This player has this admin muted
if(isnewplayer(M) && (M.client.prefs.sound & SOUND_LOBBY))
M.stop_sound_channel(CHANNEL_LOBBYMUSIC)
uploaded_sound.volume = 100 * M.client.prefs.get_channel_volume(CHANNEL_ADMIN)
var/this_uid = M.client.UID()
to_chat(M, "<span class='boldannounce'>[ckey] played <code>[S]</code> (<a href='?src=[this_uid];action=silenceSound'>SILENCE</a>) (<a href='?src=[this_uid];action=muteAdmin&a=[ckey]'>ALWAYS SILENCE THIS ADMIN</a>)</span>")
SEND_SOUND(M, uploaded_sound)
SSblackbox.record_feedback("tally", "admin_verb", 1, "Play Global Sound") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
+12
View File
@@ -172,6 +172,18 @@
switch(href_list["action"])
if("openLink")
src << link(href_list["link"])
return
if("silenceSound")
usr.stop_sound_channel(CHANNEL_ADMIN)
return
if("muteAdmin")
usr.stop_sound_channel(CHANNEL_ADMIN)
prefs.admin_sound_ckey_ignore |= href_list["a"]
to_chat(usr, "You will no longer hear admin playsounds from <code>[href_list["a"]]</code>. To remove them, go to Preferences --&gt; <code>Manage Admin Sound Mutes</code>.")
prefs.save_preferences(src)
return
//fun fact: Topic() acts like a verb and is executed at the end of the tick like other verbs. So we have to queue it if the server is
//overloaded
@@ -27,7 +27,8 @@
ghost_darkness_level,
colourblind_mode,
keybindings,
server_region
server_region,
muted_adminsounds_ckeys
FROM player
WHERE ckey=:ckey"}, list(
"ckey" = C.ckey
@@ -126,6 +126,8 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
var/list/keybindings_overrides = null
/// Player's region override for routing optimisation
var/server_region = null
/// List of admin ckeys this player wont hear sounds from
var/list/admin_sound_ckey_ignore = list()
/datum/preferences/New(client/C, datum/db_query/Q) // Process our query
parent = C
@@ -3,6 +3,7 @@
// Check ../login_processing/10-load_preferences.dm
//general preferences
var/raw_muted_admins
while(query.NextRow())
ooccolor = query.item[1]
UI_style = query.item[2]
@@ -27,6 +28,7 @@
colourblind_mode = query.item[21]
keybindings = init_keybindings(raw = query.item[22])
server_region = query.item[23]
raw_muted_admins = query.item[24]
lastchangelog_2 = lastchangelog // Clone please
@@ -50,6 +52,12 @@
ghost_darkness_level = sanitize_integer(ghost_darkness_level, 0, 255, initial(ghost_darkness_level))
colourblind_mode = sanitize_inlist(colourblind_mode, list(COLOURBLIND_MODE_NONE, COLOURBLIND_MODE_DEUTER, COLOURBLIND_MODE_PROT, COLOURBLIND_MODE_TRIT), COLOURBLIND_MODE_NONE)
if(length(raw_muted_admins))
try
admin_sound_ckey_ignore = json_decode(raw_muted_admins)
catch
admin_sound_ckey_ignore = list() // Invalid JSON, handle safely please
// Sanitize the region
if(!(server_region in GLOB.configuration.system.region_map))
server_region = null // This region doesnt exist anymore
@@ -89,7 +97,8 @@
ghost_darkness_level=:ghost_darkness_level,
colourblind_mode=:colourblind_mode,
keybindings=:keybindings,
server_region=:server_region
server_region=:server_region,
muted_adminsounds_ckeys=:muted_adminsounds_ckeys
WHERE ckey=:ckey"}, list(
// OH GOD THE PARAMETERS
"ooccolour" = ooccolor,
@@ -115,6 +124,7 @@
"keybindings" = json_encode(keybindings_overrides),
"ckey" = C.ckey,
"server_region" = server_region,
"muted_adminsounds_ckeys" = json_encode(admin_sound_ckey_ignore),
))
if(!query.warn_execute())
@@ -373,3 +373,20 @@
prefs.toggles2 ^= PREFTOGGLE_2_DANCE_DISCO
prefs.save_preferences(src)
to_chat(usr, "You will [(prefs.toggles2 & PREFTOGGLE_2_DANCE_DISCO) ? "now" : "no longer"] dance to the radiant dance machine.")
/client/verb/manage_adminsound_mutes()
set name = "Manage Admin Sound Mutes"
set category = "Preferences"
set desc = "Manage admins that you wont hear played audio from"
if(!length(prefs.admin_sound_ckey_ignore))
to_chat(usr, "You have no admins with muted sounds.")
return
var/choice = input(usr, "Select an admin to unmute sounds from.", "Pick an admin") as null|anything in prefs.admin_sound_ckey_ignore
if(!choice)
return
prefs.admin_sound_ckey_ignore -= choice
to_chat(usr, "You will now hear sounds from <code>[choice]</code> again.")
prefs.save_preferences(src)