Adds(Paintings): The Ability to late-load persistent paintings

Staff may make an atom ProcCall on painting frames to load any painting desired from persistence.
This commit is contained in:
Runa Dacino
2023-08-18 23:40:49 +02:00
parent 5fabd9f272
commit 3d48f6f124
+82 -1
View File
@@ -527,6 +527,87 @@
loaded = TRUE
update_appearance()
/*
* Recursive Proc. If given no arguments, requests user to input arguments with warning that generating the list may be res intensive
* Upon generating arguments, calls itself and spawns the painting
* Ideally called using the vvar dropdown admin verb and used using debugging the SSpersistence list to minimize lag
* usr must have an admin holder (ergo: only staff may use this)
* TODO: create a machine in the library for curators to spawn canvases and refactor this to use the proc used there.
* For now, we do it this way because calling this on a canvas itself might cause issues due to the whole dimension thing.
*/
/obj/structure/sign/painting/proc/admin_lateload_painting(var/spawn_specific = 0, var/which_painting = 0)
if(!usr.client.holder)
return 0
if(spawn_specific && isnum(which_painting))
var/list/painting = SSpersistence.all_paintings[which_painting]
var/title = painting["title"]
var/author_name = painting["author"]
var/author_ckey = painting["ckey"]
var/persistence_id = painting["persistence_id"]
var/png = "data/persistent/paintings/[persistence_id]/[painting["md5"]].png"
to_chat(usr, span_notice("The chosen painting is the following \n\n \
Title: [title] \n \
Author's Name: [author_name]. \n \
Author's CKey: [author_ckey]"))
if(tgui_alert(usr, "Check your chat log (if filtering for notices, check where you don't) for painting details.",
"Is this the painting you want?", list("Yes", "No")) == "No")
return 0
if(!fexists("data/persistent/paintings/[persistence_id]/[painting["md5"]].png"))
to_chat(usr, span_warning("Chosen painting could not be loaded! Incident was logged, but no action taken at this time"))
log_debug("[usr] tried to spawn painting of list id [which_painting] in all_paintings list and associated file could not be found. \n \
Painting was titled [title] by [author_ckey] of [persistence_id]")
return 0
var/icon/I = new(png)
var/obj/item/canvas/new_canvas
var/w = I.Width()
var/h = I.Height()
for(var/T in typesof(/obj/item/canvas))
new_canvas = T
if(initial(new_canvas.width) == w && initial(new_canvas.height) == h)
new_canvas = new T(src)
break
if(!new_canvas)
warning("Couldn't find a canvas to match [w]x[h] of painting")
return 0
new_canvas.fill_grid_from_icon(I)
new_canvas.generated_icon = I
new_canvas.icon_generated = TRUE
new_canvas.finalized = TRUE
new_canvas.painting_name = title
new_canvas.author_name = author_name
new_canvas.author_ckey = author_ckey
new_canvas.name = "painting - [title]"
current_canvas = new_canvas
loaded = TRUE
update_appearance()
log_and_message_admins("spawned painting from [author_ckey] with title [title]", usr)
else
if(tgui_alert(usr, "No painting list ID was given. You may obtain such by debugging SSPersistence and checking the all_paintings entry. \
If you do not wish to do that, you may request a list to be generated of painting titles. This might be resource intensive. \
Proceed? It will likely have over 500 entries", "Generate list?", list("Proceed!", "Cancel")) == "Cancel")
return
log_debug("[usr] generated list of paintings from SSPersistence")
var/list/paintings = list()
var/current = 1
for(var/entry in SSpersistence.all_paintings)
var/key = "[entry["title"]] by [entry["author"]]"
paintings[key] = current
current += 1
var/choice = tgui_input_list(usr, "Choose which painting to spawn!", "Spawn painting", paintings, null)
if(!choice)
return 0
admin_lateload_painting(1, paintings[choice])
/obj/structure/sign/painting/proc/save_persistent()
if(!persistence_id || !current_canvas || current_canvas.no_save)
return
@@ -598,4 +679,4 @@
QDEL_NULL(P.current_canvas)
P.update_appearance()
loaded = FALSE
log_and_message_admins("<span class='notice'>[key_name_admin(user)] has deleted persistent painting made by [author].</span>")
log_and_message_admins("<span class='notice'>[key_name_admin(user)] has deleted persistent painting made by [author].</span>")