From b749f10957dc5b7dcd775e1af3aea0560b9b21b4 Mon Sep 17 00:00:00 2001 From: KadeDeveloper Date: Fri, 13 Aug 2021 14:54:26 -0700 Subject: [PATCH 1/8] fix deleting not removing selected boxes --- source/ChartingState.hx | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/source/ChartingState.hx b/source/ChartingState.hx index 2c6f9af..c44e4b5 100644 --- a/source/ChartingState.hx +++ b/source/ChartingState.hx @@ -2719,6 +2719,7 @@ class ChartingState extends MusicBeatState var box = new ChartingBox(note.x,note.y,note); box.connectedNoteData = i; selectedBoxes.add(box); + note.charterSelected = true; curSelectedNoteObject.charterSelected = true; } @@ -2763,18 +2764,14 @@ class ChartingState extends MusicBeatState if (note.sustainLength > 0) curRenderedSustains.remove(note.noteCharterObject); - if (note.charterSelected) + for(i in 0...selectedBoxes.members.length) { - note.charterSelected = false; - for(i in 0...selectedBoxes.members.length) + var box = selectedBoxes.members[i]; + if (box.connectedNote == note) { - var box = selectedBoxes.members[i]; - if (box.connectedNote == note) - { - selectedBoxes.members.remove(box); - box.destroy(); - return; - } + selectedBoxes.members.remove(box); + box.destroy(); + return; } } } From 94b6cba78d04023b948aa8cd1a81e99cea14dab4 Mon Sep 17 00:00:00 2001 From: KadeDeveloper Date: Fri, 13 Aug 2021 15:00:37 -0700 Subject: [PATCH 2/8] make claps based on time instead of y positions --- source/ChartingState.hx | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/source/ChartingState.hx b/source/ChartingState.hx index c44e4b5..84a50ec 100644 --- a/source/ChartingState.hx +++ b/source/ChartingState.hx @@ -2134,16 +2134,10 @@ class ChartingState extends MusicBeatState { curRenderedNotes.forEach(function(note:Note) { - if (FlxG.sound.music.playing) + if (note.strumTime <= Conductor.songPosition && !claps.contains(note)) { - if (strumLine.overlaps(note)) - { - if(!claps.contains(note)) - { - claps.push(note); - FlxG.sound.play(Paths.sound('SNAP')); - } - } + claps.push(note); + FlxG.sound.play(Paths.sound('SNAP')); } }); } From 2b13c590fe9fb3489c235643e773ca1dcaa5df59 Mon Sep 17 00:00:00 2001 From: KadeDeveloper Date: Fri, 13 Aug 2021 15:01:03 -0700 Subject: [PATCH 3/8] optimization for claps as well --- source/ChartingState.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/ChartingState.hx b/source/ChartingState.hx index 84a50ec..c5ed8e0 100644 --- a/source/ChartingState.hx +++ b/source/ChartingState.hx @@ -2132,14 +2132,14 @@ class ChartingState extends MusicBeatState if (playClaps) { - curRenderedNotes.forEach(function(note:Note) + for(note in shownNotes) { if (note.strumTime <= Conductor.songPosition && !claps.contains(note)) { claps.push(note); FlxG.sound.play(Paths.sound('SNAP')); } - }); + } } /*curRenderedNotes.forEach(function(note:Note) { if (strumLine.overlaps(note) && strumLine.y == note.y) // yandere dev type shit From 73d5f068c32816103f4e326a98f411197bfd50d2 Mon Sep 17 00:00:00 2001 From: KadeDeveloper Date: Fri, 13 Aug 2021 15:05:03 -0700 Subject: [PATCH 4/8] oh and a playing check lol --- source/ChartingState.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/ChartingState.hx b/source/ChartingState.hx index c5ed8e0..3d59846 100644 --- a/source/ChartingState.hx +++ b/source/ChartingState.hx @@ -2134,7 +2134,7 @@ class ChartingState extends MusicBeatState { for(note in shownNotes) { - if (note.strumTime <= Conductor.songPosition && !claps.contains(note)) + if (note.strumTime <= Conductor.songPosition && !claps.contains(note) && FlxG.sound.music.playing) { claps.push(note); FlxG.sound.play(Paths.sound('SNAP')); From c3020d9dff1051975e27ffac5a8f8751dc4fae1c Mon Sep 17 00:00:00 2001 From: KadeDeveloper Date: Fri, 13 Aug 2021 16:05:06 -0700 Subject: [PATCH 5/8] fix play here --- source/ChartingState.hx | 45 +++++++++++++++------------ source/PlayState.hx | 67 ++++++++++++++++++++++++----------------- 2 files changed, 65 insertions(+), 47 deletions(-) diff --git a/source/ChartingState.hx b/source/ChartingState.hx index 3d59846..cb55627 100644 --- a/source/ChartingState.hx +++ b/source/ChartingState.hx @@ -1285,7 +1285,7 @@ class ChartingState extends MusicBeatState FlxG.sound.music.stop(); if (!PlayState.isSM) vocals.stop(); - PlayState.startTime = lastUpdatedSection.startTime; + PlayState.startTime = _song.notes[curSection].startTime; LoadingState.loadAndSwitchState(new PlayState()); }); @@ -1834,6 +1834,7 @@ class ChartingState extends MusicBeatState { if (i.overlaps(selectBox) && !i.charterSelected) { + trace("seleting " + i.strumTime); selectNote(i, false); } } @@ -2225,7 +2226,7 @@ class ChartingState extends MusicBeatState { if (FlxG.keys.pressed.CONTROL) { - selectNote(note); + selectNote(note, false); } else { @@ -2699,27 +2700,31 @@ class ChartingState extends MusicBeatState selectedBoxes.members.remove(selectedBoxes.members[0]); } - for (i in getSectionByTime(note.strumTime).sectionNotes) + for(sec in _song.notes) { - if (i[0] == note.strumTime && i[1] == note.rawNoteData) + swagNum = 0; + for(i in sec.sectionNotes) { - curSelectedNote = getSectionByTime(note.strumTime).sectionNotes[swagNum]; - if (curSelectedNoteObject != null) - curSelectedNoteObject.charterSelected = false; - - curSelectedNoteObject = note; - if (!note.charterSelected) - { - var box = new ChartingBox(note.x,note.y,note); - box.connectedNoteData = i; - selectedBoxes.add(box); - note.charterSelected = true; - curSelectedNoteObject.charterSelected = true; - } - - } + if (i[0] == note.strumTime && i[1] == note.rawNoteData) + { + curSelectedNote = sec.sectionNotes[swagNum]; + if (curSelectedNoteObject != null) + curSelectedNoteObject.charterSelected = false; - swagNum += 1; + curSelectedNoteObject = note; + if (!note.charterSelected) + { + var box = new ChartingBox(note.x,note.y,note); + box.connectedNoteData = i; + selectedBoxes.add(box); + note.charterSelected = true; + curSelectedNoteObject.charterSelected = true; + } + + + } + swagNum += 1; + } } updateNoteUI(); diff --git a/source/PlayState.hx b/source/PlayState.hx index 3de8d13..a3fed22 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -1061,6 +1061,46 @@ class PlayState extends MusicBeatState } } + if (startTime != 0) + { + var toBeRemoved = []; + for(i in 0...notes.members.length) + { + var dunceNote:Note = notes.members[i]; + + if (dunceNote.strumTime - startTime <= 0) + toBeRemoved.push(dunceNote); + else + { + if (PlayStateChangeables.useDownscroll) + { + if (dunceNote.mustPress) + dunceNote.y = (playerStrums.members[Math.floor(Math.abs(dunceNote.noteData))].y + + 0.45 * (startTime - dunceNote.strumTime) * FlxMath.roundDecimal(PlayStateChangeables.scrollSpeed == 1 ? SONG.speed : PlayStateChangeables.scrollSpeed, + 2)) - dunceNote.noteYOff; + else + dunceNote.y = (strumLineNotes.members[Math.floor(Math.abs(dunceNote.noteData))].y + + 0.45 * (startTime - dunceNote.strumTime) * FlxMath.roundDecimal(PlayStateChangeables.scrollSpeed == 1 ? SONG.speed : PlayStateChangeables.scrollSpeed, + 2)) - dunceNote.noteYOff; + } + else + { + if (dunceNote.mustPress) + dunceNote.y = (playerStrums.members[Math.floor(Math.abs(dunceNote.noteData))].y + - 0.45 * (startTime - dunceNote.strumTime) * FlxMath.roundDecimal(PlayStateChangeables.scrollSpeed == 1 ? SONG.speed : PlayStateChangeables.scrollSpeed, + 2)) + dunceNote.noteYOff; + else + dunceNote.y = (strumLineNotes.members[Math.floor(Math.abs(dunceNote.noteData))].y + - 0.45 * (startTime - dunceNote.strumTime) * FlxMath.roundDecimal(PlayStateChangeables.scrollSpeed == 1 ? SONG.speed : PlayStateChangeables.scrollSpeed, + 2)) + dunceNote.noteYOff; + } + } + } + + for(i in toBeRemoved) + notes.members.remove(i); + } + trace('generated'); // add(strumLine); @@ -1362,34 +1402,7 @@ class PlayState extends MusicBeatState //generateStaticArrows(0); //generateStaticArrows(1); - if (startTime != 0) - { - var toBeRemoved = []; - for(i in 0...unspawnNotes.length) - { - var dunceNote:Note = unspawnNotes[i]; - if (dunceNote.strumTime - startTime <= 0) - toBeRemoved.push(dunceNote); - else if (dunceNote.strumTime - startTime < 3500) - { - notes.add(dunceNote); - - if (dunceNote.mustPress) - dunceNote.y = (playerStrums.members[Math.floor(Math.abs(dunceNote.noteData))].y - + 0.45 * (startTime - dunceNote.strumTime) * FlxMath.roundDecimal(PlayStateChangeables.scrollSpeed == 1 ? SONG.speed : PlayStateChangeables.scrollSpeed, - 2)) - dunceNote.noteYOff; - else - dunceNote.y = (strumLineNotes.members[Math.floor(Math.abs(dunceNote.noteData))].y - + 0.45 * (startTime - dunceNote.strumTime) * FlxMath.roundDecimal(PlayStateChangeables.scrollSpeed == 1 ? SONG.speed : PlayStateChangeables.scrollSpeed, - 2)) - dunceNote.noteYOff; - toBeRemoved.push(dunceNote); - } - } - - for(i in toBeRemoved) - unspawnNotes.remove(i); - } #if windows // pre lowercasing the song name (startCountdown) From 5eb3a66b0c84ce7f6fcc767f8ef967556db90598 Mon Sep 17 00:00:00 2001 From: KadeDeveloper Date: Fri, 13 Aug 2021 17:20:55 -0700 Subject: [PATCH 6/8] if optimize mode is on, then remove assets and free memory --- source/FreeplayState.hx | 2 ++ source/HelperFunctions.hx | 1 + source/MainMenuState.hx | 1 + source/MusicBeatState.hx | 19 +++++++++++++++++++ source/OptionsMenu.hx | 3 +++ source/PauseSubState.hx | 4 ++++ source/PlayState.hx | 11 +++++++++++ source/ResultsScreen.hx | 3 +++ source/TitleState.hx | 5 +++++ 9 files changed, 49 insertions(+) diff --git a/source/FreeplayState.hx b/source/FreeplayState.hx index 5148bf2..d4372e0 100644 --- a/source/FreeplayState.hx +++ b/source/FreeplayState.hx @@ -67,6 +67,7 @@ class FreeplayState extends MusicBeatState override function create() { + clean(); var initSonglist = CoolUtil.coolTextFile(Paths.txt('data/freeplaySonglist')); //var diffList = ""; @@ -398,6 +399,7 @@ class FreeplayState extends MusicBeatState PlayState.isSM = false; #end LoadingState.loadAndSwitchState(new PlayState()); + clean(); } } diff --git a/source/HelperFunctions.hx b/source/HelperFunctions.hx index 4b704c1..e6dc6a9 100644 --- a/source/HelperFunctions.hx +++ b/source/HelperFunctions.hx @@ -1,3 +1,4 @@ +import flixel.FlxG; import flixel.math.FlxMath; class HelperFunctions diff --git a/source/MainMenuState.hx b/source/MainMenuState.hx index 774dbae..7f60215 100644 --- a/source/MainMenuState.hx +++ b/source/MainMenuState.hx @@ -49,6 +49,7 @@ class MainMenuState extends MusicBeatState override function create() { + clean(); #if windows // Updating Discord Rich Presence DiscordClient.changePresence("In the Menus", null); diff --git a/source/MusicBeatState.hx b/source/MusicBeatState.hx index 47dac29..0d13d80 100644 --- a/source/MusicBeatState.hx +++ b/source/MusicBeatState.hx @@ -1,5 +1,6 @@ package; +import flixel.FlxBasic; #if windows import Discord.DiscordClient; #end @@ -22,6 +23,24 @@ class MusicBeatState extends FlxUIState inline function get_controls():Controls return PlayerSettings.player1.controls; + private var assets:Array = []; + + override function add(Object:flixel.FlxBasic):flixel.FlxBasic + { + if (FlxG.save.data.optimize) + assets.push(Object); + return super.add(Object); + } + + public function clean() + { + if (FlxG.save.data.optimize) + for(i in assets) + { + remove(i); + } + } + override function create() { TimingStruct.clearTimings(); diff --git a/source/OptionsMenu.hx b/source/OptionsMenu.hx index 95454c8..ca7596b 100644 --- a/source/OptionsMenu.hx +++ b/source/OptionsMenu.hx @@ -134,12 +134,15 @@ class OptionsMenu extends MusicBeatState override function update(elapsed:Float) { + clean(); super.update(elapsed); if (acceptInput) { if (controls.BACK && !isCat) + { FlxG.switchState(new MainMenuState()); + } else if (controls.BACK) { isCat = false; diff --git a/source/PauseSubState.hx b/source/PauseSubState.hx index 747c7cb..8f22367 100644 --- a/source/PauseSubState.hx +++ b/source/PauseSubState.hx @@ -209,6 +209,7 @@ class PauseSubState extends MusicBeatSubstate { var daSelected:String = menuItems[curSelected]; + switch (daSelected) { case "Resume": @@ -221,6 +222,7 @@ class PauseSubState extends MusicBeatSubstate PlayState.instance.remove(PlayState.instance.videoSprite); PlayState.instance.removedVideo = true; } + PlayState.instance.clean(); FlxG.resetState(); case "Exit to menu": PlayState.startTime = 0; @@ -247,6 +249,8 @@ class PauseSubState extends MusicBeatSubstate if (FlxG.save.data.fpsCap > 290) (cast (Lib.current.getChildAt(0), Main)).setFPSCap(290); + PlayState.instance.clean(); + if (PlayState.isStoryMode) FlxG.switchState(new StoryMenuState()); else diff --git a/source/PlayState.hx b/source/PlayState.hx index a3fed22..ba06ca6 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -2443,6 +2443,7 @@ class PlayState extends MusicBeatState { trace('GITAROO MAN EASTER EGG'); FlxG.switchState(new GitarooPause()); + clean(); } else openSubState(new PauseSubState(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y)); @@ -2464,7 +2465,9 @@ class PlayState extends MusicBeatState #if windows DiscordClient.changePresence("Chart Editor", null, null, true); #end + FlxG.switchState(new ChartingState()); + clean(); FlxG.stage.removeEventListener(KeyboardEvent.KEY_DOWN, handleInput); FlxG.stage.removeEventListener(KeyboardEvent.KEY_UP, releaseInput); #if windows @@ -2518,6 +2521,7 @@ class PlayState extends MusicBeatState } FlxG.switchState(new AnimationDebug(SONG.player2)); + clean(); FlxG.stage.removeEventListener(KeyboardEvent.KEY_DOWN, handleInput); FlxG.stage.removeEventListener(KeyboardEvent.KEY_UP, releaseInput); #if windows @@ -2532,6 +2536,7 @@ class PlayState extends MusicBeatState if (FlxG.keys.justPressed.ZERO) { FlxG.switchState(new AnimationDebug(SONG.player1)); + clean(); FlxG.stage.removeEventListener(KeyboardEvent.KEY_DOWN, handleInput); FlxG.stage.removeEventListener(KeyboardEvent.KEY_UP, releaseInput); #if windows @@ -3392,6 +3397,7 @@ class PlayState extends MusicBeatState FlxG.sound.playMusic(Paths.music('freakyMenu')); offsetTesting = false; LoadingState.loadAndSwitchState(new OptionsMenu()); + clean(); FlxG.save.data.offset = offsetTest; } else @@ -3429,6 +3435,7 @@ class PlayState extends MusicBeatState FlxG.sound.playMusic(Paths.music('freakyMenu')); Conductor.changeBPM(102); FlxG.switchState(new StoryMenuState()); + clean(); } #if windows @@ -3483,6 +3490,7 @@ class PlayState extends MusicBeatState FlxG.sound.music.stop(); LoadingState.loadAndSwitchState(new PlayState()); + clean(); } } else @@ -3503,7 +3511,10 @@ class PlayState extends MusicBeatState }); } else + { FlxG.switchState(new FreeplayState()); + clean(); + } } } } diff --git a/source/ResultsScreen.hx b/source/ResultsScreen.hx index 7c7920a..66b5569 100644 --- a/source/ResultsScreen.hx +++ b/source/ResultsScreen.hx @@ -218,6 +218,7 @@ class ResultsScreen extends FlxSubState } else FlxG.switchState(new FreeplayState()); + PlayState.instance.clean(); } if (FlxG.keys.justPressed.F1 && !PlayState.loadRep) @@ -288,6 +289,7 @@ class ResultsScreen extends FlxSubState PlayState.isStoryMode = false; PlayState.storyDifficulty = PlayState.rep.replay.songDiff; LoadingState.loadAndSwitchState(new PlayState()); + PlayState.instance.clean(); } if (FlxG.keys.justPressed.F2 && !PlayState.loadRep) @@ -324,6 +326,7 @@ class ResultsScreen extends FlxSubState PlayState.isStoryMode = false; PlayState.storyDifficulty = PlayState.storyDifficulty; LoadingState.loadAndSwitchState(new PlayState()); + PlayState.instance.clean(); } super.update(elapsed); diff --git a/source/TitleState.hx b/source/TitleState.hx index 4860e3a..3c63121 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -99,8 +99,10 @@ class TitleState extends MusicBeatState #if FREEPLAY FlxG.switchState(new FreeplayState()); + clean(); #elseif CHARTING FlxG.switchState(new ChartingState()); + clean(); #else #if !cpp new FlxTimer().start(1, function(tmr:FlxTimer) @@ -305,16 +307,19 @@ class TitleState extends MusicBeatState OutdatedSubState.needVer = returnedData[0]; OutdatedSubState.currChanges = returnedData[1]; FlxG.switchState(new OutdatedSubState()); + clean(); } else { FlxG.switchState(new MainMenuState()); + clean(); } } http.onError = function (error) { trace('error: $error'); FlxG.switchState(new MainMenuState()); // fail but we go anyway + clean(); } http.request(); From ae269dd74b385173226156511c17646e7551d8b6 Mon Sep 17 00:00:00 2001 From: KadeDeveloper Date: Fri, 13 Aug 2021 17:28:36 -0700 Subject: [PATCH 7/8] optiatmi --- source/MusicBeatState.hx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/MusicBeatState.hx b/source/MusicBeatState.hx index 0d13d80..5575771 100644 --- a/source/MusicBeatState.hx +++ b/source/MusicBeatState.hx @@ -35,10 +35,12 @@ class MusicBeatState extends FlxUIState public function clean() { if (FlxG.save.data.optimize) + { for(i in assets) { remove(i); } + } } override function create() From 7d590483329103b27ff68cac959257967aa3d8fd Mon Sep 17 00:00:00 2001 From: KadeDeveloper Date: Fri, 13 Aug 2021 17:46:59 -0700 Subject: [PATCH 8/8] ughuhuh --- source/OptionsMenu.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/OptionsMenu.hx b/source/OptionsMenu.hx index ca7596b..440df09 100644 --- a/source/OptionsMenu.hx +++ b/source/OptionsMenu.hx @@ -86,6 +86,7 @@ class OptionsMenu extends MusicBeatState var blackBorder:FlxSprite; override function create() { + clean(); instance = this; var menuBG:FlxSprite = new FlxSprite().loadGraphic(Paths.image("menuDesat")); @@ -134,7 +135,6 @@ class OptionsMenu extends MusicBeatState override function update(elapsed:Float) { - clean(); super.update(elapsed); if (acceptInput)