Skip to content

Commit

Permalink
fixed bug sustain notes position is wrong on downscroll, and timing f…
Browse files Browse the repository at this point in the history
…ixed bopping charas
  • Loading branch information
HRK-EXEX committed Jan 12, 2025
1 parent b753453 commit 1c2d59d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ art/build_x32-officialrelease.bat
art/build_x64-officialrelease.bat
art/test_x64-debug-officialrelease.bat

# unknown thing
dump/*

### VS Code
export/*
.vscode/*
Expand Down
5 changes: 3 additions & 2 deletions source/backend/CoolUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ class CoolUtil
}

// stolen and modded from FlxStringUtil
static final byteUnits:Array<String> = ["Bytes", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
static final byteUnits:Array<String> = ["Bytes", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", "RB", "QB"];
static var curUnit:Int;
public static function formatBytes(bytes:Float, precision:Int = 2, keepPrec:Bool = false, fixedSI:Int = -1):String
{
Expand All @@ -399,7 +399,8 @@ class CoolUtil
}
if(keepPrec) {
if(fixedSI < 0) {
precision = 5 - Std.int(logX(bytes, 10) + 1);
precision = (precision+3) - Std.int(logX(bytes, 10) + 1);
if (precision < 0) precision = 0;
}
return CoolUtil.floatToStringPrecision(bytes, precision) + byteUnits[curUnit];
}
Expand Down
2 changes: 1 addition & 1 deletion source/debug/FPSBg.hx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class FPSBg extends Sprite

bgCard = new Sprite();
bgCard.graphics.beginFill(0x000000, 0.5);
bgCard.graphics.drawRect(0, 0, 300, 55);
bgCard.graphics.drawRect(0, 0, 276, 55);
bgCard.graphics.endFill();
addChild(bgCard);
relocate(0, 0, ClientPrefs.data.wideScreen);
Expand Down
8 changes: 4 additions & 4 deletions source/debug/FPSCounter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ class FPSCounter extends TextField

// so people can override it in hscript
public dynamic function updateText() {
text = 'FPS: ${ClientPrefs.data.ffmpegMode ? ClientPrefs.data.targetFPS + " - Rendering Mode" : '$currentFPS\n'}' +
'RAM: ${CoolUtil.formatBytes(Memory.getCurrentUsage(), 2, true)}' +
' / ${MemoryUtil.isGcEnabled ? CoolUtil.formatBytes(Gc.memInfo64(Gc.MEM_INFO_USAGE), 2, true) : "Disabled"}' +
' / ${CoolUtil.formatBytes(Memory.getPeakUsage(), 2, true)}\n' + os;
text = 'FPS: ${ClientPrefs.data.ffmpegMode ? ClientPrefs.data.targetFPS + " - Rendering Mode" : '$currentFPS - ${ClientPrefs.data.vsync ? "VSync" : "No VSync"}\n'}' +
'RAM: ${CoolUtil.formatBytes(Memory.getCurrentUsage(), 1, true)}' +
' / ${MemoryUtil.isGcEnabled ? CoolUtil.formatBytes(Gc.memInfo64(Gc.MEM_INFO_USAGE), 1, true) : "Disabled"}' +
' / ${CoolUtil.formatBytes(Memory.getPeakUsage(), 1, true)}\n' + os;

if (!ClientPrefs.data.ffmpegMode)
{
Expand Down
22 changes: 16 additions & 6 deletions source/objects/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ class Note extends FlxSprite
public var ratingDisabled:Bool = false;

public var texture(default, set):String = null;
public var downScr:Bool = false;
public var prevDownScr:Bool = false;

public var noAnimation:Bool = false;
public var noMissAnimation:Bool = false;
Expand Down Expand Up @@ -324,7 +326,7 @@ class Note extends FlxSprite
// {
// alpha = multAlpha = 0.6;
// hitsoundDisabled = true;
// if(ClientPrefs.data.downScroll) flipY = true;
// if(ClientPrefs.data.downScroll) downScr = true;

// offsetX += width / 2;
// copyAngle = false;
Expand Down Expand Up @@ -582,7 +584,14 @@ class Note extends FlxSprite

if (isSustainNote)
{
flipY = ClientPrefs.data.downScroll;
downScr = ClientPrefs.data.downScroll;
flipY = downScr;

if (prevDownScr != downScr) {
correctionOffset = isSustainNote && !downScr ? originalHeight * 0.5 : 0;
prevDownScr = downScr;
}

scale.set(0.7, animation != null && animation.curAnim != null && animation.curAnim.name.endsWith('end') ? 1 : Conductor.stepCrochet * 0.0105 * (songSpeed * multSpeed) * sustainScale);
if (PlayState.isPixelStage)
{
Expand Down Expand Up @@ -672,8 +681,9 @@ class Note extends FlxSprite
var playbackRate:Float;

public function recycleNote(target:CastNote, ?oldNote:Note) {
wasGoodHit = hitByOpponent = tooLate = canBeHit = spawned = followed = false; // Don't make an update call of this for the note group
exists = true;
wasGoodHit = hitByOpponent = tooLate = false;
canBeHit = spawned = followed = false; // Don't make an update call of this for the note group
exists = true; flipY = false;

isBotplay = PlayState.instance != null ? PlayState.instance.cpuControlled : false;

Expand Down Expand Up @@ -712,10 +722,10 @@ class Note extends FlxSprite
// if (this.parent != null) parent.tail = [];

copyAngle = !isSustainNote;
flipY = ClientPrefs.data.downScroll && isSustainNote;
downScr = prevDownScr = ClientPrefs.data.downScroll;

animation.play(colArray[noteData % colArray.length] + 'Scroll', true);
correctionOffset = isSustainNote ? (flipY ? -originalHeight * 0.5 : originalHeight * 0.5) : 0;
correctionOffset = isSustainNote && !downScr ? originalHeight * 0.5 : 0;

if (PlayState.isPixelStage) offsetX = -5;

Expand Down
31 changes: 16 additions & 15 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ class PlayState extends MusicBeatState

startTimer = new FlxTimer().start(Conductor.crochet / 1000 / playbackRate, function(tmr:FlxTimer)
{
if (swagCounter < 4) characterBopper(tmr.loopsLeft);
characterBopper(tmr.loopsLeft);

var introAssets:Map<String, Array<String>> = new Map<String, Array<String>>();
var introImagesArray:Array<String> = switch (stageUI)
Expand Down Expand Up @@ -2909,19 +2909,6 @@ Average NPS in loading: ${numFormat(notes / takenNoteTime, 3)}');
tooLate = Conductor.songPosition - daNote.strumTime > noteKillOffset;

daNote.followStrumNote(songSpeed); ++shownCnt;

if (canBeHit) {
if (daNote.mustPress) {
if (cpuControlled)
if (!daNote.blockHit && daNote.canBeHit || daNote.isSustainNote)
goodNoteHit(daNote);
} else if (!daNote.hitByOpponent && !daNote.ignoreNote || daNote.isSustainNote)
opponentNoteHit(daNote);

if (daNote.isSustainNote && daNote.strum.sustainReduce) {
daNote.clipToStrumNote();
}
}

if (tooLate) {
// Kill extremely late notes and cause misses
Expand All @@ -2937,6 +2924,20 @@ Average NPS in loading: ${numFormat(notes / takenNoteTime, 3)}');
opponentNoteHit(daNote);

invalidateNote(daNote);
canBeHit = false;
}

if (canBeHit) {
if (daNote.mustPress) {
if (cpuControlled)
if (!daNote.blockHit && daNote.canBeHit || daNote.isSustainNote)
goodNoteHit(daNote);
} else if (!daNote.hitByOpponent && !daNote.ignoreNote || daNote.isSustainNote)
opponentNoteHit(daNote);

if (daNote.isSustainNote && daNote.strum.sustainReduce) {
daNote.clipToStrumNote();
}
}
} else if (daNote == null) invalidateNote(daNote);
});
Expand Down Expand Up @@ -4996,7 +4997,7 @@ Average NPS in loading: ${numFormat(notes / takenNoteTime, 3)}');
iconP1.updateHitbox();
iconP2.updateHitbox();

characterBopper(curBeat);
if (curBeat > 0) characterBopper(curBeat);

super.beatHit();
lastBeatHit = curBeat;
Expand Down

0 comments on commit 1c2d59d

Please sign in to comment.