-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathClientPrefs.hx
More file actions
302 lines (281 loc) · 10.1 KB
/
ClientPrefs.hx
File metadata and controls
302 lines (281 loc) · 10.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
package;
import flixel.FlxG;
import flixel.util.FlxSave;
import flixel.input.keyboard.FlxKey;
import flixel.graphics.FlxGraphic;
import Controls;
class ClientPrefs {
public static var downScroll:Bool = false;
public static var middleScroll:Bool = false;
public static var showFPS:Bool = true;
public static var flashing:Bool = true;
public static var globalAntialiasing:Bool = true;
public static var noteSplashes:Bool = true;
public static var lowQuality:Bool = false;
public static var framerate:Int = 60;
public static var easyMode:Bool = false;
public static var shaders:Bool = false;
public static var cursing:Bool = true;
public static var violence:Bool = true;
public static var camZooms:Bool = true;
public static var hideHud:Bool = false;
public static var noteOffset:Int = 0;
public static var arrowHSV:Array<Array<Int>> = [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]];
public static var imagesPersist:Bool = false;
public static var ghostTapping:Bool = true;
public static var timeBarType:String = 'Time Left';
public static var scoreZoom:Bool = true;
public static var noReset:Bool = false;
public static var healthBarAlpha:Float = 1;
public static var controllerMode:Bool = false;
public static var hitsoundVolume:Float = 0;
public static var pauseMusic:String = 'Tea Time';
public static var gameplaySettings:Map<String, Dynamic> = [
'scrollspeed' => 1.0,
'scrolltype' => 'multiplicative',
// anyone reading this, amod is multiplicative speed mod, cmod is constant speed mod, and xmod is bpm based speed mod.
// an amod example would be chartSpeed * multiplier
// cmod would just be constantSpeed = chartSpeed
// and xmod basically works by basing the speed on the bpm.
// iirc (beatsPerSecond * (conductorToNoteDifference / 1000)) * noteSize (110 or something like that depending on it, prolly just use note.height)
// bps is calculated by bpm / 60
// oh yeah and you'd have to actually convert the difference to seconds which I already do, because this is based on beats and stuff. but it should work
// just fine. but I wont implement it because I don't know how you handle sustains and other stuff like that.
// oh yeah when you calculate the bps divide it by the songSpeed or rate because it wont scroll correctly when speeds exist.
'songspeed' => 1.0,
'healthgain' => 1.0,
'healthloss' => 1.0,
'instakill' => false,
'practice' => false,
'botplay' => false,
'opponentplay' => false
];
public static var comboOffset:Array<Int> = [0, 0, 0, 0];
public static var ratingOffset:Int = 0;
public static var sickWindow:Int = 45;
public static var goodWindow:Int = 90;
public static var badWindow:Int = 135;
public static var safeFrames:Float = 10;
//Every key has two binds, add your key bind down here and then add your control on options/ControlsSubState.hx and Controls.hx
public static var keyBinds:Map<String, Array<FlxKey>> = [
//Key Bind, Name for ControlsSubState
'note_left' => [A, LEFT],
'note_down' => [S, DOWN],
'note_up' => [W, UP],
'note_right' => [D, RIGHT],
'ui_left' => [A, LEFT],
'ui_down' => [S, DOWN],
'ui_up' => [W, UP],
'ui_right' => [D, RIGHT],
'accept' => [SPACE, ENTER],
'back' => [BACKSPACE, ESCAPE],
'pause' => [ENTER, ESCAPE],
'reset' => [R, NONE],
'volume_mute' => [ZERO, NONE],
'volume_up' => [NUMPADPLUS, PLUS],
'volume_down' => [NUMPADMINUS, MINUS],
'debug_1' => [SEVEN, NONE],
'debug_2' => [EIGHT, NONE]
];
public static var defaultKeys:Map<String, Array<FlxKey>> = null;
public static function loadDefaultKeys() {
defaultKeys = keyBinds.copy();
//trace(defaultKeys);
}
public static function saveSettings() {
FlxG.save.data.downScroll = downScroll;
FlxG.save.data.middleScroll = middleScroll;
FlxG.save.data.showFPS = showFPS;
FlxG.save.data.flashing = flashing;
FlxG.save.data.globalAntialiasing = globalAntialiasing;
FlxG.save.data.noteSplashes = noteSplashes;
FlxG.save.data.lowQuality = lowQuality;
FlxG.save.data.framerate = framerate;
//FlxG.save.data.cursing = cursing;
//FlxG.save.data.violence = violence;
FlxG.save.data.camZooms = camZooms;
FlxG.save.data.noteOffset = noteOffset;
FlxG.save.data.hideHud = hideHud;
FlxG.save.data.easyMode = easyMode;
FlxG.save.data.shaders = shaders;
FlxG.save.data.arrowHSV = arrowHSV;
FlxG.save.data.imagesPersist = imagesPersist;
FlxG.save.data.ghostTapping = ghostTapping;
FlxG.save.data.timeBarType = timeBarType;
FlxG.save.data.scoreZoom = scoreZoom;
FlxG.save.data.noReset = noReset;
FlxG.save.data.healthBarAlpha = healthBarAlpha;
FlxG.save.data.comboOffset = comboOffset;
FlxG.save.data.achievementsMap = Achievements.achievementsMap;
FlxG.save.data.henchmenDeath = Achievements.henchmenDeath;
FlxG.save.data.ratingOffset = ratingOffset;
FlxG.save.data.sickWindow = sickWindow;
FlxG.save.data.goodWindow = goodWindow;
FlxG.save.data.badWindow = badWindow;
FlxG.save.data.safeFrames = safeFrames;
FlxG.save.data.gameplaySettings = gameplaySettings;
FlxG.save.data.controllerMode = controllerMode;
FlxG.save.data.hitsoundVolume = hitsoundVolume;
FlxG.save.data.pauseMusic = pauseMusic;
FlxG.save.flush();
var save:FlxSave = new FlxSave();
save.bind('controls_v2', 'ninjamuffin99'); //Placing this in a separate save so that it can be manually deleted without removing your Score and stuff
save.data.customControls = keyBinds;
save.flush();
FlxG.log.add("Settings saved!");
}
public static function loadPrefs() {
if(FlxG.save.data.downScroll != null) {
downScroll = FlxG.save.data.downScroll;
}
if(FlxG.save.data.middleScroll != null) {
middleScroll = FlxG.save.data.middleScroll;
}
if(FlxG.save.data.showFPS != null) {
showFPS = FlxG.save.data.showFPS;
if(Main.fpsVar != null) {
Main.fpsVar.visible = showFPS;
}
}
if(FlxG.save.data.flashing != null) {
flashing = FlxG.save.data.flashing;
}
if(FlxG.save.data.globalAntialiasing != null) {
globalAntialiasing = FlxG.save.data.globalAntialiasing;
}
if(FlxG.save.data.noteSplashes != null) {
noteSplashes = FlxG.save.data.noteSplashes;
}
if(FlxG.save.data.lowQuality != null) {
lowQuality = FlxG.save.data.lowQuality;
}
if(FlxG.save.data.framerate != null) {
framerate = FlxG.save.data.framerate;
if(framerate > FlxG.drawFramerate) {
FlxG.updateFramerate = framerate;
FlxG.drawFramerate = framerate;
} else {
FlxG.drawFramerate = framerate;
FlxG.updateFramerate = framerate;
}
}
/*if(FlxG.save.data.cursing != null) {
cursing = FlxG.save.data.cursing;
}
if(FlxG.save.data.violence != null) {
violence = FlxG.save.data.violence;
}*/
if(FlxG.save.data.camZooms != null) {
camZooms = FlxG.save.data.camZooms;
}
if(FlxG.save.data.shaders != null){
shaders = FlxG.save.data.shaders;
}
if(FlxG.save.data.easyMode != null){
easyMode = FlxG.save.data.easyMode;
}
if(FlxG.save.data.hideHud != null) {
hideHud = FlxG.save.data.hideHud;
}
if(FlxG.save.data.noteOffset != null) {
noteOffset = FlxG.save.data.noteOffset;
}
if(FlxG.save.data.arrowHSV != null) {
arrowHSV = FlxG.save.data.arrowHSV;
}
if(FlxG.save.data.ghostTapping != null) {
ghostTapping = FlxG.save.data.ghostTapping;
}
if(FlxG.save.data.timeBarType != null) {
timeBarType = FlxG.save.data.timeBarType;
}
if(FlxG.save.data.scoreZoom != null) {
scoreZoom = FlxG.save.data.scoreZoom;
}
if(FlxG.save.data.noReset != null) {
noReset = FlxG.save.data.noReset;
}
if(FlxG.save.data.healthBarAlpha != null) {
healthBarAlpha = FlxG.save.data.healthBarAlpha;
}
if(FlxG.save.data.comboOffset != null) {
comboOffset = FlxG.save.data.comboOffset;
}
if(FlxG.save.data.ratingOffset != null) {
ratingOffset = FlxG.save.data.ratingOffset;
}
if(FlxG.save.data.sickWindow != null) {
sickWindow = FlxG.save.data.sickWindow;
}
if(FlxG.save.data.goodWindow != null) {
goodWindow = FlxG.save.data.goodWindow;
}
if(FlxG.save.data.badWindow != null) {
badWindow = FlxG.save.data.badWindow;
}
if(FlxG.save.data.safeFrames != null) {
safeFrames = FlxG.save.data.safeFrames;
}
if(FlxG.save.data.controllerMode != null) {
controllerMode = FlxG.save.data.controllerMode;
}
if(FlxG.save.data.hitsoundVolume != null) {
hitsoundVolume = FlxG.save.data.hitsoundVolume;
}
if(FlxG.save.data.pauseMusic != null) {
pauseMusic = FlxG.save.data.pauseMusic;
}
if(FlxG.save.data.gameplaySettings != null)
{
var savedMap:Map<String, Dynamic> = FlxG.save.data.gameplaySettings;
for (name => value in savedMap)
{
gameplaySettings.set(name, value);
}
}
// flixel automatically saves your volume!
if(FlxG.save.data.volume != null)
{
FlxG.sound.volume = FlxG.save.data.volume;
}
if (FlxG.save.data.mute != null)
{
FlxG.sound.muted = FlxG.save.data.mute;
}
var save:FlxSave = new FlxSave();
save.bind('controls_v2', 'ninjamuffin99');
if(save != null && save.data.customControls != null) {
var loadedControls:Map<String, Array<FlxKey>> = save.data.customControls;
for (control => keys in loadedControls) {
keyBinds.set(control, keys);
}
reloadControls();
}
}
inline public static function getGameplaySetting(name:String, defaultValue:Dynamic):Dynamic {
return /*PlayState.isStoryMode ? defaultValue : */ (gameplaySettings.exists(name) ? gameplaySettings.get(name) : defaultValue);
}
public static function reloadControls() {
PlayerSettings.player1.controls.setKeyboardScheme(KeyboardScheme.Solo);
TitleState.muteKeys = copyKey(keyBinds.get('volume_mute'));
TitleState.volumeDownKeys = copyKey(keyBinds.get('volume_down'));
TitleState.volumeUpKeys = copyKey(keyBinds.get('volume_up'));
FlxG.sound.muteKeys = TitleState.muteKeys;
FlxG.sound.volumeDownKeys = TitleState.volumeDownKeys;
FlxG.sound.volumeUpKeys = TitleState.volumeUpKeys;
}
public static function copyKey(arrayToCopy:Array<FlxKey>):Array<FlxKey> {
var copiedArray:Array<FlxKey> = arrayToCopy.copy();
var i:Int = 0;
var len:Int = copiedArray.length;
while (i < len) {
if(copiedArray[i] == NONE) {
copiedArray.remove(NONE);
--i;
}
i++;
len = copiedArray.length;
}
return copiedArray;
}
}