From c1f85434873123e6d649b027386bb80f2ebeb89b Mon Sep 17 00:00:00 2001 From: MrStonedOne Date: Tue, 29 Nov 2016 14:04:10 -0800 Subject: [PATCH] Adds some dropdown options to lists I was gonna make it so you could mark lists, but too much code assumed they had a .type and adding the proper istypes to them was too bloaty. --- code/datums/datumvars.dm | 65 ++++++++++++++++++++- code/modules/admin/verbs/massmodvar.dm | 2 +- code/modules/admin/verbs/modifyvariables.dm | 12 ++-- 3 files changed, 72 insertions(+), 7 deletions(-) diff --git a/code/datums/datumvars.dm b/code/datums/datumvars.dm index 3d62b69738f..129f8878d47 100644 --- a/code/datums/datumvars.dm +++ b/code/datums/datumvars.dm @@ -114,7 +114,16 @@ varedited_line = "
Var Edited" var/list/dropdownoptions = list() - if (!islist) + 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;listshuttle=[refid]" + ) + else dropdownoptions = D.vv_get_dropdown() var/list/dropdownoptions_html = list() @@ -616,6 +625,60 @@ log_admin("[key_name(src)] modified list's contents: REMOVED=[variable]") message_admins("[key_name_admin(src)] modified list's contents: REMOVED=[variable]") + else if(href_list["listadd"]) + var/list/L = locate(href_list["listadd"]) + if (!istype(L)) + usr << "This can only be used on instances of type /list" + return + + mod_list_add(L, null, "list", "contents") + + else if(href_list["listdupes"]) + var/list/L = locate(href_list["listdupes"]) + if (!istype(L)) + usr << "This can only be used on instances of type /list" + return + + L = uniqueList(L) + world.log << "### 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") + + else if(href_list["listnulls"]) + var/list/L = locate(href_list["listnulls"]) + if (!istype(L)) + usr << "This can only be used on instances of type /list" + return + + listclearnulls(L) + world.log << "### 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") + + else if(href_list["listlen"]) + var/list/L = locate(href_list["listlen"]) + if (!istype(L)) + usr << "This can only be used on instances of type /list" + return + var/value = vv_get_value(VV_NUM) + if (value["class"] != VV_NUM) + return + + L.len = value["value"] + world.log << "### ListVarEdit by [src]: /list len: [L.len]" + log_admin("[key_name(src)] modified list's len: [L.len]") + message_admins("[key_name_admin(src)] modified list's len: [L.len]") + + else if(href_list["listshuffle"]) + var/list/L = locate(href_list["listshuffle"]) + if (!istype(L)) + usr << "This can only be used on instances of type /list" + return + + L = shuffle(L) + world.log << "### 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") else if(href_list["give_spell"]) if(!check_rights(0)) diff --git a/code/modules/admin/verbs/massmodvar.dm b/code/modules/admin/verbs/massmodvar.dm index 5da63bc8d3a..7ac21e52477 100644 --- a/code/modules/admin/verbs/massmodvar.dm +++ b/code/modules/admin/verbs/massmodvar.dm @@ -49,7 +49,7 @@ if(variable in VVpixelmovement) if(!check_rights(R_DEBUG)) return - var/prompt = alert(src, "Editing this var may irreparably break tile gliding for the rest of the round. THIS CAN'T BE UNDONE", "DANGER", "ABORT", "Continue", "ABORT") + var/prompt = alert(src, "Editing this var may irreparably break tile gliding for the rest of the round. THIS CAN'T BE UNDONE", "DANGER", "ABORT ", "Continue", " ABORT") if (prompt != "Continue") return diff --git a/code/modules/admin/verbs/modifyvariables.dm b/code/modules/admin/verbs/modifyvariables.dm index 2fbc9bf1d3d..7bd80561c2c 100644 --- a/code/modules/admin/verbs/modifyvariables.dm +++ b/code/modules/admin/verbs/modifyvariables.dm @@ -325,14 +325,16 @@ var/list/VVpixelmovement = list("step_x", "step_y", "bound_height", "bound_width for(var/V in varsvars) var_value = replacetext(var_value,"\[[V]]","[O.vars[V]]") - var/list/newlist = L.Copy() - newlist += var_value + if (O) + L = L.Copy() + + L += var_value switch(alert("Would you like to associate a value with the list entry?",,"Yes","No")) if("Yes") - newlist[var_value] = mod_list_add_ass(O) //hehe + L[var_value] = mod_list_add_ass(O) //hehe if (O) - if (O.vv_edit_var(objectvar, newlist) == FALSE) + if (O.vv_edit_var(objectvar, L) == FALSE) src << "Your edit was rejected by the object." return world.log << "### ListVarEdit by [src]: [(O ? O.type : "/list")] [objectvar]: ADDED=[var_value]" @@ -537,7 +539,7 @@ var/list/VVpixelmovement = list("step_x", "step_y", "bound_height", "bound_width if(variable in VVpixelmovement) if(!check_rights(R_DEBUG)) return - var/prompt = alert(src, "Editing this var may irreparably break tile gliding for the rest of the round. THIS CAN'T BE UNDONE", "DANGER", "ABORT", "Continue", "ABORT") + var/prompt = alert(src, "Editing this var may irreparably break tile gliding for the rest of the round. THIS CAN'T BE UNDONE", "DANGER", "ABORT ", "Continue", " ABORT") if (prompt != "Continue") return