diff --git a/code/_globalvars/_regexes.dm b/code/_globalvars/_regexes.dm index 63d9c73c451..934296fe1bc 100644 --- a/code/_globalvars/_regexes.dm +++ b/code/_globalvars/_regexes.dm @@ -6,6 +6,7 @@ GLOBAL_DATUM_INIT(is_email, /regex, regex("\[a-z0-9_-]+@\[a-z0-9_-]+.\[a-z0-9_-] 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}$")) +GLOBAL_DATUM_INIT(is_alpha_color, /regex, regex("^#\[0-9a-fA-F]{8}$")) //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/greyscale_modify_menu.dm b/code/modules/admin/greyscale_modify_menu.dm index c9cf8252007..fd6dc442981 100644 --- a/code/modules/admin/greyscale_modify_menu.dm +++ b/code/modules/admin/greyscale_modify_menu.dm @@ -35,15 +35,15 @@ /// Whether the menu is currently locked down to prevent abuse from players. Currently is only unlocked when opened from vv. var/unlocked = FALSE - /// If defined, this ui state will be used instead of the target's - var/datum/ui_state/specific_ui_state + /// If defined, the always state will be used, and the user will be able to set the alpha channel of the colors too. + var/vv_mode = FALSE -/datum/greyscale_modify_menu/New(atom/target, client/user, list/allowed_configs, datum/callback/apply_callback, starting_icon_state="", starting_config, starting_colors, datum/ui_state/specific_ui_state) +/datum/greyscale_modify_menu/New(atom/target, client/user, list/allowed_configs, datum/callback/apply_callback, starting_icon_state="", starting_config, starting_colors, vv_mode = FALSE) src.target = target src.user = user src.apply_callback = apply_callback || CALLBACK(src, PROC_REF(DefaultApply)) icon_state = starting_icon_state - src.specific_ui_state = specific_ui_state + src.vv_mode = vv_mode SetupConfigOwner() @@ -72,7 +72,7 @@ return ..() /datum/greyscale_modify_menu/ui_state(mob/user) - return specific_ui_state || target.ui_state(user) + return vv_mode ? GLOB.always_state : GLOB.greyscale_menu_state /datum/greyscale_modify_menu/ui_close() qdel(src) @@ -80,7 +80,7 @@ /datum/greyscale_modify_menu/ui_interact(mob/user, datum/tgui/ui) ui = SStgui.try_update_ui(user, src, ui) if(!ui) - ui = new(user, target, "GreyscaleModifyMenu") + ui = new(user, src, "GreyscaleModifyMenu") ui.open() /datum/greyscale_modify_menu/ui_data(mob/user) @@ -139,7 +139,7 @@ if("recolor") var/index = text2num(params["color_index"]) var/new_color = lowertext(params["new_color"]) - if(split_colors[index] != new_color && findtext(new_color, GLOB.is_color)) + if(split_colors[index] != new_color && (findtext(new_color, GLOB.is_color) || (vv_mode && findtext(new_color, GLOB.is_alpha_color)))) split_colors[index] = new_color queue_refresh() @@ -225,11 +225,11 @@ This is highly likely to cause massive amounts of lag as every object in the gam config.EnableAutoRefresh(config_owner_type) /datum/greyscale_modify_menu/proc/ReadColorsFromString(colorString) - var/list/raw_colors = splittext(colorString, "#") - var/new_split_colors = list() - for(var/index in 2 to length(raw_colors)) - var/color = "[raw_colors[index]]" - if(!findtext(color, GLOB.is_color)) + var/list/new_split_colors = list() + var/list/colors = splittext(colorString, "#") + for(var/index in 2 to length(colors)) + var/color = "#[colors[index]]" + if(!findtext(color, GLOB.is_color) && (!vv_mode || !findtext(color, GLOB.is_alpha_color))) return FALSE new_split_colors += color split_colors = new_split_colors @@ -254,7 +254,7 @@ This is highly likely to cause massive amounts of lag as every object in the gam /datum/greyscale_modify_menu/proc/refresh_preview() for(var/i in length(split_colors) + 1 to config.expected_colors) - split_colors += rgb(100, 100, 100) + LAZYADD(split_colors, rgb(100, 100, 100)) var/list/used_colors = split_colors.Copy(1, config.expected_colors+1) sprite_data = list() diff --git a/code/modules/admin/view_variables/topic_basic.dm b/code/modules/admin/view_variables/topic_basic.dm index df350d53e32..9804b3ed88b 100644 --- a/code/modules/admin/view_variables/topic_basic.dm +++ b/code/modules/admin/view_variables/topic_basic.dm @@ -140,7 +140,7 @@ if(href_list[VV_HK_MODIFY_GREYSCALE]) if(!check_rights(NONE)) return - var/datum/greyscale_modify_menu/menu = new(target, usr, SSgreyscale.configurations, specific_ui_state = GLOB.always_state) + var/datum/greyscale_modify_menu/menu = new(target, usr, SSgreyscale.configurations, vv_mode = TRUE) menu.Unlock() menu.ui_interact(usr) if(href_list[VV_HK_CALLPROC]) diff --git a/code/modules/tgui/states/greyscale_menu.dm b/code/modules/tgui/states/greyscale_menu.dm new file mode 100644 index 00000000000..58936f807d9 --- /dev/null +++ b/code/modules/tgui/states/greyscale_menu.dm @@ -0,0 +1,11 @@ +/** + * tgui state: greyscale menu + * + * Checks that the target var of the greyscale menu meets the default can_use_topic criteria + */ + +GLOBAL_DATUM_INIT(greyscale_menu_state, /datum/ui_state/greyscale_menu_state, new) + +/datum/ui_state/greyscale_menu_state/can_use_topic(src_object, mob/user) + var/datum/greyscale_modify_menu/menu = src_object + return GLOB.default_state.can_use_topic(menu.target, user) diff --git a/tgstation.dme b/tgstation.dme index ca7fd824ab0..bb527c7ac44 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -5197,6 +5197,7 @@ #include "code\modules\tgui\states\deep_inventory.dm" #include "code\modules\tgui\states\default.dm" #include "code\modules\tgui\states\fun.dm" +#include "code\modules\tgui\states\greyscale_menu.dm" #include "code\modules\tgui\states\hands.dm" #include "code\modules\tgui\states\human_adjacent.dm" #include "code\modules\tgui\states\inventory.dm"