From 1048fc554f88acf81c420e86200eeb60bef39736 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Tue, 6 Apr 2021 14:44:00 +0200 Subject: [PATCH] [MIRROR] Allows admins to pick colours in VV (#4698) * added colour picking to VV (#58173) Co-authored-by: Thunder12345 * Allows admins to pick colours in VV Co-authored-by: Thunder12345 Co-authored-by: Thunder12345 --- code/__DEFINES/vv.dm | 1 + code/__HELPERS/sanitize_values.dm | 3 +-- code/_globalvars/regexes.dm | 1 + code/modules/admin/view_variables/get_variables.dm | 9 +++++++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/code/__DEFINES/vv.dm b/code/__DEFINES/vv.dm index 5423bf92410..c5f491fc729 100644 --- a/code/__DEFINES/vv.dm +++ b/code/__DEFINES/vv.dm @@ -1,6 +1,7 @@ #define VV_NUM "Number" #define VV_TEXT "Text" #define VV_MESSAGE "Mutiline Text" +#define VV_COLOR "Color" #define VV_ICON "Icon" #define VV_ATOM_REFERENCE "Atom Reference" #define VV_DATUM_REFERENCE "Datum Reference" diff --git a/code/__HELPERS/sanitize_values.dm b/code/__HELPERS/sanitize_values.dm index 0ca4f690528..75ed837aae9 100644 --- a/code/__HELPERS/sanitize_values.dm +++ b/code/__HELPERS/sanitize_values.dm @@ -95,5 +95,4 @@ /// Makes sure the input color is text with a # at the start followed by 6 hexadecimal characters. Examples: "#ff1234", "#A38321", COLOR_GREEN_GRAY /proc/sanitize_ooccolor(color) - var/static/regex/color_regex = regex(@"^#[0-9a-fA-F]{6}$") - return findtext(color, color_regex) ? color : GLOB.normal_ooc_colour + return findtext(color, GLOB.is_color) ? color : GLOB.normal_ooc_colour diff --git a/code/_globalvars/regexes.dm b/code/_globalvars/regexes.dm index 73eaab76440..a2e317e60d4 100644 --- a/code/_globalvars/regexes.dm +++ b/code/_globalvars/regexes.dm @@ -5,6 +5,7 @@ GLOBAL_DATUM_INIT(is_website, /regex, regex("http|www.|\[a-z0-9_-]+.(com|org|net GLOBAL_DATUM_INIT(is_email, /regex, regex("\[a-z0-9_-]+@\[a-z0-9_-]+.\[a-z0-9_-]+", "i")) GLOBAL_DATUM_INIT(is_alphanumeric, /regex, regex("\[a-z0-9]+", "i")) GLOBAL_DATUM_INIT(is_punctuation, /regex, regex("\[.!?]+", "i")) +GLOBAL_DATUM_INIT(is_color, /regex, regex("^#\[0-9a-fA-F]{6}$")) //finds text strings recognized as links on discord. Mainly used to stop embedding. GLOBAL_DATUM_INIT(has_discord_embeddable_links, /regex, regex("(https?://\[^\\s|<\]{2,})")) diff --git a/code/modules/admin/view_variables/get_variables.dm b/code/modules/admin/view_variables/get_variables.dm index e391c48c798..1c197dd7429 100644 --- a/code/modules/admin/view_variables/get_variables.dm +++ b/code/modules/admin/view_variables/get_variables.dm @@ -11,6 +11,8 @@ else if(istext(var_value)) if(findtext(var_value, "\n")) . = VV_MESSAGE + else if(findtext(var_value, GLOB.is_color)) + . = VV_COLOR else . = VV_TEXT @@ -54,6 +56,7 @@ VV_TEXT, VV_MESSAGE, VV_ICON, + VV_COLOR, VV_ATOM_REFERENCE, VV_DATUM_REFERENCE, VV_MOB_REFERENCE, @@ -269,3 +272,9 @@ while(!D) .["type"] = D.type .["value"] = D + + if(VV_COLOR) + .["value"] = input("Enter new color:", "Color", current_value) as color|null + if(.["value"] == null) + .["class"] = null + return