diff options
Diffstat (limited to 'src/com/fourisland/fourpuzzle/window/ChoiceWindow.java')
| -rwxr-xr-x | src/com/fourisland/fourpuzzle/window/ChoiceWindow.java | 28 |
1 files changed, 12 insertions, 16 deletions
| diff --git a/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java b/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java index bf193c1..ca84383 100755 --- a/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java +++ b/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java | |||
| @@ -6,9 +6,9 @@ | |||
| 6 | package com.fourisland.fourpuzzle.window; | 6 | 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.database.Database; | 10 | import com.fourisland.fourpuzzle.database.Database; |
| 10 | import com.fourisland.fourpuzzle.database.Sound; | 11 | import com.fourisland.fourpuzzle.database.Sound; |
| 11 | import java.awt.Font; | ||
| 12 | import java.awt.Graphics2D; | 12 | import java.awt.Graphics2D; |
| 13 | import java.awt.Rectangle; | 13 | import java.awt.Rectangle; |
| 14 | import java.awt.TexturePaint; | 14 | import java.awt.TexturePaint; |
| @@ -26,20 +26,18 @@ public class ChoiceWindow { | |||
| 26 | private List<String> choices; | 26 | private List<String> choices; |
| 27 | int numChoices; | 27 | int numChoices; |
| 28 | boolean center; | 28 | boolean center; |
| 29 | private int width; | ||
| 30 | private int height; | ||
| 31 | BufferedImage cacheBase; | ||
| 29 | public ChoiceWindow(List<String> choices, boolean center) | 32 | public ChoiceWindow(List<String> choices, boolean center) |
| 30 | { | 33 | { |
| 31 | this.choices = choices; | 34 | this.choices = choices; |
| 32 | numChoices = choices.size(); | 35 | numChoices = choices.size(); |
| 33 | this.center = center; | 36 | this.center = center; |
| 34 | 37 | ||
| 35 | createGraphic(new BufferedImage(Window.Default.getFullWidth(width), Window.Default.getFullHeight(height), BufferedImage.TYPE_INT_ARGB).createGraphics()); | 38 | Graphics2D g3 = Display.createCanvas(1, 1).createGraphics(); |
| 36 | } | 39 | Display.setFont(g3); |
| 37 | 40 | ||
| 38 | private int width; | ||
| 39 | private int height; | ||
| 40 | BufferedImage cacheBase; | ||
| 41 | private void createGraphic(Graphics2D g3) | ||
| 42 | { | ||
| 43 | for (String choice : choices) | 41 | for (String choice : choices) |
| 44 | { | 42 | { |
| 45 | int l = g3.getFontMetrics().stringWidth(choice); | 43 | int l = g3.getFontMetrics().stringWidth(choice); |
| @@ -58,12 +56,12 @@ public class ChoiceWindow { | |||
| 58 | 56 | ||
| 59 | public void render(Graphics2D g2, int x, int y) | 57 | public void render(Graphics2D g2, int x, int y) |
| 60 | { | 58 | { |
| 61 | g2.drawImage(cacheBase, x, y, null); | 59 | Display.setFont(g2); |
| 62 | 60 | ||
| 63 | g2.setFont(g2.getFont().deriveFont(Font.BOLD)); | 61 | g2.drawImage(cacheBase, x, y, null); |
| 64 | 62 | ||
| 65 | int fh = g2.getFontMetrics().getHeight(); | 63 | int fh = g2.getFontMetrics().getHeight(); |
| 66 | int ty = Window.Default.getTopY()+fh-(SPACER/2)+y; | 64 | int ty = Window.Default.getTopY()+fh+y; |
| 67 | for (String choice : choices) | 65 | for (String choice : choices) |
| 68 | { | 66 | { |
| 69 | int fw = g2.getFontMetrics().stringWidth(choice); | 67 | int fw = g2.getFontMetrics().stringWidth(choice); |
| @@ -76,7 +74,7 @@ public class ChoiceWindow { | |||
| 76 | 74 | ||
| 77 | if (getSelected().equals(choice)) | 75 | if (getSelected().equals(choice)) |
| 78 | { | 76 | { |
| 79 | g2.drawImage(Window.Selector.getImage(fw-Window.Selector.getLeftX(), fh-Window.Selector.getTopY()), tx-SPACER, ty-fh, null); | 77 | g2.drawImage(Window.Selector.getImage(fw-Window.Selector.getLeftX(), fh-Window.Selector.getTopY()), tx-SPACER, ty-fh-SPACER, null); |
| 80 | } | 78 | } |
| 81 | 79 | ||
| 82 | g2.setPaint(new TexturePaint(SystemGraphic.getTextColor(), new Rectangle(tx, ty, fw, fh))); | 80 | g2.setPaint(new TexturePaint(SystemGraphic.getTextColor(), new Rectangle(tx, ty, fw, fh))); |
| @@ -84,8 +82,6 @@ public class ChoiceWindow { | |||
| 84 | 82 | ||
| 85 | ty+=(SPACER+g2.getFontMetrics().getHeight()); | 83 | ty+=(SPACER+g2.getFontMetrics().getHeight()); |
| 86 | } | 84 | } |
| 87 | |||
| 88 | g2.setFont(g2.getFont().deriveFont(Font.PLAIN)); | ||
| 89 | } | 85 | } |
| 90 | 86 | ||
| 91 | public int getWidth() | 87 | public int getWidth() |
| @@ -124,4 +120,4 @@ public class ChoiceWindow { | |||
| 124 | return choices.get(selected); | 120 | return choices.get(selected); |
| 125 | } | 121 | } |
| 126 | 122 | ||
| 127 | } | 123 | } \ No newline at end of file |
