Minor GameContainer changes.

Added copy of GameContainer.java:
- updateAndRender() no longer calls Log.error(), and re-throws the original exception as a SlickException.  This prevents errors from being logged twice, and now the relevant one is shown in the error popup (instead of a useless "failure" message).
- getBuildVersion() no longer calls Log.error(), and removed slick build information from "version" file.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han
2015-03-06 19:16:43 -05:00
parent 3df08e5357
commit 9138b70a24
4 changed files with 931 additions and 14 deletions

View File

@@ -21,6 +21,7 @@ package itdelatrisu.opsu;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.downloads.DownloadList;
import org.lwjgl.opengl.Display;
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.Game;
import org.newdawn.slick.SlickException;
@@ -79,6 +80,28 @@ public class Container extends AppGameContainer {
Opsu.exit();
}
@Override
protected void gameLoop() throws SlickException {
int delta = getDelta();
if (!Display.isVisible() && updateOnlyOnVisible) {
try { Thread.sleep(100); } catch (Exception e) {}
} else {
try {
updateAndRender(delta);
} catch (SlickException e) {
this.e = e; // store exception to display later
running = false;
return;
}
}
updateFPS();
Display.update();
if (Display.isCloseRequested()) {
if (game.closeRequested())
running = false;
}
}
/**
* Actions to perform before destroying the game container.
*/
@@ -102,16 +125,6 @@ public class Container extends AppGameContainer {
OsuGroupList.get().reset();
}
@Override
protected void updateAndRender(int delta) throws SlickException {
try {
super.updateAndRender(delta);
} catch (SlickException e) {
this.e = e; // store exception to display later
throw e; // re-throw exception
}
}
@Override
public void exit() {
// show confirmation dialog if any downloads are active