From 5557dbf28fe490419e0db12bbc25982ff9bddc1f Mon Sep 17 00:00:00 2001 From: Mike Welsh Date: Mon, 4 Mar 2024 02:59:10 -0800 Subject: [PATCH 1/8] Avoid unpausing music when debugger is toggled Workaround a Flixel issue where sounds can unpause after toggling the Flixel debugger with F2, caused by the debugger throwing a spurious onFocus event without an onFocusLost event. --- source/funkin/audio/FunkinSound.hx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source/funkin/audio/FunkinSound.hx b/source/funkin/audio/FunkinSound.hx index 06ba48e81..cf28ed08e 100644 --- a/source/funkin/audio/FunkinSound.hx +++ b/source/funkin/audio/FunkinSound.hx @@ -90,6 +90,11 @@ class FunkinSound extends FlxSound implements ICloneable */ var _label:String = "unknown"; + /** + * Whether we received a focus lost event. + */ + var _lostFocus:Bool = false; + public function new() { super(); @@ -177,7 +182,10 @@ class FunkinSound extends FlxSound implements ICloneable */ override function onFocus():Void { - if (!_alreadyPaused) + // Flixel can sometimes toss spurious `onFocus` events, e.g. if the Flixel debugger is toggled + // on and off. We only want to resume the sound if we actually lost focus, and if we weren't + // already paused before we lost focus. + if (_lostFocus && !_alreadyPaused) { resume(); } @@ -185,6 +193,7 @@ class FunkinSound extends FlxSound implements ICloneable { trace('Not resuming audio on focus!'); } + _lostFocus = false; } /** @@ -193,6 +202,7 @@ class FunkinSound extends FlxSound implements ICloneable override function onFocusLost():Void { trace('Focus lost, pausing audio!'); + _lostFocus = true; _alreadyPaused = _paused; pause(); } From 5d00f57bfb9704f1ced5b86afb126d1fd388c038 Mon Sep 17 00:00:00 2001 From: Mike Welsh Date: Mon, 4 Mar 2024 03:43:17 -0800 Subject: [PATCH 2/8] Properly handle pausing sounds with negative startTime --- source/funkin/audio/FunkinSound.hx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/source/funkin/audio/FunkinSound.hx b/source/funkin/audio/FunkinSound.hx index cf28ed08e..a1e14d705 100644 --- a/source/funkin/audio/FunkinSound.hx +++ b/source/funkin/audio/FunkinSound.hx @@ -172,8 +172,18 @@ class FunkinSound extends FlxSound implements ICloneable public override function pause():FunkinSound { - super.pause(); - this._shouldPlay = false; + if (_shouldPlay) + { + // This sound will eventually play, but is still at a negative timestamp. + // Manually set the paused flag to ensure proper focus/unfocus behavior. + _shouldPlay = false; + _paused = true; + active = false; + } + else + { + super.pause(); + } return this; } @@ -211,7 +221,10 @@ class FunkinSound extends FlxSound implements ICloneable { if (this._time < 0) { - this._shouldPlay = true; + // Sound with negative timestamp, restart the timer. + _shouldPlay = true; + _paused = false; + active = true; } else { From 7f4c36c8f45f39efbda97cc38fc3fa936ea7ba58 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 4 Mar 2024 19:03:43 -0500 Subject: [PATCH 3/8] some checkstyle stuff --- checkstyle.json | 26 ++----------- hxformat.json | 61 +++++++++++++++---------------- source/funkin/play/ResultState.hx | 28 +++++++------- 3 files changed, 47 insertions(+), 68 deletions(-) diff --git a/checkstyle.json b/checkstyle.json index 445f82b42..a5e4465b5 100644 --- a/checkstyle.json +++ b/checkstyle.json @@ -23,10 +23,10 @@ }, { "props": { - "allowSingleArgParens": false, - "allowReturn": false, - "allowFunction": false, - "allowCurlyBody": false + "allowSingleArgParens": true, + "allowReturn": true, + "allowFunction": true, + "allowCurlyBody": true }, "type": "ArrowFunction" }, @@ -64,10 +64,6 @@ }, "type": "CodeSimilarity" }, - { - "props": {}, - "type": "CommentedOutCode" - }, { "props": { "policy": "aligned", @@ -352,13 +348,6 @@ "props": {}, "type": "MultipleVariableDeclarations" }, - { - "props": { - "allowSingleLineStatement": true, - "tokens": ["FOR", "IF", "ELSE_IF", "WHILE", "DO_WHILE"] - }, - "type": "NeedBraces" - }, { "props": { "max": 3, @@ -558,13 +547,6 @@ }, "type": "Spacing" }, - { - "props": { - "policy": "onlySingle", - "allowException": true - }, - "type": "StringLiteral" - }, { "props": { "format": "^\\s*(TODO|FIXME|HACK|XXX|BUG)" diff --git a/hxformat.json b/hxformat.json index cacbbf810..88a528e34 100644 --- a/hxformat.json +++ b/hxformat.json @@ -1,31 +1,30 @@ -{ - "disableFormatting": false, - - "indentation": { - "character": " ", - "tabWidth": 2, - "indentCaseLabels": true - }, - - "lineEnds": { - "anonFunctionCurly": { - "emptyCurly": "break", - "leftCurly": "after", - "rightCurly": "both" - }, - "leftCurly": "both", - "rightCurly": "both" - }, - - "sameLine": { - "ifBody": "same", - "ifElse": "next", - "doWhile": "next", - "tryBody": "next", - "tryCatch": "next" - }, - - "whitespace": { - "switchPolicy": "around" - } -} +{ + "disableFormatting": false, + + "indentation": { + "character": " ", + "tabWidth": 2, + "indentCaseLabels": true + }, + "lineEnds": { + "anonFunctionCurly": { + "emptyCurly": "break", + "leftCurly": "after", + "rightCurly": "both" + }, + "leftCurly": "both", + "rightCurly": "both" + }, + + "sameLine": { + "ifBody": "same", + "ifElse": "next", + "doWhile": "next", + "tryBody": "next", + "tryCatch": "next" + }, + + "whitespace": { + "switchPolicy": "around" + } +} diff --git a/source/funkin/play/ResultState.hx b/source/funkin/play/ResultState.hx index 223043c28..bd9a08589 100644 --- a/source/funkin/play/ResultState.hx +++ b/source/funkin/play/ResultState.hx @@ -2,27 +2,25 @@ package funkin.play; import funkin.ui.story.StoryMenuState; import funkin.graphics.adobeanimate.FlxAtlasSprite; -import flixel.FlxBasic; import flixel.FlxSprite; import funkin.graphics.FunkinSprite; -import flixel.graphics.frames.FlxAtlasFrames; import flixel.graphics.frames.FlxBitmapFont; import flixel.group.FlxGroup.FlxTypedGroup; import flixel.math.FlxPoint; import funkin.ui.MusicBeatSubState; import flixel.math.FlxRect; import flixel.text.FlxBitmapText; -import flixel.text.FlxText; import flixel.tweens.FlxEase; import funkin.ui.freeplay.FreeplayState; import flixel.tweens.FlxTween; -import flixel.util.FlxColor; import flixel.util.FlxGradient; import flixel.util.FlxTimer; import funkin.graphics.shaders.LeftMaskShader; import funkin.play.components.TallyCounter; -import flxanimate.FlxAnimate.Settings; +/** + * The state for the results screen after a song or week is finished. + */ class ResultState extends MusicBeatSubState { final params:ResultsStateParams; @@ -31,8 +29,8 @@ class ResultState extends MusicBeatSubState var songName:FlxBitmapText; var difficulty:FlxSprite; - var maskShaderSongName = new LeftMaskShader(); - var maskShaderDifficulty = new LeftMaskShader(); + var maskShaderSongName:LeftMaskShader = new LeftMaskShader(); + var maskShaderDifficulty:LeftMaskShader = new LeftMaskShader(); public function new(params:ResultsStateParams) { @@ -50,22 +48,22 @@ class ResultState extends MusicBeatSubState else resultsVariation = NORMAL; - var loops = resultsVariation != SHIT; + var loops:Bool = resultsVariation != SHIT; FlxG.sound.playMusic(Paths.music("results" + resultsVariation), 1, loops); // TEMP-ish, just used to sorta "cache" the 3000x3000 image! - var cacheBullShit = new FlxSprite().loadGraphic(Paths.image("resultScreen/soundSystem")); + var cacheBullShit:FlxSprite = new FlxSprite().loadGraphic(Paths.image("resultScreen/soundSystem")); add(cacheBullShit); - var dumb = new FlxSprite().loadGraphic(Paths.image("resultScreen/scorePopin")); + var dumb:FlxSprite = new FlxSprite().loadGraphic(Paths.image("resultScreen/scorePopin")); add(dumb); var bg:FlxSprite = FlxGradient.createGradientFlxSprite(FlxG.width, FlxG.height, [0xFFFECC5C, 0xFFFDC05C], 90); bg.scrollFactor.set(); add(bg); - var bgFlash:FlxSprite = FlxGradient.createGradientFlxSprite(FlxG.width, FlxG.height, [0xFFffeb69, 0xFFffe66a], 90); + var bgFlash:FlxSprite = FlxGradient.createGradientFlxSprite(FlxG.width, FlxG.height, [0xFFFFEB69, 0xFFFFE66A], 90); bgFlash.scrollFactor.set(); bgFlash.visible = false; add(bgFlash); @@ -202,7 +200,7 @@ class ResultState extends MusicBeatSubState var tallyGood:TallyCounter = new TallyCounter(210, (hStuf * 6) + extraYOffset, params.tallies.good, 0xFF89C9E5); ratingGrp.add(tallyGood); - var tallyBad:TallyCounter = new TallyCounter(190, (hStuf * 7) + extraYOffset, params.tallies.bad, 0xffE6CF8A); + var tallyBad:TallyCounter = new TallyCounter(190, (hStuf * 7) + extraYOffset, params.tallies.bad, 0xFFE6CF8A); ratingGrp.add(tallyBad); var tallyShit:TallyCounter = new TallyCounter(220, (hStuf * 8) + extraYOffset, params.tallies.shit, 0xFFE68C8A); @@ -274,13 +272,13 @@ class ResultState extends MusicBeatSubState super.create(); } - function timerThenSongName() + function timerThenSongName():Void { movingSongStuff = false; difficulty.x = 555; - var diffYTween = 122; + var diffYTween:Float = 122; difficulty.y = -difficulty.height; FlxTween.tween(difficulty, {y: diffYTween}, 0.5, {ease: FlxEase.quartOut, startDelay: 0.8}); @@ -310,7 +308,7 @@ class ResultState extends MusicBeatSubState // maskShaderSongName.frameUV = songName.frame.uv; } - override function update(elapsed:Float) + override function update(elapsed:Float):Void { // maskShaderSongName.swagSprX = songName.x; maskShaderDifficulty.swagSprX = difficulty.x; From d2b124efcaf3a644ad3af889517b031752ac4ccc Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 4 Mar 2024 20:47:23 -0500 Subject: [PATCH 4/8] some highscore tallies debugging stuf in progress --- checkstyle.json | 26 +++++--------------------- source/funkin/Highscore.hx | 8 +++++++- source/funkin/InitState.hx | 5 +++-- source/funkin/data/song/SongData.hx | 2 ++ source/funkin/play/PlayState.hx | 11 +++++++---- source/funkin/play/ResultState.hx | 4 ++++ source/funkin/util/TrackerUtil.hx | 23 +++++++++++++++++++++++ 7 files changed, 51 insertions(+), 28 deletions(-) create mode 100644 source/funkin/util/TrackerUtil.hx diff --git a/checkstyle.json b/checkstyle.json index a5e4465b5..dae5a33a9 100644 --- a/checkstyle.json +++ b/checkstyle.json @@ -76,7 +76,7 @@ "props": { "ignoreExtern": true, "format": "^[A-Z][A-Z0-9]*(_[A-Z0-9_]+)*$", - "tokens": [] + "tokens": ["INLINE"] }, "type": "ConstantName" }, @@ -174,13 +174,7 @@ "fieldType": "BOTH", "requireReturn": true, "ignoreOverride": true, - "tokens": [ - "ABSTRACT_DEF", - "CLASS_DEF", - "ENUM_DEF", - "INTERFACE_DEF", - "TYPEDEF_DEF" - ], + "tokens": ["ABSTRACT_DEF", "CLASS_DEF", "ENUM_DEF", "INTERFACE_DEF"], "modifier": "PUBLIC", "excludeNames": ["new", "toString"] }, @@ -194,10 +188,6 @@ }, "type": "FileLength" }, - { - "props": {}, - "type": "Final" - }, { "props": { "option": "upperCase" @@ -364,7 +354,7 @@ }, { "props": { - "max": 1 + "max": 4 }, "type": "NestedIfDepth" }, @@ -376,7 +366,7 @@ }, { "props": { - "option": "nullDefault" + "option": "questionMark" }, "type": "NullableParameter" }, @@ -577,13 +567,7 @@ }, { "props": { - "tokens": [ - "ABSTRACT_DEF", - "CLASS_DEF", - "ENUM_DEF", - "INTERFACE_DEF", - "TYPEDEF_DEF" - ] + "tokens": ["CLASS_DEF", "ENUM_DEF", "INTERFACE_DEF", "TYPEDEF_DEF"] }, "type": "TypeDocComment" }, diff --git a/source/funkin/Highscore.hx b/source/funkin/Highscore.hx index 24b65832b..44b0e0f74 100644 --- a/source/funkin/Highscore.hx +++ b/source/funkin/Highscore.hx @@ -1,10 +1,16 @@ package funkin; +import flixel.FlxG; + /** * A core class which handles tracking score and combo for the current song. */ class Highscore { + /** + * Keeps track of notes hit for the current song / week, + * and how accurate you were with each note (bad, missed, shit, etc.) + */ public static var tallies:Tallies = new Tallies(); } @@ -51,7 +57,7 @@ typedef RawTallies = var totalNotesHit:Int; /** - * How many notes PASSED BY AND/OR HIT!!! + * How many notes in the current chart */ var totalNotes:Int; } diff --git a/source/funkin/InitState.hx b/source/funkin/InitState.hx index 2368d09f2..9ecf66ec7 100644 --- a/source/funkin/InitState.hx +++ b/source/funkin/InitState.hx @@ -32,6 +32,7 @@ import funkin.util.CLIUtil; import funkin.util.CLIUtil.CLIParams; import funkin.util.tools.TimerTools; import funkin.ui.transition.LoadingState; +import funkin.util.TrackerUtil; #if discord_rpc import Discord.DiscordClient; #end @@ -67,7 +68,7 @@ class InitState extends FlxState /** * Setup a bunch of important Flixel stuff. */ - function setupShit() + function setupShit():Void { // // GAME SETUP @@ -95,7 +96,7 @@ class InitState extends FlxState #if (debug || FORCE_DEBUG_VERSION) // Disable using ~ to open the console (we use that for the Editor menu) FlxG.debugger.toggleKeys = [F2]; - + TrackerUtil.initTrackers(); // Adds an additional Close Debugger button. // This big obnoxious white button is for MOBILE, so that you can press it // easily with your finger when debug bullshit pops up during testing lol! diff --git a/source/funkin/data/song/SongData.hx b/source/funkin/data/song/SongData.hx index 24febea86..938859ff2 100644 --- a/source/funkin/data/song/SongData.hx +++ b/source/funkin/data/song/SongData.hx @@ -106,6 +106,8 @@ class SongMetadata implements ICloneable /** * Serialize this SongMetadata into a JSON string. + * @param pretty Whether the JSON should be big ol string (false), + * or formatted with tabs (true) * @return The JSON string. */ public function serialize(pretty:Bool = true):String diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index d090b4f8a..6e8f22908 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -1732,7 +1732,6 @@ class PlayState extends MusicBeatSubState if (strumTime < startTime) continue; // Skip notes that are before the start time. var noteData:Int = songNote.getDirection(); - var playerNote:Bool = true; if (noteData > 3) playerNote = false; @@ -1741,6 +1740,8 @@ class PlayState extends MusicBeatSubState { case 0: playerNoteData.push(songNote); + // increment totalNotes for total possible notes able to be hit by the player + Highscore.tallies.totalNotes++; case 1: opponentNoteData.push(songNote); } @@ -2457,6 +2458,8 @@ class PlayState extends MusicBeatSubState health += healthChange; + FlxG.watch.addQuick("COMBO: ", Highscore.tallies.combo); + if (isComboBreak) { // Break the combo, but don't increment tallies.misses. @@ -2617,9 +2620,9 @@ class PlayState extends MusicBeatSubState combo: Highscore.tallies.combo, maxCombo: Highscore.tallies.maxCombo, totalNotesHit: Highscore.tallies.totalNotesHit, - totalNotes: Highscore.tallies.totalNotes, + totalNotes: currentChart.notes.length, }, - accuracy: Highscore.tallies.totalNotesHit / Highscore.tallies.totalNotes, + accuracy: Highscore.tallies.totalNotesHit / currentChart.notes.length, }; if (Save.instance.isSongHighScore(currentSong.id, currentDifficulty, data)) @@ -2669,7 +2672,7 @@ class PlayState extends MusicBeatSubState totalNotesHit: 0, totalNotes: 0, }, - accuracy: Highscore.tallies.totalNotesHit / Highscore.tallies.totalNotes, + accuracy: Highscore.tallies.totalNotesHit / currentChart.notes.length, }; if (Save.instance.isLevelHighScore(PlayStatePlaylist.campaignId, PlayStatePlaylist.campaignDifficulty, data)) diff --git a/source/funkin/play/ResultState.hx b/source/funkin/play/ResultState.hx index bd9a08589..f77c3fc6b 100644 --- a/source/funkin/play/ResultState.hx +++ b/source/funkin/play/ResultState.hx @@ -186,6 +186,10 @@ class ResultState extends MusicBeatSubState var ratingGrp:FlxTypedGroup = new FlxTypedGroup(); add(ratingGrp); + /** + * NOTE: We display how many notes were HIT, not how many notes there were in total. + * + */ var totalHit:TallyCounter = new TallyCounter(375, hStuf * 3, params.tallies.totalNotesHit); ratingGrp.add(totalHit); diff --git a/source/funkin/util/TrackerUtil.hx b/source/funkin/util/TrackerUtil.hx new file mode 100644 index 000000000..b8ed0c995 --- /dev/null +++ b/source/funkin/util/TrackerUtil.hx @@ -0,0 +1,23 @@ +package funkin.util; + +// This may or may not already be imported via imports.hx... +import flixel.system.debug.watch.Tracker; +import flixel.FlxG; + +/** + * Utility class that helps manage adding profiles to the flixel debugger tracker + */ +class TrackerUtil +{ + /** + * Adds profiles to the debugger to help track certain game objects. + * NOTE: This isn't the full list of profiles made, as sometimes they're made + * on in various places in code for random debugging purposes! + * Might be good to put them all here though! + */ + public static function initTrackers():Void + { + Tracker.addProfile(new TrackerProfile(Highscore, ["tallies"])); + FlxG.console.registerClass(Highscore); + } +} From fa72fa44b1f5ba4f19ad276cfbafcfd1819bb4dd Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 4 Mar 2024 21:18:40 -0500 Subject: [PATCH 5/8] tallies for story mode --- source/funkin/Highscore.hx | 24 +++++++++++++++++++++++- source/funkin/play/PlayState.hx | 10 +++++++--- source/funkin/ui/story/StoryMenuState.hx | 4 +++- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/source/funkin/Highscore.hx b/source/funkin/Highscore.hx index 44b0e0f74..e2987443d 100644 --- a/source/funkin/Highscore.hx +++ b/source/funkin/Highscore.hx @@ -8,10 +8,32 @@ import flixel.FlxG; class Highscore { /** - * Keeps track of notes hit for the current song / week, + * Keeps track of notes hit for the current song * and how accurate you were with each note (bad, missed, shit, etc.) */ public static var tallies:Tallies = new Tallies(); + + /** + * Keeps track of notes hit for the current WEEK / level + * for use with storymode, or likely any other "playlist" esque option + */ + public static var talliesLevel:Tallies = new Tallies(); + + public static function combineTallies(tally1:Tallies, tally2:Tallies):Tallies + { + var combinedTally:Tallies = new Tallies(); + combinedTally.combo = tally1.combo + tally2.combo; + combinedTally.missed = tally1.missed + tally2.missed; + combinedTally.shit = tally1.shit + tally2.shit; + combinedTally.bad = tally1.bad + tally2.bad; + combinedTally.good = tally1.good + tally2.good; + combinedTally.sick = tally1.sick + tally2.sick; + combinedTally.totalNotes = tally1.totalNotes + tally2.totalNotes; + combinedTally.totalNotesHit = tally1.totalNotesHit + tally2.totalNotesHit; + combinedTally.maxCombo = tally1.maxCombo + tally2.maxCombo; + + return combinedTally; + } } @:forward diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 6e8f22908..04a18fb95 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -2458,8 +2458,6 @@ class PlayState extends MusicBeatSubState health += healthChange; - FlxG.watch.addQuick("COMBO: ", Highscore.tallies.combo); - if (isComboBreak) { // Break the combo, but don't increment tallies.misses. @@ -2625,6 +2623,9 @@ class PlayState extends MusicBeatSubState accuracy: Highscore.tallies.totalNotesHit / currentChart.notes.length, }; + // adds current song data into the tallies for the level (story levels) + Highscore.talliesLevel = Highscore.combineTallies(Highscore.tallies, Highscore.talliesLevel); + if (Save.instance.isSongHighScore(currentSong.id, currentDifficulty, data)) { Save.instance.setSongScore(currentSong.id, currentDifficulty, data); @@ -2893,11 +2894,14 @@ class PlayState extends MusicBeatSubState persistentUpdate = false; vocals.stop(); camHUD.alpha = 1; + + var talliesToUse:Tallies = PlayStatePlaylist.isStoryMode ? Highscore.talliesLevel : Highscore.tallies; + var res:ResultState = new ResultState( { storyMode: PlayStatePlaylist.isStoryMode, title: PlayStatePlaylist.isStoryMode ? ('${PlayStatePlaylist.campaignTitle}') : ('${currentChart.songName} by ${currentChart.songArtist}'), - tallies: Highscore.tallies, + tallies: talliesToUse, }); res.camera = camHUD; openSubState(res); diff --git a/source/funkin/ui/story/StoryMenuState.hx b/source/funkin/ui/story/StoryMenuState.hx index ba1d2ed21..59e1bbdc1 100644 --- a/source/funkin/ui/story/StoryMenuState.hx +++ b/source/funkin/ui/story/StoryMenuState.hx @@ -519,7 +519,7 @@ class StoryMenuState extends MusicBeatState } } - function selectLevel() + function selectLevel():Void { if (!currentLevel.isUnlocked()) { @@ -554,6 +554,8 @@ class StoryMenuState extends MusicBeatState PlayStatePlaylist.campaignTitle = currentLevel.getTitle(); PlayStatePlaylist.campaignDifficulty = currentDifficultyId; + Highscore.talliesLevel = new funkin.Highscore.Tallies(); + new FlxTimer().start(1, function(tmr:FlxTimer) { FlxTransitionableState.skipNextTransIn = false; FlxTransitionableState.skipNextTransOut = false; From acc75c5c5c46d5f7ca8a00a98f32d85fc318279a Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 4 Mar 2024 21:25:56 -0500 Subject: [PATCH 6/8] use totalNotes instead of currentChart.notes.length --- source/funkin/play/PlayState.hx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index 04a18fb95..b41c29c83 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -2618,9 +2618,9 @@ class PlayState extends MusicBeatSubState combo: Highscore.tallies.combo, maxCombo: Highscore.tallies.maxCombo, totalNotesHit: Highscore.tallies.totalNotesHit, - totalNotes: currentChart.notes.length, + totalNotes: Highscore.tallies.totalNotes, }, - accuracy: Highscore.tallies.totalNotesHit / currentChart.notes.length, + accuracy: Highscore.tallies.totalNotesHit / Highscore.tallies.totalNotes, }; // adds current song data into the tallies for the level (story levels) @@ -2673,7 +2673,7 @@ class PlayState extends MusicBeatSubState totalNotesHit: 0, totalNotes: 0, }, - accuracy: Highscore.tallies.totalNotesHit / currentChart.notes.length, + accuracy: Highscore.tallies.totalNotesHit / Highscore.tallies.totalNotes, }; if (Save.instance.isLevelHighScore(PlayStatePlaylist.campaignId, PlayStatePlaylist.campaignDifficulty, data)) From 08fb8be4191922a1a13a33ad9d5ebb4c722fd599 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Mon, 4 Mar 2024 22:22:19 -0500 Subject: [PATCH 7/8] Redo combine tally implementation --- source/funkin/Highscore.hx | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/source/funkin/Highscore.hx b/source/funkin/Highscore.hx index e2987443d..996e2367e 100644 --- a/source/funkin/Highscore.hx +++ b/source/funkin/Highscore.hx @@ -1,7 +1,5 @@ package funkin; -import flixel.FlxG; - /** * A core class which handles tracking score and combo for the current song. */ @@ -19,18 +17,27 @@ class Highscore */ public static var talliesLevel:Tallies = new Tallies(); - public static function combineTallies(tally1:Tallies, tally2:Tallies):Tallies + /** + * Produces a new Tallies object which represents the sum of two existing Tallies + * @param newTally The first tally + * @param baseTally The second tally + * @return The combined tally + */ + public static function combineTallies(newTally:Tallies, baseTally:Tallies):Tallies { var combinedTally:Tallies = new Tallies(); - combinedTally.combo = tally1.combo + tally2.combo; - combinedTally.missed = tally1.missed + tally2.missed; - combinedTally.shit = tally1.shit + tally2.shit; - combinedTally.bad = tally1.bad + tally2.bad; - combinedTally.good = tally1.good + tally2.good; - combinedTally.sick = tally1.sick + tally2.sick; - combinedTally.totalNotes = tally1.totalNotes + tally2.totalNotes; - combinedTally.totalNotesHit = tally1.totalNotesHit + tally2.totalNotesHit; - combinedTally.maxCombo = tally1.maxCombo + tally2.maxCombo; + combinedTally.missed = newTally.missed + baseTally.missed; + combinedTally.shit = newTally.shit + baseTally.shit; + combinedTally.bad = newTally.bad + baseTally.bad; + combinedTally.good = newTally.good + baseTally.good; + combinedTally.sick = newTally.sick + baseTally.sick; + combinedTally.totalNotes = newTally.totalNotes + baseTally.totalNotes; + combinedTally.totalNotesHit = newTally.totalNotesHit + baseTally.totalNotesHit; + + // Current combo = use most recent. + combinedTally.combo = newTally.combo; + // Max combo = use maximum value. + combinedTally.maxCombo = Std.int(Math.max(newTally.maxCombo, baseTally.maxCombo)); return combinedTally; } @@ -57,6 +64,9 @@ abstract Tallies(RawTallies) } } +/** + * A structure object containing the data for highscore tallies. + */ typedef RawTallies = { var combo:Int; From 07524c8ee8662c075e605a8706bb0f2f231baa88 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Mon, 4 Mar 2024 22:42:02 -0500 Subject: [PATCH 8/8] Eric's modifications to checkstyle.json --- checkstyle.json | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/checkstyle.json b/checkstyle.json index dae5a33a9..d41a6d617 100644 --- a/checkstyle.json +++ b/checkstyle.json @@ -64,6 +64,10 @@ }, "type": "CodeSimilarity" }, + { + "props": {}, + "type": "CommentedOutCode" + }, { "props": { "policy": "aligned", @@ -76,7 +80,7 @@ "props": { "ignoreExtern": true, "format": "^[A-Z][A-Z0-9]*(_[A-Z0-9_]+)*$", - "tokens": ["INLINE"] + "tokens": ["INLINE", "NOTINLINE"] }, "type": "ConstantName" }, @@ -338,6 +342,13 @@ "props": {}, "type": "MultipleVariableDeclarations" }, + { + "props": { + "allowSingleLineStatement": true, + "tokens": ["FOR", "IF", "ELSE_IF", "WHILE", "DO_WHILE"] + }, + "type": "NeedBraces" + }, { "props": { "max": 3, @@ -375,7 +386,6 @@ "oldFunctionTypePolicy": "none", "unaryOpPolicy": "none", "intervalOpPolicy": "none", - "newFunctionTypePolicy": "around", "ternaryOpPolicy": "around", "boolOpPolicy": "around", @@ -537,6 +547,13 @@ }, "type": "Spacing" }, + { + "props": { + "policy": "onlySingle", + "allowException": true + }, + "type": "StringLiteral" + }, { "props": { "format": "^\\s*(TODO|FIXME|HACK|XXX|BUG)" @@ -559,12 +576,6 @@ "props": {}, "type": "TrailingWhitespace" }, - { - "props": { - "ignoreEnumAbstractValues": true - }, - "type": "Type" - }, { "props": { "tokens": ["CLASS_DEF", "ENUM_DEF", "INTERFACE_DEF", "TYPEDEF_DEF"] @@ -596,12 +607,6 @@ }, "type": "UnusedLocalVar" }, - { - "props": { - "severity": "IGNORE" - }, - "type": "VariableInitialisation" - }, { "props": { "typeHintPolicy": "enforce_all",