@@ -10,7 +10,8 @@ import editors.ChartingState;
10
10
11
11
using StringTools ;
12
12
13
- typedef EventNote = {
13
+ typedef EventNote =
14
+ {
14
15
strumTime : Float ,
15
16
event : String ,
16
17
value1 : String ,
@@ -19,7 +20,7 @@ typedef EventNote = {
19
20
20
21
class Note extends FlxSprite
21
22
{
22
- public var extraData : Map <String ,Dynamic > = [];
23
+ public var extraData : Map <String , Dynamic > = [];
23
24
24
25
public var strumTime : Float = 0 ;
25
26
public var mustPress : Bool = false ;
@@ -58,7 +59,7 @@ class Note extends FlxSprite
58
59
public var lowPriority : Bool = false ;
59
60
60
61
public static var swagWidth : Float = 160 * 0.7 ;
61
-
62
+
62
63
private var colArray : Array <String > = [' purple' , ' blue' , ' green' , ' red' ];
63
64
private var pixelInt : Array <Int > = [0 , 1 , 2 , 3 ];
64
65
@@ -83,43 +84,47 @@ class Note extends FlxSprite
83
84
public var hitHealth : Float = 0.023 ;
84
85
public var missHealth : Float = 0.0475 ;
85
86
public var rating : String = ' unknown' ;
86
- public var ratingMod : Float = 0 ; // 9 = unknown, 0.25 = shit, 0.5 = bad, 0.75 = good, 1 = sick
87
+ public var ratingMod : Float = 0 ; // 9 = unknown, 0.25 = shit, 0.5 = bad, 0.75 = good, 1 = sick
87
88
public var ratingDisabled : Bool = false ;
88
89
89
90
public var texture (default , set ): String = null ;
90
91
91
92
public var noAnimation : Bool = false ;
92
93
public var noMissAnimation : Bool = false ;
93
94
public var hitCausesMiss : Bool = false ;
94
- public var distance : Float = 2000 ; // plan on doing scroll directions soon -bb
95
+ public var distance : Float = 2000 ; // plan on doing scroll directions soon -bb
95
96
96
97
public var hitsoundDisabled : Bool = false ;
97
98
98
- private function set_multSpeed (value : Float ): Float {
99
+ private function set_multSpeed (value : Float ): Float
100
+ {
99
101
resizeByRatio (value / multSpeed );
100
102
multSpeed = value ;
101
- // trace('fuck cock');
103
+ // trace('fuck cock');
102
104
return value ;
103
105
}
104
106
105
- public function resizeByRatio (ratio : Float ) // haha funny twitter shit
107
+ public function resizeByRatio (ratio : Float ) // haha funny twitter shit
106
108
{
107
- if (isSustainNote && ! animation .curAnim .name .endsWith (' end' ))
109
+ if (isSustainNote && ! animation .curAnim .name .endsWith (' end' ))
108
110
{
109
111
scale .y * = ratio ;
110
112
updateHitbox ();
111
113
}
112
114
}
113
115
114
- private function set_texture (value : String ): String {
115
- if (texture != value ) {
116
+ private function set_texture (value : String ): String
117
+ {
118
+ if (texture != value )
119
+ {
116
120
reloadNote (' ' , value );
117
121
}
118
122
texture = value ;
119
123
return value ;
120
124
}
121
125
122
- private function set_noteType (value : String ): String {
126
+ private function set_noteType (value : String ): String
127
+ {
123
128
noteSplashTexture = PlayState .SONG .splashSkin ;
124
129
if (noteData > - 1 && noteData < ClientPrefs .data .arrowHSV .length )
125
130
{
@@ -128,8 +133,10 @@ class Note extends FlxSprite
128
133
colorSwap .brightness = ClientPrefs .data .arrowHSV [noteData ][2 ] / 100 ;
129
134
}
130
135
131
- if (noteData > - 1 && noteType != value ) {
132
- switch (value ) {
136
+ if (noteData > - 1 && noteType != value )
137
+ {
138
+ switch (value )
139
+ {
133
140
case ' Hurt Note' :
134
141
ignoreNote = mustPress ;
135
142
reloadNote (' HURT' );
@@ -139,9 +146,12 @@ class Note extends FlxSprite
139
146
colorSwap .brightness = 0 ;
140
147
lowPriority = true ;
141
148
142
- if (isSustainNote ) {
149
+ if (isSustainNote )
150
+ {
143
151
missHealth = 0.1 ;
144
- } else {
152
+ }
153
+ else
154
+ {
145
155
missHealth = 0.3 ;
146
156
}
147
157
hitCausesMiss = true ;
@@ -176,17 +186,20 @@ class Note extends FlxSprite
176
186
// MAKE SURE ITS DEFINITELY OFF SCREEN?
177
187
y - = 2000 ;
178
188
this .strumTime = strumTime ;
179
- if (! inEditor ) this .strumTime + = ClientPrefs .data .noteOffset ;
189
+ if (! inEditor )
190
+ this .strumTime + = ClientPrefs .data .noteOffset ;
180
191
181
192
this .noteData = noteData ;
182
193
183
- if (noteData > - 1 ) {
194
+ if (noteData > - 1 )
195
+ {
184
196
texture = ' ' ;
185
197
colorSwap = new ColorSwap ();
186
198
shader = colorSwap .shader ;
187
199
188
200
x + = swagWidth * (noteData );
189
- if (! isSustainNote && noteData > - 1 && noteData < 4 ) { // Doing this 'if' check to fix the warnings on Senpai songs
201
+ if (! isSustainNote && noteData > - 1 && noteData < 4 )
202
+ { // Doing this 'if' check to fix the warnings on Senpai songs
190
203
var animToPlay : String = ' ' ;
191
204
animToPlay = colArray [noteData % 4 ];
192
205
animation .play (animToPlay + ' Scroll' );
@@ -195,15 +208,16 @@ class Note extends FlxSprite
195
208
196
209
// trace(prevNote);
197
210
198
- if (prevNote != null )
211
+ if (prevNote != null )
199
212
prevNote .nextNote = this ;
200
213
201
214
if (isSustainNote && prevNote != null )
202
215
{
203
216
alpha = 0.6 ;
204
217
multAlpha = 0.6 ;
205
218
hitsoundDisabled = true ;
206
- if (ClientPrefs .data .downScroll ) flipY = true ;
219
+ if (ClientPrefs .data .downScroll )
220
+ flipY = true ;
207
221
208
222
offsetX + = width / 2 ;
209
223
copyAngle = false ;
@@ -222,63 +236,80 @@ class Note extends FlxSprite
222
236
prevNote .animation .play (colArray [prevNote .noteData % 4 ] + ' hold' );
223
237
224
238
prevNote .scale .y * = Conductor .stepCrochet / 100 * 1.05 ;
225
- if (PlayState .instance != null )
239
+ if (PlayState .instance != null )
226
240
{
227
241
prevNote .scale .y * = PlayState .instance .songSpeed ;
228
242
}
229
243
230
- if (PlayState .isPixelStage ) {
244
+ if (PlayState .isPixelStage )
245
+ {
231
246
prevNote .scale .y * = 1.19 ;
232
- prevNote .scale .y * = (6 / height ); // Auto adjust note size
247
+ prevNote .scale .y * = (6 / height ); // Auto adjust note size
233
248
}
234
249
prevNote .updateHitbox ();
235
250
// prevNote.setGraphicSize();
236
251
}
237
252
238
- if (PlayState .isPixelStage ) {
253
+ if (PlayState .isPixelStage )
254
+ {
239
255
scale .y * = PlayState .daPixelZoom ;
240
256
updateHitbox ();
241
257
}
242
- } else if (! isSustainNote ) {
258
+ }
259
+ else if (! isSustainNote )
260
+ {
243
261
earlyHitMult = 1 ;
244
262
}
245
263
x + = offsetX ;
246
264
}
247
265
248
266
var lastNoteOffsetXForPixelAutoAdjusting : Float = 0 ;
249
267
var lastNoteScaleToo : Float = 1 ;
268
+
250
269
public var originalHeightForCalcs : Float = 6 ;
251
- function reloadNote (? prefix : String = ' ' , ? texture : String = ' ' , ? suffix : String = ' ' ) {
252
- if (prefix == null ) prefix = ' ' ;
253
- if (texture == null ) texture = ' ' ;
254
- if (suffix == null ) suffix = ' ' ;
270
+
271
+ function reloadNote (? prefix : String = ' ' , ? texture : String = ' ' , ? suffix : String = ' ' )
272
+ {
273
+ if (prefix == null )
274
+ prefix = ' ' ;
275
+ if (texture == null )
276
+ texture = ' ' ;
277
+ if (suffix == null )
278
+ suffix = ' ' ;
255
279
256
280
var skin : String = texture ;
257
- if (texture .length < 1 ) {
281
+ if (texture .length < 1 )
282
+ {
258
283
skin = PlayState .SONG .arrowSkin ;
259
- if (skin == null || skin .length < 1 ) {
284
+ if (skin == null || skin .length < 1 )
285
+ {
260
286
skin = ' NOTE_assets' ;
261
287
}
262
288
}
263
289
264
290
var animName : String = null ;
265
- if (animation .curAnim != null ) {
291
+ if (animation .curAnim != null )
292
+ {
266
293
animName = animation .curAnim .name ;
267
294
}
268
295
269
296
var arraySkin : Array <String > = skin .split (' /' );
270
- arraySkin [arraySkin .length - 1 ] = prefix + arraySkin [arraySkin .length - 1 ] + suffix ;
297
+ arraySkin [arraySkin .length - 1 ] = prefix + arraySkin [arraySkin .length - 1 ] + suffix ;
271
298
272
299
var lastScaleY : Float = scale .y ;
273
300
var blahblah : String = arraySkin .join (' /' );
274
- if (PlayState .isPixelStage ) {
275
- if (isSustainNote ) {
301
+ if (PlayState .isPixelStage )
302
+ {
303
+ if (isSustainNote )
304
+ {
276
305
loadGraphic (Paths .image (' pixelUI/' + blahblah + ' ENDS' ));
277
306
width = width / 4 ;
278
307
height = height / 2 ;
279
308
originalHeightForCalcs = height ;
280
309
loadGraphic (Paths .image (' pixelUI/' + blahblah + ' ENDS' ), true , Math .floor (width ), Math .floor (height ));
281
- } else {
310
+ }
311
+ else
312
+ {
282
313
loadGraphic (Paths .image (' pixelUI/' + blahblah ));
283
314
width = width / 4 ;
284
315
height = height / 5 ;
@@ -288,38 +319,44 @@ class Note extends FlxSprite
288
319
loadPixelNoteAnims ();
289
320
antialiasing = false ;
290
321
291
- if (isSustainNote ) {
322
+ if (isSustainNote )
323
+ {
292
324
offsetX + = lastNoteOffsetXForPixelAutoAdjusting ;
293
325
lastNoteOffsetXForPixelAutoAdjusting = (width - 7 ) * (PlayState .daPixelZoom / 2 );
294
326
offsetX - = lastNoteOffsetXForPixelAutoAdjusting ;
295
327
296
328
/* if(animName != null && !animName.endsWith('end'))
297
- {
298
- lastScaleY /= lastNoteScaleToo;
299
- lastNoteScaleToo = (6 / height);
300
- lastScaleY *= lastNoteScaleToo;
329
+ {
330
+ lastScaleY /= lastNoteScaleToo;
331
+ lastNoteScaleToo = (6 / height);
332
+ lastScaleY *= lastNoteScaleToo;
301
333
}*/
302
334
}
303
- } else {
335
+ }
336
+ else
337
+ {
304
338
frames = Paths .getSparrowAtlas (blahblah );
305
339
loadNoteAnims ();
306
340
antialiasing = ClientPrefs .data .globalAntialiasing ;
307
341
}
308
- if (isSustainNote ) {
342
+ if (isSustainNote )
343
+ {
309
344
scale .y = lastScaleY ;
310
345
}
311
346
updateHitbox ();
312
347
313
- if (animName != null )
348
+ if (animName != null )
314
349
animation .play (animName , true );
315
350
316
- if (inEditor ) {
351
+ if (inEditor )
352
+ {
317
353
setGraphicSize (ChartingState .GRID_SIZE , ChartingState .GRID_SIZE );
318
354
updateHitbox ();
319
355
}
320
356
}
321
357
322
- function loadNoteAnims () {
358
+ function loadNoteAnims ()
359
+ {
323
360
animation .addByPrefix (colArray [noteData ] + ' Scroll' , colArray [noteData ] + ' 0' );
324
361
325
362
if (isSustainNote )
@@ -333,11 +370,15 @@ class Note extends FlxSprite
333
370
updateHitbox ();
334
371
}
335
372
336
- function loadPixelNoteAnims () {
337
- if (isSustainNote ) {
373
+ function loadPixelNoteAnims ()
374
+ {
375
+ if (isSustainNote )
376
+ {
338
377
animation .add (colArray [noteData ] + ' holdend' , [pixelInt [noteData ] + 4 ]);
339
378
animation .add (colArray [noteData ] + ' hold' , [pixelInt [noteData ]]);
340
- } else {
379
+ }
380
+ else
381
+ {
341
382
animation .add (colArray [noteData ] + ' Scroll' , [pixelInt [noteData ] + 4 ]);
342
383
}
343
384
}
@@ -364,7 +405,7 @@ class Note extends FlxSprite
364
405
365
406
if (strumTime < Conductor .songPosition + (Conductor .safeZoneOffset * earlyHitMult ))
366
407
{
367
- if ((isSustainNote && prevNote .wasGoodHit ) || strumTime <= Conductor .songPosition )
408
+ if ((isSustainNote && prevNote .wasGoodHit ) || strumTime <= Conductor .songPosition )
368
409
wasGoodHit = true ;
369
410
}
370
411
}
@@ -375,4 +416,43 @@ class Note extends FlxSprite
375
416
alpha = 0.3 ;
376
417
}
377
418
}
419
+
420
+ public function clipToStrumNote (myStrum : StrumNote )
421
+ {
422
+ var center : Float = myStrum .y + offsetY + Note .swagWidth / 2 ;
423
+ if (isSustainNote && (mustPress || ! ignoreNote ) && (! mustPress || (wasGoodHit || (prevNote .wasGoodHit && ! canBeHit ))))
424
+ {
425
+ var swagRect : flixel.math. FlxRect = clipRect ;
426
+ if (swagRect == null )
427
+ swagRect = new flixel.math. FlxRect (0 , 0 , frameWidth , frameHeight );
428
+
429
+ if (myStrum .downScroll )
430
+ {
431
+ if (y - offset .y * scale .y + height >= center )
432
+ {
433
+ swagRect .width = frameWidth ;
434
+ swagRect .height = (center - y ) / scale .y ;
435
+ swagRect .y = frameHeight - swagRect .height ;
436
+ }
437
+ }
438
+ else if (y + offset .y * scale .y <= center )
439
+ {
440
+ swagRect .y = (center - y ) / scale .y ;
441
+ swagRect .width = width / scale .x ;
442
+ swagRect .height = (height / scale .y ) - swagRect .y ;
443
+ }
444
+ clipRect = swagRect ;
445
+ }
446
+ }
447
+
448
+ @:noCompletion
449
+ override function set_clipRect (rect : flixel.math. FlxRect ): flixel.math. FlxRect
450
+ {
451
+ clipRect = rect ;
452
+
453
+ if (frames != null )
454
+ frame = frames .frames [animation .frameIndex ];
455
+
456
+ return rect ;
457
+ }
378
458
}
0 commit comments