diff --git a/code/__DEFINES/vv.dm b/code/__DEFINES/vv.dm index c5a80da0b00..91dfd3d5e70 100644 --- a/code/__DEFINES/vv.dm +++ b/code/__DEFINES/vv.dm @@ -75,6 +75,8 @@ #define VV_HK_CALLPROC "proc_call" #define VV_HK_MARK "mark" #define VV_HK_ADDCOMPONENT "addcomponent" +#define VV_HK_REMOVECOMPONENT "removecomponent" +#define VV_HK_MASS_REMOVECOMPONENT "massremovecomponent" #define VV_HK_MODIFY_TRAITS "modtraits" // /atom diff --git a/code/datums/datumvars.dm b/code/datums/datumvars.dm index e4f04c7ef68..17f6581ab77 100644 --- a/code/datums/datumvars.dm +++ b/code/datums/datumvars.dm @@ -30,6 +30,8 @@ VV_DROPDOWN_OPTION(VV_HK_DELETE, "Delete") VV_DROPDOWN_OPTION(VV_HK_EXPOSE, "Show VV To Player") VV_DROPDOWN_OPTION(VV_HK_ADDCOMPONENT, "Add Component/Element") + VV_DROPDOWN_OPTION(VV_HK_REMOVECOMPONENT, "Remove Component/Element") + VV_DROPDOWN_OPTION(VV_HK_MASS_REMOVECOMPONENT, "Mass Remove Component/Element") VV_DROPDOWN_OPTION(VV_HK_MODIFY_TRAITS, "Modify Traits") //This proc is only called if everything topic-wise is verified. The only verifications that should happen here is things like permission checks! diff --git a/code/modules/admin/view_variables/topic_basic.dm b/code/modules/admin/view_variables/topic_basic.dm index c1dda17bef7..5753db26a10 100644 --- a/code/modules/admin/view_variables/topic_basic.dm +++ b/code/modules/admin/view_variables/topic_basic.dm @@ -78,6 +78,52 @@ target._AddElement(lst) log_admin("[key_name(usr)] has added [result] [datumname] to [key_name(target)].") message_admins(span_notice("[key_name_admin(usr)] has added [result] [datumname] to [key_name_admin(target)].")) + if(href_list[VV_HK_REMOVECOMPONENT] || href_list[VV_HK_MASS_REMOVECOMPONENT]) + if(!check_rights(NONE)) + return + var/mass_remove = href_list[VV_HK_MASS_REMOVECOMPONENT] + var/list/components = list() + var/all_components_on_target = LAZYACCESS(target.datum_components, /datum/component) + if(islist(all_components_on_target)) + for(var/datum/component/component in LAZYACCESS(target.datum_components, /datum/component)) + components += component.type + else if(all_components_on_target) + var/datum/component/component = all_components_on_target + components += component.type + var/list/names = list() + names += "---Components---" + if(length(components)) + names += sortList(components, /proc/cmp_typepaths_asc) + names += "---Elements---" + // We have to list every element here because there is no way to know what element is on this object without doing some sort of hack. + names += sortList(subtypesof(/datum/element), /proc/cmp_typepaths_asc) + var/path = tgui_input_list(usr, "Choose a component/element to remove. All elements listed here may not be on the datum.", "Remove element", names) + if(!usr || !path || path == "---Components---" || path == "---Elements---") + return + if(QDELETED(src)) + to_chat(usr, "That thing doesn't exist anymore!") + return + var/list/targets_to_remove_from = list(target) + if(mass_remove) + var/method = vv_subtype_prompt(target.type) + targets_to_remove_from = get_all_of_type(target.type, method) + + if(alert(usr, "Are you sure you want to mass-delete [path] on [target.type]?", "Mass Remove Confirmation", "Yes", "No") == "No") + return + + for(var/datum/target_to_remove_from as anything in targets_to_remove_from) + if(ispath(path, /datum/element)) + var/list/lst = get_callproc_args() + if(!lst) + lst = list() + lst.Insert(1, path) + target._RemoveElement(lst) + else + var/list/components_actual = target_to_remove_from.GetComponents(path) + for(var/to_delete in components_actual) + qdel(to_delete) + + message_admins(span_notice("[key_name_admin(usr)] has [mass_remove? "mass" : ""] removed [path] component from [mass_remove? target.type : key_name_admin(target)].")) if(href_list[VV_HK_MODIFY_GREYSCALE]) if(!check_rights(NONE)) return