diff --git a/source/funkin/Types.hx b/source/funkin/Types.hx new file mode 100644 index 00000000..08f0b17c --- /dev/null +++ b/source/funkin/Types.hx @@ -0,0 +1,4 @@ +package funkin; + +@:dox(hide) +typedef SingleOrFloat = #if (java || hl || cpp) Single #else Float #end; \ No newline at end of file diff --git a/source/funkin/backend/utils/AudioAnalyzer.hx b/source/funkin/backend/utils/AudioAnalyzer.hx index 03fc3967..49c5a991 100644 --- a/source/funkin/backend/utils/AudioAnalyzer.hx +++ b/source/funkin/backend/utils/AudioAnalyzer.hx @@ -29,8 +29,13 @@ class AudioAnalyzer { var maxByte:Int = 0; for(i in 0...Math.floor((bytesEndPos - bytesStartPos) / buffer.bitsPerSample)) { + #if js + var byte:Int = buffer.data[bytesStartPos + (i * buffer.bitsPerSample)] + | (buffer.data[bytesStartPos + (i * buffer.bitsPerSample) + 1] << 8); + #else var byte:Int = buffer.data.buffer.get(bytesStartPos + (i * buffer.bitsPerSample)) | (buffer.data.buffer.get(bytesStartPos + (i * buffer.bitsPerSample) + 1) << 8); + #end if (byte > 256 * 128) byte -= 256 * 256; if (maxByte < byte) maxByte = byte; } diff --git a/source/funkin/backend/utils/CoolUtil.hx b/source/funkin/backend/utils/CoolUtil.hx index cd345844..ef700daa 100644 --- a/source/funkin/backend/utils/CoolUtil.hx +++ b/source/funkin/backend/utils/CoolUtil.hx @@ -134,7 +134,7 @@ class CoolUtil if(result.isNothing) Logs.trace('The file where it has been tried to get the attributes from, might be corrupted or inexistent (code: ${result.getValue()})', WARNING); return result; #else - return 0; + return new FileAttributeWrapper(0); #end } diff --git a/source/funkin/editors/SaveWarning.hx b/source/funkin/editors/SaveWarning.hx index b475e3e2..b56e5775 100644 --- a/source/funkin/editors/SaveWarning.hx +++ b/source/funkin/editors/SaveWarning.hx @@ -37,7 +37,7 @@ class SaveWarning { if (closingWindow) WindowUtils.resetClosing(); } else { WindowUtils.preventClosing = false; WindowUtils.resetClosing(); - Sys.exit(0); + openfl.system.System.exit(0); } } }, @@ -51,7 +51,7 @@ class SaveWarning { if (closingWindow) WindowUtils.resetClosing(); } else { WindowUtils.preventClosing = false; WindowUtils.resetClosing(); - Sys.exit(0); + openfl.system.System.exit(0); } } } diff --git a/source/funkin/editors/charter/CharterSelection.hx b/source/funkin/editors/charter/CharterSelection.hx index 57172751..3384967c 100644 --- a/source/funkin/editors/charter/CharterSelection.hx +++ b/source/funkin/editors/charter/CharterSelection.hx @@ -34,16 +34,20 @@ class CharterSelection extends EditorTreeMenu { FlxG.switchState(new Charter(s.name, d)); }) ]; + #if sys list.push(new NewOption("New Difficulty", "New Difficulty", function() { FlxG.state.openSubState(new ChartCreationScreen(saveChart)); })); + #end optionsTree.add(new OptionsScreen(s.name, "Select a difficulty to continue.", list)); }, s.parsedColor.getDefault(0xFFFFFFFF)) ]; + #if sys list.insert(0, new NewOption("New Song", "New Song", function() { FlxG.state.openSubState(new SongCreationScreen(saveSong)); })); + #end main = new OptionsScreen("Chart Editor", "Select a song to modify the charts from.", list); @@ -88,6 +92,7 @@ class CharterSelection extends EditorTreeMenu { } } + #if sys public function saveSong(creation:SongCreationData) { var songAlreadyExists:Bool = [for (s in freeplayList.songs) s.name.toLowerCase()].contains(creation.meta.name.toLowerCase()); @@ -163,4 +168,5 @@ class CharterSelection extends EditorTreeMenu { CoolUtil.safeSaveFile('$songFolder/meta.json', Json.stringify(meta)); } } + #end } \ No newline at end of file diff --git a/source/funkin/game/Note.hx b/source/funkin/game/Note.hx index d14b87fd..7738dad1 100644 --- a/source/funkin/game/Note.hx +++ b/source/funkin/game/Note.hx @@ -191,7 +191,7 @@ class Note extends FlxSprite } public var lastScrollSpeed:Null = null; - public var gapFix:Single = 0; + public var gapFix:SingleOrFloat = 0; public var useAntialiasingFix(get, set):Bool; inline function set_useAntialiasingFix(v:Bool) { if(v != useAntialiasingFix) { diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 2e58e98b..c089652f 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -1224,7 +1224,7 @@ class PlayState extends MusicBeatState if (SaveWarning.selectionClass != null) FlxG.switchState(Type.createInstance(SaveWarning.selectionClass, [])); } else { WindowUtils.preventClosing = false; WindowUtils.resetClosing(); - Sys.exit(0); + openfl.system.System.exit(0); } } }, @@ -1237,7 +1237,7 @@ class PlayState extends MusicBeatState if (SaveWarning.selectionClass != null) FlxG.switchState(Type.createInstance(SaveWarning.selectionClass, [])); } else { WindowUtils.preventClosing = false; WindowUtils.resetClosing(); - Sys.exit(0); + openfl.system.System.exit(0); } } }, diff --git a/source/funkin/import.hx b/source/funkin/import.hx index 88a2efdb..31ebc7c8 100644 --- a/source/funkin/import.hx +++ b/source/funkin/import.hx @@ -23,6 +23,7 @@ import flixel.tweens.FlxEase; import flixel.util.FlxDestroyUtil; import funkin.backend.system.Flags; +import funkin.Types; import funkin.menus.ui.Alphabet; import flixel.group.FlxGroup.FlxTypedGroup; diff --git a/source/funkin/menus/ui/Alphabet.hx b/source/funkin/menus/ui/Alphabet.hx index 3ae5a127..7714647a 100644 --- a/source/funkin/menus/ui/Alphabet.hx +++ b/source/funkin/menus/ui/Alphabet.hx @@ -52,7 +52,9 @@ class Alphabet extends FlxSpriteGroup public function refreshAlphabetXML(path:String) { AlphaCharacter.__alphaPath = Paths.getAssetsRoot() + path; try { - var xml = new Access(Xml.parse(Assets.getText(path)).firstElement()); + var file = Assets.getText(path); + if(file == null) return; + var xml = new Access(Xml.parse(file).firstElement()); AlphaCharacter.boldAnims = []; AlphaCharacter.letterAnims = []; AlphaCharacter.boldAlphabetPath = AlphaCharacter.letterAlphabetPath = 'ui/alphabet'; diff --git a/source/funkin/options/type/GithubIconOption.hx b/source/funkin/options/type/GithubIconOption.hx index 15a063cd..ef2d187b 100644 --- a/source/funkin/options/type/GithubIconOption.hx +++ b/source/funkin/options/type/GithubIconOption.hx @@ -49,7 +49,21 @@ class GithubUserIcon extends FlxSprite super.update(elapsed); } + #if target.threaded final mutex = new sys.thread.Mutex(); + #end + + inline function acquireMutex() { + #if target.threaded + mutex.acquire(); + #end + } + inline function releaseMutex() { + #if target.threaded + mutex.release(); + #end + } + override function drawComplex(camera:FlxCamera):Void { // Making the image download only if the player actually sees it on the screen - Nex if(waitUntilLoad <= 0) { waitUntilLoad = null; @@ -82,19 +96,19 @@ class GithubUserIcon extends FlxSprite } if(bmap != null) try { - mutex.acquire(); // Avoiding critical section - Nex + acquireMutex(); // Avoiding critical section - Nex var leGraphic:FlxGraphic = FlxG.bitmap.add(bmap, false, key); leGraphic.persist = true; updateDaFunni(leGraphic); bmap = null; - mutex.release(); + releaseMutex(); } catch(e) { Logs.traceColored([Logs.logText('Failed to update the pfp for ${user.login}: ${e.message}', RED)], ERROR); } } else { - mutex.acquire(); + acquireMutex(); updateDaFunni(bmap); - mutex.release(); + releaseMutex(); } }); }