diff --git a/code/__defines/typeids.dm b/code/__defines/typeids.dm
index 53028be294..6ee99f62a0 100644
--- a/code/__defines/typeids.dm
+++ b/code/__defines/typeids.dm
@@ -2,5 +2,5 @@
#define TYPEID_NULL "0"
#define TYPEID_NORMAL_LIST "f"
//helper macros
-#define GET_TYPEID(ref) ( ( (length(ref) <= 10) ? "TYPEID_NULL" : copytext(ref, 4, length(ref)-6) ) )
+#define GET_TYPEID(ref) ( ( (length(ref) <= 10) ? "TYPEID_NULL" : copytext(ref, 4, -7) ) )
#define IS_NORMAL_LIST(L) (GET_TYPEID("\ref[L]") == TYPEID_NORMAL_LIST)
diff --git a/code/__defines/vv.dm b/code/__defines/vv.dm
index 97e3a02e0d..e71d6e2f8f 100644
--- a/code/__defines/vv.dm
+++ b/code/__defines/vv.dm
@@ -27,7 +27,7 @@
#define VV_NORMAL_LIST_NO_EXPAND_THRESHOLD 50
#define VV_SPECIAL_LIST_NO_EXPAND_THRESHOLD 150
-#define IS_VALID_ASSOC_KEY(V) (istext(V) || isdatum(V) || islist(V))
+#define IS_VALID_ASSOC_KEY(V) (!isnum(V))
//Helpers for vv_get_dropdown()
#define VV_DROPDOWN_OPTION(href_key, name) . += ""
@@ -35,6 +35,16 @@
//Helpers for vv_do_topic(list/href_list)
#define IF_VV_OPTION(href_key) if(href_list[href_key])
+// vv_do_list() keys
+#define VV_HK_LIST_ADD "listadd"
+#define VV_HK_LIST_EDIT "listedit"
+#define VV_HK_LIST_CHANGE "listchange"
+#define VV_HK_LIST_REMOVE "listremove"
+#define VV_HK_LIST_ERASE_NULLS "listnulls"
+#define VV_HK_LIST_ERASE_DUPES "listdupes"
+#define VV_HK_LIST_SHUFFLE "listshuffle"
+#define VV_HK_LIST_SET_LENGTH "listlen"
+
// /datum
#define VV_HK_DELETE "delete"
#define VV_HK_EXPOSE "expose"
diff --git a/code/modules/admin/view_variables/debug_variables.dm b/code/modules/admin/view_variables/debug_variables.dm
index bcf097f813..97ce67e61b 100644
--- a/code/modules/admin/view_variables/debug_variables.dm
+++ b/code/modules/admin/view_variables/debug_variables.dm
@@ -8,7 +8,7 @@
name = DA[name] //name is really the index until this line
else
value = DA[name]
- header = "
(E) (C) (-) "
+ header = "(E) (C) (-) "
else
header = "(E) (C) (M) "
else
diff --git a/code/modules/admin/view_variables/modify_variables.dm b/code/modules/admin/view_variables/modify_variables.dm
index 1e3aef04bd..9a999e1a75 100644
--- a/code/modules/admin/view_variables/modify_variables.dm
+++ b/code/modules/admin/view_variables/modify_variables.dm
@@ -97,9 +97,10 @@ GLOBAL_PROTECT(VVpixelmovement)
L += var_value
- switch(alert("Would you like to associate a value with the list entry?",,"Yes","No"))
- if("Yes")
- L[var_value] = mod_list_add_ass(O) //hehe
+ if(IS_VALID_ASSOC_KEY(var_value))
+ switch(alert("Would you like to associate a value with the list entry?",,"Yes","No"))
+ if("Yes")
+ L[var_value] = mod_list_add_ass(O) //hehe
if (O)
if (O.vv_edit_var(objectvar, L) == FALSE)
to_chat(src, "Your edit was rejected by the object.")
@@ -179,12 +180,13 @@ GLOBAL_PROTECT(VVpixelmovement)
if (index == null)
return
var/assoc = 0
- var/prompt = alert(src, "Do you want to edit the key or its assigned value?", "Associated List", "Key", "Assigned Value", "Cancel")
- if (prompt == "Cancel")
- return
- if (prompt == "Assigned Value")
- assoc = 1
- assoc_key = L[index]
+ if(IS_VALID_ASSOC_KEY(L[index]))
+ var/prompt = alert(src, "Do you want to edit the key or its assigned value?", "Associated List", "Key", "Assigned Value", "Cancel")
+ if (prompt == "Cancel")
+ return
+ if (prompt == "Assigned Value")
+ assoc = 1
+ assoc_key = L[index]
var/default
var/variable
var/old_assoc_value //EXPERIMENTAL - Keep old associated value while modifying key, if any
@@ -193,9 +195,10 @@ GLOBAL_PROTECT(VVpixelmovement)
else
variable = L[index]
//EXPERIMENTAL - Keep old associated value while modifying key, if any
- var/found = L[variable]
- if(!isnull(found))
- old_assoc_value = found
+ if(IS_VALID_ASSOC_KEY(variable))
+ var/found = L[variable]
+ if(!isnull(found))
+ old_assoc_value = found
//
default = vv_get_class(objectvar, variable)
diff --git a/code/modules/admin/view_variables/topic.dm b/code/modules/admin/view_variables/topic.dm
index b524ade4b2..43c51e65c6 100644
--- a/code/modules/admin/view_variables/topic.dm
+++ b/code/modules/admin/view_variables/topic.dm
@@ -4,8 +4,10 @@
if((usr.client != src) || !src.holder)
return
var/datum/target = locate(href_list["target"])
- if(target)
+ if(istype(target))
target.vv_do_topic(href_list)
+ else if(islist(target))
+ vv_do_list(target, href_list)
if(href_list["Vars"])
debug_variables(locate(href_list["Vars"]))
@@ -519,6 +521,6 @@
if(href_list["datumrefresh"])
var/datum/DAT = locate(href_list["datumrefresh"])
- if(istype(DAT, /datum) || istype(DAT, /client))
+ if(istype(DAT, /datum) || istype(DAT, /client) || islist(DAT))
debug_variables(DAT)
diff --git a/code/modules/admin/view_variables/topic_list.dm b/code/modules/admin/view_variables/topic_list.dm
new file mode 100644
index 0000000000..c76023ec1f
--- /dev/null
+++ b/code/modules/admin/view_variables/topic_list.dm
@@ -0,0 +1,44 @@
+//LISTS - CAN NOT DO VV_DO_TOPIC BECAUSE LISTS AREN'T DATUMS :(
+/client/proc/vv_do_list(list/target, href_list)
+ if(!check_rights(R_VAREDIT))
+ return
+ var/target_index = text2num(href_list["index"])
+ if(target_index)
+ if(href_list[VV_HK_LIST_EDIT])
+ mod_list(target, null, "list", "contents", target_index, autodetect_class = TRUE)
+ if(href_list[VV_HK_LIST_CHANGE])
+ mod_list(target, null, "list", "contents", target_index, autodetect_class = FALSE)
+ if(href_list[VV_HK_LIST_REMOVE])
+ var/variable = target[target_index]
+ var/prompt = alert("Do you want to remove item number [target_index] from list?", "Confirm", "Yes", "No")
+ if (prompt != "Yes")
+ return
+ target.Cut(target_index, target_index+1)
+ log_world("### ListVarEdit by [src]: /list's contents: REMOVED=[html_encode("[variable]")]")
+ log_admin("[key_name(src)] modified list's contents: REMOVED=[variable]")
+ message_admins("[key_name_admin(src)] modified list's contents: REMOVED=[variable]")
+ if(href_list[VV_HK_LIST_ADD])
+ mod_list_add(target, null, "list", "contents")
+ if(href_list[VV_HK_LIST_ERASE_DUPES])
+ uniqueList_inplace(target)
+ log_world("### ListVarEdit by [src]: /list contents: CLEAR DUPES")
+ log_admin("[key_name(src)] modified list's contents: CLEAR DUPES")
+ message_admins("[key_name_admin(src)] modified list's contents: CLEAR DUPES")
+ if(href_list[VV_HK_LIST_ERASE_NULLS])
+ listclearnulls(target)
+ log_world("### ListVarEdit by [src]: /list contents: CLEAR NULLS")
+ log_admin("[key_name(src)] modified list's contents: CLEAR NULLS")
+ message_admins("[key_name_admin(src)] modified list's contents: CLEAR NULLS")
+ if(href_list[VV_HK_LIST_SET_LENGTH])
+ var/value = vv_get_value(VV_NUM)
+ if (value["class"] != VV_NUM || value["value"] > max(5000, target.len)) //safety - would rather someone not put an extra 0 and erase the server's memory lmao.
+ return
+ target.len = value["value"]
+ log_world("### ListVarEdit by [src]: /list len: [target.len]")
+ log_admin("[key_name(src)] modified list's len: [target.len]")
+ message_admins("[key_name_admin(src)] modified list's len: [target.len]")
+ if(href_list[VV_HK_LIST_SHUFFLE])
+ shuffle_inplace(target)
+ log_world("### ListVarEdit by [src]: /list contents: SHUFFLE")
+ log_admin("[key_name(src)] modified list's contents: SHUFFLE")
+ message_admins("[key_name_admin(src)] modified list's contents: SHUFFLE")
diff --git a/code/modules/admin/view_variables/view_variables.dm b/code/modules/admin/view_variables/view_variables.dm
index efa6f424f1..767d693abd 100644
--- a/code/modules/admin/view_variables/view_variables.dm
+++ b/code/modules/admin/view_variables/view_variables.dm
@@ -55,12 +55,12 @@
if (islist)
dropdownoptions = list(
"---",
- "Add Item" = "?_src_=vars;listadd=[refid]",
- "Remove Nulls" = "?_src_=vars;listnulls=[refid]",
- "Remove Dupes" = "?_src_=vars;listdupes=[refid]",
- "Set len" = "?_src_=vars;listlen=[refid]",
- "Shuffle" = "?_src_=vars;listshuffle=[refid]",
- "Show VV To Player" = "?_src_=vars;expose=[refid]"
+ "Add Item" = "?_src_=vars;[VV_HK_LIST_ADD]=TRUE;target=[refid]",
+ "Remove Nulls" = "?_src_=vars;[VV_HK_LIST_ERASE_NULLS]=TRUE;target=[refid]",
+ "Remove Dupes" = "?_src_=vars;[VV_HK_LIST_ERASE_DUPES]=TRUE;target=[refid]",
+ "Set len" = "?_src_=vars;[VV_HK_LIST_SET_LENGTH]=TRUE;target=[refid]",
+ "Shuffle" = "?_src_=vars;[VV_HK_LIST_SHUFFLE]=TRUE;target=[refid]",
+ // "Show VV To Player" = "?_src_=vars;[VV_HK_EXPOSE]=TRUE;target=[refid]" // TODO - Not yet implemented for lists
)
autoconvert_dropdown = TRUE
else
@@ -88,7 +88,7 @@
for (var/i in 1 to L.len)
var/key = L[i]
var/value
- if (IS_NORMAL_LIST(L) && !isnum(key))
+ if (IS_NORMAL_LIST(L) && IS_VALID_ASSOC_KEY(key))
value = L[key]
variable_html += debug_variable(i, value, 0, D)
else
diff --git a/vorestation.dme b/vorestation.dme
index aa692ba28d..d14ea1af2a 100644
--- a/vorestation.dme
+++ b/vorestation.dme
@@ -1588,6 +1588,7 @@
#include "code\modules\admin\view_variables\mass_edit_variables.dm"
#include "code\modules\admin\view_variables\modify_variables.dm"
#include "code\modules\admin\view_variables\topic.dm"
+#include "code\modules\admin\view_variables\topic_list.dm"
#include "code\modules\admin\view_variables\view_variables.dm"
#include "code\modules\ai\_defines.dm"
#include "code\modules\ai\ai_holder.dm"