refactors suit storage allowed + new vv bitfield system (#7381)

This commit is contained in:
silicons
2025-11-04 10:19:15 +01:00
committed by GitHub
parent 5f16804ab2
commit 8402a432dc
170 changed files with 448 additions and 680 deletions
+4 -1
View File
@@ -15,7 +15,10 @@
switch(alert("Proc owned by something?",,"Yes","No"))
if("Yes")
targetselected = TRUE
var/list/value = vv_get_value(default_class = VV_ATOM_REFERENCE, classes = list(VV_ATOM_REFERENCE, VV_DATUM_REFERENCE, VV_MOB_REFERENCE, VV_CLIENT, VV_MARKED_DATUM, VV_TEXT_LOCATE, VV_PROCCALL_RETVAL))
var/list/value = vv_get_value(
default_class = VV_ATOM_REFERENCE,
classes = list(VV_ATOM_REFERENCE, VV_DATUM_REFERENCE, VV_MOB_REFERENCE, VV_CLIENT, VV_MARKED_DATUM, VV_TEXT_LOCATE, VV_PROCCALL_RETVAL),
)
if (!value["class"] || !value["value"])
return
target = value["value"]
@@ -16,6 +16,7 @@
header = "<li>"
var/item
var/datum/bitfield/maybe_bitfield
if (isnull(value))
item = "[VV_HTML_ENCODE(name)] = <span class='value'>null</span>"
@@ -70,12 +71,13 @@
else
item = "<a href='?_src_=vars;[HrefToken()];Vars=[REF(value)]'>[VV_HTML_ENCODE(name)] = /list ([L.len])</a>"
else if (name in GLOB.bitfields)
else if ((maybe_bitfield = fetch_bitfield(D?.type, name)))
var/list/flags = list()
for (var/i in GLOB.bitfields[name])
if (value & GLOB.bitfields[name][i])
flags += i
item = "[VV_HTML_ENCODE(name)] = [VV_HTML_ENCODE(jointext(flags, ", "))]"
for(var/i in 1 to maybe_bitfield.get_declared_count())
var/bit = maybe_bitfield.bits[i]
if(value & bit)
flags += maybe_bitfield.names[i]
item = "[VV_HTML_ENCODE(name)] = [jointext(flags, ", ")]"
else
item = "[VV_HTML_ENCODE(name)] = <span class='value'>[VV_HTML_ENCODE(value)]</span>"
@@ -1,9 +1,9 @@
/proc/vv_get_class(var_name, var_value)
/proc/vv_get_class(var_name, var_value, datum/target)
if(isnull(var_value))
. = VV_NULL
else if(isnum(var_value))
if(var_name in GLOB.bitfields)
if(fetch_bitfield(target?.type, var_name))
. = VV_BITFIELD
else
. = VV_NUM
@@ -39,13 +39,15 @@
else if(islist(var_value))
. = VV_LIST
else if(isalist(var_value))
. = VV_ALIST
else if(isfile(var_value))
. = VV_FILE
else
. = VV_NULL
/client/proc/vv_get_value(class, default_class, current_value, list/restricted_classes, list/extra_classes, list/classes, var_name)
/client/proc/vv_get_value(class, default_class, current_value, list/restricted_classes, list/extra_classes, list/classes, var_name, datum/maybe_datum)
. = list("class" = class, "value" = null)
if(!class)
if(!classes)
@@ -66,6 +68,7 @@
VV_NEW_DATUM,
VV_NEW_TYPE,
VV_NEW_LIST,
VV_NEW_ALIST,
VV_NULL,
VV_RESTORE_DEFAULT,
VV_TEXT_LOCATE,
@@ -83,6 +86,9 @@
if(extra_classes)
classes += extra_classes
if(!maybe_datum)
classes -= VV_BITFIELD
.["class"] = input(src, "What kind of data?", "Variable Type", default_class) as null|anything in classes
if(holder && holder.marked_datum && .["class"] == markstring)
.["class"] = VV_MARKED_DATUM
@@ -98,32 +104,26 @@
if(.["value"] == null)
.["class"] = null
return
if(VV_NUM)
.["value"] = input("Enter new number:", "Num", current_value) as null|num
if(.["value"] == null)
.["class"] = null
return
if(VV_BITFIELD)
.["value"] = input_bitfield(usr, "Editing bitfield: [var_name]", var_name, current_value)
.["value"] = input_bitfield(usr, "Editing bitfield: [var_name]", fetch_bitfield(maybe_datum?.type, var_name), current_value)
if(.["value"] == null)
.["class"] = null
return
if(VV_ATOM_TYPE)
.["value"] = pick_closest_path(FALSE)
if(.["value"] == null)
.["class"] = null
return
if(VV_DATUM_TYPE)
.["value"] = pick_closest_path(FALSE, get_fancy_list_of_datum_types())
if(.["value"] == null)
.["class"] = null
return
if(VV_TYPE)
var/type = current_value
var/error = ""
@@ -253,6 +253,10 @@
.["value"] = list()
.["type"] = /list
if(VV_NEW_ALIST)
.["value"] = alist()
.["type"] = /alist
if(VV_TEXT_LOCATE)
var/datum/D
do
@@ -53,7 +53,7 @@
if (prompt != "Continue")
return
default = vv_get_class(variable, var_value)
default = vv_get_class(variable, var_value, O)
if(isnull(default))
to_chat(src, "Unable to determine variable type.")
@@ -77,7 +77,7 @@
if(dir_text)
to_chat(src, "If a direction, direction is: [dir_text]")
var/value = vv_get_value(default_class = default)
var/value = vv_get_value(default_class = default, maybe_datum = O)
var/new_value = value["value"]
var/class = value["class"]
@@ -231,7 +231,7 @@ GLOBAL_PROTECT(VVpixelmovement)
if (default == VV_TEXT)
default = VV_MESSAGE
class = default
var/list/LL = vv_get_value(default_class = default, current_value = original_var, restricted_classes = list(VV_RESTORE_DEFAULT), extra_classes = list(VV_LIST, "DELETE FROM LIST"))
var/list/LL = vv_get_value(default_class = default, current_value = original_var, restricted_classes = list(VV_RESTORE_DEFAULT), extra_classes = list(VV_LIST, VV_ALIST, "DELETE FROM LIST"))
class = LL["class"]
if (!class)
return
@@ -243,6 +243,8 @@ GLOBAL_PROTECT(VVpixelmovement)
switch(class) //Spits a runtime error if you try to modify an entry in the contents list. Dunno how to fix it, yet.
if(VV_LIST)
mod_list(variable, O, original_name, objectvar)
if(VV_ALIST)
mod_list(variable, O, original_name, objectvar)
if("DELETE FROM LIST")
L.Cut(index, index+1)
@@ -320,7 +322,7 @@ GLOBAL_PROTECT(VVpixelmovement)
if(!vv_varname_lockcheck(variable))
return
var/default = vv_get_class(variable, var_value)
var/default = vv_get_class(variable, var_value, O)
if(isnull(default))
to_chat(src, "Unable to determine variable type.")
@@ -349,7 +351,14 @@ GLOBAL_PROTECT(VVpixelmovement)
default = VV_MESSAGE
class = default
var/list/value = vv_get_value(class, default, var_value, extra_classes = list(VV_LIST), var_name = variable)
var/list/value = vv_get_value(
class,
default,
var_value,
extra_classes = list(VV_LIST, VV_ALIST),
var_name = variable,
maybe_datum = O
)
class = value["class"]
if (!class)
@@ -362,10 +371,13 @@ GLOBAL_PROTECT(VVpixelmovement)
var/original_name = "[O]"
switch(class)
if(VV_ALIST)
if(!isalist(var_value))
mod_list(alist(), O, original_name, variable)
mod_list(var_value, O, original_name, variable)
if(VV_LIST)
if(!islist(var_value))
mod_list(list(), O, original_name, variable)
mod_list(var_value, O, original_name, variable)
return