fix html5 compile and input

This commit is contained in:
Kade M 2021-07-11 23:26:23 -07:00
parent 361555cfa3
commit 4f947ca6e6
3 changed files with 33 additions and 13 deletions

View File

@ -1,3 +1,4 @@
#if sys
package; package;
import lime.app.Application; import lime.app.Application;
@ -172,3 +173,4 @@ class Caching extends MusicBeatState
} }
} }
#end

View File

@ -130,26 +130,44 @@ class Paths
inline static public function getSparrowAtlas(key:String, ?library:String, ?isCharacter:Bool = false) 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 (isCharacter)
if (FlxG.save.data.cacheImages) if (usecahce)
#if cpp
return FlxAtlasFrames.fromSparrow(imageCached(key), file('images/characters/$key.xml', library)); return FlxAtlasFrames.fromSparrow(imageCached(key), file('images/characters/$key.xml', library));
#else
return null;
#end
else else
return FlxAtlasFrames.fromSparrow(image('characters/$key'), file('images/characters/$key.xml')); return FlxAtlasFrames.fromSparrow(image('characters/$key'), file('images/characters/$key.xml'));
return FlxAtlasFrames.fromSparrow(image(key, library), file('images/$key.xml', library)); return FlxAtlasFrames.fromSparrow(image(key, library), file('images/$key.xml', library));
} }
#if cpp
inline static public function imageCached(key:String):FlxGraphic inline static public function imageCached(key:String):FlxGraphic
{ {
var data = Caching.bitmapData.get(key); var data = Caching.bitmapData.get(key);
trace('finding ${key} - ${data.bitmap}'); trace('finding ${key} - ${data.bitmap}');
return data; return data;
} }
#end
inline static public function getPackerAtlas(key:String, ?library:String, ?isCharacter:Bool = false) 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 (isCharacter)
if (FlxG.save.data.cacheImages) if (usecahce)
#if cpp
return FlxAtlasFrames.fromSpriteSheetPacker(imageCached(key), file('images/$key.txt', library)); return FlxAtlasFrames.fromSpriteSheetPacker(imageCached(key), file('images/$key.txt', library));
#else
return null;
#end
else else
return FlxAtlasFrames.fromSpriteSheetPacker(image('characters/$key'), file('images/characters/$key.txt')); return FlxAtlasFrames.fromSpriteSheetPacker(image('characters/$key'), file('images/characters/$key.txt'));
return FlxAtlasFrames.fromSpriteSheetPacker(image(key, library), file('images/$key.txt', library)); return FlxAtlasFrames.fromSpriteSheetPacker(image(key, library), file('images/$key.txt', library));

View File

@ -1209,7 +1209,6 @@ class PlayState extends MusicBeatState
FlxG.stage.addEventListener(KeyboardEvent.KEY_DOWN, handleInput); FlxG.stage.addEventListener(KeyboardEvent.KEY_DOWN, handleInput);
FlxG.stage.addEventListener(KeyboardEvent.KEY_UP, releaseInput); FlxG.stage.addEventListener(KeyboardEvent.KEY_UP, releaseInput);
super.create(); super.create();
} }
@ -2220,8 +2219,10 @@ class PlayState extends MusicBeatState
{ {
GlobalVideo.get().stop(); GlobalVideo.get().stop();
remove(videoSprite); remove(videoSprite);
#if sys
FlxG.stage.window.onFocusOut.remove(focusOut); FlxG.stage.window.onFocusOut.remove(focusOut);
FlxG.stage.window.onFocusIn.remove(focusIn); FlxG.stage.window.onFocusIn.remove(focusIn);
#end
removedVideo = true; removedVideo = true;
} }
#if windows #if windows
@ -3451,8 +3452,6 @@ class PlayState extends MusicBeatState
}; };
#end #end
var nonCpp = false;
// Prevent player input if botplay is on // Prevent player input if botplay is on
if (PlayStateChangeables.botPlay) if (PlayStateChangeables.botPlay)
{ {
@ -3461,10 +3460,6 @@ class PlayState extends MusicBeatState
releaseArray = [false, false, false, false]; releaseArray = [false, false, false, false];
} }
#if !cpp
nonCpp = true;
#end
var anas:Array<Ana> = [null, null, null, null]; var anas:Array<Ana> = [null, null, null, null];
for (i in 0...pressArray.length) 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 // PRESSES, check for note hits
if (pressArray.contains(true) && generatedMusic) if (pressArray.contains(true) && generatedMusic)
@ -3521,6 +3516,7 @@ class PlayState extends MusicBeatState
} }
else else
{ {
directionsAccounted[daNote.noteData] = true;
possibleNotes.push(daNote); possibleNotes.push(daNote);
directionList.push(daNote.noteData); directionList.push(daNote.noteData);
} }
@ -3536,6 +3532,9 @@ class PlayState extends MusicBeatState
} }
possibleNotes.sort((a, b) -> Std.int(a.strumTime - b.strumTime)); possibleNotes.sort((a, b) -> Std.int(a.strumTime - b.strumTime));
var hit = [false,false,false,false];
if (perfectMode) if (perfectMode)
goodNoteHit(possibleNotes[0]); goodNoteHit(possibleNotes[0]);
else if (possibleNotes.length > 0) else if (possibleNotes.length > 0)
@ -3550,10 +3549,11 @@ class PlayState extends MusicBeatState
} }
for (coolNote in possibleNotes) for (coolNote in possibleNotes)
{ {
if (pressArray[coolNote.noteData]) if (pressArray[coolNote.noteData] && !hit[coolNote.noteData])
{ {
if (mashViolations != 0) if (mashViolations != 0)
mashViolations--; mashViolations--;
hit[coolNote.noteData] = true;
scoreTxt.color = FlxColor.WHITE; scoreTxt.color = FlxColor.WHITE;
var noteDiff:Float = -(coolNote.strumTime - Conductor.songPosition); var noteDiff:Float = -(coolNote.strumTime - Conductor.songPosition);
anas[coolNote.noteData].hit = true; anas[coolNote.noteData].hit = true;