VV refactor: dropdown actions. (#29673)

* VV refactor: dropdown actions.

* helps if it builds

* append to list cuz we have multiple separators

* fix datumrefresh

* tiny cleanup

* fix jump to turf

* Apply suggestions from code review

Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
Signed-off-by: warriorstar-orion <orion@snowfrost.garden>

* Apply suggestions from code review

Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
Signed-off-by: warriorstar-orion <orion@snowfrost.garden>

* fix typo

---------

Signed-off-by: warriorstar-orion <orion@snowfrost.garden>
Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
This commit is contained in:
warriorstar-orion
2025-07-09 14:33:47 +00:00
committed by GitHub
co-authored by Burzah
parent ce0a9924ea
commit 6c2aa06eb3
15 changed files with 896 additions and 950 deletions
+99
View File
@@ -0,0 +1,99 @@
/atom/vv_edit_var(var_name, var_value)
. = ..()
switch(var_name)
if("light_power", "light_range", "light_color")
update_light()
if("color")
add_atom_colour(color, ADMIN_COLOUR_PRIORITY)
/atom/vv_get_dropdown()
. = ..()
VV_DROPDOWN_OPTION(VV_HK_MANIPULATE_COLOR_MATRIX, "Manipulate Colour Matrix")
var/turf/curturf = get_turf(src)
if(curturf)
. += "<option value='byond://?_src_=holder;adminplayerobservecoodjump=1;X=[curturf.x];Y=[curturf.y];Z=[curturf.z]'>Jump to turf</option>"
VV_DROPDOWN_OPTION(VV_HK_ADDREAGENT, "Add reagent")
VV_DROPDOWN_OPTION(VV_HK_EDITREAGENTS, "Edit reagents")
VV_DROPDOWN_OPTION(VV_HK_EXPLODE, "Trigger explosion")
VV_DROPDOWN_OPTION(VV_HK_EMP, "Trigger EM pulse")
/atom/vv_get_header()
. = ..()
. += "<a href='byond://?_src_=vars;datumedit=[UID()];varnameedit=name'><b>[src]</b></a>"
if(dir)
. += "<br><font size='1'><a href='byond://?_src_=vars;rotatedatum=TRUE;[VV_HK_TARGET]=[UID()];rotatedir=left'><<</a> <a href='byond://?_src_=vars;datumedit=[UID()];varnameedit=dir'>[dir2text(dir)]</a> <a href='byond://?_src_=vars;rotatedatum=TRUE;[VV_HK_TARGET]=[UID()];rotatedir=right'>>></a></font>"
/atom/vv_do_topic(list/href_list)
. = ..()
if(!.)
return
if(href_list["rotatedatum"])
if(!check_rights(R_DEBUG|R_ADMIN))
return
switch(href_list["rotatedir"])
if("right") dir = turn(dir, -45)
if("left") dir = turn(dir, 45)
message_admins("[key_name_admin(usr)] has rotated \the [src]")
log_admin("[key_name(usr)] has rotated \the [src]")
href_list["datumrefresh"] = UID()
if(href_list[VV_HK_EXPLODE])
if(!check_rights(R_DEBUG|R_EVENT))
return
usr.client.cmd_admin_explosion(src)
href_list["datumrefresh"] = UID()
if(href_list[VV_HK_EMP])
if(!check_rights(R_DEBUG|R_EVENT))
return
usr.client.cmd_admin_emp(src)
href_list["datumrefresh"] = UID()
if(href_list[VV_HK_ADDREAGENT]) /* Made on /TG/, credit to them. */
if(!check_rights(R_DEBUG|R_ADMIN))
return
if(!reagents)
var/amount = input(usr, "Specify the reagent size of [src]", "Set Reagent Size", 50) as num
if(amount)
create_reagents(amount)
if(reagents)
var/chosen_id
var/list/reagent_options = sortAssoc(GLOB.chemical_reagents_list)
switch(alert(usr, "Choose a method.", "Add Reagents", "Enter ID", "Choose ID"))
if("Enter ID")
var/valid_id
while(!valid_id)
chosen_id = stripped_input(usr, "Enter the ID of the reagent you want to add.")
if(!chosen_id) //Get me out of here!
break
for(var/ID in reagent_options)
if(ID == chosen_id)
valid_id = 1
if(!valid_id)
to_chat(usr, "<span class='warning'>A reagent with that ID doesn't exist!</span>")
if("Choose ID")
chosen_id = input(usr, "Choose a reagent to add.", "Choose a reagent.") as null|anything in reagent_options
if(chosen_id)
var/amount = input(usr, "Choose the amount to add.", "Choose the amount.", reagents.maximum_volume) as num
if(amount)
reagents.add_reagent(chosen_id, amount)
log_admin("[key_name(usr)] has added [amount] units of [chosen_id] to \the [src]")
message_admins("<span class='notice'>[key_name(usr)] has added [amount] units of [chosen_id] to \the [src]</span>")
if(href_list[VV_HK_EDITREAGENTS])
if(!check_rights(R_DEBUG|R_ADMIN))
return
usr.client.try_open_reagent_editor(src)
if(href_list[VV_HK_MANIPULATE_COLOR_MATRIX])
if(!check_rights(R_DEBUG))
return
message_admins("[key_name_admin(usr)] is manipulating the colour matrix for [src]")
var/datum/ui_module/colour_matrix_tester/CMT = new(target=src)
CMT.ui_interact(usr)
+2 -21
View File
@@ -505,7 +505,7 @@
*
* Arguments:
* - updates: A set of bitflags dictating what should be updated. Defaults to [ALL]
*
*
* Supported bitflags: UPDATE_NAME, UPDATE_DESC, UPDATE_ICON
*/
/atom/proc/update_appearance(updates=ALL)
@@ -540,7 +540,7 @@
*
* Arguments:
* - updates: A set of bitflags dictating what should be updated. Defaults to [ALL]
*
*
* Supported bitflags: UPDATE_ICON_STATE, UPDATE_OVERLAYS
*/
/atom/proc/update_icon(updates=ALL)
@@ -1258,25 +1258,6 @@ GLOBAL_LIST_EMPTY(blood_splatter_icons)
/atom/proc/speech_bubble(bubble_state = "", bubble_loc = src, list/bubble_recipients = list())
return
/atom/vv_edit_var(var_name, var_value)
. = ..()
switch(var_name)
if("light_power", "light_range", "light_color")
update_light()
if("color")
add_atom_colour(color, ADMIN_COLOUR_PRIORITY)
/atom/vv_get_dropdown()
. = ..()
.["Manipulate Colour Matrix"] = "byond://?_src_=vars;manipcolours=[UID()]"
var/turf/curturf = get_turf(src)
if(curturf)
.["Jump to turf"] = "byond://?_src_=holder;adminplayerobservecoodjump=1;X=[curturf.x];Y=[curturf.y];Z=[curturf.z]"
.["Add reagent"] = "byond://?_src_=vars;addreagent=[UID()]"
.["Edit reagents"] = "byond://?_src_=vars;editreagents=[UID()]"
.["Trigger explosion"] = "byond://?_src_=vars;explode=[UID()]"
.["Trigger EM pulse"] = "byond://?_src_=vars;emp=[UID()]"
/atom/proc/AllowDrop()
return FALSE
-8
View File
@@ -961,14 +961,6 @@
/atom/movable/proc/stop_deadchat_plays()
DeleteComponent(/datum/component/deadchat_control)
/atom/movable/vv_get_dropdown()
. = ..()
if(!GetComponent(/datum/component/deadchat_control))
.["Give deadchat control"] = "byond://?_src_=vars;grantdeadchatcontrol=[UID()]"
else
.["Remove deadchat control"] = "byond://?_src_=vars;removedeadchatcontrol=[UID()]"
//Update the screentip to reflect what we're hovering over
/atom/movable/MouseEntered(location, control, params)
if(invisibility > usr.see_invisible)
+67
View File
@@ -0,0 +1,67 @@
#define VV_HK_GIVE_DEADCHAT_CONTROL "grantdeadchatcontrol"
#define VV_HK_REMOVE_DEADCHAT_CONTROL "removedeadchatcontrol"
/atom/movable/vv_get_dropdown()
. = ..()
if(!GetComponent(/datum/component/deadchat_control))
VV_DROPDOWN_OPTION(VV_HK_GIVE_DEADCHAT_CONTROL, "Give deadchat control")
else
VV_DROPDOWN_OPTION(VV_HK_REMOVE_DEADCHAT_CONTROL, "Remove deadchat control")
/atom/movable/vv_do_topic(list/href_list)
. = ..()
if(!.)
return
if(href_list[VV_HK_GIVE_DEADCHAT_CONTROL])
if(!check_rights(R_EVENT))
return
if(!GLOB.dsay_enabled)
// TODO verify what happens when deadchat is muted
to_chat(usr, "<span class='warning'>Deadchat is globally muted, un-mute deadchat before enabling this.</span>")
return
if(GetComponent(/datum/component/deadchat_control))
to_chat(usr, "<span class='warning'>[src] is already under deadchat control!</span>")
return
var/control_mode = tgui_input_list(usr, "Please select the control mode", "Deadchat Control", list("Democracy", "Anarchy"))
var/selected_mode
switch(control_mode)
if("Democracy")
selected_mode = DEADCHAT_DEMOCRACY_MODE
if("Anarchy")
selected_mode = DEADCHAT_ANARCHY_MODE
else
return
var/cooldown = tgui_input_number(usr, "Please enter a cooldown time in seconds. For Democracy, it's the time between actions (must be greater than zero). For Anarchy, it's the time between each user's actions, or -1 for no cooldown.", "Cooldown")
if(isnull(cooldown) || (cooldown == -1 && selected_mode == DEADCHAT_DEMOCRACY_MODE))
return
if(cooldown < 0 && selected_mode == DEADCHAT_DEMOCRACY_MODE)
to_chat(usr, "<span class='warning'>The cooldown for Democracy mode must be greater than zero.</span>")
return
if(cooldown == -1)
cooldown = 0
else
cooldown = cooldown SECONDS
deadchat_plays(selected_mode, cooldown)
message_admins("[key_name_admin(usr)] provided deadchat control to [src].")
if(href_list[VV_HK_REMOVE_DEADCHAT_CONTROL])
if(!check_rights(R_EVENT))
return
if(!GetComponent(/datum/component/deadchat_control))
to_chat(usr, "<span class='warning'>[src] is not currently under deadchat control!</span>")
return
stop_deadchat_plays()
message_admins("[key_name_admin(usr)] removed deadchat control from [src].")
#undef VV_HK_GIVE_DEADCHAT_CONTROL
#undef VV_HK_REMOVE_DEADCHAT_CONTROL
+120
View File
@@ -0,0 +1,120 @@
/obj/vv_get_dropdown()
. = ..()
VV_DROPDOWN_OPTION(VV_HK_DELALL, "Delete all of type")
if(!speed_process)
VV_DROPDOWN_OPTION(VV_HK_MAKESPEEDY, "Make speed process")
else
VV_DROPDOWN_OPTION(VV_HK_MAKENORMALSPEED, "Make normal process")
VV_DROPDOWN_OPTION(VV_HK_MODIFYARMOR, "Modify armor values")
/obj/vv_do_topic(list/href_list)
. = ..()
if(!.)
return
if(href_list[VV_HK_DELALL])
if(!check_rights(R_DEBUG|R_SERVER))
return
var/action_type = tgui_alert(usr, "Strict type ([type]) or type and all subtypes?", "Select", list("Strict type", "Type and Subtypes", "Cancel"))
if(action_type == "Cancel" || !action_type)
return
if(tgui_alert(usr, "Are you really sure you want to delete all objects of type [type]?", "Confirm", list("Yes", "No")) != "Yes")
return
if(tgui_alert("Second confirmation required. Delete?", "Confirm", list("Yes", "No")) != "Yes")
return
var/O_type = type
switch(action_type)
if("Strict type")
var/i = 0
for(var/obj/Obj in world)
if(Obj.type == O_type)
i++
qdel(Obj)
if(!i)
to_chat(usr, "<span class='notice'>No objects of this type exist.</span>")
return
log_admin("[key_name(usr)] deleted all objects of type [O_type] ([i] objects deleted)")
message_admins("[key_name_admin(usr)] deleted all objects of type [O_type] ([i] objects deleted)")
if("Type and Subtypes")
var/i = 0
for(var/obj/Obj in world)
if(istype(Obj, O_type))
i++
qdel(Obj)
if(!i)
to_chat(usr, "<span class='notice'>No objects of this type exist.</span>")
return
log_admin("[key_name(usr)] deleted all objects of type or subtype of [O_type] ([i] objects deleted)")
message_admins("[key_name_admin(usr)] deleted all objects of type or subtype of [O_type] ([i] objects deleted)")
if(href_list[VV_HK_MAKESPEEDY])
if(!check_rights(R_DEBUG|R_ADMIN))
return
var_edited = TRUE
makeSpeedProcess()
log_admin("[key_name(usr)] has made [src] speed process")
message_admins("<span class='notice'>[key_name(usr)] has made [src] speed process</span>")
if(href_list[VV_HK_MAKENORMALSPEED])
if(!check_rights(R_DEBUG|R_ADMIN))
return
var_edited = TRUE
makeNormalProcess()
log_admin("[key_name(usr)] has made [src] process normally")
message_admins("<span class='notice'>[key_name(usr)] has made [src] process normally</span>")
if(href_list[VV_HK_MODIFYARMOR])
if(!check_rights(R_DEBUG|R_ADMIN))
return
var_edited = TRUE
var/list/armorlist = armor.getList()
var/list/displaylist
var/result
do
displaylist = list()
for(var/key in armorlist)
displaylist += "[key] = [armorlist[key]]"
result = input(usr, "Select an armor type to modify..", "Modify armor") as null|anything in displaylist + "(ADD ALL)" + "(SET ALL)" + "(DONE)"
if(result == "(DONE)")
break
else if(result == "(ADD ALL)" || result == "(SET ALL)")
var/new_amount = tgui_input_number(usr, result == "(ADD ALL)" ? "Enter armor to add to all types:" : "Enter new armor value for all types:", "Modify all types")
if(isnull(new_amount))
continue
var/proper_amount = text2num(new_amount)
if(isnull(proper_amount))
continue
for(var/key in armorlist)
armorlist[key] = (result == "(ADD ALL)" ? armorlist[key] : 0) + proper_amount
else if(result)
var/list/fields = splittext(result, " = ")
if(length(fields) != 2)
continue
var/type = fields[1]
if(isnull(armorlist[type]))
continue
var/new_amount = tgui_input_number(usr, "Enter new armor value for [type]:", "Modify [type]")
if(isnull(new_amount))
continue
var/proper_amount = text2num(new_amount)
if(isnull(proper_amount))
continue
armorlist[type] = proper_amount
while(result)
if(!result || !QDELETED(src))
return TRUE
armor = armor.setRating(armorlist[MELEE], armorlist[BULLET], armorlist[LASER], armorlist[ENERGY], armorlist[BOMB], armorlist[RAD], armorlist[FIRE], armorlist[ACID], armorlist[MAGIC])
log_admin("[key_name(usr)] modified the armor on [src] to: melee = [armorlist[MELEE]], bullet = [armorlist[BULLET]], laser = [armorlist[LASER]], energy = [armorlist[ENERGY]], bomb = [armorlist[BOMB]], rad = [armorlist[RAD]], fire = [armorlist[FIRE]], acid = [armorlist[ACID]], magic = [armorlist[MAGIC]]")
message_admins("<span class='notice'>[key_name(usr)] modified the armor on [src] to: melee = [armorlist[MELEE]], bullet = [armorlist[BULLET]], laser = [armorlist[LASER]], energy = [armorlist[ENERGY]], bomb = [armorlist[BOMB]], rad = [armorlist[RAD]], fire = [armorlist[FIRE]], acid = [armorlist[ACID]], magic = [armorlist[MAGIC]]</span>")
-9
View File
@@ -236,15 +236,6 @@
START_PROCESSING(SSobj, src)
STOP_PROCESSING(SSfastprocess, src)
/obj/vv_get_dropdown()
. = ..()
.["Delete all of type"] = "byond://?_src_=vars;delall=[UID()]"
if(!speed_process)
.["Make speed process"] = "byond://?_src_=vars;makespeedy=[UID()]"
else
.["Make normal process"] = "byond://?_src_=vars;makenormalspeed=[UID()]"
.["Modify armor values"] = "byond://?_src_=vars;modifyarmor=[UID()]"
/obj/proc/check_uplink_validity()
return TRUE