diff --git a/source/funkin/InitState.hx b/source/funkin/InitState.hx index 3193f9b8d..44db393c7 100644 --- a/source/funkin/InitState.hx +++ b/source/funkin/InitState.hx @@ -82,11 +82,8 @@ class InitState extends FlxState // GAME SETUP // - // Setup window events (like callbacks for onWindowClose) - // and fullscreen keybind setup + // Setup window events (like callbacks for onWindowClose) and fullscreen keybind setup WindowUtil.initWindowEvents(); - // Disable the thing on Windows where it tries to send a bug report to Microsoft because why do they care? - WindowUtil.disableCrashHandler(); #if FEATURE_DEBUG_TRACY funkin.util.WindowUtil.initTracy(); diff --git a/source/funkin/modding/PolymodErrorHandler.hx b/source/funkin/modding/PolymodErrorHandler.hx index 63c705f61..f778e0263 100644 --- a/source/funkin/modding/PolymodErrorHandler.hx +++ b/source/funkin/modding/PolymodErrorHandler.hx @@ -5,19 +5,6 @@ import polymod.Polymod; @:nullSafety class PolymodErrorHandler { - /** - * Show a popup with the given text. - * This displays a system popup, it WILL interrupt the game. - * Make sure to only use this when it's important, like when there's a script error. - * - * @param name The name at the top of the popup. - * @param desc The body text of the popup. - */ - public static function showAlert(name:String, desc:String):Void - { - lime.app.Application.current.window.alert(desc, name); - } - public static function onPolymodError(error:PolymodError):Void { // Perform an action based on the error code. @@ -37,12 +24,12 @@ class PolymodErrorHandler // A syntax error when parsing a script. logError(error.message); // Notify the user via popup. - showAlert('Polymod Script Parsing Error', error.message); + funkin.util.WindowUtil.showError('Polymod Script Parsing Error', error.message); case SCRIPT_RUNTIME_EXCEPTION: // A runtime error when running a script. logError(error.message); // Notify the user via popup. - showAlert('Polymod Script Exception', error.message); + funkin.util.WindowUtil.showError('Polymod Script Exception', error.message); case SCRIPT_CLASS_MODULE_NOT_FOUND: // A scripted class tried to reference an unknown class or module. logError(error.message); @@ -54,13 +41,12 @@ class PolymodErrorHandler msg += '\nCheck to ensure the class exists and is spelled correctly.'; // Notify the user via popup. - showAlert('Polymod Script Import Error', msg); + funkin.util.WindowUtil.showError('Polymod Script Import Error', msg); case SCRIPT_CLASS_MODULE_BLACKLISTED: // A scripted class tried to reference a blacklisted class or module. logError(error.message); // Notify the user via popup. - showAlert('Polymod Script Blacklist Violation', error.message); - + funkin.util.WindowUtil.showError('Polymod Script Blacklist Violation', error.message); default: // Log the message based on its severity. switch (error.severity) diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index d7679d354..cdbc5c6ab 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -916,7 +916,7 @@ class PlayState extends MusicBeatSubState } // Display a popup. This blocks the application until the user clicks OK. - lime.app.Application.current.window.alert(message, 'Error loading PlayState'); + funkin.util.WindowUtil.showError(message, 'Error loading PlayState'); // Force the user back to the main menu. if (isSubState) @@ -1912,7 +1912,7 @@ class PlayState extends MusicBeatSubState else { // lolol - lime.app.Application.current.window.alert('Unable to load stage ${id}, is its data corrupted?.', 'Stage Error'); + funkin.util.WindowUtil.showError('Unable to load stage ${id}, is its data corrupted?.', 'Stage Error'); } } diff --git a/source/funkin/play/cutscene/VideoCutscene.hx b/source/funkin/play/cutscene/VideoCutscene.hx index ab42d2dc2..f59e5adbf 100644 --- a/source/funkin/play/cutscene/VideoCutscene.hx +++ b/source/funkin/play/cutscene/VideoCutscene.hx @@ -66,7 +66,7 @@ class VideoCutscene if (!openfl.Assets.exists(filePath)) { // Display a popup. - // lime.app.Application.current.window.alert('Video file does not exist: ${filePath}', 'Error playing video'); + // funkin.util.WindowUtil.showError('Video file does not exist: ${filePath}', 'Error playing video'); // return; // TODO: After moving videos to their own library, diff --git a/source/funkin/save/Save.hx b/source/funkin/save/Save.hx index e77daa9b5..5235cc5a6 100644 --- a/source/funkin/save/Save.hx +++ b/source/funkin/save/Save.hx @@ -1220,7 +1220,7 @@ class Save { var msg = 'There was an error loading your save data in slot ${slot}.'; msg += '\nPlease report this issue to the developers.'; - lime.app.Application.current.window.alert(msg, "Save Data Failure"); + funkin.util.WindowUtil.showError(msg, "Save Data Failure"); // Don't touch that slot anymore. // Instead, load the next available slot. @@ -1407,7 +1407,7 @@ class Save var msg = 'There was an error loading your save data from Newgrounds.'; msg += '\n${errorMsg}'; msg += '\nAre you sure you are connected to the internet?'; - lime.app.Application.current.window.alert(msg, "Newgrounds Save Slot Failure"); + funkin.util.WindowUtil.showError(msg, "Newgrounds Save Slot Failure"); }); } #end diff --git a/source/funkin/save/migrator/SaveDataMigrator.hx b/source/funkin/save/migrator/SaveDataMigrator.hx index 3dc012fce..fcdcaa8cb 100644 --- a/source/funkin/save/migrator/SaveDataMigrator.hx +++ b/source/funkin/save/migrator/SaveDataMigrator.hx @@ -41,7 +41,7 @@ class SaveDataMigrator var message:String = 'Error migrating save data, expected ${Save.SAVE_DATA_VERSION}.'; var slot:Int = Save.archiveBadSaveData(inputData); var fullMessage:String = 'An error occurred migrating your save data.\n${message}\nInvalid data has been moved to save slot ${slot}.'; - lime.app.Application.current.window.alert(fullMessage, "Save Data Failure"); + funkin.util.WindowUtil.showError(fullMessage, "Save Data Failure"); return new Save(Save.getDefault()); } } diff --git a/source/funkin/util/WindowUtil.hx b/source/funkin/util/WindowUtil.hx index 2ee34ee80..96b47093e 100644 --- a/source/funkin/util/WindowUtil.hx +++ b/source/funkin/util/WindowUtil.hx @@ -7,13 +7,6 @@ using StringTools; /** * Utilities for operating on the current window, such as changing the title. */ -#if (cpp && windows) -@:cppFileCode(' -#include -#include -#include -') -#end @:nullSafety class WindowUtil { @@ -147,18 +140,6 @@ class WindowUtil _initializedWindowEvents = true; } - /** - * Turns off that annoying "Report to Microsoft" dialog that pops up when the game crashes. - */ - public static function disableCrashHandler():Void - { - #if (cpp && windows) - untyped __cpp__('SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);'); - #else - // Do nothing. - #end - } - /** * Sets the title of the application window. * @param value The title to use. @@ -168,6 +149,62 @@ class WindowUtil lime.app.Application.current.window.title = value; } + /** + * Shows an error dialog with an error icon. + * @param name The title of the dialog window. + * @param desc The error message to display. + */ + public static function showError(name:String, desc:String):Void + { + #if (windows && cpp) + funkin.external.windows.WinAPI.showError(desc, name); + #else + lime.app.Application.current.window.alert(desc, name); + #end + } + + /** + * Shows a warning dialog with a warning icon. + * @param name The title of the dialog window. + * @param desc The warning message to display. + */ + public static function showWarning(name:String, desc:String):Void + { + #if (windows && cpp) + funkin.external.windows.WinAPI.showWarning(desc, name); + #else + lime.app.Application.current.window.alert(desc, name); + #end + } + + /** + * Shows an information dialog with an information icon. + * @param name The title of the dialog window. + * @param desc The information message to display. + */ + public static function showInformation(name:String, desc:String):Void + { + #if (windows && cpp) + funkin.external.windows.WinAPI.showInformation(desc, name); + #else + lime.app.Application.current.window.alert(desc, name); + #end + } + + /** + * Shows a question dialog with a question icon and OK/Cancel buttons. + * @param name The title of the dialog window. + * @param desc The question message to display. + */ + public static function showQuestion(name:String, desc:String):Void + { + #if (windows && cpp) + funkin.external.windows.WinAPI.showQuestion(desc, name); + #else + lime.app.Application.current.window.alert(desc, name); + #end + } + public static function setVSyncMode(value:lime.ui.WindowVSyncMode):Void { // vsync crap dont worky on mac rn derp diff --git a/source/funkin/util/logging/CrashHandler.hx b/source/funkin/util/logging/CrashHandler.hx index ec3b8510c..a3f19dd60 100644 --- a/source/funkin/util/logging/CrashHandler.hx +++ b/source/funkin/util/logging/CrashHandler.hx @@ -109,7 +109,7 @@ class CrashHandler static function displayErrorMessage(message:String):Void { - lime.app.Application.current.window.alert(message, "Fatal Uncaught Exception"); + funkin.util.WindowUtil.showError(message, "Fatal Uncaught Exception"); } #if sys