From 529e55be05c7fde216aba89f9cb63b749e052a78 Mon Sep 17 00:00:00 2001 From: Charlie Nolan Date: Wed, 29 Jan 2025 05:22:02 -0800 Subject: [PATCH] Proc calls now use vv_get_value, which can get things you click on. (#28172) --- code/__DEFINES/vv.dm | 3 + code/modules/admin/verbs/debug.dm | 55 ++----------------- code/modules/admin/verbs/modifyvariables.dm | 61 +++++++++++++++++++++ 3 files changed, 69 insertions(+), 50 deletions(-) diff --git a/code/__DEFINES/vv.dm b/code/__DEFINES/vv.dm index a0e61765766..a53db2764de 100644 --- a/code/__DEFINES/vv.dm +++ b/code/__DEFINES/vv.dm @@ -21,3 +21,6 @@ #define VV_MARKED_DATUM "Marked Datum" #define VV_BITFIELD "Bitfield" #define VV_REGEX "Regex" +#define VV_VISIBLE_ATOM "Visible Atom" +#define VV_INSIDE_VISIBLE_ATOM "Inside a Visible Atom" +#define VV_VISIBLE_TURF "Visible Turf" diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index 5d1a9a66529..86f792611c5 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -208,57 +208,12 @@ GLOBAL_PROTECT(AdminProcCallSpamPrevention) //this will protect us from a fair few errors ~Carn while(argnum--) - var/class = null - // Make a list with each index containing one variable, to be given to the proc - if(src.holder && src.holder.marked_datum) - class = input("What kind of variable?","Variable Type") in list("text","num","type","reference","reference in range","reference in view", "mob reference","icon","file","client","mob's area","Marked datum ([holder.marked_datum.type])","CANCEL") - if(holder.marked_datum && class == "Marked datum ([holder.marked_datum.type])") - class = "Marked datum" - else - class = input("What kind of variable?","Variable Type") in list("text","num","type","reference","mob reference","reference in range","reference in view","icon","file","client","mob's area","CANCEL") - switch(class) - if("CANCEL") - return null + var/list/value = vv_get_value(restricted_classes = list(VV_RESTORE_DEFAULT)) + var/class = value["class"] + if(!class) + return null - if("text") - lst += clean_input("Enter new text:","Text",null) - - if("num") - lst += input("Enter new number:","Num",0) as num - - if("type") - lst += input("Enter type:","Type") in typesof(/obj,/mob,/area,/turf) - - if("reference") - lst += input("Select reference:","Reference",src) as mob|obj|turf|area in world - - if("reference in range") - lst += input("Select reference in range:", "Reference in range", src) as mob|obj|turf|area in range(view) - - if("reference in view") - lst += input("Select reference in view:", "Reference in view", src) as mob|obj|turf|area in view(view) - - if("mob reference") - lst += input("Select reference:","Reference",usr) as mob in world - - if("file") - lst += input("Pick file:","File") as file - - if("icon") - lst += input("Pick icon:","Icon") as icon - - if("client") - var/list/keys = list() - for(var/mob/M in world) - keys += M.client - lst += input("Please, select a player!", "Selection", null, null) as null|anything in keys - - if("mob's area") - var/mob/temp = input("Select mob", "Selection", usr) as mob in world - lst += temp.loc - - if("Marked datum") - lst += holder.marked_datum + lst += value["value"] return lst /client/proc/Cell() diff --git a/code/modules/admin/verbs/modifyvariables.dm b/code/modules/admin/verbs/modifyvariables.dm index e4bbb76dddc..7ea49e42e10 100644 --- a/code/modules/admin/verbs/modifyvariables.dm +++ b/code/modules/admin/verbs/modifyvariables.dm @@ -87,6 +87,9 @@ GLOBAL_PROTECT(VVmaint_only) VV_NEW_DATUM, VV_NEW_TYPE, VV_NEW_LIST, + VV_VISIBLE_ATOM, + VV_INSIDE_VISIBLE_ATOM, + VV_VISIBLE_TURF, VV_NULL, VV_RESTORE_DEFAULT ) @@ -211,6 +214,45 @@ GLOBAL_PROTECT(VVmaint_only) .["value"] = things[value] + if(VV_VISIBLE_ATOM) + var/atom/clicked = prompt_for_atom_click("Click an atom.") + if(!clicked) + .["class"] = null + return + .["value"] = clicked + if(VV_INSIDE_VISIBLE_ATOM) + var/atom/clicked = prompt_for_atom_click("Click an atom to search inside.") + if(!clicked) + .["class"] = null + return + + // Collect everything inside the atom. + var/list/ancestors = list(clicked) + var/list/descendants = list() + while(length(ancestors) > 0 && length(descendants) < 100) + var/atom/ancestor = ancestors[length(ancestors)] + ancestors.len-- + for(var/atom/child in ancestor) + ancestors += child + descendants += child + + // Prompt for which to pick. + var/descendant = input("Pick an atom:", "Inside a Visible Atom", src) in descendants + if(!descendant) + .["class"] = null + return + .["value"] = descendant + if(VV_VISIBLE_TURF) + var/atom/clicked = prompt_for_atom_click("Pick a turf (or any atom on it).") + if(!clicked) + .["class"] = null + return + var/turf/where = get_turf(clicked) + if(!where) + .["class"] = null + return + .["value"] = where + if(VV_CLIENT) .["value"] = input("Select reference:", "Reference", current_value) as null|anything in GLOB.clients @@ -557,6 +599,25 @@ GLOBAL_PROTECT(VVmaint_only) return TRUE +/datum/click_intercept/pick_atom + var/picked = null + +/datum/click_intercept/pick_atom/InterceptClickOn(user, params, atom/object) + picked = object + +/client/proc/prompt_for_atom_click(prompt = "Click something!") + to_chat(src, "[prompt]") + var/datum/click_intercept/pick_atom/picker = new() + click_intercept = picker + while(isnull(picker.picked)) + if(isnull(src) || click_intercept != picker) + return null + sleep(1) + + click_intercept = null + return picker.picked + + /client/proc/modify_variables(atom/O, param_var_name = null, autodetect_class = 0) if(!check_rights(R_VAREDIT)) return