summaryrefslogtreecommitdiffstats
path: root/src/subconscious/graphics/Scene.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/subconscious/graphics/Scene.java')
-rw-r--r--src/subconscious/graphics/Scene.java23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/subconscious/graphics/Scene.java b/src/subconscious/graphics/Scene.java
index a544b1c..f6cd4e1 100644
--- a/src/subconscious/graphics/Scene.java
+++ b/src/subconscious/graphics/Scene.java
@@ -98,12 +98,12 @@ public abstract class Scene extends Panel
private Scene requestedScene = null;
private boolean requestedPrevScene = false;
- protected volatile boolean running = true;
- private volatile boolean threadPaused = false;
+ protected boolean running = true;
+ private boolean threadPaused = false;
private Lock pauseLock = new ReentrantLock();
private Condition threadResumed = pauseLock.newCondition();
- protected volatile Dimension canvasSize = GameWindow.WINDOW_SIZE;
+ protected Dimension canvasSize = GameWindow.WINDOW_SIZE;
protected Canvas canvas = new Canvas();
protected BufferStrategy buffer;
@@ -196,8 +196,15 @@ public abstract class Scene extends Panel
}
protected void removeWidget(Widget widget) {
- // TODO
- throw new UnsupportedOperationException("TODO");
+ this.widgets.remove(widget);
+
+ if (widget instanceof Dynamic) {
+ this.dynamicWidgetsCache.remove(widget);
+ }
+
+ if (widget instanceof Clickable) {
+ this.clickableWidgetsCache.remove(widget);
+ }
}
/* call render and updates */
@@ -307,17 +314,17 @@ public abstract class Scene extends Panel
}
/* thread pause controls */
- public void stop() {
+ public synchronized void stop() {
// stop thread even if paused
this.resumeThread();
this.running = false;
}
- public void pauseThread() {
+ public synchronized void pauseThread() {
this.threadPaused = true;
}
- public void resumeThread() {
+ public synchronized void resumeThread() {
if (!this.threadPaused)
return;