mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-27 06:54:18 +01:00
Extended list viewer now has an edit button (#19706)
Extended list viewer now has an edit button, and the ability to edit the extended list it's seeing; it's also (opinionately) better formatted.
This commit is contained in:
@@ -1,18 +1,32 @@
|
||||
/client/proc/view_extended_list(var/list/L)
|
||||
if(!check_rights(R_VAREDIT|R_DEV)) return
|
||||
/**
|
||||
* Used to create a tgui Extended List Viewer
|
||||
*
|
||||
* Accepts either an associative list or a flat list
|
||||
*
|
||||
* If an associative list is passed, the key is a string and the value the datum
|
||||
*/
|
||||
/client/proc/view_extended_list(list/L, datum/original_datum)
|
||||
if(!check_rights(R_VAREDIT|R_DEV))
|
||||
return
|
||||
|
||||
if(istype(L))
|
||||
new /datum/tgui_module/list_viewer(L, usr)
|
||||
new /datum/tgui_module/list_viewer(L, usr, original_datum = original_datum)
|
||||
|
||||
/datum/tgui_module/list_viewer
|
||||
var/list/viewed_list
|
||||
var/datum/weakref/original_datum_ref
|
||||
|
||||
/datum/tgui_module/list_viewer/New(var/list/L, mob/user)
|
||||
/datum/tgui_module/list_viewer/New(list/L, mob/user, datum/original_datum)
|
||||
if(istype(L))
|
||||
viewed_list = L
|
||||
if(istype(original_datum))
|
||||
original_datum_ref = WEAKREF(original_datum)
|
||||
if(!original_datum_ref)
|
||||
stack_trace("Unable to create a weakref to the original datum, please report this to a developer")
|
||||
|
||||
ui_interact(user)
|
||||
|
||||
/datum/tgui_module/list_viewer/ui_interact(mob/user, var/datum/tgui/ui)
|
||||
/datum/tgui_module/list_viewer/ui_interact(mob/user, datum/tgui/ui)
|
||||
if(!check_rights(R_VAREDIT|R_DEV|R_MOD))
|
||||
return
|
||||
|
||||
@@ -41,3 +55,48 @@
|
||||
index++
|
||||
|
||||
return data
|
||||
|
||||
/datum/tgui_module/list_viewer/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
|
||||
if(!check_rights(R_VAREDIT|R_DEV))
|
||||
return
|
||||
|
||||
var/client/user_client = ui.user?.client
|
||||
if(!user_client)
|
||||
stack_trace("No client found to open entry in, despite having received a request to edit a list, uh oh!")
|
||||
return
|
||||
|
||||
switch(action)
|
||||
|
||||
if("open_entry")
|
||||
|
||||
var/datum/entry_to_open = null
|
||||
|
||||
if(isnum(text2num(params["open_entry_key"])))
|
||||
entry_to_open = viewed_list[text2num(params["open_entry_key"])]
|
||||
else
|
||||
entry_to_open = viewed_list[params["open_entry_key"]]
|
||||
|
||||
if(!entry_to_open)
|
||||
to_chat(usr, "No entry found to open!")
|
||||
return FALSE
|
||||
|
||||
user_client.debug_variables_open(entry_to_open)
|
||||
|
||||
return TRUE
|
||||
|
||||
if("open_whole_list")
|
||||
if(tgui_alert(usr, "Opening the whole list in VV might take a long time or cause issues, are you sure?", "Confirm", list("Yes", "No")) != "Yes")
|
||||
return FALSE
|
||||
|
||||
var/datum/original_datum = original_datum_ref.resolve()
|
||||
if(!original_datum)
|
||||
tgui_alert(usr, "Unable to open the list, the original datum has been deleted or has never been set.")
|
||||
return FALSE
|
||||
|
||||
user_client.mod_list(viewed_list, original_datum)
|
||||
|
||||
return TRUE
|
||||
|
||||
Reference in New Issue
Block a user