add code to exit from code

This commit is contained in:
yugecin 2017-01-18 16:55:30 +01:00
parent b1ccfe3019
commit 02863de1cf
3 changed files with 13 additions and 17 deletions

View File

@ -597,9 +597,7 @@ public class MainMenu extends BaseOpsuState {
} else if (restartButton.contains(x, y) && status == Updater.Status.UPDATE_DOWNLOADED) { } else if (restartButton.contains(x, y) && status == Updater.Status.UPDATE_DOWNLOADED) {
SoundController.playSound(SoundEffect.MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
Updater.get().prepareUpdate(); Updater.get().prepareUpdate();
// TODO: exit? displayContainer.exitRequested = true;
//container.setForceExit(false);
//container.exit();
return true; return true;
} }
} }
@ -624,8 +622,7 @@ public class MainMenu extends BaseOpsuState {
enterSongMenu(); enterSongMenu();
return true; return true;
} else if (exitButton.contains(x, y, 0.25f)) { } else if (exitButton.contains(x, y, 0.25f)) {
// TODO exit? displayContainer.exitRequested = true;
//container.exit();
return true; return true;
} }
} }

View File

@ -185,16 +185,14 @@ public class Splash extends BaseOpsuState {
@Override @Override
public boolean keyPressed(int key, char c) { public boolean keyPressed(int key, char c) {
if (key == Input.KEY_ESCAPE) { if (key != Input.KEY_ESCAPE) {
// close program return false;
if (++escapeCount >= 3) System.out.println("hi");
//container.exit(); // TODO
// stop parsing beatmaps by sending interrupt to BeatmapParser
else if (thread != null)
thread.interrupt();
return true;
} }
return false; if (++escapeCount >= 3) {
displayContainer.exitRequested = true;
} else if (thread != null) {
thread.interrupt();
}
return true;
} }
} }

View File

@ -93,6 +93,8 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
public int renderDelta; public int renderDelta;
public int delta; public int delta;
public boolean exitRequested;
public int timeSinceLastRender; public int timeSinceLastRender;
private long lastFrame; private long lastFrame;
@ -153,7 +155,7 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
public void run() throws LWJGLException { public void run() throws LWJGLException {
while(!(Display.isCloseRequested() && state.onCloseRequest())) { while(!exitRequested && !(Display.isCloseRequested() && state.onCloseRequest())) {
delta = getDelta(); delta = getDelta();
timeSinceLastRender += delta; timeSinceLastRender += delta;
@ -196,7 +198,6 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
Display.processMessages(); Display.processMessages();
Display.sync(targetUpdatesPerSecond); Display.sync(targetUpdatesPerSecond);
} }
teardown();
} }
public void setup() throws Exception { public void setup() throws Exception {