diff options
Diffstat (limited to 'src/com/fourisland/fourpuzzle/window/ChoiceWindow.java')
| -rwxr-xr-x | src/com/fourisland/fourpuzzle/window/ChoiceWindow.java | 45 |
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 | ||
| 8 | import com.fourisland.fourpuzzle.Audio; | 8 | import com.fourisland.fourpuzzle.Audio; |
| 9 | import com.fourisland.fourpuzzle.Display; | 9 | import com.fourisland.fourpuzzle.Display; |
| 10 | import com.fourisland.fourpuzzle.Game; | ||
| 10 | import com.fourisland.fourpuzzle.database.Database; | 11 | import com.fourisland.fourpuzzle.database.Database; |
| 11 | import com.fourisland.fourpuzzle.database.Sound; | 12 | import com.fourisland.fourpuzzle.database.Sound; |
| 13 | import com.fourisland.fourpuzzle.util.Renderable; | ||
| 12 | import java.awt.Graphics2D; | 14 | import java.awt.Graphics2D; |
| 13 | import java.awt.Rectangle; | 15 | import java.awt.Rectangle; |
| 14 | import java.awt.TexturePaint; | 16 | import java.awt.TexturePaint; |
| @@ -19,7 +21,7 @@ import java.util.List; | |||
| 19 | * | 21 | * |
| 20 | * @author hatkirby | 22 | * @author hatkirby |
| 21 | */ | 23 | */ |
| 22 | public class ChoiceWindow { | 24 | public 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 |
