summary refs log tree commit diff stats
path: root/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/fourisland/fourpuzzle/window/ChoiceWindow.java')
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/window/ChoiceWindow.java45
1 files changed, 42 insertions, 3 deletions
diff --git a/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java b/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java index ca84383..8399422 100755 --- a/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java +++ b/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java
@@ -7,8 +7,10 @@ package com.fourisland.fourpuzzle.window;
7 7
8import com.fourisland.fourpuzzle.Audio; 8import com.fourisland.fourpuzzle.Audio;
9import com.fourisland.fourpuzzle.Display; 9import com.fourisland.fourpuzzle.Display;
10import com.fourisland.fourpuzzle.Game;
10import com.fourisland.fourpuzzle.database.Database; 11import com.fourisland.fourpuzzle.database.Database;
11import com.fourisland.fourpuzzle.database.Sound; 12import com.fourisland.fourpuzzle.database.Sound;
13import com.fourisland.fourpuzzle.util.Renderable;
12import java.awt.Graphics2D; 14import java.awt.Graphics2D;
13import java.awt.Rectangle; 15import java.awt.Rectangle;
14import java.awt.TexturePaint; 16import java.awt.TexturePaint;
@@ -19,7 +21,7 @@ import java.util.List;
19 * 21 *
20 * @author hatkirby 22 * @author hatkirby
21 */ 23 */
22public class ChoiceWindow { 24public class ChoiceWindow implements Renderable {
23 25
24 private static final int SPACER = 4; 26 private static final int SPACER = 4;
25 27
@@ -29,7 +31,9 @@ public class ChoiceWindow {
29 private int width; 31 private int width;
30 private int height; 32 private int height;
31 BufferedImage cacheBase; 33 BufferedImage cacheBase;
32 public ChoiceWindow(List<String> choices, boolean center) 34 int x;
35 int y;
36 public ChoiceWindow(List<String> choices, boolean center, ChoiceWindowLocation cwl)
33 { 37 {
34 this.choices = choices; 38 this.choices = choices;
35 numChoices = choices.size(); 39 numChoices = choices.size();
@@ -52,9 +56,12 @@ public class ChoiceWindow {
52 width += SPACER*2; 56 width += SPACER*2;
53 57
54 cacheBase = Window.Default.getImage(width, height); 58 cacheBase = Window.Default.getImage(width, height);
59
60 x = cwl.getX(width);
61 y = cwl.getY(height);
55 } 62 }
56 63
57 public void render(Graphics2D g2, int x, int y) 64 public void render(Graphics2D g2)
58 { 65 {
59 Display.setFont(g2); 66 Display.setFont(g2);
60 67
@@ -119,5 +126,37 @@ public class ChoiceWindow {
119 { 126 {
120 return choices.get(selected); 127 return choices.get(selected);
121 } 128 }
129
130 public static enum ChoiceWindowLocation
131 {
132 BottomLeft
133 {
134 public int getX(int width)
135 {
136 return (Game.WIDTH/5)-(width/2);
137 }
138 },
139 BottomCenter
140 {
141 public int getX(int width)
142 {
143 return (Game.WIDTH/2)-(width/2);
144 }
145 },
146 BottomRight
147 {
148 public int getX(int width)
149 {
150 return (Game.WIDTH/5*4)-(width/2);
151 }
152 };
153
154 public abstract int getX(int width);
155
156 public int getY(int height)
157 {
158 return (Game.HEIGHT/4*3)-(height/2);
159 }
160 }
122 161
123} \ No newline at end of file 162} \ No newline at end of file