on exceptions that make game crash, show dialog with the real cause (close #51)

This commit is contained in:
yugecin 2016-11-20 13:45:05 +01:00
parent 3ddda20b64
commit 7daafd612e

View File

@ -40,6 +40,8 @@ public class Container extends AppGameContainer {
/** SlickException causing game failure. */ /** SlickException causing game failure. */
protected SlickException e = null; protected SlickException e = null;
private Exception anyException = null;
public static Container instance; public static Container instance;
/** /**
@ -63,14 +65,16 @@ public class Container extends AppGameContainer {
while (running()) while (running())
gameLoop(); gameLoop();
} catch(Exception e) { } catch(Exception e) {
e.printStackTrace(); anyException = e;
} finally { } finally {
// destroy the game container // destroy the game container
close_sub(); close_sub();
destroy(); destroy();
// report any critical errors if (anyException != null) {
if (e != null) { ErrorHandler.error("Something bad happend while playing", anyException, true);
anyException = null;
} else if (e != null) {
ErrorHandler.error(null, e, true); ErrorHandler.error(null, e, true);
e = null; e = null;
} }
@ -112,7 +116,9 @@ public class Container extends AppGameContainer {
Options.saveOptions(); Options.saveOptions();
// reset cursor // reset cursor
if (UI.getCursor() != null) {
UI.getCursor().reset(); UI.getCursor().reset();
}
// destroy images // destroy images
InternalTextureLoader.get().clear(); InternalTextureLoader.get().clear();