From 45eb682ee66a46dbb61d4a416b2ab1c2bd3e2898 Mon Sep 17 00:00:00 2001 From: Ryll Ryll <3589655+Ryll-Ryll@users.noreply.github.com> Date: Tue, 21 Dec 2021 17:00:46 -0500 Subject: [PATCH] Adds Datum Tagging for admins (#62982) --- code/__DEFINES/keybinding.dm | 1 + code/__DEFINES/vv.dm | 2 + code/_onclick/click.dm | 15 ++- code/_onclick/observer.dm | 5 +- code/datums/datumvars.dm | 1 + code/datums/keybinding/admin.dm | 14 +++ code/modules/admin/admin_verbs.dm | 2 + code/modules/admin/holder2.dm | 3 + code/modules/admin/tag.dm | 108 ++++++++++++++++++ code/modules/admin/topic.dm | 21 ++++ .../admin/view_variables/get_variables.dm | 20 ++++ .../modules/admin/view_variables/tag_datum.dm | 18 +++ .../admin/view_variables/topic_basic.dm | 2 + tgstation.dme | 2 + 14 files changed, 212 insertions(+), 2 deletions(-) create mode 100644 code/modules/admin/tag.dm create mode 100644 code/modules/admin/view_variables/tag_datum.dm diff --git a/code/__DEFINES/keybinding.dm b/code/__DEFINES/keybinding.dm index eacb3a02714..2fc4f935809 100644 --- a/code/__DEFINES/keybinding.dm +++ b/code/__DEFINES/keybinding.dm @@ -14,6 +14,7 @@ #define COMSIG_KB_ADMIN_INVISIMINTOGGLE_DOWN "keybinding_admin_invisimintoggle_down" #define COMSIG_KB_ADMIN_DEADMIN_DOWN "keybinding_admin_deadmin_down" #define COMSIG_KB_ADMIN_READMIN_DOWN "keybinding_admin_readmin_down" +#define COMSIG_KB_ADMIN_VIEWTAGS_DOWN "keybinding_admin_viewtags_down" //Carbon #define COMSIG_KB_CARBON_HOLDRUNMOVEINTENT_DOWN "keybinding_carbon_holdrunmoveintent_down" diff --git a/code/__DEFINES/vv.dm b/code/__DEFINES/vv.dm index 85d6b5483d4..23da32cc827 100644 --- a/code/__DEFINES/vv.dm +++ b/code/__DEFINES/vv.dm @@ -21,6 +21,7 @@ #define VV_INFINITY "Infinity" #define VV_RESTORE_DEFAULT "Restore to Default" #define VV_MARKED_DATUM "Marked Datum" +#define VV_TAGGED_DATUM "Tagged Datum" #define VV_BITFIELD "Bitfield" #define VV_TEXT_LOCATE "Custom Reference Locate" #define VV_PROCCALL_RETVAL "Return Value of Proccall" @@ -76,6 +77,7 @@ #define VV_HK_EXPOSE "expose" #define VV_HK_CALLPROC "proc_call" #define VV_HK_MARK "mark" +#define VV_HK_TAG "tag" #define VV_HK_ADDCOMPONENT "addcomponent" #define VV_HK_REMOVECOMPONENT "removecomponent" #define VV_HK_MASS_REMOVECOMPONENT "massremovecomponent" diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm index 7295da34a61..cda883bb946 100644 --- a/code/_onclick/click.dm +++ b/code/_onclick/click.dm @@ -90,7 +90,10 @@ ShiftClickOn(A) return if(LAZYACCESS(modifiers, MIDDLE_CLICK)) - MiddleClickOn(A, params) + if(LAZYACCESS(modifiers, CTRL_CLICK)) + CtrlMiddleClickOn(A) + else + MiddleClickOn(A, params) return if(LAZYACCESS(modifiers, ALT_CLICK)) // alt and alt-gr (rightalt) if(LAZYACCESS(modifiers, RIGHT_CLICK)) @@ -381,6 +384,13 @@ return ..() +/mob/proc/CtrlMiddleClickOn(atom/A) + if(check_rights_for(client, R_ADMIN)) + client.toggle_tag_datum(A) + else + A.CtrlClick(src) + return + /** * Alt click * Unused except for AI @@ -414,6 +424,9 @@ return FALSE if(SEND_SIGNAL(src, COMSIG_CLICK_ALT_SECONDARY, user) & COMPONENT_CANCEL_CLICK_ALT_SECONDARY) return + if(isobserver(user) && user.client && check_rights_for(user.client, R_DEBUG)) + user.client.toggle_tag_datum(src) + return /// Use this instead of [/mob/proc/AltClickOn] where you only want turf content listing without additional atom alt-click interaction /atom/proc/AltClickNoInteract(mob/user, atom/A) diff --git a/code/_onclick/observer.dm b/code/_onclick/observer.dm index c54c130ee2d..005e869e32e 100644 --- a/code/_onclick/observer.dm +++ b/code/_onclick/observer.dm @@ -31,7 +31,10 @@ ShiftClickOn(A) return if(LAZYACCESS(modifiers, MIDDLE_CLICK)) - MiddleClickOn(A, params) + if(LAZYACCESS(modifiers, CTRL_CLICK)) + CtrlMiddleClickOn(A) + else + MiddleClickOn(A, params) return if(LAZYACCESS(modifiers, ALT_CLICK)) AltClickNoInteract(src, A) diff --git a/code/datums/datumvars.dm b/code/datums/datumvars.dm index 17f6581ab77..d35c562fc1f 100644 --- a/code/datums/datumvars.dm +++ b/code/datums/datumvars.dm @@ -27,6 +27,7 @@ VV_DROPDOWN_OPTION("", "---") VV_DROPDOWN_OPTION(VV_HK_CALLPROC, "Call Proc") VV_DROPDOWN_OPTION(VV_HK_MARK, "Mark Object") + VV_DROPDOWN_OPTION(VV_HK_TAG, "Tag Datum") VV_DROPDOWN_OPTION(VV_HK_DELETE, "Delete") VV_DROPDOWN_OPTION(VV_HK_EXPOSE, "Show VV To Player") VV_DROPDOWN_OPTION(VV_HK_ADDCOMPONENT, "Add Component/Element") diff --git a/code/datums/keybinding/admin.dm b/code/datums/keybinding/admin.dm index 10d9722eaa8..39fa27f40c3 100644 --- a/code/datums/keybinding/admin.dm +++ b/code/datums/keybinding/admin.dm @@ -130,3 +130,17 @@ return user.readmin() return TRUE + +/datum/keybinding/admin/view_tags + hotkey_keys = list("F9") + name = "view_tags" + full_name = "View Tags" + description = "Open the View-Tags menu" + keybind_signal = COMSIG_KB_ADMIN_VIEWTAGS_DOWN + +/datum/keybinding/admin/view_tags/down(client/user) + . = ..() + if(.) + return + user.holder?.display_tags() + return TRUE diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 529a45a32e5..27c746b392e 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -17,6 +17,7 @@ GLOBAL_PROTECT(admin_verbs_default) /client/proc/cmd_admin_pm_panel, /*admin-pm list*/ /client/proc/stop_sounds, /client/proc/mark_datum_mapview, + /client/proc/tag_datum_mapview, /client/proc/debugstatpanel, /client/proc/fix_air, /*resets air in designated radius to its default atmos composition*/ /client/proc/requests @@ -77,6 +78,7 @@ GLOBAL_PROTECT(admin_verbs_admin) /datum/admins/proc/view_all_sdql_spells, /datum/admins/proc/known_alts_panel, /datum/admins/proc/paintings_manager, + /datum/admins/proc/display_tags, ) GLOBAL_LIST_INIT(admin_verbs_ban, list(/client/proc/unban_panel, /client/proc/ban_panel, /client/proc/stickybanpanel)) GLOBAL_PROTECT(admin_verbs_ban) diff --git a/code/modules/admin/holder2.dm b/code/modules/admin/holder2.dm index d8a1bf0a334..a8172670a0a 100644 --- a/code/modules/admin/holder2.dm +++ b/code/modules/admin/holder2.dm @@ -39,6 +39,9 @@ GLOBAL_PROTECT(href_token) /// Whether or not this user can bypass 2FA var/bypass_2fa = FALSE + /// A lazylist of tagged datums, for quick reference with the View Tags verb + var/list/tagged_datums + /datum/admins/New(datum/admin_rank/R, ckey, force_active = FALSE, protected) if(IsAdminAdvancedProcCall()) var/msg = " has tried to elevate permissions!" diff --git a/code/modules/admin/tag.dm b/code/modules/admin/tag.dm new file mode 100644 index 00000000000..c0c22806636 --- /dev/null +++ b/code/modules/admin/tag.dm @@ -0,0 +1,108 @@ +/** + * Inserts the target_datum into [/datum/admins/var/tagged_datums], for later reference. + * + * Arguments: + * * target_datum - The datum you want to create a tag for + */ +/datum/admins/proc/add_tagged_datum(datum/target_datum) + if(LAZYFIND(tagged_datums, target_datum)) + to_chat(owner, span_warning("[target_datum] is already tagged!")) + return + + LAZYADD(tagged_datums, target_datum) + RegisterSignal(target_datum, COMSIG_PARENT_QDELETING, .proc/handle_tagged_del, override = TRUE) + to_chat(owner, span_notice("[target_datum] has been tagged.")) + +/// Get ahead of the curve with deleting +/datum/admins/proc/handle_tagged_del(datum/source) + SIGNAL_HANDLER + + if(owner) + to_chat(owner, span_boldnotice("Tagged datum [source] ([source.type]) has been deleted.")) + remove_tagged_datum(source, silent = TRUE) + +/** + * Attempts to remove the specified datum from [/datum/admins/var/tagged_datums] if it exists + * + * Arguments: + * * target_datum - The datum you want to remove from the tagged_datums list + * * silent - If TRUE, won't print messages to the owner's chat + */ +/datum/admins/proc/remove_tagged_datum(datum/target_datum, silent=FALSE) + if(!istype(target_datum)) + return + + if(LAZYFIND(tagged_datums, target_datum)) + LAZYREMOVE(tagged_datums, target_datum) + if(!silent) + to_chat(owner, span_notice("[target_datum] has been untagged.")) + else if(!silent) + to_chat(owner, span_warning("[target_datum] was not already tagged.")) + +/// Quick define for readability +#define TAG_DEL(X) "(UNTAG)" +#define TAG_MARK(X) "(MARK)" +#define TAG_SIMPLE_HEALTH(X) "Health: [X.health]" +#define TAG_CARBON_HEALTH(X) "Health: [X.health] (\ + [X.getBruteLoss()] \ + [X.getFireLoss()] \ + [X.getToxLoss()] \ + [X.getOxyLoss()]\ + [X.getCloneLoss() ? " [X.getCloneLoss()]" : ""])" + +/// Display all of the tagged datums +/datum/admins/proc/display_tags() + set category = "Admin.Game" + set name = "View Tags" + + if (!istype(src, /datum/admins)) + src = usr.client.holder + if (!istype(src, /datum/admins)) + to_chat(usr, "Error: you are not an admin!", confidential = TRUE) + return + + var/index = 0 + var/list/dat = list("