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.java29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/subconscious/graphics/Scene.java b/src/subconscious/graphics/Scene.java
index 711a60f..3747318 100644
--- a/src/subconscious/graphics/Scene.java
+++ b/src/subconscious/graphics/Scene.java
@@ -74,10 +74,10 @@ public abstract class Scene extends Panel
RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED
);
- protected EnumMap<Widget.Anchor, Point> widgetAnchors = new EnumMap<Widget.Anchor, Point>(Widget.Anchor.class);
- protected ArrayList<Widget> widgets = new ArrayList<>();
- protected ArrayList<Widget> dynamicWidgetsCache = new ArrayList<>();
- protected ArrayList<Widget> clickableWidgetsCache = new ArrayList<>();
+ protected final EnumMap<Widget.Anchor, Point> widgetAnchors = new EnumMap<Widget.Anchor, Point>(Widget.Anchor.class);
+ private ArrayList<Widget> widgets = new ArrayList<>();
+ private ArrayList<Widget> dynamicWidgetsCache = new ArrayList<>();
+ private ArrayList<Widget> clickableWidgetsCache = new ArrayList<>();
// Game is never cached in the local thread
protected volatile Game game;
@@ -160,7 +160,7 @@ public abstract class Scene extends Panel
protected void renderWidgets(Graphics2D g) {
for (Widget w : this.widgets) {
- Point absPos = this.widgetAnchors.get(w.getAnchor());
+ Point absPos = new Point(this.widgetAnchors.get(w.getAnchor()));
absPos.translate(w.getX(), w.getY());
Graphics2D widgetGraphics = (Graphics2D) g.create(
@@ -185,6 +185,11 @@ public abstract class Scene extends Panel
}
}
+ protected void removeWidget(Widget widget) {
+ // TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
/* request scenes */
protected synchronized void requestPrevScene() {
this.requestedPrevScene = true;
@@ -333,14 +338,14 @@ public abstract class Scene extends Panel
public synchronized void updateCanvasSize(Dimension newSize) {
this.canvasSize = newSize;
- this.widgetAnchors.get(Widget.Anchor.SO).move(0, this.canvasSize.height);
- this.widgetAnchors.get(Widget.Anchor.S ).move(this.canvasSize.width / 2, this.canvasSize.height);
- this.widgetAnchors.get(Widget.Anchor.SE).move(this.canvasSize.width, this.canvasSize.height);
- this.widgetAnchors.get(Widget.Anchor.E ).move(this.canvasSize.width, this.canvasSize.width);
- this.widgetAnchors.get(Widget.Anchor.NE).move(this.canvasSize.width, 0);
- this.widgetAnchors.get(Widget.Anchor.N ).move(this.canvasSize.width / 2, 0);
+ this.widgetAnchors.get(Widget.Anchor.SO).move(0, newSize.height);
+ this.widgetAnchors.get(Widget.Anchor.S ).move(newSize.width / 2, newSize.height);
+ this.widgetAnchors.get(Widget.Anchor.SE).move(newSize.width, newSize.height);
+ this.widgetAnchors.get(Widget.Anchor.E ).move(newSize.width, newSize.width / 2);
+ this.widgetAnchors.get(Widget.Anchor.NE).move(newSize.width, 0);
+ this.widgetAnchors.get(Widget.Anchor.N ).move(newSize.width / 2, 0);
this.widgetAnchors.get(Widget.Anchor.NO).move(0, 0);
- this.widgetAnchors.get(Widget.Anchor.O ).move(0, this.canvasSize.height / 2);
+ this.widgetAnchors.get(Widget.Anchor.O ).move(0, newSize.height / 2);
}
/* key listener */