Skip to content

Commit a6e3216

Browse files
authored
Merge pull request #17 from LeonGamerPS1/main
a small fix for project.xml and psych engine 0.7.x note sustain cliprect
2 parents 2c5a1bc + 4004dfe commit a6e3216

File tree

3 files changed

+1280
-778
lines changed

3 files changed

+1280
-778
lines changed

Project.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<!-- ____________________________ Window Settings ___________________________ -->
1919

2020
<!--These window settings apply to all targets-->
21-
<window width="1280" height="720" fps="" background="#000000" hardware="true" vsync="false" />
21+
<window width="1280" height="720" fps="60" background="#000000" hardware="true" vsync="false" />
2222

2323
<!--HTML5-specific-->
2424
<window if="html5" resizable="true" />

source/Note.hx

Lines changed: 131 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import editors.ChartingState;
1010

1111
using StringTools;
1212

13-
typedef EventNote = {
13+
typedef EventNote =
14+
{
1415
strumTime:Float,
1516
event:String,
1617
value1:String,
@@ -19,7 +20,7 @@ typedef EventNote = {
1920

2021
class Note extends FlxSprite
2122
{
22-
public var extraData:Map<String,Dynamic> = [];
23+
public var extraData:Map<String, Dynamic> = [];
2324

2425
public var strumTime:Float = 0;
2526
public var mustPress:Bool = false;
@@ -58,7 +59,7 @@ class Note extends FlxSprite
5859
public var lowPriority:Bool = false;
5960

6061
public static var swagWidth:Float = 160 * 0.7;
61-
62+
6263
private var colArray:Array<String> = ['purple', 'blue', 'green', 'red'];
6364
private var pixelInt:Array<Int> = [0, 1, 2, 3];
6465

@@ -83,43 +84,47 @@ class Note extends FlxSprite
8384
public var hitHealth:Float = 0.023;
8485
public var missHealth:Float = 0.0475;
8586
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
8788
public var ratingDisabled:Bool = false;
8889

8990
public var texture(default, set):String = null;
9091

9192
public var noAnimation:Bool = false;
9293
public var noMissAnimation:Bool = false;
9394
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
9596

9697
public var hitsoundDisabled:Bool = false;
9798

98-
private function set_multSpeed(value:Float):Float {
99+
private function set_multSpeed(value:Float):Float
100+
{
99101
resizeByRatio(value / multSpeed);
100102
multSpeed = value;
101-
//trace('fuck cock');
103+
// trace('fuck cock');
102104
return value;
103105
}
104106

105-
public function resizeByRatio(ratio:Float) //haha funny twitter shit
107+
public function resizeByRatio(ratio:Float) // haha funny twitter shit
106108
{
107-
if(isSustainNote && !animation.curAnim.name.endsWith('end'))
109+
if (isSustainNote && !animation.curAnim.name.endsWith('end'))
108110
{
109111
scale.y *= ratio;
110112
updateHitbox();
111113
}
112114
}
113115

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+
{
116120
reloadNote('', value);
117121
}
118122
texture = value;
119123
return value;
120124
}
121125

122-
private function set_noteType(value:String):String {
126+
private function set_noteType(value:String):String
127+
{
123128
noteSplashTexture = PlayState.SONG.splashSkin;
124129
if (noteData > -1 && noteData < ClientPrefs.data.arrowHSV.length)
125130
{
@@ -128,8 +133,10 @@ class Note extends FlxSprite
128133
colorSwap.brightness = ClientPrefs.data.arrowHSV[noteData][2] / 100;
129134
}
130135

131-
if(noteData > -1 && noteType != value) {
132-
switch(value) {
136+
if (noteData > -1 && noteType != value)
137+
{
138+
switch (value)
139+
{
133140
case 'Hurt Note':
134141
ignoreNote = mustPress;
135142
reloadNote('HURT');
@@ -139,9 +146,12 @@ class Note extends FlxSprite
139146
colorSwap.brightness = 0;
140147
lowPriority = true;
141148

142-
if(isSustainNote) {
149+
if (isSustainNote)
150+
{
143151
missHealth = 0.1;
144-
} else {
152+
}
153+
else
154+
{
145155
missHealth = 0.3;
146156
}
147157
hitCausesMiss = true;
@@ -176,17 +186,20 @@ class Note extends FlxSprite
176186
// MAKE SURE ITS DEFINITELY OFF SCREEN?
177187
y -= 2000;
178188
this.strumTime = strumTime;
179-
if(!inEditor) this.strumTime += ClientPrefs.data.noteOffset;
189+
if (!inEditor)
190+
this.strumTime += ClientPrefs.data.noteOffset;
180191

181192
this.noteData = noteData;
182193

183-
if(noteData > -1) {
194+
if (noteData > -1)
195+
{
184196
texture = '';
185197
colorSwap = new ColorSwap();
186198
shader = colorSwap.shader;
187199

188200
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
190203
var animToPlay:String = '';
191204
animToPlay = colArray[noteData % 4];
192205
animation.play(animToPlay + 'Scroll');
@@ -195,15 +208,16 @@ class Note extends FlxSprite
195208

196209
// trace(prevNote);
197210

198-
if(prevNote!=null)
211+
if (prevNote != null)
199212
prevNote.nextNote = this;
200213

201214
if (isSustainNote && prevNote != null)
202215
{
203216
alpha = 0.6;
204217
multAlpha = 0.6;
205218
hitsoundDisabled = true;
206-
if(ClientPrefs.data.downScroll) flipY = true;
219+
if (ClientPrefs.data.downScroll)
220+
flipY = true;
207221

208222
offsetX += width / 2;
209223
copyAngle = false;
@@ -222,63 +236,80 @@ class Note extends FlxSprite
222236
prevNote.animation.play(colArray[prevNote.noteData % 4] + 'hold');
223237

224238
prevNote.scale.y *= Conductor.stepCrochet / 100 * 1.05;
225-
if(PlayState.instance != null)
239+
if (PlayState.instance != null)
226240
{
227241
prevNote.scale.y *= PlayState.instance.songSpeed;
228242
}
229243

230-
if(PlayState.isPixelStage) {
244+
if (PlayState.isPixelStage)
245+
{
231246
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
233248
}
234249
prevNote.updateHitbox();
235250
// prevNote.setGraphicSize();
236251
}
237252

238-
if(PlayState.isPixelStage) {
253+
if (PlayState.isPixelStage)
254+
{
239255
scale.y *= PlayState.daPixelZoom;
240256
updateHitbox();
241257
}
242-
} else if(!isSustainNote) {
258+
}
259+
else if (!isSustainNote)
260+
{
243261
earlyHitMult = 1;
244262
}
245263
x += offsetX;
246264
}
247265

248266
var lastNoteOffsetXForPixelAutoAdjusting:Float = 0;
249267
var lastNoteScaleToo:Float = 1;
268+
250269
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 = '';
255279

256280
var skin:String = texture;
257-
if(texture.length < 1) {
281+
if (texture.length < 1)
282+
{
258283
skin = PlayState.SONG.arrowSkin;
259-
if(skin == null || skin.length < 1) {
284+
if (skin == null || skin.length < 1)
285+
{
260286
skin = 'NOTE_assets';
261287
}
262288
}
263289

264290
var animName:String = null;
265-
if(animation.curAnim != null) {
291+
if (animation.curAnim != null)
292+
{
266293
animName = animation.curAnim.name;
267294
}
268295

269296
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;
271298

272299
var lastScaleY:Float = scale.y;
273300
var blahblah:String = arraySkin.join('/');
274-
if(PlayState.isPixelStage) {
275-
if(isSustainNote) {
301+
if (PlayState.isPixelStage)
302+
{
303+
if (isSustainNote)
304+
{
276305
loadGraphic(Paths.image('pixelUI/' + blahblah + 'ENDS'));
277306
width = width / 4;
278307
height = height / 2;
279308
originalHeightForCalcs = height;
280309
loadGraphic(Paths.image('pixelUI/' + blahblah + 'ENDS'), true, Math.floor(width), Math.floor(height));
281-
} else {
310+
}
311+
else
312+
{
282313
loadGraphic(Paths.image('pixelUI/' + blahblah));
283314
width = width / 4;
284315
height = height / 5;
@@ -288,38 +319,44 @@ class Note extends FlxSprite
288319
loadPixelNoteAnims();
289320
antialiasing = false;
290321

291-
if(isSustainNote) {
322+
if (isSustainNote)
323+
{
292324
offsetX += lastNoteOffsetXForPixelAutoAdjusting;
293325
lastNoteOffsetXForPixelAutoAdjusting = (width - 7) * (PlayState.daPixelZoom / 2);
294326
offsetX -= lastNoteOffsetXForPixelAutoAdjusting;
295327

296328
/*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;
301333
}*/
302334
}
303-
} else {
335+
}
336+
else
337+
{
304338
frames = Paths.getSparrowAtlas(blahblah);
305339
loadNoteAnims();
306340
antialiasing = ClientPrefs.data.globalAntialiasing;
307341
}
308-
if(isSustainNote) {
342+
if (isSustainNote)
343+
{
309344
scale.y = lastScaleY;
310345
}
311346
updateHitbox();
312347

313-
if(animName != null)
348+
if (animName != null)
314349
animation.play(animName, true);
315350

316-
if(inEditor) {
351+
if (inEditor)
352+
{
317353
setGraphicSize(ChartingState.GRID_SIZE, ChartingState.GRID_SIZE);
318354
updateHitbox();
319355
}
320356
}
321357

322-
function loadNoteAnims() {
358+
function loadNoteAnims()
359+
{
323360
animation.addByPrefix(colArray[noteData] + 'Scroll', colArray[noteData] + '0');
324361

325362
if (isSustainNote)
@@ -333,11 +370,15 @@ class Note extends FlxSprite
333370
updateHitbox();
334371
}
335372

336-
function loadPixelNoteAnims() {
337-
if(isSustainNote) {
373+
function loadPixelNoteAnims()
374+
{
375+
if (isSustainNote)
376+
{
338377
animation.add(colArray[noteData] + 'holdend', [pixelInt[noteData] + 4]);
339378
animation.add(colArray[noteData] + 'hold', [pixelInt[noteData]]);
340-
} else {
379+
}
380+
else
381+
{
341382
animation.add(colArray[noteData] + 'Scroll', [pixelInt[noteData] + 4]);
342383
}
343384
}
@@ -364,7 +405,7 @@ class Note extends FlxSprite
364405

365406
if (strumTime < Conductor.songPosition + (Conductor.safeZoneOffset * earlyHitMult))
366407
{
367-
if((isSustainNote && prevNote.wasGoodHit) || strumTime <= Conductor.songPosition)
408+
if ((isSustainNote && prevNote.wasGoodHit) || strumTime <= Conductor.songPosition)
368409
wasGoodHit = true;
369410
}
370411
}
@@ -375,4 +416,43 @@ class Note extends FlxSprite
375416
alpha = 0.3;
376417
}
377418
}
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+
}
378458
}

0 commit comments

Comments
 (0)