Replace the application popup.

This commit is contained in:
MAJigsaw77
2025-08-05 01:14:22 -04:00
committed by Eric
parent e16391a05c
commit bb7b00cf77
8 changed files with 68 additions and 48 deletions
+1 -4
View File
@@ -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();
+4 -18
View File
@@ -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)
+2 -2
View File
@@ -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');
}
}
+1 -1
View File
@@ -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,
+2 -2
View File
@@ -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
@@ -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());
}
}
+56 -19
View File
@@ -7,13 +7,6 @@ using StringTools;
/**
* Utilities for operating on the current window, such as changing the title.
*/
#if (cpp && windows)
@:cppFileCode('
#include <iostream>
#include <windows.h>
#include <psapi.h>
')
#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
+1 -1
View File
@@ -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