update filters (#7456)

<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request

<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

## Why It's Good For The Game

<!-- Argue for the merits of your changes and how they benefit the game,
especially if they are controversial and/or far reaching. If you can't
actually explain WHY what you are doing will improve the game, then it
probably isn't good for the game in the first place. -->

## Changelog

<!-- If your PR modifies aspects of the game that can be concretely
observed by players or admins you should add a changelog. If your change
does NOT meet this description, remove this section. Please note that
maintainers freely reserve the right to remove and add tags should they
deem it appropriate. You can attempt to finagle the system all you want,
but it's best to shoot for clear communication right off the bat. -->

🆑
code: update filters
/🆑

<!-- Both 🆑's are required for the changelog to work! You can put
your name to the right of the first 🆑 if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
This commit is contained in:
Letter N
2026-01-08 01:35:37 -05:00
committed by GitHub
parent 7dc8a866c2
commit 31751a9729
11 changed files with 542 additions and 231 deletions
@@ -10,7 +10,7 @@
/datum/filter_editor/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "Filteriffic")
ui = new(user, src, "Filterrific")
ui.open()
/datum/filter_editor/ui_static_data(mob/user, datum/tgui/ui)
@@ -21,7 +21,14 @@
/datum/filter_editor/ui_data(mob/user, datum/tgui/ui)
var/list/data = list()
data["target_name"] = target.name
data["target_filter_data"] = target.filter_data
var/list/target_filter_data = list()
for (var/list/filter_info as anything in target.filter_data)
filter_info = deep_copy_list(filter_info)
if (filter_info["transform"])
var/matrix/filter_transform = filter_info["transform"]
filter_info["transform"] = list("a" = filter_transform.a, "b" = filter_transform.b, "c" = filter_transform.c, "d" = filter_transform.d, "e" = filter_transform.e, "f" = filter_transform.f)
target_filter_data += list(filter_info)
data["target_filter_data"] = target_filter_data
return data
/datum/filter_editor/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state, datum/event_args/actor/actor)
@@ -32,7 +39,7 @@
switch(action)
if("add_filter")
var/target_name = params["name"]
while(target.filter_data && target.filter_data[target_name])
while(target.get_filter(target_name))
target_name = "[target_name]-dupe"
target.add_filter(target_name, params["priority"], list("type" = params["type"]))
. = TRUE
@@ -40,9 +47,9 @@
target.remove_filter(params["name"])
. = TRUE
if("rename_filter")
var/list/filter_data = target.filter_data[params["name"]]
var/list/filter_info = target.get_filter_data(params["name"])
target.remove_filter(params["name"])
target.add_filter(params["new_name"], filter_data["priority"], filter_data)
target.add_filter(params["new_name"], filter_data["priority"], filter_info)
. = TRUE
if("edit_filter")
target.remove_filter(params["name"])
@@ -56,43 +63,43 @@
target.transition_filter(params["name"], params["new_data"], 4)
. = TRUE
if("modify_filter_value")
var/list/old_filter_data = target.filter_data[params["name"]]
var/list/new_filter_data = old_filter_data.Copy()
for(var/entry in params["new_data"])
new_filter_data[entry] = params["new_data"][entry]
for(var/entry in new_filter_data)
if(entry == GLOB.master_filter_info[old_filter_data["type"]]["defaults"][entry])
new_filter_data.Remove(entry)
target.remove_filter(params["name"])
target.add_filter(params["name"], old_filter_data["priority"], new_filter_data)
target.modify_filter(params["name"], params["new_data"])
. = TRUE
if("modify_color_value")
var/new_color = input(usr, "Pick new filter color", "Filteriffic Colors!") as color|null
var/new_color = input(usr, "Pick new filter color", "Filterrific Colors!") as color|null
if(new_color)
target.transition_filter(params["name"], list("color" = new_color), 4)
. = TRUE
if("modify_icon_value")
var/icon/new_icon = usr.client.prompt_for_icon_or_null("Pick icon", "Icon")
var/icon/new_icon = input("Pick icon:", "Icon") as null|icon
if(new_icon)
target.filter_data[params["name"]]["icon"] = new_icon
target.update_filters()
target.modify_filter(params["name"], list("icon" = new_icon))
. = TRUE
if("modify_transform_value")
var/list/filter_info = target.get_filter_data(params["name"])
if (!filter_info)
return
var/matrix/new_transform = matrix(filter_info[params["field_name"]])
if (!(params["transform_key"] in list("a", "b", "c", "d", "e", "f")))
return
new_transform.vars[params["transform_key"]] = text2num(params["transform_value"])
target.modify_filter(params["name"], list(params["field_name"] = new_transform))
. = TRUE
if("mass_apply")
if(!check_rights(R_FUN))
to_chat(usr, SPAN_DANGER("Stay in your lane, jannie."))
if(!check_rights_for(usr.client, R_FUN))
to_chat(usr, SPAN_USERDANGER("Stay in your lane, jannie."))
return
var/target_path = text2path(params["path"])
if(!target_path)
return
var/filters_to_copy = target.filters
var/filter_data_to_copy = target.filter_data
var/list/filter_data_to_copy = target.filter_data
var/count = 0
for(var/thing in world.contents)
if(istype(thing, target_path))
var/atom/thing_at = thing
thing_at.filters = filters_to_copy
thing_at.filter_data = filter_data_to_copy
count += 1
for(var/atom/thing_at as anything in world.contents)
if(!istype(thing_at, target_path))
continue
thing_at.filter_data = filter_data_to_copy.Copy()
thing_at.update_filters()
count += 1
message_admins("LOCAL CLOWN [usr.ckey] JUST MASS FILTER EDITED [count] WITH PATH OF [params["path"]]!")
log_admin("LOCAL CLOWN [usr.ckey] JUST MASS FILTER EDITED [count] WITH PATH OF [params["path"]]!")