Skip to content

Commit

Permalink
working on new crash handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Fyrid19 committed Sep 9, 2024
1 parent 8fc97a8 commit 589a8c6
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 18 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@ jobs:
haxe-version: 4.2.5
- name: Set up Haxelib dependencies
run: haxe -cp cmd -D analyzer-optimize --run Main
- name: Update submodules
run: git submodule update --init --recursive
- name: Build crash handler
run: |
cd crash
haxelib run lime build windows
# - name: Update submodules
# run: git submodule update --init --recursive
- name: Build project
run: |
cd D:/a/Proto-Engine-FNF/Proto-Engine-FNF
haxelib run lime build windows
- name: Uploading artifact
uses: actions/upload-artifact@v2
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

4 changes: 2 additions & 2 deletions Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- _________________________ Application Settings _________________________ -->

<app
title="FNF Prototype Engine"
title="Friday Night Funkin': Prototype Engine"
file="ProtoEngine"
packageName="com.fyridev.prototype"
package="com.fyridev.prototype"
Expand Down Expand Up @@ -73,7 +73,7 @@

<assets path='mods' embed='false'/>

<assets path='crash/export/release/windows/bin' rename='crash' if='CRASH_HANDLER' />
<!-- <assets path='crash/export/release/windows/bin' rename='crash' if='CRASH_HANDLER' /> -->

<!-- <template path="example_mods" rename="mods" /> -->

Expand Down
1 change: 0 additions & 1 deletion crash
Submodule crash deleted from 65a17f
6 changes: 4 additions & 2 deletions source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ class Main extends Sprite {
}

private function init(?E:Event):Void {
if (hasEventListener(Event.ADDED_TO_STAGE))
{
if (hasEventListener(Event.ADDED_TO_STAGE)) {
removeEventListener(Event.ADDED_TO_STAGE, init);
}

Expand All @@ -65,6 +64,9 @@ class Main extends Sprite {
gameWidth = Math.ceil(stageWidth / zoom);
gameHeight = Math.ceil(stageHeight / zoom);
}

haxe.ui.Toolkit.theme = 'dark';
haxe.ui.Toolkit.init();

game = new FNFGame(gameWidth, gameHeight, initialState, framerate, framerate, skipSplash, startFullscreen);
addChild(game);
Expand Down
11 changes: 11 additions & 0 deletions source/funkin/crash/CrashState.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package funkin.crash;

class CrashState extends MusicBeatState {
override function create() {
super.create();
}

override function update(elapsed:Float) {
super.update(elapsed);
}
}
27 changes: 24 additions & 3 deletions source/funkin/states/InitialState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class InitialState extends MusicBeatState {
}

// base code by sqirra-rng
#if CRASH_HANDLER
// #if CRASH_HANDLER
function onCrash(e:UncaughtErrorEvent):Void {
var errMsg:String = '';
var errData:String = '';
Expand All @@ -112,8 +112,29 @@ class InitialState extends MusicBeatState {
}
}

new Process("./crash/ProtoCrash.exe", [errMsg, errData, dateNow]);
var appVer:String = '1.0';
var crashLocation:String = "./crash/crashlog/";
var fileName:String = 'ProtoCrashLog_' + dateFormat + '.txt';
var normalFilePath:String = Path.normalize(crashLocation + fileName);
final errCompact:String = 'Prototype Engine Crash Handler v' + appVer + '\n'
+ errMsg + '\n\n'
+ errData + '\n\n' + 'Crash at $crashDate\n'
+ 'Original code by sqirra-rng';
if (!FileSystem.exists("./crash/")) {
crashLocation = "./crashlog/";
normalFilePath = Path.normalize(crashLocation + fileName);
}

if (!FileSystem.exists(crashLocation))
FileSystem.createDirectory(crashLocation);

if (!FileSystem.exists(crashLocation + fileName)) {
File.saveContent(crashLocation + fileName, errCompact);
}

// new Process("./crash/ProtoCrash.exe", [errMsg, errData, dateNow]);
Lib.application.window.alert(errCompact, 'Prototype Engine Crash Handler');
Sys.exit(0);
}
#end
// #end
}

0 comments on commit 589a8c6

Please sign in to comment.