close window on game end
This commit is contained in:
@@ -431,6 +431,7 @@ public class DDDView extends GameAdapter implements CommandSender {
|
||||
@Override
|
||||
public void onGameEnd() {
|
||||
openPopup("End");
|
||||
this.window.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -64,6 +64,8 @@ public class Window implements Closeable {
|
||||
private ImInt detailLevel = new ImInt(10);
|
||||
private ImBoolean pixelatedFrame = new ImBoolean(true);
|
||||
|
||||
private boolean shouldBeClosed = false;
|
||||
|
||||
public Window(Renderer renderer, World world, Camera camera) {
|
||||
this.renderer = new Renderer();
|
||||
this.cam = camera;
|
||||
@@ -280,7 +282,7 @@ public class Window implements Closeable {
|
||||
|
||||
// Run the rendering loop until the user has attempted to close
|
||||
// the window or has pressed the ESCAPE key.
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
while (!shouldBeClosed && !glfwWindowShouldClose(window)) {
|
||||
|
||||
newFrame();
|
||||
|
||||
@@ -304,8 +306,13 @@ public class Window implements Closeable {
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
shouldBeClosed = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
shouldBeClosed = true;
|
||||
this.renderer.close();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user