@@ -30,7 +30,7 @@ class LfEngine {
3030 /**
3131 * The current version of the engine
3232 */
33- public static final VERSION : String = " 1.5.0 " ;
33+ public static final VERSION : String = " 1.5.1 " ;
3434
3535 /**
3636 * Function to be called when the engine exits
@@ -65,81 +65,86 @@ class LfEngine {
6565 * @param state The initial state
6666 */
6767 public static function initEngine (gamePath : String , renderMode : LfWindowType = LfWindowType .DRC , state : LfState ): Void {
68- Proc . WHBProcInit ();
69- Log_udp . WHBLogUdpInit ();
70- Crash . WHBInitCrashHandler (); // This really works?
68+ try {
69+ Proc . WHBProcInit ();
70+ Log_udp . WHBLogUdpInit ();
71+ Crash . WHBInitCrashHandler (); // This really works?
7172
72- Sys .println (" [Leafy Engine initial state - no logger started] Starting Leafy Engine [" + VERSION + " ]" );
73+ Sys .println (" [Leafy Engine initial state - no logger started] Starting Leafy Engine [" + VERSION + " ]" );
7374
74- if (renderMode == null ) {
75- Sys .println (" [Leafy Engine initial state - no logger started -> WARNING] Render mode cannot be null, defaulting to DRC mode" );
76- renderMode = LfWindowType .DRC ;
77- }
75+ if (renderMode == null ) {
76+ Sys .println (" [Leafy Engine initial state - no logger started -> WARNING] Render mode cannot be null, defaulting to DRC mode" );
77+ renderMode = LfWindowType .DRC ;
78+ }
7879
79- if (gamePath == null || gamePath == " " ) {
80- Sys .println (" [Leafy Engine initial state - no logger started -> WARNING] Game path cannot be null, defaulting to LEAFY_GAME" );
81- gamePath = " LEAFY_GAME" ;
82- }
80+ if (gamePath == null || gamePath == " " ) {
81+ Sys .println (" [Leafy Engine initial state - no logger started -> WARNING] Game path cannot be null, defaulting to LEAFY_GAME" );
82+ gamePath = " LEAFY_GAME" ;
83+ }
8384
84- windowMode = renderMode ;
85+ windowMode = renderMode ;
8586
86- // initialize the engine systems
87- LfSystemPaths .initFSSystem ();
88- LeafyDebug .initLogger ();
89- SubEngines .startSDL ();
87+ // initialize the engine systems
88+ LfSystemPaths .initFSSystem ();
89+ LeafyDebug .initLogger ();
90+ SubEngines .startSDL ();
9091
91- // Set the engine main path
92- LfSystemPaths .setEngineMainPath (gamePath );
92+ // Set the engine main path
93+ LfSystemPaths .setEngineMainPath (gamePath );
9394
94- // Initialize the Wii U Gamepad
95- LfGamepadInternal .initDRC ();
95+ // Initialize the Wii U Gamepad
96+ LfGamepadInternal .initDRC ();
9697
97- #if debug
98- LeafyDebug .log (" Haxe debug mode is enabled in this build, lag may occur when printing many more logs!" , WARNING );
99- #end
98+ #if debug
99+ LeafyDebug .log (" Haxe debug mode is enabled in this build, lag may occur when printing many more logs!" , WARNING );
100+ #end
100101
101- LeafyDebug .log (" Leafy Engine [" + VERSION + " ] initialized" , INFO );
102+ LeafyDebug .log (" Leafy Engine [" + VERSION + " ] initialized" , INFO );
102103
103- // Call the onEngineInitFinished function
104- if (untyped __cpp__ (" onEngineInitFinished != NULL" )) {
105- onEngineInitFinished ();
106- }
107-
108- // Set and initialize the initial state
109- if (state == null ) {
110- LeafyDebug .criticalError (" initial state cannot be null." );
111- }
112- LfStateHandler .initFirstState (state );
113- initState = state ;
114- Leafy .currentState = state ;
104+ // Call the onEngineInitFinished function
105+ if (untyped __cpp__ (" onEngineInitFinished != NULL" )) {
106+ onEngineInitFinished ();
107+ }
108+
109+ // Set and initialize the initial state
110+ if (state == null ) {
111+ LeafyDebug .criticalError (" initial state cannot be null." );
112+ }
113+ LfStateHandler .initFirstState (state );
114+ initState = state ;
115+ Leafy .currentState = state ;
115116
116- // /////////////////////////////////////////
117+ // /////////////////////////////////////////
117118
118- _isRunning = Proc . WHBProcIsRunning ();
119- // Start the main loop, the engine will shutdown when the main loop ends
120- while (_isRunning ) {
121119 _isRunning = Proc . WHBProcIsRunning ();
122- LfWindowRender .updateRenderers ();
123- LeafyDebug .updateLogTime ();
124- Leafy .update ();
125-
126- if (! _isRunning ) {
127- Leafy .paused = true ;
120+ // Start the main loop, the engine will shutdown when the main loop ends
121+ while (_isRunning ) {
122+ _isRunning = Proc . WHBProcIsRunning ();
123+ LfWindowRender .updateRenderers ();
124+ LeafyDebug .updateLogTime ();
125+ Leafy .update ();
126+
127+ if (! _isRunning ) {
128+ Leafy .paused = true ;
129+ }
130+ };
131+
132+ // Shutdown the engine //////////
133+ // Call the onEngineExit function
134+ if (onEngineExit != null ) {
135+ onEngineExit ();
128136 }
129- };
130-
131- // Shutdown the engine //////////
132- // Call the onEngineExit function
133- if (onEngineExit != null ) {
134- onEngineExit ();
135- }
136137
137- LeafyDebug .log (" Shutting down Leafy Engine [" + VERSION + " ]" , INFO );
138+ LeafyDebug .log (" Shutting down Leafy Engine [" + VERSION + " ]" , INFO );
138139
139- LfStateHandler .destroyCurrentState ();
140- SubEngines .shutdownSDL ();
141- LfSystemPaths .deinitFSSystem ();
142- Log_udp . WHBLogUdpDeinit ();
143- Proc . WHBProcShutdown ();
140+ LfStateHandler .destroyCurrentState ();
141+ SubEngines .shutdownSDL ();
142+ LfSystemPaths .deinitFSSystem ();
143+ Log_udp . WHBLogUdpDeinit ();
144+ Proc . WHBProcShutdown ();
145+ }
146+ catch (e ) {
147+ LeafyDebug .crashHandler (e .message );
148+ }
144149 }
145150}
0 commit comments