From 75b4c732dbf2c7817f15e22afa9bc0d9c050c200 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Wed, 1 Mar 2023 18:22:28 -0500 Subject: [PATCH] Mac fix, doh! --- source/funkin/modding/PolymodHandler.hx | 1 + .../funkin/play/cutscene/VanillaCutscenes.hx | 2 +- source/funkin/util/FileUtil.hx | 19 +++++++++++++------ source/funkin/util/WindowUtil.hx | 7 +++---- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/source/funkin/modding/PolymodHandler.hx b/source/funkin/modding/PolymodHandler.hx index 73a4de6e7..08b070835 100644 --- a/source/funkin/modding/PolymodHandler.hx +++ b/source/funkin/modding/PolymodHandler.hx @@ -169,6 +169,7 @@ class PolymodHandler // `polymod.*` for (cls in ClassMacro.listClassesInPackage('polymod')) { + if (cls == null) continue; var className = Type.getClassName(cls); Polymod.blacklistImport(className); } diff --git a/source/funkin/play/cutscene/VanillaCutscenes.hx b/source/funkin/play/cutscene/VanillaCutscenes.hx index 9f51b214c..a0cbd965b 100644 --- a/source/funkin/play/cutscene/VanillaCutscenes.hx +++ b/source/funkin/play/cutscene/VanillaCutscenes.hx @@ -60,7 +60,7 @@ class VanillaCutscenes #if html5 // Video displays OVER the FlxState. vid = new FlxVideo(path); - vid.finishCallback = finishCutscene; + vid.finishCallback = finishCutscene.bind(0.5); #else // Video displays OVER the FlxState. // vid = new FlxVideoSprite(0, 0); diff --git a/source/funkin/util/FileUtil.hx b/source/funkin/util/FileUtil.hx index 89aaaaf77..c30eacba8 100644 --- a/source/funkin/util/FileUtil.hx +++ b/source/funkin/util/FileUtil.hx @@ -5,6 +5,10 @@ import lime.utils.Bytes; import lime.ui.FileDialog; import openfl.net.FileFilter; import haxe.io.Path; +#if html5 +import openfl.net.FileReference; +import openfl.events.Event; +#end /** * Utilities for reading and writing files on various platforms. @@ -141,8 +145,6 @@ class FileUtil fileDialog.open(filter, defaultPath, dialogTitle); return true; #elseif html5 - var filter = convertTypeFilter(typeFilter); - var onFileLoaded = function(event) { var loadedFileRef:FileReference = event.target; trace('Loaded file: ' + loadedFileRef.name); @@ -157,8 +159,9 @@ class FileUtil } var fileRef = new FileReference(); - file.addEventListener(Event.SELECT, onFileSelected); - file.open(filter, defaultPath, dialogTitle); + fileRef.addEventListener(Event.SELECT, onFileSelected); + fileRef.browse(typeFilter); + return true; #else onCancel(); return false; @@ -169,7 +172,6 @@ class FileUtil * Browses for a single file location, then writes the provided `haxe.io.Bytes` data and calls `onSave(path)` when done. * Works great on desktop and HTML5. * - * @param typeFilter TODO What does this do? * @return Whether the file dialog was opened successfully. */ public static function saveFile(data:Bytes, ?onSave:String->Void, ?onCancel:Void->Void, ?defaultFileName:String, ?dialogTitle:String):Bool @@ -191,6 +193,7 @@ class FileUtil if (onCancel != null) fileDialog.onCancel.add(onCancel); fileDialog.save(data, filter, defaultFileName, dialogTitle); + return true; #else onCancel(); return false; @@ -374,7 +377,11 @@ class FileUtil */ public static function appendStringToPath(path:String, data:String) { + #if sys sys.io.File.append(path, false).writeString(data); + #else + throw 'Direct file writing by path not supported on this platform.'; + #end } /** @@ -410,7 +417,7 @@ class FileUtil { path = Sys.getEnv(envName); - if (path == "") path = null; + if (path == '') path = null; if (path != null) break; } diff --git a/source/funkin/util/WindowUtil.hx b/source/funkin/util/WindowUtil.hx index c566d154c..f2f1dcf0a 100644 --- a/source/funkin/util/WindowUtil.hx +++ b/source/funkin/util/WindowUtil.hx @@ -2,7 +2,7 @@ package funkin.util; import flixel.util.FlxSignal.FlxTypedSignal; -#if cpp +#if (cpp && windows) @:cppFileCode(' #include #include @@ -35,8 +35,7 @@ class WindowUtil // onUpdate is called every frame just before rendering. // onExit is called when the game window is closed. - openfl.Lib.current.stage.application.onExit.add(function(exitCode:Int) - { + openfl.Lib.current.stage.application.onExit.add(function(exitCode:Int) { windowExit.dispatch(exitCode); }); } @@ -46,7 +45,7 @@ class WindowUtil */ public static function disableCrashHandler() { - #if cpp + #if (cpp && windows) untyped __cpp__('SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);'); #else // Do nothing.