Adds direct support for weakrefs to vv (#64521)

* Adds direct support for weakrefs to vv

* Update code/modules/admin/view_variables/get_variables.dm

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>

* Fine, have a readable name.

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
This commit is contained in:
AnturK
2022-02-02 00:34:43 -05:00
committed by GitHub
co-authored by Mothblocks
parent 51b6fcdd2a
commit c244d6c69a
4 changed files with 37 additions and 0 deletions
@@ -61,6 +61,9 @@
item = "[name_part] = <a href='?_src_=vars;[HrefToken()];Vars=[REF(value)]'>[DV] [DV.type] [REF(value)]</a>"
else
item = "[name_part] = <a href='?_src_=vars;[HrefToken()];Vars=[REF(value)]'>[DV.type] [REF(value)]</a>"
if(istype(value,/datum/weakref))
var/datum/weakref/weakref = value
item += " <a href='?_src_=vars;[HrefToken()];Vars=[REF(weakref.reference)]'>(Resolve)</a>"
else if (islist(value))
var/list/L = value
@@ -28,6 +28,9 @@
else if(istype(var_value, /client))
. = VV_CLIENT
else if(istype(var_value, /datum/weakref))
. = VV_WEAKREF
else if(istype(var_value, /datum))
. = VV_DATUM_REFERENCE
@@ -78,6 +81,7 @@
VV_RESTORE_DEFAULT,
VV_TEXT_LOCATE,
VV_PROCCALL_RETVAL,
VV_WEAKREF,
)
var/markstring
@@ -201,6 +205,19 @@
return
.["value"] = things[value]
if(VV_WEAKREF)
var/type = pick_closest_path(FALSE, get_fancy_list_of_datum_types())
var/subtypes = vv_subtype_prompt(type)
if(subtypes == null)
.["class"] = null
return
var/list/things = vv_reference_list(type, subtypes)
var/value = input("Select reference:", "Reference", current_value) as null|anything in things
if(!value)
.["class"] = null
return
.["value"] = WEAKREF(things[value])
if(VV_CLIENT)
.["value"] = input("Select reference:", "Reference", current_value) as null|anything in GLOB.clients
if(.["value"] == null)