From 4f947ca6e62a6cda158127a7099feb773dea73cd Mon Sep 17 00:00:00 2001 From: Kade M Date: Sun, 11 Jul 2021 23:26:23 -0700 Subject: [PATCH] fix html5 compile and input --- source/Caching.hx | 4 +++- source/Paths.hx | 24 +++++++++++++++++++++--- source/PlayState.hx | 18 +++++++++--------- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/source/Caching.hx b/source/Caching.hx index fdf458a..1cf66ac 100644 --- a/source/Caching.hx +++ b/source/Caching.hx @@ -1,3 +1,4 @@ +#if sys package; import lime.app.Application; @@ -171,4 +172,5 @@ class Caching extends MusicBeatState FlxG.switchState(new TitleState()); } -} \ No newline at end of file +} +#end \ No newline at end of file diff --git a/source/Paths.hx b/source/Paths.hx index 2c74380..5d7b07a 100644 --- a/source/Paths.hx +++ b/source/Paths.hx @@ -130,26 +130,44 @@ class Paths inline static public function getSparrowAtlas(key:String, ?library:String, ?isCharacter:Bool = false) { + var usecahce = FlxG.save.data.cacheImages; + #if !cpp + usecahce = false; + #end if (isCharacter) - if (FlxG.save.data.cacheImages) + if (usecahce) + #if cpp return FlxAtlasFrames.fromSparrow(imageCached(key), file('images/characters/$key.xml', library)); + #else + return null; + #end else return FlxAtlasFrames.fromSparrow(image('characters/$key'), file('images/characters/$key.xml')); return FlxAtlasFrames.fromSparrow(image(key, library), file('images/$key.xml', library)); } + #if cpp inline static public function imageCached(key:String):FlxGraphic { var data = Caching.bitmapData.get(key); trace('finding ${key} - ${data.bitmap}'); return data; } - + #end + inline static public function getPackerAtlas(key:String, ?library:String, ?isCharacter:Bool = false) { + var usecahce = FlxG.save.data.cacheImages; + #if !cpp + usecahce = false; + #end if (isCharacter) - if (FlxG.save.data.cacheImages) + if (usecahce) + #if cpp return FlxAtlasFrames.fromSpriteSheetPacker(imageCached(key), file('images/$key.txt', library)); + #else + return null; + #end else return FlxAtlasFrames.fromSpriteSheetPacker(image('characters/$key'), file('images/characters/$key.txt')); return FlxAtlasFrames.fromSpriteSheetPacker(image(key, library), file('images/$key.txt', library)); diff --git a/source/PlayState.hx b/source/PlayState.hx index c7b846b..368d68f 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -1209,7 +1209,6 @@ class PlayState extends MusicBeatState FlxG.stage.addEventListener(KeyboardEvent.KEY_DOWN, handleInput); FlxG.stage.addEventListener(KeyboardEvent.KEY_UP, releaseInput); - super.create(); } @@ -2220,8 +2219,10 @@ class PlayState extends MusicBeatState { GlobalVideo.get().stop(); remove(videoSprite); + #if sys FlxG.stage.window.onFocusOut.remove(focusOut); FlxG.stage.window.onFocusIn.remove(focusIn); + #end removedVideo = true; } #if windows @@ -3451,8 +3452,6 @@ class PlayState extends MusicBeatState }; #end - var nonCpp = false; - // Prevent player input if botplay is on if (PlayStateChangeables.botPlay) { @@ -3461,10 +3460,6 @@ class PlayState extends MusicBeatState releaseArray = [false, false, false, false]; } - #if !cpp - nonCpp = true; - #end - var anas:Array = [null, null, null, null]; for (i in 0...pressArray.length) @@ -3484,7 +3479,7 @@ class PlayState extends MusicBeatState }); } - if ((KeyBinds.gamepad && !FlxG.keys.justPressed.ANY) || nonCpp) + if ((KeyBinds.gamepad && !FlxG.keys.justPressed.ANY)) { // PRESSES, check for note hits if (pressArray.contains(true) && generatedMusic) @@ -3521,6 +3516,7 @@ class PlayState extends MusicBeatState } else { + directionsAccounted[daNote.noteData] = true; possibleNotes.push(daNote); directionList.push(daNote.noteData); } @@ -3536,6 +3532,9 @@ class PlayState extends MusicBeatState } possibleNotes.sort((a, b) -> Std.int(a.strumTime - b.strumTime)); + + var hit = [false,false,false,false]; + if (perfectMode) goodNoteHit(possibleNotes[0]); else if (possibleNotes.length > 0) @@ -3550,10 +3549,11 @@ class PlayState extends MusicBeatState } for (coolNote in possibleNotes) { - if (pressArray[coolNote.noteData]) + if (pressArray[coolNote.noteData] && !hit[coolNote.noteData]) { if (mashViolations != 0) mashViolations--; + hit[coolNote.noteData] = true; scoreTxt.color = FlxColor.WHITE; var noteDiff:Float = -(coolNote.strumTime - Conductor.songPosition); anas[coolNote.noteData].hit = true;