diff --git a/code/game/objects/structures/artstuff.dm b/code/game/objects/structures/artstuff.dm index 7b795f2430..afa263a8ac 100644 --- a/code/game/objects/structures/artstuff.dm +++ b/code/game/objects/structures/artstuff.dm @@ -336,6 +336,7 @@ var/persistence_id var/loaded = FALSE var/curator = "nobody! Report bug if you see this." + var/static/list/art_appreciators = list() //Presets for art gallery mapping, for paintings to be shared across stations /obj/structure/sign/painting/public @@ -406,11 +407,12 @@ if(current_canvas) current_canvas.tgui_interact(user) . += "Use wirecutters to remove the painting." - + . += "Paintings hung here are curated based on interest. The more often someone EXAMINEs the painting, the longer it will stay in rotation." // Painting loaded and persistent frame, give a hint about removal safety if(persistence_id) if(loaded) - . += "Don't worry, the currently framed painting has already been entered into the archives and can be safely removed. It will still be used on future shifts." + . += "Don't worry, the currently framed painting has already been entered into the archives and can be safely removed. It will still be used on future shifts." + back_of_the_line(user) else . += "This painting has not been entered into the archives yet. Removing it will prevent that from happening." @@ -554,6 +556,20 @@ "ckey" = current_canvas.author_ckey )) +/obj/structure/sign/painting/proc/back_of_the_line(mob/user) + if(user.ckey in art_appreciators) + return + if(!persistence_id || !current_canvas || current_canvas.no_save) + return + var/data = current_canvas.get_data_string() + var/md5 = md5(lowertext(data)) + for(var/list/entry in SSpersistence.all_paintings) + if(entry["md5"] == md5 && entry["persistence_id"] == persistence_id) + SSpersistence.all_paintings.Remove(list(entry)) + SSpersistence.all_paintings.Add(list(entry)) + art_appreciators += user.ckey + to_chat(user, "Showing interest in this painting renews its position in the curator database.") + /obj/structure/sign/painting/vv_get_dropdown() . = ..() VV_DROPDOWN_OPTION("removepainting", "Remove Persistent Painting") diff --git a/code/modules/persistence/paintings.dm b/code/modules/persistence/paintings.dm index d864659218..fd9ff9c434 100644 --- a/code/modules/persistence/paintings.dm +++ b/code/modules/persistence/paintings.dm @@ -1,6 +1,7 @@ /datum/persistent/paintings name = "paintings" - entries_expire_at = 1000 // Basically forever + //entries_expire_at = 1000 // Basically forever + var/max_entries = 1000 //1000 paintings is a lot, and will take a long time to cycle through. /datum/persistent/paintings/SetFilename() filename = "data/persistent/paintings.json" @@ -14,7 +15,7 @@ token["age"]++ // Increment age! if(!CheckTokenSanity(token)) tokens -= token - + SSpersistence.unpicked_paintings = SSpersistence.all_paintings.Copy() for(var/obj/structure/sign/painting/P in SSpersistence.painting_frames) @@ -24,14 +25,29 @@ var/png_filename = "data/paintings/[token["persistence_id"]]/[token["md5"]].png" if(!fexists(png_filename)) return FALSE - if(token["age"] > entries_expire_at) - fdel(png_filename) - return FALSE +// if(token["age"] > entries_expire_at) +// fdel(png_filename) +// return FALSE /datum/persistent/paintings/Shutdown() for(var/obj/structure/sign/painting/P in SSpersistence.painting_frames) P.save_persistent() + if(SSpersistence.all_paintings.len > max_entries) + var/this_many = SSpersistence.all_paintings.len + var/over = this_many - max_entries + log_admin("There are [over] more painting(s) stored than the maximum allowed.") + while(over > 0) + var/list/d = SSpersistence.all_paintings[1] + var/png_filename = "data/paintings/[d["persistence_id"]]/[d["md5"]].png" + fdel(png_filename) + if(SSpersistence.all_paintings.Remove(list(d))) + log_admin("A painting was deleted") + else + log_and_message_admins("Attempted to delete a painting, but failed.") + over -- + + if(fexists(filename)) fdel(filename) - to_file(file(filename), json_encode(SSpersistence.all_paintings)) + to_file(file(filename), json_encode(SSpersistence.all_paintings)) \ No newline at end of file