mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-24 05:30:05 +01:00
Adds a colorblind accessability testing tool (#65217)
* Adds a colorblind accessability testing tool I keep finding myself worrying about if things I create will be parsable for colorblind people. So I've made a debug tool for approximating different extreme forms of colorblindness. It's very very much a hack. We can't do the proper correction required to actually deal directly with long medium and short wavelengths of light, so we need to rely on approximations. Part of that means say, bright things being brighter then they ought to be. S not how people actually experience things, but it's not something we can do anything about in byond. Anyway uh, it works by taking color matrixes, and using the plane master grouping system floyd added to apply them to most all parts of the game you would want to color correct. There's some slight fragility here, but I couldn't think of a better way of handling it. We also need to deal with planes that have BLEND_MULTIPLY as their blendmode, since that fucks up the filter. I've come up with a hack for it, since I wanted to avoid breaking anything. Oh and since I want it to apply to huds too I added plane masters to represent them. I think that's about it. Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
This commit is contained in:
co-authored by
Mothblocks
parent
d549098226
commit
745426eff2
@@ -162,6 +162,7 @@ GLOBAL_PROTECT(admin_verbs_debug)
|
||||
/client/proc/set_dynex_scale,
|
||||
/client/proc/cmd_display_del_log,
|
||||
/client/proc/outfit_manager,
|
||||
/client/proc/open_colorblind_test,
|
||||
/client/proc/generate_wikichem_list,
|
||||
/client/proc/modify_goals,
|
||||
/client/proc/debug_huds,
|
||||
|
||||
@@ -32,6 +32,7 @@ GLOBAL_PROTECT(href_token)
|
||||
var/deadmined
|
||||
|
||||
var/datum/filter_editor/filteriffic
|
||||
var/datum/colorblind_tester/color_test = new
|
||||
|
||||
/// Whether or not the user tried to connect, but was blocked by 2FA
|
||||
var/blocked_by_2fa = FALSE
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/// Used to test the game for issues with different types of color blindness
|
||||
/// WARNING ASSHOLE: Because we can only apply matrixes, and can't preform gamma correction
|
||||
/// https://web.archive.org/web/20220227030606/https://ixora.io/projects/colorblindness/color-blindness-simulation-research/
|
||||
/// The results of this tool aren't perfect. It's way better then nothing, but IT IS NOT A PROPER SIMULATION
|
||||
/// Please do not make us look like assholes by assuming it is. Thanks.
|
||||
/datum/colorblind_tester
|
||||
/// List of simulated blindness -> matrix to use
|
||||
/// Most of these matrixes are based off https://web.archive.org/web/20220227030606/https://ixora.io/projects/colorblindness/color-blindness-simulation-research/
|
||||
/// AGAIN, THESE ARE NOT PERFECT BECAUSE WE CANNOT COMPUTE GAMMA CORRECTION, AND CONVERT SRGB TO LINEAR RGB
|
||||
/// Do not assume this is absolute
|
||||
var/list/color_matrixes = list(
|
||||
"Protanopia" = list(0.56,0.43,0,0, 0.55,0.44,0,0, 0,0.24,0.75,0, 0,0,0,1, 0,0,0,0),
|
||||
"Deuteranopia" = list(0.62,0.37,0,0, 0.70,0.30,0,0, 0,0.30,0.70,0, 0,0,0,1, 0,0,0,0),
|
||||
"Tritanopia" = list(0.95,0.5,0,0, 0,0.43,0.56,0, 0,0.47,0.52,0, 0,0,0,1, 0,0,0,0),
|
||||
"Achromatopsia" = list(0.33,0.33,0.33,0, 0.33,0.33,0.33,0, 0.33,0.33,0.33,0, 0,0,0,1, 0,0,0,0),
|
||||
)
|
||||
var/list/descriptions = list(
|
||||
"Protanopia" = "No long wavelength cones, ends up not being able to see red light. Troubles with blue/green and red/green",
|
||||
"Deuteranopia" = "No medium wavelength cones. Because the red and green parts of light nearly overlap in this space, trouble is mostly with red/green",
|
||||
"Tritanopia" = "No short wavelength cones, so trouble with blue/green and yellow/violet. Aggressively rare, and equally hard to simulate",
|
||||
"Achromatopsia" = "No cones at all, which leads to something close to monochromatic vision"
|
||||
)
|
||||
var/selected_type = ""
|
||||
|
||||
/datum/colorblind_tester/ui_state(mob/user)
|
||||
return GLOB.admin_state
|
||||
|
||||
/datum/colorblind_tester/ui_interact(mob/user, datum/tgui/ui)
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
if(!ui)
|
||||
ui = new(user, src, "ColorBlindTester")
|
||||
ui.open()
|
||||
|
||||
/datum/colorblind_tester/ui_data()
|
||||
var/list/data = list()
|
||||
data["details"] = descriptions
|
||||
data["selected"] = selected_type
|
||||
return data
|
||||
|
||||
/datum/colorblind_tester/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
|
||||
var/datum/hud/our_hud = ui.user?.hud_used
|
||||
if(!our_hud) // Nothing to act on
|
||||
return
|
||||
|
||||
switch(action)
|
||||
if("set_matrix")
|
||||
set_selected_type(params["name"], our_hud)
|
||||
return TRUE
|
||||
if("clear_matrix")
|
||||
set_selected_type("", our_hud)
|
||||
return TRUE
|
||||
|
||||
/datum/colorblind_tester/proc/set_selected_type(selected, datum/hud/remove_from)
|
||||
var/atom/movable/plane_master_controller/colorblind_plane = remove_from.plane_master_controllers[PLANE_MASTERS_COLORBLIND]
|
||||
// This is dumb, but well
|
||||
// The parralax plane has a blend mode of 4, or BLEND_MULTIPLY
|
||||
// It's like that so it is properly masked by darkness and such
|
||||
// The problem is blend modes apply to filters like this too
|
||||
// So I need to manually set and reset its blendmode to allow for proper shading of the background
|
||||
// Sorry...
|
||||
var/atom/movable/screen/plane_master/parralax = colorblind_plane.controlled_planes["[PLANE_SPACE_PARALLAX]"]
|
||||
if(selected_type)
|
||||
colorblind_plane.remove_filter(selected_type)
|
||||
parralax.blend_mode = initial(parralax.blend_mode)
|
||||
selected_type = selected
|
||||
if(selected_type)
|
||||
var/list/matrix = color_matrixes[selected_type]
|
||||
colorblind_plane.add_filter(selected_type, 0, color_matrix_filter(matrix))
|
||||
parralax.blend_mode = BLEND_DEFAULT
|
||||
@@ -601,6 +601,15 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
|
||||
|
||||
usr << browse(replacetext(SSatoms.InitLog(), "\n", "<br>"), "window=initlog")
|
||||
|
||||
/client/proc/open_colorblind_test()
|
||||
set category = "Debug"
|
||||
set name = "Colorblind Testing"
|
||||
set desc = "Change your view to a budget version of colorblindness to test for usability"
|
||||
|
||||
if(!holder)
|
||||
return
|
||||
holder.color_test.ui_interact(mob)
|
||||
|
||||
/client/proc/debug_huds(i as num)
|
||||
set category = "Debug"
|
||||
set name = "Debug HUDs"
|
||||
|
||||
Reference in New Issue
Block a user