Skip to content

Commit

Permalink
Fixing crash handler and full screen for Android (#56)
Browse files Browse the repository at this point in the history
* Fixing crash handler and full screen for Android
- It's seems like the crash handler is came from SUtil instead from Main

* Update Main.hx

you forgot to add a " LOL

---------

Co-authored-by: JordanSantiagoYT <61796448+JordanSantiagoYT@users.noreply.github.com>
  • Loading branch information
Stefan2008Git and JordanSantiagoYT authored Oct 29, 2023
1 parent 364015b commit f84e1c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 44 deletions.
12 changes: 8 additions & 4 deletions source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ class Main extends Sprite {
public function new() {
super();

SUtil.gameCrashCheck();
if (stage != null) {
init();
} else {
Expand Down Expand Up @@ -149,7 +148,12 @@ class Main extends Sprite {
SUtil.doTheCheck();

ClientPrefs.loadDefaultKeys();
addChild(new FlxGame(game.width, game.height, game.initialState, game.framerate, game.framerate, game.skipSplash, game.startFullscreen));
// This is gonna make your FPS counter to be outside from game screen and fix full screen issue because of latest OpenFL library version. -- MaysLastPlay says
#if android
addChild(new FlxGame(1280, 720, TitleState, 60, 60, true, false));
#else
addChild(new FlxGame(game.width, game.height, game.initialState, #if (flixel < "5.0.0") game.zoom, #end game.framerate, game.framerate, game.skipSplash, game.startFullscreen));
#end

fpsVar = new FPS(10, 3, 0xFFFFFF);
addChild(fpsVar);
Expand Down Expand Up @@ -222,11 +226,11 @@ class Main extends Sprite {
Sys.println(errorMessage);
Sys.println("Crash dump saved in " + Path.normalize(path));

Application.current.window.alert("Error! JS Engine v" + MainMenuState.psychEngineJSVersion, errorMessage);
Application.current.window.alert("Error! JS Engine v" + MainMenuState.psychEngineJSVersion + "(" + Main.__superCoolErrorMessagesArray[FlxG.random.int(0, Main.__superCoolErrorMessagesArray.length)] + ")", errorMessage);
#if desktop
DiscordClient.shutdown();
#end
Sys.exit(1);
}
#end
}
}
40 changes: 0 additions & 40 deletions source/SUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -82,46 +82,6 @@ class SUtil
#end
}

public static function gameCrashCheck()
{
Lib.current.loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onCrash);
}

public static function onCrash(e:UncaughtErrorEvent):Void
{
var callStack:Array<StackItem> = CallStack.exceptionStack(true);
var dateNow:String = Date.now().toString();
dateNow = StringTools.replace(dateNow, " ", "_");
dateNow = StringTools.replace(dateNow, ":", "'");

var path:String = "crash/" + "JS Engine_" + dateNow + ".txt";
var errorMessage:String = "";

for (stackItem in callStack)
{
switch (stackItem)
{
case FilePos(s, file, line, column):
errorMessage += file + " (Line " + line + ")\n";
default:
Sys.println(stackItem);
}
}

errorMessage += "\nUncaught Error: " + e.error + "\nPlease report this error to the GitHub page: https://github.com/JordanSantiagoYT/FNF-PsychEngine-NoBotplayLag\n\n> Crash Handler written by: sqirra-rng";

if (!FileSystem.exists(SUtil.getPath() + "crash"))
FileSystem.createDirectory(SUtil.getPath() + "crash");

File.saveContent(SUtil.getPath() + path, errorMessage + "\n");

Sys.println(errorMessage);
Sys.println("Crash dump saved in " + Path.normalize(path));

SUtil.applicationAlert("Error! (" + Main.__superCoolErrorMessagesArray[FlxG.random.int(0, Main.__superCoolErrorMessagesArray.length)] + ")", errorMessage);
System.exit(0);
}

private static function applicationAlert(title:String, description:String)
{
Application.current.window.alert(description, title);
Expand Down

0 comments on commit f84e1c5

Please sign in to comment.