diff --git a/code/__HELPERS/filters.dm b/code/__HELPERS/filters.dm index 3c73f1c7b4b7b4..be41892c69fc80 100644 --- a/code/__HELPERS/filters.dm +++ b/code/__HELPERS/filters.dm @@ -8,7 +8,7 @@ GLOBAL_LIST_INIT(master_filter_info, list( "y" = 0, "icon" = ICON_NOT_SET, "render_source" = "", - "flags" = 0 + "flags" = NONE ), "flags" = list( "MASK_INVERSE" = MASK_INVERSE, @@ -30,14 +30,20 @@ GLOBAL_LIST_INIT(master_filter_info, list( "alpha" = 255 ) ), - // Not implemented, but if this isn't uncommented some windows will just error + // Not fully implemented, but if this isn't uncommented some windows will just error // Needs either a proper matrix editor, or just a hook to our existing one - // Issue is filterrific assumes variables will have the same value type if they share the same name, which this violates - // Gotta refactor this sometime "color" = list( "defaults" = list( "color" = matrix(), "space" = FILTER_COLOR_RGB + ), + "options" = list( + "space" = list( + "FILTER_COLOR_RGB" = FILTER_COLOR_RGB, + "FILTER_COLOR_HSV" = FILTER_COLOR_HSV, + "FILTER_COLOR_HSL" = FILTER_COLOR_HSL, + "FILTER_COLOR_HCY" = FILTER_COLOR_HCY + ) ) ), "displace" = list( @@ -46,7 +52,11 @@ GLOBAL_LIST_INIT(master_filter_info, list( "y" = 0, "size" = null, "icon" = ICON_NOT_SET, - "render_source" = "" + "render_source" = "", + "flags" = NONE + ), + "flags" = list( + "FILTER_OVERLAY" = FILTER_OVERLAY ) ), "drop_shadow" = list( @@ -70,10 +80,24 @@ GLOBAL_LIST_INIT(master_filter_info, list( "icon" = ICON_NOT_SET, "render_source" = "", "flags" = FILTER_OVERLAY, - "color" = "", + "color" = COLOR_WHITE, "transform" = null, "blend_mode" = BLEND_DEFAULT + ), + "flags" = list( + "FILTER_OVERLAY" = FILTER_OVERLAY, + ), + "options" = list( + "blend_mode" = list( + "BLEND_DEFAULT" = BLEND_DEFAULT, + "BLEND_OVERLAY" = BLEND_OVERLAY, + "BLEND_ADD" = BLEND_ADD, + "BLEND_SUBTRACT" = BLEND_SUBTRACT, + "BLEND_MULTIPLY" = BLEND_MULTIPLY, + "BLEND_INSET_OVERLAY" = BLEND_INSET_OVERLAY + ) ) + ), "motion_blur" = list( "defaults" = list( diff --git a/code/datums/datum.dm b/code/datums/datum.dm index fe69f6d6cc3f82..b0e84ed1bb95e0 100644 --- a/code/datums/datum.dm +++ b/code/datums/datum.dm @@ -334,11 +334,13 @@ var/list/copied_parameters = params.Copy() copied_parameters["name"] = name copied_parameters["priority"] = priority - for (var/list/filter_info as anything in filter_data) - if (filter_info["name"] == name) - filter_data -= filter_info - filter_cache -= name - break + for (var/index in 1 to length(filter_data)) + var/list/filter_info = filter_data[index] + if (filter_info["name"] != name) + continue + filter_data -= list(filter_info) + filter_cache -= filter_cache[index] + break BINARY_INSERT_DEFINE(list(copied_parameters), filter_data, SORT_VAR_NO_TYPE, copied_parameters, SORT_PRIORITY_INDEX, COMPARE_KEY) @@ -486,6 +488,12 @@ var/atom/atom_cast = src // filters only work with images or atoms. return atom_cast.filters[name] +/// Returns filter data associated with the passed key +/datum/proc/get_filter_data(name) + for (var/list/filter_info as anything in filter_data) + if (filter_info["name"] == name) + return filter_info.Copy() + /// Removes the passed filter, or multiple filters, if supplied with a list. /datum/proc/remove_filter(name_or_names, update = TRUE) ASSERT(isatom(src) || isimage(src)) diff --git a/code/modules/admin/verbs/plane_debugger.dm b/code/modules/admin/verbs/plane_debugger.dm index 90c12c931d7800..d983bf9eb96bc8 100644 --- a/code/modules/admin/verbs/plane_debugger.dm +++ b/code/modules/admin/verbs/plane_debugger.dm @@ -154,14 +154,12 @@ this_relay["blend_mode"] = GLOB.blend_names["[relay.blend_mode]"] relays += list(this_relay) - for (var/filter_id in plane.filter_data) - var/list/filter = plane.filter_data[filter_id] + for (var/list/filter in plane.filter_data) if(!filter["render_source"]) continue var/list/filter_info = filter.Copy() - filter_info["name"] = filter_id - filter_info["our_ref"] = "[plane.plane]-[filter_id]" + filter_info["our_ref"] = "[plane.plane]-[filter_info["name"]]" filters += list(filter_info) this_plane["relays"] = relays diff --git a/code/modules/admin/view_variables/filterrific.dm b/code/modules/admin/view_variables/filterrific.dm index 0ddd07aec4fe93..4a7b9f9f2f09a5 100644 --- a/code/modules/admin/view_variables/filterrific.dm +++ b/code/modules/admin/view_variables/filterrific.dm @@ -32,7 +32,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 +40,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,15 +56,7 @@ 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 @@ -83,16 +75,13 @@ 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"]]!") - - diff --git a/tgui/packages/tgui/interfaces/Filteriffic.jsx b/tgui/packages/tgui/interfaces/Filteriffic.jsx index eb74398ed66f23..7f86bfca128d96 100644 --- a/tgui/packages/tgui/interfaces/Filteriffic.jsx +++ b/tgui/packages/tgui/interfaces/Filteriffic.jsx @@ -174,8 +174,29 @@ const FilterFlagsEntry = (props) => { )); }; +const FilterOptionsEntry = (props) => { + const { name, value, filterName, filterType } = props; + const { act, data } = useBackend(); + const filterInfo = data.filter_info; + const options = filterInfo[filterType].options[name]; + return ( + value === options[x])} + options={Object.keys(options)} + onSelected={(value) => + act('modify_filter_value', { + name: filterName, + new_data: { + [name]: options[value], + }, + }) + } + /> + ); +}; + const FilterDataEntry = (props) => { - const { name, value, hasValue, filterName } = props; + const { name, value, hasValue, filterName, filterType } = props; const filterEntryTypes = { int: , @@ -184,6 +205,8 @@ const FilterDataEntry = (props) => { color: , icon: , flags: , + options: , + plug: 'Not Implemented', }; const filterEntryMap = { @@ -193,19 +216,32 @@ const FilterDataEntry = (props) => { render_source: 'string', flags: 'flags', size: 'float', - color: 'color', + color: { default: 'color', color: 'plug' }, offset: 'float', - radius: 'float', + radius: 'int', falloff: 'float', density: 'int', - threshold: 'float', + alpha: 'int', + threshold: { rays: 'float', bloom: 'color' }, factor: 'float', repeat: 'int', + space: 'options', + blend_mode: 'options', + transform: 'plug', }; + let filterInputType = filterEntryMap[name]; + // i hate javascript, this checks if its a dict + if (filterInputType !== undefined && filterInputType.constructor === Object) { + filterInputType = filterInputType[filterType] || filterInputType.default; + } + return ( - {filterEntryTypes[filterEntryMap[name]] || 'Not Found (This is an error)'}{' '} + + {filterEntryTypes[filterInputType] || + 'Not Found (This is an error)'}{' '} + {!hasValue && ( (Default) @@ -341,7 +377,11 @@ export const Filteriffic = (props) => { No filters ) : ( map(filters, (entry, key) => ( - + )) )}