Skip to content

Commit

Permalink
[MIRROR] [NO GBP] Retain filtering capabilities for paintings [MDB IG…
Browse files Browse the repository at this point in the history
…NORE] (#444)

* [NO GBP] Retain filtering capabilities for paintings (#79504)

---------
Co-authored-by: tattle <[email protected]>
  • Loading branch information
Steals-The-PRs authored Nov 4, 2023
1 parent 8ab0a57 commit 8846cd1
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions code/controllers/subsystem/persistent_paintings.dm
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ SUBSYSTEM_DEF(persistent_paintings)
"creator" = painting.creator_name,
"md5" = painting.md5,
"ref" = REF(painting),
"width" = painting.width,
"height" = painting.height,
"ratio" = painting.width/painting.height,
))

Expand All @@ -177,18 +179,26 @@ SUBSYSTEM_DEF(persistent_paintings)
*/
/datum/controller/subsystem/persistent_paintings/proc/painting_ui_data(filter=NONE, admin=FALSE, search_text)
var/searching = filter & (PAINTINGS_FILTER_SEARCH_TITLE|PAINTINGS_FILTER_SEARCH_CREATOR) && search_text
for(var/datum/painting/painting as anything in paintings)
if(filter & PAINTINGS_FILTER_AI_PORTRAIT && ((painting.width != 24 && painting.width != 23) || (painting.height != 24 && painting.height != 23)))

if(!searching)
return admin ? admin_painting_data : cached_painting_data

var/list/filtered_paintings = list()
var/list/searched_paintings = admin ? admin_painting_data : cached_painting_data

for(var/painting as anything in searched_paintings)
if(filter & PAINTINGS_FILTER_AI_PORTRAIT && ((painting["width"] != 24 && painting["width"] != 23) || (painting["height"] != 24 && painting["height"] != 23)))
continue
if(searching)
var/haystack_text = ""
if(filter & PAINTINGS_FILTER_SEARCH_TITLE)
haystack_text = painting.title
haystack_text = painting["title"]
else if(filter & PAINTINGS_FILTER_SEARCH_CREATOR)
haystack_text = painting.creator_name
haystack_text = painting["creator"]
if(!findtext(haystack_text, search_text))
continue
return admin ? admin_painting_data : cached_painting_data
filtered_paintings += painting
return filtered_paintings

/// Returns paintings with given tag.
/datum/controller/subsystem/persistent_paintings/proc/get_paintings_with_tag(tag_name)
Expand Down

0 comments on commit 8846cd1

Please sign in to comment.