From 9c3f9101cb2346100fe46dc31d4427fe780b596f Mon Sep 17 00:00:00 2001 From: san7890 Date: Sat, 2 Jul 2022 01:38:15 -0600 Subject: [PATCH] Adds Preferences To Suppress Ghost Role Rolls (#68102) Hey there, Ever since November of 2021, I've wanted something where I could simply not get any ghost roles while adminned. Some people also do not want to get any ghost rolls whatsoever when they play, for it is their personal preference. This PR seeks to resolve both of these issues with two new preferences. The first preference will show up to everyone, Suppress All Ghost Rolls. It will return on the main proc that pops up the window, does the sound, all that. You will not hear a peep of a word out of your game. This is dangerous if you like playing as ghost roles, but if you abhor the thought of it... it's just for you. The second preference is for admins. You can selectively suppress ghost roles while adminned. This is useful because when you're running an event or doing stuff where you need to offer multiple ghost roles (or you need to focus on a ticket and someone is spamming Xenobiology mob spawns), this is absolutely perfect for suppressing. Same return as the player option, but it checks to see if you are currently adminned via the client.holder variable. This is just because some admins (i'm some admins) don't want to turn in on just in case they forget to turn it off down the line because they actually play the game (lying). There's probably a much cleaner way to do this code-wise, but I couldn't figure it out. Any help is appreciated. I tested it extensively on my local (even using a guest account), and everything seems to work rather nicely after about an hour of trial-and-error. Why It's Good For The Game Players who want to just alt-tab or maybe chill in deadchat (or have an extreme loathing of ghost roles) can just simply not get any of that. Admins who want to focus on tickets and not have windows pop up to interfere in good administrative work (and be the most annoying thing in the world) can also do that. Everyone is happy. Changelog cl qol: There is now a new preference in Game Preferences, Suppress All Ghost Rolls. If you tick this preference, you will not get a singular window pop-up whenever a Ghost Role is available. Intended for the few who really do need it. admin: Admins get another additional preference where Suppress All Ghost Roles only works while they are currently in an adminned state. They will still get ghost rolls normally when they are in a deadminned state. /cl --- code/__HELPERS/game.dm | 8 ++++++++ code/modules/client/preferences/admin.dm | 12 ++++++++++++ code/modules/client/preferences/ghost.dm | 6 ++++++ .../preferences/features/game_preferences/admin.tsx | 13 +++++++++++++ .../preferences/features/game_preferences/ghost.tsx | 12 ++++++++++++ 5 files changed, 51 insertions(+) diff --git a/code/__HELPERS/game.dm b/code/__HELPERS/game.dm index f655d89511b..feb2736a111 100644 --- a/code/__HELPERS/game.dm +++ b/code/__HELPERS/game.dm @@ -162,6 +162,14 @@ /proc/show_candidate_poll_window(mob/candidate_mob, poll_time, question, list/candidates, ignore_category, time_passed, flashwindow = TRUE) set waitfor = 0 + // Universal opt-out for all players. + if ((!candidate_mob.client.prefs.read_preference(/datum/preference/toggle/ghost_roles))) + return + + // Opt-out for admins whom are currently adminned. + if ((!candidate_mob.client.prefs.read_preference(/datum/preference/toggle/ghost_roles_as_admin)) && candidate_mob.client.holder) + return + SEND_SOUND(candidate_mob, 'sound/misc/notice2.ogg') //Alerting them to their consideration if(flashwindow) window_flash(candidate_mob.client) diff --git a/code/modules/client/preferences/admin.dm b/code/modules/client/preferences/admin.dm index 5d26cff7c69..965116fdff9 100644 --- a/code/modules/client/preferences/admin.dm +++ b/code/modules/client/preferences/admin.dm @@ -50,3 +50,15 @@ return FALSE return is_admin(preferences.parent) + +/// When enabled, prevents any and all ghost role pop-ups WHILE ADMINNED. +/datum/preference/toggle/ghost_roles_as_admin + category = PREFERENCE_CATEGORY_GAME_PREFERENCES + savefile_key = "ghost_roles_as_admin" + savefile_identifier = PREFERENCE_PLAYER + +/datum/preference/toggle/ghost_roles_as_admin/is_accessible(datum/preferences/preferences) + if (!..(preferences)) + return FALSE + + return is_admin(preferences.parent) diff --git a/code/modules/client/preferences/ghost.dm b/code/modules/client/preferences/ghost.dm index ce8e05235ee..ab191873c1b 100644 --- a/code/modules/client/preferences/ghost.dm +++ b/code/modules/client/preferences/ghost.dm @@ -176,3 +176,9 @@ savefile_key = "inquisitive_ghost" savefile_identifier = PREFERENCE_PLAYER category = PREFERENCE_CATEGORY_GAME_PREFERENCES + +/// When enabled, prevents any and all ghost role pop-ups. +/datum/preference/toggle/ghost_roles + category = PREFERENCE_CATEGORY_GAME_PREFERENCES + savefile_key = "ghost_roles" + savefile_identifier = PREFERENCE_PLAYER diff --git a/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/admin.tsx b/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/admin.tsx index a2587849d54..f72caa6c2ac 100644 --- a/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/admin.tsx +++ b/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/admin.tsx @@ -1,4 +1,5 @@ import { CheckboxInput, FeatureColorInput, Feature, FeatureDropdownInput, FeatureToggle } from '../base'; +import { multiline } from 'common/string'; export const asaycolor: Feature = { name: 'Admin chat color', @@ -29,3 +30,15 @@ export const fast_mc_refresh: FeatureToggle = { 'Whether or not the MC tab of the Stat Panel refreshes fast. This is expensive so make sure you need it.', component: CheckboxInput, }; + +export const ghost_roles_as_admin: FeatureToggle = { + name: 'Get ghost roles while adminned', + category: 'ADMIN', + description: multiline` + If you de-select this, you will not get any ghost role pop-ups while + adminned! Every single pop-up WILL never show up for you in an adminned + state. However, this does not suppress notifications when you are + a regular player (deadminned). +`, + component: CheckboxInput, +}; diff --git a/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/ghost.tsx b/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/ghost.tsx index 344146d39f1..e92c08b6bdf 100644 --- a/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/ghost.tsx +++ b/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/ghost.tsx @@ -130,3 +130,15 @@ export const inquisitive_ghost: FeatureToggle = { description: 'Clicking on something as a ghost will examine it.', component: CheckboxInput, }; + +export const ghost_roles: FeatureToggle = { + name: 'Get ghost roles', + category: 'GHOST', + description: multiline` + If you de-select this, you will not get any ghost role pop-ups what-so-ever! + Every single type of these pop-ups WILL be muted for you when you are + ghosted. Very useful for those who find ghost roles or the + pop-ups annoying, use at your own peril. +`, + component: CheckboxInput, +};