Adds colourblind mode and a colour matrix editor (#17933)

* Colourblind mode + Matrix editor

* increase that

* Protanopia filter

* Tritanopia filter

* The SQL part

* Refactor

* you saw nothing
This commit is contained in:
AffectedArc07
2022-06-11 00:52:28 +01:00
committed by GitHub
parent 0d465cdd6f
commit 7d5a7ad85d
20 changed files with 266 additions and 61 deletions
+2
View File
@@ -332,6 +332,8 @@
. = ..() //calls mob.Login()
mob.update_client_colour(0) // Activate colourblind mode if they have one set
if(ckey in GLOB.clientmessages)
for(var/message in GLOB.clientmessages[ckey])
@@ -22,7 +22,8 @@
2fa_status,
screentip_mode,
screentip_color,
ghost_darkness_level
ghost_darkness_level,
colourblind_mode
FROM player
WHERE ckey=:ckey"}, list(
"ckey" = C.ckey
@@ -875,6 +875,12 @@
else
switch(href_list["preference"])
if("cbmode")
var/cb_mode = input(user, "Select a colourblind mode\nNote this will disable special screen effects such as the cursed heart warnings!") as null|anything in list(COLOURBLIND_MODE_NONE, COLOURBLIND_MODE_DEUTER, COLOURBLIND_MODE_PROT, COLOURBLIND_MODE_TRIT)
if(cb_mode)
colourblind_mode = cb_mode
user.update_client_colour(0)
if("publicity")
if(unlock_content)
toggles ^= PREFTOGGLE_MEMBER_PUBLIC
@@ -115,6 +115,8 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
var/datum/character_save/active_character
/// How dark things are if client is a ghost, 0-255
var/ghost_darkness_level = LIGHTING_PLANE_ALPHA_VISIBLE
/// Colourblind mode
var/colourblind_mode = COLOURBLIND_MODE_NONE
/datum/preferences/New(client/C, datum/db_query/Q) // Process our query
parent = C
@@ -363,6 +365,7 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
dat += "<b>Attack Animations:</b> <a href='?_src_=prefs;preference=ghost_att_anim'>[(toggles2 & PREFTOGGLE_2_ITEMATTACK) ? "Yes" : "No"]</a><br>"
if(unlock_content)
dat += "<b>BYOND Membership Publicity:</b> <a href='?_src_=prefs;preference=publicity'><b>[(toggles & PREFTOGGLE_MEMBER_PUBLIC) ? "Public" : "Hidden"]</b></a><br>"
dat += "<b>Colourblind Mode:</b> <a href='?_src_=prefs;preference=cbmode'>[colourblind_mode]</a><br>"
dat += "<b>Custom UI settings:</b><br>"
dat += " - <b>Alpha (transparency):</b> <a href='?_src_=prefs;preference=UIalpha'><b>[UI_style_alpha]</b></a><br>"
dat += " - <b>Color:</b> <a href='?_src_=prefs;preference=UIcolor'><b>[UI_style_color]</b></a> <span style='border: 1px solid #161616; background-color: [UI_style_color];'>&nbsp;&nbsp;&nbsp;</span><br>"
@@ -477,7 +480,7 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
dat += "<a href='?_src_=prefs;preference=reset_all'>Reset Setup</a>"
dat += "</center>"
var/datum/browser/popup = new(user, "preferences", "<div align='center'>Character Setup</div>", 820, 660)
var/datum/browser/popup = new(user, "preferences", "<div align='center'>Character Setup</div>", 820, 720)
popup.set_content(dat)
popup.open(0)
@@ -24,6 +24,7 @@
screentip_mode = query.item[18]
screentip_color = query.item[19]
ghost_darkness_level = query.item[20]
colourblind_mode = query.item[21]
//Sanitize
ooccolor = sanitize_hexcolor(ooccolor, initial(ooccolor))
@@ -43,10 +44,10 @@
screentip_mode = sanitize_integer(screentip_mode, 0, 20, initial(screentip_mode))
screentip_color = sanitize_hexcolor(screentip_color, initial(screentip_color))
ghost_darkness_level = sanitize_integer(ghost_darkness_level, 0, 255, initial(ghost_darkness_level))
colourblind_mode = sanitize_inlist(colourblind_mode, list(COLOURBLIND_MODE_NONE, COLOURBLIND_MODE_DEUTER, COLOURBLIND_MODE_PROT, COLOURBLIND_MODE_TRIT), COLOURBLIND_MODE_NONE)
return TRUE
/datum/preferences/proc/save_preferences(client/C)
// Might as well scrub out any malformed be_special list entries while we're here
for(var/role in be_special)
if(!(role in GLOB.special_roles))
@@ -58,57 +59,57 @@
deltimer(volume_mixer_saving)
volume_mixer_saving = null
var/datum/db_query/query = SSdbcore.NewQuery({"UPDATE player
SET
ooccolor=:ooccolour,
UI_style=:ui_style,
UI_style_color=:ui_colour,
UI_style_alpha=:ui_alpha,
be_role=:berole,
default_slot=:defaultslot,
toggles=:toggles,
toggles_2=:toggles2,
atklog=:atklog,
sound=:sound,
volume_mixer=:volume_mixer,
lastchangelog=:lastchangelog,
clientfps=:clientfps,
parallax=:parallax,
2fa_status=:_2fa_status,
screentip_mode=:screentip_mode,
screentip_color=:screentip_color,
ghost_darkness_level=:ghost_darkness_level
WHERE ckey=:ckey"}, list(
// OH GOD THE PARAMETERS
"ooccolour" = ooccolor,
"ui_style" = UI_style,
"ui_colour" = UI_style_color,
"ui_alpha" = UI_style_alpha,
"berole" = list2params(be_special),
"defaultslot" = default_slot,
// Even though its a number in the DB, you have to use num2text here, otherwise byond adds scientific notation to the number
"toggles" = num2text(toggles, CEILING(log(10, (TOGGLES_TOTAL)), 1)),
"toggles2" = num2text(toggles2, CEILING(log(10, (TOGGLES_2_TOTAL)), 1)),
"atklog" = atklog,
"sound" = sound,
"volume_mixer" = serialize_volume_mixer(volume_mixer),
"lastchangelog" = lastchangelog,
"clientfps" = clientfps,
"parallax" = parallax,
"_2fa_status" = _2fa_status,
"screentip_mode" = screentip_mode,
"screentip_color" = screentip_color,
"ghost_darkness_level" = ghost_darkness_level,
"ckey" = C.ckey,
)
)
var/datum/db_query/query = SSdbcore.NewQuery({"UPDATE player SET
ooccolor=:ooccolour,
UI_style=:ui_style,
UI_style_color=:ui_colour,
UI_style_alpha=:ui_alpha,
be_role=:berole,
default_slot=:defaultslot,
toggles=:toggles,
toggles_2=:toggles2,
atklog=:atklog,
sound=:sound,
volume_mixer=:volume_mixer,
lastchangelog=:lastchangelog,
clientfps=:clientfps,
parallax=:parallax,
2fa_status=:_2fa_status,
screentip_mode=:screentip_mode,
screentip_color=:screentip_color,
ghost_darkness_level=:ghost_darkness_level,
colourblind_mode=:colourblind_mode
WHERE ckey=:ckey"}, list(
// OH GOD THE PARAMETERS
"ooccolour" = ooccolor,
"ui_style" = UI_style,
"ui_colour" = UI_style_color,
"ui_alpha" = UI_style_alpha,
"berole" = list2params(be_special),
"defaultslot" = default_slot,
// Even though its a number in the DB, you have to use num2text here, otherwise byond adds scientific notation to the number
"toggles" = num2text(toggles, CEILING(log(10, (TOGGLES_TOTAL)), 1)),
"toggles2" = num2text(toggles2, CEILING(log(10, (TOGGLES_2_TOTAL)), 1)),
"atklog" = atklog,
"sound" = sound,
"volume_mixer" = serialize_volume_mixer(volume_mixer),
"lastchangelog" = lastchangelog,
"clientfps" = clientfps,
"parallax" = parallax,
"_2fa_status" = _2fa_status,
"screentip_mode" = screentip_mode,
"screentip_color" = screentip_color,
"ghost_darkness_level" = ghost_darkness_level,
"colourblind_mode" = colourblind_mode,
"ckey" = C.ckey,
))
if(!query.warn_execute())
qdel(query)
return
qdel(query)
return 1
return TRUE
/datum/preferences/proc/load_random_character_slot(client/C)
var/list/datum/character_save/valid_slots = list()