Skip to content
This repository was archived by the owner on Jul 27, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions beestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
#include "code\__HELPERS\dates.dm"
#include "code\__HELPERS\dna.dm"
#include "code\__HELPERS\files.dm"
#include "code\__HELPERS\filters.dm"
#include "code\__HELPERS\game.dm"
#include "code\__HELPERS\global_lists.dm"
#include "code\__HELPERS\heap.dm"
Expand Down Expand Up @@ -1335,6 +1336,7 @@
#include "code\modules\admin\verbs\SDQL2\SDQL_2_wrappers.dm"
#include "code\modules\admin\view_variables\admin_delete.dm"
#include "code\modules\admin\view_variables\debug_variables.dm"
#include "code\modules\admin\view_variables\filterrific.dm"
#include "code\modules\admin\view_variables\get_variables.dm"
#include "code\modules\admin\view_variables\mark_datum.dm"
#include "code\modules\admin\view_variables\mass_edit_variables.dm"
Expand Down
2 changes: 2 additions & 0 deletions code/__DEFINES/colors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,5 @@
"#D6B20C",\
"#FF902A",\
)

#define COLOR_HALF_TRANSPARENT_BLACK "#0000007A"
5 changes: 5 additions & 0 deletions code/__DEFINES/vv.dm
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@
#define VV_HK_TRIGGER_EMP "empulse"
#define VV_HK_TRIGGER_EXPLOSION "explode"
#define VV_HK_AUTO_RENAME "auto_rename"
<<<<<<< HEAD
=======
#define VV_HK_EDIT_FILTERS "edit_filters"
#define VV_HK_ADD_AI "add_ai"
>>>>>>> 203156d3e2 (ports tg's filter debug menu & minor filter refactor (#4434))

// /obj
#define VV_HK_OSAY "osay"
Expand Down
319 changes: 319 additions & 0 deletions code/__HELPERS/filters.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,319 @@
#define ICON_NOT_SET "Not Set"

//This is stored as a nested list instead of datums or whatever because it json encodes nicely for usage in tgui
GLOBAL_LIST_INIT(master_filter_info, list(
"alpha" = list(
"defaults" = list(
"x" = 0,
"y" = 0,
"icon" = ICON_NOT_SET,
"render_source" = "",
"flags" = 0
),
"flags" = list(
"MASK_INVERSE" = MASK_INVERSE,
"MASK_SWAP" = MASK_SWAP
)
),
"angular_blur" = list(
"defaults" = list(
"x" = 0,
"y" = 0,
"size" = 1
)
),
/* Not supported because making a proper matrix editor on the frontend would be a huge dick pain.
Uncomment if you ever implement it
"color" = list(
"defaults" = list(
"color" = matrix(),
"space" = FILTER_COLOR_RGB
)
),
*/
"displace" = list(
"defaults" = list(
"x" = 0,
"y" = 0,
"size" = null,
"icon" = ICON_NOT_SET,
"render_source" = ""
)
),
"drop_shadow" = list(
"defaults" = list(
"x" = 1,
"y" = -1,
"size" = 1,
"offset" = 0,
"color" = COLOR_HALF_TRANSPARENT_BLACK
)
),
"blur" = list(
"defaults" = list(
"size" = 1
)
),
"layer" = list(
"defaults" = list(
"x" = 0,
"y" = 0,
"icon" = ICON_NOT_SET,
"render_source" = "",
"flags" = FILTER_OVERLAY,
"color" = "",
"transform" = null,
"blend_mode" = BLEND_DEFAULT
)
),
"motion_blur" = list(
"defaults" = list(
"x" = 0,
"y" = 0
)
),
"outline" = list(
"defaults" = list(
"size" = 0,
"color" = COLOR_BLACK,
"flags" = NONE
),
"flags" = list(
"OUTLINE_SHARP" = OUTLINE_SHARP,
"OUTLINE_SQUARE" = OUTLINE_SQUARE
)
),
"radial_blur" = list(
"defaults" = list(
"x" = 0,
"y" = 0,
"size" = 0.01
)
),
"rays" = list(
"defaults" = list(
"x" = 0,
"y" = 0,
"size" = 16,
"color" = COLOR_WHITE,
"offset" = 0,
"density" = 10,
"threshold" = 0.5,
"factor" = 0,
"flags" = FILTER_OVERLAY | FILTER_UNDERLAY
),
"flags" = list(
"FILTER_OVERLAY" = FILTER_OVERLAY,
"FILTER_UNDERLAY" = FILTER_UNDERLAY
)
),
"ripple" = list(
"defaults" = list(
"x" = 0,
"y" = 0,
"size" = 1,
"repeat" = 2,
"radius" = 0,
"falloff" = 1,
"flags" = NONE
),
"flags" = list(
"WAVE_BOUNDED" = WAVE_BOUNDED
)
),
"wave" = list(
"defaults" = list(
"x" = 0,
"y" = 0,
"size" = 1,
"offset" = 0,
"flags" = NONE
),
"flags" = list(
"WAVE_SIDEWAYS" = WAVE_SIDEWAYS,
"WAVE_BOUNDED" = WAVE_BOUNDED
)
)
))

#undef ICON_NOT_SET

//Helpers to generate lists for filter helpers
//This is the only practical way of writing these that actually produces sane lists
/proc/alpha_mask_filter(x, y, icon/icon, render_source, flags)
. = list("type" = "alpha")
if(!isnull(x))
.["x"] = x
if(!isnull(y))
.["y"] = y
if(!isnull(icon))
.["icon"] = icon
if(!isnull(render_source))
.["render_source"] = render_source
if(!isnull(flags))
.["flags"] = flags

/proc/angular_blur_filter(x, y, size)
. = list("type" = "angular_blur")
if(!isnull(x))
.["x"] = x
if(!isnull(y))
.["y"] = y
if(!isnull(size))
.["size"] = size

/proc/color_matrix_filter(matrix/in_matrix, space)
. = list("type" = "color")
.["color"] = in_matrix
if(!isnull(space))
.["space"] = space

/proc/displacement_map_filter(icon, render_source, x, y, size = 32)
. = list("type" = "displace")
if(!isnull(icon))
.["icon"] = icon
if(!isnull(render_source))
.["render_source"] = render_source
if(!isnull(x))
.["x"] = x
if(!isnull(y))
.["y"] = y
if(!isnull(size))
.["size"] = size

/proc/drop_shadow_filter(x, y, size, offset, color)
. = list("type" = "drop_shadow")
if(!isnull(x))
.["x"] = x
if(!isnull(y))
.["y"] = y
if(!isnull(size))
.["size"] = size
if(!isnull(offset))
.["offset"] = offset
if(!isnull(color))
.["color"] = color

/proc/gauss_blur_filter(size)
. = list("type" = "blur")
if(!isnull(size))
.["size"] = size

/proc/layering_filter(icon, render_source, x, y, flags, color, transform, blend_mode)
. = list("type" = "layer")
if(!isnull(icon))
.["icon"] = icon
if(!isnull(render_source))
.["render_source"] = render_source
if(!isnull(x))
.["x"] = x
if(!isnull(y))
.["y"] = y
if(!isnull(color))
.["color"] = color
if(!isnull(flags))
.["flags"] = flags
if(!isnull(transform))
.["transform"] = transform
if(!isnull(blend_mode))
.["blend_mode"] = blend_mode

/proc/motion_blur_filter(x, y)
. = list("type" = "motion_blur")
if(!isnull(x))
.["x"] = x
if(!isnull(y))
.["y"] = y

/proc/outline_filter(size, color, flags)
. = list("type" = "outline")
if(!isnull(size))
.["size"] = size
if(!isnull(color))
.["color"] = color
if(!isnull(flags))
.["flags"] = flags

/proc/radial_blur_filter(size, x, y)
. = list("type" = "radial_blur")
if(!isnull(size))
.["size"] = size
if(!isnull(x))
.["x"] = x
if(!isnull(y))
.["y"] = y

/proc/rays_filter(size, color, offset, density, threshold, factor, x, y, flags)
. = list("type" = "rays")
if(!isnull(size))
.["size"] = size
if(!isnull(color))
.["color"] = color
if(!isnull(offset))
.["offset"] = offset
if(!isnull(density))
.["density"] = density
if(!isnull(threshold))
.["threshold"] = threshold
if(!isnull(factor))
.["factor"] = factor
if(!isnull(x))
.["x"] = x
if(!isnull(y))
.["y"] = y
if(!isnull(flags))
.["flags"] = flags

/proc/ripple_filter(radius, size, falloff, repeat, x, y, flags)
. = list("type" = "ripple")
if(!isnull(radius))
.["radius"] = radius
if(!isnull(size))
.["size"] = size
if(!isnull(falloff))
.["falloff"] = falloff
if(!isnull(repeat))
.["repeat"] = repeat
if(!isnull(flags))
.["flags"] = flags
if(!isnull(x))
.["x"] = x
if(!isnull(y))
.["y"] = y

/proc/wave_filter(x, y, size, offset, flags)
. = list("type" = "wave")
if(!isnull(size))
.["size"] = size
if(!isnull(x))
.["x"] = x
if(!isnull(y))
.["y"] = y
if(!isnull(offset))
.["offset"] = offset
if(!isnull(flags))
.["flags"] = flags

/proc/apply_wibbly_filters(atom/in_atom, length)
for(var/i in 1 to 7)
//This is a very baffling and strange way of doing this but I am just preserving old functionality
var/X
var/Y
var/rsq
do
X = 60*rand() - 30
Y = 60*rand() - 30
rsq = X*X + Y*Y
while(rsq<100 || rsq>900) // Yeah let's just loop infinitely due to bad luck what's the worst that could happen?
var/random_roll = rand()
in_atom.add_filter("wibbly-[i]", 5, wave_filter(x = X, y = Y, size = rand() * 2.5 + 0.5, offset = random_roll))
var/filter = in_atom.get_filter("wibbly-[i]")
animate(filter, offset = random_roll, time = 0, loop = -1, flags = ANIMATION_PARALLEL)
animate(offset = random_roll - 1, time = rand() * 20 + 10)

/proc/remove_wibbly_filters(atom/in_atom)
var/filter
for(var/i in 1 to 7)
filter = in_atom.get_filter("wibbly-[i]")
animate(filter)
in_atom.remove_filter("wibbly-[i]")
13 changes: 0 additions & 13 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1621,16 +1621,3 @@ config_setting should be one of the following:
var/list/servers = CONFIG_GET(keyed_list/insecure_cross_server)
for(var/I in servers)
world.Export("[servers[I]]?[list2params(message)]")

/proc/drop_shadow_filter(x, y, size, offset, color)
. = list("type" = "drop_shadow")
if(!isnull(x))
.["x"] = x
if(!isnull(y))
.["y"] = y
if(!isnull(size))
.["size"] = size
if(!isnull(offset))
.["offset"] = offset
if(!isnull(color))
.["color"] = color
Loading