-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathStrumNote.hx
More file actions
338 lines (311 loc) · 12.3 KB
/
StrumNote.hx
File metadata and controls
338 lines (311 loc) · 12.3 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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
package;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.graphics.frames.FlxAtlasFrames;
using StringTools;
class StrumNote extends FlxSprite
{
public var resetAnim:Float = 0;
private var noteData:Int = 0;
public var direction:Float = 90;//plan on doing scroll directions soon -bb
public var downScroll:Bool = false;//plan on doing scroll directions soon -bb
public var sustainReduce:Bool = true;
private var player:Int;
public var texture(default, set):String = null;
// # region dge core
public var animConfirm:String = 'confirm';//'confirm', 'static', 'pressed', 'notes'(mayybe could custom if use callPropertyFromGroup())
public var fieldName:String = '';//only use for remove object and target of 'customStrum'
public var memberID:Int =0; //only use target 'customStrum'(deprecated)
public var camTarget(default, set):String = null;
public var scrollFactorCam(default,set):Array<Float> = [0.0, 0.0];//only can affected in camGame
public var gfType:Bool = false;
public var snapX:Float = 0;
public var snapY:Float = 0;
public var snapAngle:Float = 0;
public var snapAlpha:Float = 0;
public var ignoreTextureChange:Bool = false;
public var sustainReducePoint:Float = 0.5;//how height before sustain note cliped(0:top of strum, 1:bottom of strum)
public var resetTime:Float = 0.2;//how time to reset to static anim(<=0 is permanent btw)
public var classicAnim:Bool = ClientPrefs.classicAnim;//use classic anim behavior
public var isLocked:Bool = false;//strums become unpresseable(affected dpending gamemode)(inspired retrospcter p2 chain notes)
public var reloadAnimation:Bool = true;//if false it will not reload anim when playAnim called
//fake strum stats (for custom strum, it will use these stats instead of strum stats, if not null)
//not anything because kinda odd to put it XD
public var fakeStrumX:Null<Float> = null;//override strum stat x to 'this' position x
public var fakeStrumY:Null<Float> = null;//override strum stat y to 'this' position y
public var fakeStrumAngle:Null<Float> = null;//override strum stat angle to 'this' angle
public var fakeStrumAlpha:Null<Float> = null;//override strum stat alpha to 'this' alpha
public var fakeStrumDirection:Null<Float> = null;//override strum stat direction to 'this' direction
public var fakeStrumDownScroll:Null<Bool> = null;//override strum stat downScroll to 'this' downScroll
// # endregion
private function set_texture(value:String):String {
if (value == null) {
value = '';
}
if(texture != value) {
texture = value;
reloadNote(texture);
}
return value;
}
public function new(x:Float, y:Float, leData:Int, player:Int, gf:Bool = false) {
noteData = leData;
this.player = player;
this.noteData = leData;
super(x, y);
gfType = gf;
texture = '';
shaderType = 'swap';
camTarget = 'hud';
scrollFactor.set(scrollFactorCam[0], scrollFactorCam[1]);
}
public function reloadNote(image:String = '')
{
var lastAnim:String = null;
if(animation.curAnim != null) lastAnim = animation.curAnim.name;
reloadAnims(image);
if(lastAnim != null)
{
playAnim(lastAnim, true);
}
}
public function postAddedToGroup() {
playAnim('static');
ID = noteData;
}
override function update(elapsed:Float) {
if(resetAnim > 0) {
resetAnim -= elapsed;
if(resetAnim <= 0) {
playAnim('static');
resetAnim = 0;
}
}
if(animation != null && animation.curAnim != null){ //my bad i was upset
if(animation.curAnim.name == animConfirm && !PlayState.isPixelStage) {
centerOrigin();
}
}
super.update(elapsed);
}
public function playAnim(anim:String, ?force:Bool = false, sustainNote:Bool = false, ?note:Note = null, reloadAnim:Bool = false) {
if (animation != null && animation.curAnim != null && animation.curAnim.name == anim && sustainNote && !classicAnim) return;
if (reloadAnim && reloadAnimation) {
reloadAnims(texture, note);
}
animation.play(anim, force);
centerOrigin();
centerOffsets();
if(animation.curAnim == null || animation.curAnim.name == 'static') {
colorSwap.hue = 0;
colorSwap.saturation = 0;
colorSwap.brightness = 0;
} else {
if (noteData > -1)
{
colorSwap.hue = ClientPrefs.arrowHSV[noteData % 4][0] / 360;
colorSwap.saturation = ClientPrefs.arrowHSV[noteData % 4][1] / 100;
colorSwap.brightness = ClientPrefs.arrowHSV[noteData % 4][2] / 100;
}
if(animation.curAnim.name == animConfirm && !PlayState.isPixelStage) {
centerOrigin();
}
}
}
private function set_camTarget(value:String):String {
if (camTarget != value && FlxG.state is PlayState) {
if (value != '') {
var camArray:Array<String> = value.split(',');
var realCam:Array<String> = [];
for (i in 0...camArray.length) {
realCam[i] = camArray[i].trim();
}
cameras = FunkinLua.cameraArrayFromString(realCam);
} else {
cameras = null;
}
}
camTarget = value;
return value;
}
function set_scrollFactorCam(value:Array<Float>):Array<Float> {
if (scrollFactorCam[0] != value[0] || scrollFactorCam[1] != value[1]) {
scrollFactor.set(value[0], value[1]);
}
scrollFactorCam[0] = value[0];
scrollFactorCam[1] = value[1];
return value;
}
override public function set_y(value:Float):Float {
if (snapY > 0) {
var dist = value - y;
var snapped = Math.round(dist / snapY) * snapY;
return super.set_y(y+snapped);
}
return super.set_y(value);
}
override public function set_x(value:Float):Float {
if (snapX > 0) {
var dist = value - x;
var snapped = Math.round(dist / snapX) * snapX;
return super.set_x(x+snapped);
}
return super.set_x(value);
}
override public function set_angle(value:Float):Float {
if (snapAngle > 0) {
var dist = value - angle;
var snapped = Math.round(dist / snapAngle) * snapAngle;
return super.set_angle(angle+snapped);
}
return super.set_angle(value);
}
override public function set_alpha(value:Float):Float {
if (snapAlpha > 0) {
var dist = value - alpha;
var snapped = Math.round(dist / snapAlpha) * snapAlpha;
return super.set_alpha(alpha+snapped);
}
return super.set_alpha(value);
}
function reloadAnims(image:String, ?note:Note) {
var skin:String = PlayState.SONG.arrowSkin;
var skinOpt:String = PlayState.SONG.arrowSkinOpt;
var skinSec:String = PlayState.SONG.arrowSkinSec;
if (skin == null || skin.length < 1) {
skin = ClientPrefs.dflnoteskin;
}
//if opponent notes didt iput it ill use player skin/default. if sec opt not set texture it ill use opponent texture. bruh idk how to explain this
if(skinOpt == null || skinOpt.length < 1) {
skinOpt = skin;
}
if(skinSec == null || skinSec.length < 1) {
if(skinOpt == null || skinOpt.length < 1) {
skinOpt = skin;
}
skinSec = skinOpt;
}
if (image == '' || image.length < 1) {
if (player == 1) {
image = skin;
} else {
if (gfType) {
image = skinSec;
} else {
image = skinOpt;
}
}
}
if(PlayState.isPixelStage)
{
loadGraphic(Paths.image('pixelUI/' + image));
width = width / 4;
height = height / 5;
loadGraphic(Paths.image('pixelUI/' + image), true, Math.floor(width), Math.floor(height));
antialiasing = false;
setGraphicSize(Std.int(width * PlayState.daPixelZoom));
animation.add('green', [6]);
animation.add('red', [7]);
animation.add('blue', [5]);
animation.add('purple', [4]);
switch (Math.abs(noteData) % 4)
{
case 0:
animation.add('static', [0]);
animation.add('pressed', [4, 8], (ClientPrefs.fpsStrumAnim)/2, false);
animation.add('notes', [4]);
animation.add('confirm', [12, 16], ClientPrefs.fpsStrumAnim, false);
case 1:
animation.add('static', [1]);
animation.add('pressed', [5, 9], (ClientPrefs.fpsStrumAnim)/2, false);
animation.add('notes', [5]);
animation.add('confirm', [13, 17], ClientPrefs.fpsStrumAnim, false);
case 2:
animation.add('static', [2]);
animation.add('pressed', [6, 10], (ClientPrefs.fpsStrumAnim)/2, false);
animation.add('notes', [6]);
animation.add('confirm', [14, 18], (ClientPrefs.fpsStrumAnim)/2, false);
case 3:
animation.add('static', [3]);
animation.add('pressed', [7, 11], (ClientPrefs.fpsStrumAnim)/2, false);
animation.add('notes', [7]);
animation.add('confirm', [15, 19], ClientPrefs.fpsStrumAnim, false);
}
}
else
{
try{
frames = Paths.getSparrowAtlas(image);
} catch(e:Dynamic) {
try{
frames = Paths.getSparrowAtlas(ClientPrefs.dflnoteskin);
} catch (e:Dynamic) {
frames = Paths.getSparrowAtlas('NOTE_assets');
}
}
animation.addByPrefix('green', 'arrowUP');
animation.addByPrefix('blue', 'arrowDOWN');
animation.addByPrefix('purple', 'arrowLEFT');
animation.addByPrefix('red', 'arrowRIGHT');
setGraphicSize(Std.int(width * ClientPrefs.strumsize));
antialiasing = ClientPrefs.globalAntialiasing;
var addAnimThingy = CoolUtil.addSpecialAnimation;
switch (Math.abs(noteData) % 4)
{
case 0:
if ((note != null && note.getActualDownscroll()) || ClientPrefs.downScroll) {
addAnimThingy(this, 'static', 'arrowLEFT_DownScroll0', 'arrowLEFT0', true, ClientPrefs.fpsStrumAnim);
addAnimThingy(this, 'pressed', 'left press_DownScroll0', 'left press0', false, ClientPrefs.fpsStrumAnim);
addAnimThingy(this, 'confirm', 'left confirm_DownScroll0', 'left confirm0', false, ClientPrefs.fpsStrumAnim);
addAnimThingy(this, 'notes', 'purple Downscroll0', 'purple0', false, ClientPrefs.fpsStrumAnim);
} else {
animation.addByPrefix('static', 'arrowLEFT0');
animation.addByPrefix('pressed', 'left press0', ClientPrefs.fpsStrumAnim, false);
animation.addByPrefix('confirm', 'left confirm0', ClientPrefs.fpsStrumAnim, false);
animation.addByPrefix('notes', 'purple0', ClientPrefs.fpsStrumAnim, false);
}
case 1:
if (note != null && note.getActualDownscroll() || ClientPrefs.downScroll) {
addAnimThingy(this, 'static', 'arrowDOWN_DownScroll0', 'arrowDOWN0', true, ClientPrefs.fpsStrumAnim);
addAnimThingy(this, 'pressed', 'down press_DownScroll0', 'down press0', false, ClientPrefs.fpsStrumAnim);
addAnimThingy(this, 'confirm', 'down confirm_DownScroll0', 'down confirm0', false, ClientPrefs.fpsStrumAnim);
addAnimThingy(this, 'notes', 'blue Downscroll0', 'blue0', false, ClientPrefs.fpsStrumAnim);
} else {
animation.addByPrefix('static', 'arrowDOWN0');
animation.addByPrefix('pressed', 'down press0', ClientPrefs.fpsStrumAnim, false);
animation.addByPrefix('confirm', 'down confirm0', ClientPrefs.fpsStrumAnim, false);
animation.addByPrefix('notes', 'blue0', ClientPrefs.fpsStrumAnim, false);
}
case 2:
if (note != null && note.getActualDownscroll() || ClientPrefs.downScroll) {
addAnimThingy(this, 'static', 'arrowUP_DownScroll0', 'arrowUP0', true, ClientPrefs.fpsStrumAnim);
addAnimThingy(this, 'pressed', 'up press_DownScroll0', 'up press0', false, ClientPrefs.fpsStrumAnim);
addAnimThingy(this, 'confirm', 'up confirm_DownScroll0', 'up confirm0', false, ClientPrefs.fpsStrumAnim);
addAnimThingy(this, 'notes', 'green Downscroll0', 'green0', false, ClientPrefs.fpsStrumAnim);
} else {
animation.addByPrefix('static', 'arrowUP0');
animation.addByPrefix('pressed', 'up press0', ClientPrefs.fpsStrumAnim, false);
animation.addByPrefix('confirm', 'up confirm0', ClientPrefs.fpsStrumAnim, false);
animation.addByPrefix('notes', 'green0', ClientPrefs.fpsStrumAnim, false);
}
case 3:
if (note != null && note.getActualDownscroll() || ClientPrefs.downScroll) {
addAnimThingy(this, 'static', 'arrowRIGHT_DownScroll0', 'arrowRIGHT0', true, ClientPrefs.fpsStrumAnim);
addAnimThingy(this, 'pressed', 'right press_DownScroll0', 'right press0', false, ClientPrefs.fpsStrumAnim);
addAnimThingy(this, 'confirm', 'right confirm_DownScroll0', 'right confirm0', false, ClientPrefs.fpsStrumAnim);
addAnimThingy(this, 'notes', 'red Downscroll0', 'red0', false, ClientPrefs.fpsStrumAnim);
} else {
animation.addByPrefix('static', 'arrowRIGHT0');
animation.addByPrefix('pressed', 'right press0', ClientPrefs.fpsStrumAnim, false);
animation.addByPrefix('confirm', 'right confirm0', ClientPrefs.fpsStrumAnim, false);
animation.addByPrefix('notes', 'red0', ClientPrefs.fpsStrumAnim, false);
}
}
}
updateHitbox();
if (player == 0 && PlayState.SONG.secOpt) {
scale.x *= 0.75;
scale.y *= 0.75;
}
}
}