Skip to content

Commit 83d01be

Browse files
committed
Make it work as intended
1 parent 400ef63 commit 83d01be

File tree

2 files changed

+30
-22
lines changed

2 files changed

+30
-22
lines changed

source/funkin/play/notes/Strumline.hx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ class Strumline extends FlxSpriteGroup
700700
else if (conductorInUse.songPosition > holdNote.strumTime && holdNote.hitNote)
701701
{
702702
// Hold note is currently being hit, clip it off.
703-
holdConfirm(holdNote.noteDirection);
703+
holdConfirm(holdNote.noteDirection, holdNote.fullSustainLength);
704704
holdNote.visible = true;
705705

706706
holdNote.sustainLength = (holdNote.strumTime + holdNote.fullSustainLength) - conductorInUse.songPosition;
@@ -1019,9 +1019,9 @@ class Strumline extends FlxSpriteGroup
10191019
* Play a confirm animation for a hold note.
10201020
* @param direction The direction of the note to play the confirm animation for.
10211021
*/
1022-
public function holdConfirm(direction:NoteDirection):Void
1022+
public function holdConfirm(direction:NoteDirection, ?length:Float = 0):Void
10231023
{
1024-
getByDirection(direction).holdConfirm();
1024+
getByDirection(direction).holdConfirm(length / 1000);
10251025

10261026
if (isPlayer) noteVibrations.noteStatuses[direction] = NoteStatus.holdConfirm;
10271027
}

source/funkin/play/notes/StrumlineNote.hx

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ class StrumlineNote extends FunkinSprite
7373
{
7474
// Run a timer before we stop playing the confirm animation.
7575
// On player, this allows holding the confirm key to fall back to press.
76-
if (isPlayer && name == 'confirm')
76+
if (isPlayer && name == 'confirm' && !holding)
7777
{
78-
confirmHoldTimer = 0;
78+
confirmHoldTimer = CONFIRM_HOLD_TIME;
7979
}
8080
}
8181

@@ -85,15 +85,16 @@ class StrumlineNote extends FunkinSprite
8585

8686
centerOrigin();
8787

88-
if (confirmHoldTimer >= 0)
88+
if (confirmHoldTimer > 0)
8989
{
90-
confirmHoldTimer += elapsed;
90+
confirmHoldTimer -= elapsed;
9191

9292
// Ensure the opponent stops holding the key after a certain amount of time.
93-
if (confirmHoldTimer >= CONFIRM_HOLD_TIME)
93+
if (confirmHoldTimer <= 0)
9494
{
9595
confirmHoldTimer = -1;
9696
playStatic();
97+
holding = false;
9798
}
9899
}
99100
}
@@ -145,36 +146,43 @@ class StrumlineNote extends FunkinSprite
145146

146147
// On opponent, run a timer to stop playing the confirm animation.
147148
// On player, stop the timer to avoid stopping the confirm animation earlier.
148-
confirmHoldTimer = isPlayer ? -1 : 0;
149+
confirmHoldTimer = isPlayer ? -1 : CONFIRM_HOLD_TIME;
150+
holding = false;
149151
}
150152

151153
public function isConfirm():Bool
152154
{
153155
return getCurrentAnimation().startsWith('confirm');
154156
}
155157

156-
public function holdConfirm():Void
158+
public var holding:Bool = false;
159+
160+
public function holdConfirm(?length:Float = 0):Void
157161
{
158162
this.active = true;
159163

160-
if (getCurrentAnimation() == "confirm-hold")
161-
{
162-
return;
163-
}
164-
else if (getCurrentAnimation() == "confirm")
164+
if (holding) return;
165+
166+
this.confirmHoldTimer = isPlayer ? -1 : Math.max(length, CONFIRM_HOLD_TIME);
167+
168+
if ((getCurrentAnimation() == 'confirm' && isAnimationFinished()) || !gotCorrectConfirmHoldAnimation()) holding = true;
169+
170+
if (holding)
165171
{
166-
if (isAnimationFinished())
172+
if (gotCorrectConfirmHoldAnimation())
167173
{
168-
this.confirmHoldTimer = -1;
169174
this.playAnimation('confirm-hold', false, false);
170175
}
171-
}
172-
else
173-
{
174-
this.playAnimation('confirm', false, false);
176+
else
177+
{
178+
// Commented out, since it will spam this trace in console on every hold note with default notestlyes lol.
179+
// trace('[WARN] Incorrect data for `confirm-hold` animation!');
180+
}
175181
}
176182
}
177183

184+
private inline function gotCorrectConfirmHoldAnimation():Bool
185+
return animation?.getByName("confirm-hold")?.looped ?? false;
178186
/**
179187
* Returns the name of the animation that is currently playing.
180188
* If no animation is playing (usually this means the sprite is BROKEN!),
@@ -188,7 +196,7 @@ class StrumlineNote extends FunkinSprite
188196

189197
public function isAnimationFinished():Bool
190198
{
191-
return this.animation.finished;
199+
return this.animation?.finished ?? true;
192200
}
193201

194202
static final DEFAULT_OFFSET:Int = 13;

0 commit comments

Comments
 (0)