Skip to content
This repository was archived by the owner on Aug 29, 2022. It is now read-only.

Commit 100bf4b

Browse files
committed
colorblind mode & hide opponent arrows when middlescroll
1 parent bfabbfd commit 100bf4b

6 files changed

+96
-1
lines changed

source/ClientPrefs.hx

+10
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class ClientPrefs {
2626
public static var imagesPersist:Bool = false;
2727
public static var ghostTapping:Bool = true;
2828
public static var timeBarType:String = 'Time Left';
29+
public static var colorblindMode:String = 'None';
30+
public static var hideMidScrollOpArrows:Bool = false;
2931
public static var scoreZoom:Bool = true;
3032
public static var noReset:Bool = false;
3133
public static var healthBarAlpha:Float = 1;
@@ -112,6 +114,8 @@ class ClientPrefs {
112114
//FlxG.save.data.cursing = cursing;
113115
//FlxG.save.data.violence = violence;
114116
FlxG.save.data.camZooms = camZooms;
117+
FlxG.save.data.colorblindMode = colorblindMode;
118+
FlxG.save.data.hideMidScrollOpArrows = hideMidScrollOpArrows;
115119
FlxG.save.data.noteOffset = noteOffset;
116120
FlxG.save.data.hideHud = hideHud;
117121
FlxG.save.data.hideWatermark = hideWatermark;
@@ -171,6 +175,12 @@ class ClientPrefs {
171175
if(FlxG.save.data.globalAntialiasing != null) {
172176
globalAntialiasing = FlxG.save.data.globalAntialiasing;
173177
}
178+
if(FlxG.save.data.colorblindMode != null) {
179+
colorblindMode = FlxG.save.data.colorblindMode;
180+
}
181+
if(FlxG.save.data.hideMidScrollOpArrows != null) {
182+
hideMidScrollOpArrows = FlxG.save.data.hideMidScrollOpArrows;
183+
}
174184
if(FlxG.save.data.noteSplashes != null) {
175185
noteSplashes = FlxG.save.data.noteSplashes;
176186
}

source/ColorblindFilters.hx

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package;
2+
3+
import flixel.FlxG;
4+
import openfl.filters.BitmapFilter;
5+
import openfl.filters.ColorMatrixFilter;
6+
7+
class ColorblindFilters {
8+
// i honesly have no ideas how to make it, so i hope that works
9+
public static var filterArray:Array<BitmapFilter> = [];
10+
public static var filterMap:Map<String, {filter:BitmapFilter, ?onUpdate:Void->Void}> = [
11+
12+
/*
13+
I found these values in official haxe guides :D
14+
*/
15+
16+
"Deuteranopia" => {
17+
var matrix:Array<Float> = [
18+
0.43, 0.72, -.15, 0, 0,
19+
0.34, 0.57, 0.09, 0, 0,
20+
-.02, 0.03, 1, 0, 0,
21+
0, 0, 0, 1, 0,
22+
];
23+
24+
{filter: new ColorMatrixFilter(matrix)}
25+
},
26+
"Protanopia" => {
27+
var matrix:Array<Float> = [
28+
0.20, 0.99, -.19, 0, 0,
29+
0.16, 0.79, 0.04, 0, 0,
30+
0.01, -.01, 1, 0, 0,
31+
0, 0, 0, 1, 0,
32+
];
33+
34+
{filter: new ColorMatrixFilter(matrix)}
35+
},
36+
"Tritanopia" => {
37+
var matrix:Array<Float> = [
38+
0.97, 0.11, -.08, 0, 0,
39+
0.02, 0.82, 0.16, 0, 0,
40+
0.06, 0.88, 0.18, 0, 0,
41+
0, 0, 0, 1, 0,
42+
];
43+
44+
{filter: new ColorMatrixFilter(matrix)}
45+
}
46+
];
47+
48+
public static function applyFiltersOnGame() {
49+
filterArray = [];
50+
FlxG.game.setFilters(filterArray);
51+
if (ClientPrefs.colorblindMode != "None") { // actually self explanatory, isn't it?
52+
if (filterMap.get(ClientPrefs.colorblindMode) != null) { // anticrash system
53+
var thisF = filterMap.get(ClientPrefs.colorblindMode).filter;
54+
if (thisF != null) {
55+
filterArray.push(thisF);
56+
}
57+
}
58+
}
59+
FlxG.game.setFilters(filterArray);
60+
}
61+
}

source/PlayState.hx

+6-1
Original file line numberDiff line numberDiff line change
@@ -1579,7 +1579,11 @@ class PlayState extends MusicBeatState
15791579
note.copyAlpha = false;
15801580
note.alpha = note.multAlpha;
15811581
if(ClientPrefs.middleScroll && !note.mustPress) {
1582-
note.alpha *= 0.5;
1582+
if (!ClientPrefs.hideMidScrollOpArrows) {
1583+
note.alpha *= 0.5;
1584+
} else {
1585+
note.alpha *= 0;
1586+
}
15831587
}
15841588
});
15851589
callOnLuas('onCountdownTick', [swagCounter]);
@@ -1923,6 +1927,7 @@ class PlayState extends MusicBeatState
19231927
// FlxG.log.add(i);
19241928
var targetAlpha:Float = 1;
19251929
if (player < 1 && ClientPrefs.middleScroll) targetAlpha = 0.35;
1930+
if (ClientPrefs.hideMidScrollOpArrows && ClientPrefs.middleScroll && player < 1) targetAlpha = 0;
19261931

19271932
var babyArrow:StrumNote = new StrumNote(ClientPrefs.middleScroll ? STRUM_X_MIDDLESCROLL : STRUM_X, strumLine.y, i, player);
19281933
babyArrow.downScroll = ClientPrefs.downScroll;

source/TitleState.hx

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import flixel.addons.transition.TransitionData;
1515
import haxe.Json;
1616
import openfl.display.Bitmap;
1717
import openfl.display.BitmapData;
18+
import ColorblindFilters;
1819
#if MODS_ALLOWED
1920
import sys.FileSystem;
2021
import sys.io.File;
@@ -220,6 +221,7 @@ class TitleState extends MusicBeatState
220221

221222
function startIntro()
222223
{
224+
ColorblindFilters.applyFiltersOnGame(); // applies colorbind filters, ok?
223225
if (!initialized)
224226
{
225227
/*var diamond:FlxGraphic = FlxGraphic.fromClass(GraphicTransTileDiamond);

source/options/GameplaySettingsSubState.hx

+7
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ class GameplaySettingsSubState extends BaseOptionsMenu
5656
false);
5757
addOption(option);
5858

59+
var option:Option = new Option('Hide Middlescroll Opponent Notes',
60+
'If checked, hides opponent arrows when playing with middlescroll',
61+
'hideMidScrollOpArrows',
62+
'bool',
63+
false);
64+
addOption(option);
65+
5966
var option:Option = new Option('Ghost Tapping',
6067
"If checked, you won't get misses from pressing keys\nwhile there are no notes able to be hit.",
6168
'ghostTapping',

source/options/VisualsUISubState.hx

+10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import flixel.FlxSprite;
99
import flixel.addons.display.FlxGridOverlay;
1010
import flixel.group.FlxGroup.FlxTypedGroup;
1111
import flixel.math.FlxMath;
12+
import ColorblindFilters;
1213
import flixel.text.FlxText;
1314
import flixel.util.FlxColor;
1415
import lime.utils.Assets;
@@ -77,6 +78,15 @@ class VisualsUISubState extends BaseOptionsMenu
7778
'bool',
7879
false);
7980
addOption(option);
81+
82+
var option:Option = new Option('Colorblind Filter',
83+
'You can set colorblind filter (makes the game more playable for colorblind people)',
84+
'colorblindMode',
85+
'string',
86+
'None',
87+
['None', 'Deuteranopia', 'Protanopia', 'Tritanopia']);
88+
option.onChange = ColorblindFilters.applyFiltersOnGame;
89+
addOption(option);
8090

8191
var option:Option = new Option('Time Bar:',
8292
"What should the Time Bar display?",

0 commit comments

Comments
 (0)