summary refs log tree commit diff stats
path: root/src/com/fourisland
diff options
context:
space:
mode:
authorStarla Insigna <hatkirby@fourisland.com>2009-02-08 12:12:57 -0500
committerStarla Insigna <hatkirby@fourisland.com>2009-02-08 12:12:57 -0500
commit78f9af78f7966163791737741b0004568f8fdf50 (patch)
treedd206b5c5c922be86b12042ee230c43ba8f077d4 /src/com/fourisland
parenteca79b20cdb258768668c2ecf1b7333de62c7d7f (diff)
downloadfourpuzzle-78f9af78f7966163791737741b0004568f8fdf50.tar.gz
fourpuzzle-78f9af78f7966163791737741b0004568f8fdf50.tar.bz2
fourpuzzle-78f9af78f7966163791737741b0004568f8fdf50.zip
Added text centering to ChoiceWindow
Diffstat (limited to 'src/com/fourisland')
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java3
-rw-r--r--src/com/fourisland/fourpuzzle/window/ChoiceWindow.java12
2 files changed, 11 insertions, 4 deletions
diff --git a/src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java b/src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java index 621ec0d..2f5dc97 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java +++ b/src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java
@@ -28,8 +28,7 @@ public class TitleScreenGameState implements GameState {
28 { 28 {
29 Audio.playMusic(Database.getMusic("Title")); 29 Audio.playMusic(Database.getMusic("Title"));
30 30
31 choices = new ChoiceWindow(Arrays.asList(Database.getVocab("NewGame"), Database.getVocab("LoadGame"), Database.getVocab("EndGame"))); 31 choices = new ChoiceWindow(Arrays.asList(Database.getVocab("NewGame"), Database.getVocab("LoadGame"), Database.getVocab("EndGame")), true);
32
33 wx = (Game.WIDTH/2)-(choices.getWidth()/2); 32 wx = (Game.WIDTH/2)-(choices.getWidth()/2);
34 wy = (Game.HEIGHT/4*3)-(choices.getHeight()/2); 33 wy = (Game.HEIGHT/4*3)-(choices.getHeight()/2);
35 } 34 }
diff --git a/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java b/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java index ed20ab0..bf7391e 100644 --- a/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java +++ b/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java
@@ -28,10 +28,12 @@ public class ChoiceWindow {
28 28
29 private List<String> choices; 29 private List<String> choices;
30 int numChoices; 30 int numChoices;
31 public ChoiceWindow(List<String> choices) 31 boolean center;
32 public ChoiceWindow(List<String> choices, boolean center)
32 { 33 {
33 this.choices = choices; 34 this.choices = choices;
34 numChoices = choices.size(); 35 numChoices = choices.size();
36 this.center = center;
35 37
36 createGraphic(new BufferedImage(TopLeft.getWidth()+getWidth()+TopRight.getWidth(), TopLeft.getHeight()+getHeight()+BottomLeft.getHeight(), BufferedImage.TYPE_INT_ARGB).createGraphics()); 38 createGraphic(new BufferedImage(TopLeft.getWidth()+getWidth()+TopRight.getWidth(), TopLeft.getHeight()+getHeight()+BottomLeft.getHeight(), BufferedImage.TYPE_INT_ARGB).createGraphics());
37 } 39 }
@@ -74,10 +76,16 @@ public class ChoiceWindow {
74 g2.drawImage(Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(temp.getSource(), new TransparentPixelFilter(-25600))), 0, 0, null); 76 g2.drawImage(Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(temp.getSource(), new TransparentPixelFilter(-25600))), 0, 0, null);
75 g2.setFont(g2.getFont().deriveFont(Font.BOLD)); 77 g2.setFont(g2.getFont().deriveFont(Font.BOLD));
76 78
77 int tx = TopLeft.getWidth();
78 int ty = TopLeft.getHeight()+g2.getFontMetrics().getHeight()-SPACER; 79 int ty = TopLeft.getHeight()+g2.getFontMetrics().getHeight()-SPACER;
79 for (String choice : choices) 80 for (String choice : choices)
80 { 81 {
82 int tx = TopLeft.getWidth();
83
84 if (center)
85 {
86 tx += ((width/2)-(g2.getFontMetrics().stringWidth(choice)/2));
87 }
88
81 /* TODO The following code paints the text onto the window. However, 89 /* TODO The following code paints the text onto the window. However,
82 * when it paints the lowercase 'y', the tail is white, not the 90 * when it paints the lowercase 'y', the tail is white, not the
83 * correct gradient. */ 91 * correct gradient. */