2022-03-26 22:18:26 -04:00
|
|
|
package funkin.util;
|
|
|
|
|
2023-01-02 17:40:53 -05:00
|
|
|
import flixel.util.FlxSignal.FlxTypedSignal;
|
|
|
|
|
2023-03-01 20:27:29 -05:00
|
|
|
#if (cpp && windows)
|
2023-01-22 19:55:30 -05:00
|
|
|
@:cppFileCode('
|
|
|
|
#include <iostream>
|
|
|
|
#include <windows.h>
|
|
|
|
#include <psapi.h>
|
|
|
|
')
|
|
|
|
#end
|
2022-03-26 22:18:26 -04:00
|
|
|
class WindowUtil
|
|
|
|
{
|
2023-01-22 19:55:30 -05:00
|
|
|
public static function openURL(targetUrl:String)
|
|
|
|
{
|
|
|
|
#if CAN_OPEN_LINKS
|
|
|
|
#if linux
|
|
|
|
// Sys.command('/usr/bin/xdg-open', [, "&"]);
|
|
|
|
Sys.command('/usr/bin/xdg-open', [targetUrl, "&"]);
|
|
|
|
#else
|
|
|
|
FlxG.openURL(targetUrl);
|
|
|
|
#end
|
|
|
|
#else
|
|
|
|
trace('Cannot open');
|
|
|
|
#end
|
|
|
|
}
|
2023-01-02 17:40:53 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
/**
|
|
|
|
* Dispatched when the game window is closed.
|
|
|
|
*/
|
|
|
|
public static final windowExit:FlxTypedSignal<Int->Void> = new FlxTypedSignal<Int->Void>();
|
2023-01-02 17:40:53 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
public static function initWindowEvents()
|
|
|
|
{
|
|
|
|
// onUpdate is called every frame just before rendering.
|
2023-01-02 17:40:53 -05:00
|
|
|
|
2023-01-22 19:55:30 -05:00
|
|
|
// onExit is called when the game window is closed.
|
2023-03-01 20:27:29 -05:00
|
|
|
openfl.Lib.current.stage.application.onExit.add(function(exitCode:Int) {
|
2023-01-22 19:55:30 -05:00
|
|
|
windowExit.dispatch(exitCode);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Turns off that annoying "Report to Microsoft" dialog that pops up when the game crashes.
|
|
|
|
*/
|
|
|
|
public static function disableCrashHandler()
|
|
|
|
{
|
2023-03-01 20:27:29 -05:00
|
|
|
#if (cpp && windows)
|
2023-01-22 19:55:30 -05:00
|
|
|
untyped __cpp__('SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);');
|
|
|
|
#else
|
|
|
|
// Do nothing.
|
|
|
|
#end
|
|
|
|
}
|
2022-03-26 22:18:26 -04:00
|
|
|
}
|