summary refs log tree commit diff stats
path: root/src/com/fourisland/fourpuzzle/window/MessageWindow.java
diff options
context:
space:
mode:
authorStarla Insigna <hatkirby@fourisland.com>2009-02-14 09:18:53 -0500
committerStarla Insigna <hatkirby@fourisland.com>2009-02-14 09:18:53 -0500
commit67890906cf4c4aa2967bdc50cd947335e6fafb5c (patch)
tree150c8a5c1e5224c18674971d040d65e70cbf8652 /src/com/fourisland/fourpuzzle/window/MessageWindow.java
parent165d7e5591b44dce6bf1e090d51e85c4ad5ad2f3 (diff)
downloadfourpuzzle-67890906cf4c4aa2967bdc50cd947335e6fafb5c.tar.gz
fourpuzzle-67890906cf4c4aa2967bdc50cd947335e6fafb5c.tar.bz2
fourpuzzle-67890906cf4c4aa2967bdc50cd947335e6fafb5c.zip
Engine: Compacted MessageWindow
MessageWindow is now shorter, and more compact. The font size has also been decreased to allow for more text.

Closes #5
Diffstat (limited to 'src/com/fourisland/fourpuzzle/window/MessageWindow.java')
-rw-r--r--src/com/fourisland/fourpuzzle/window/MessageWindow.java33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/com/fourisland/fourpuzzle/window/MessageWindow.java b/src/com/fourisland/fourpuzzle/window/MessageWindow.java index 7947730..595fb55 100644 --- a/src/com/fourisland/fourpuzzle/window/MessageWindow.java +++ b/src/com/fourisland/fourpuzzle/window/MessageWindow.java
@@ -28,7 +28,15 @@ import java.util.concurrent.CountDownLatch;
28public class MessageWindow implements Renderable { 28public class MessageWindow implements Renderable {
29 29
30 private static final int SPACER = 4; 30 private static final int SPACER = 4;
31 private static final int HEIGHT = 4*(Display.createCanvas(1, 1).createGraphics().getFontMetrics().getHeight()+SPACER); 31 private static final int HEIGHT;
32
33 static
34 {
35 BufferedImage d = Display.createCanvas(1, 1);
36 Display.setFont(d.createGraphics());
37
38 HEIGHT = 3*(d.createGraphics().getFontMetrics().getHeight()+SPACER);
39 }
32 40
33 String message; 41 String message;
34 private volatile List<String> messages; 42 private volatile List<String> messages;
@@ -104,7 +112,7 @@ public class MessageWindow implements Renderable {
104 int length = width - SPACER; 112 int length = width - SPACER;
105 if (hasFace) 113 if (hasFace)
106 { 114 {
107 length -= (48 + (SPACER*2)); 115 length -= (48 + (SPACER*3));
108 } 116 }
109 117
110 String temp = message; 118 String temp = message;
@@ -162,22 +170,23 @@ public class MessageWindow implements Renderable {
162 170
163 g2.drawImage(cacheBase, 0, y, null); 171 g2.drawImage(cacheBase, 0, y, null);
164 172
173 int fw = g2.getFontMetrics().stringWidth(message);
165 int fh = g2.getFontMetrics().getHeight(); 174 int fh = g2.getFontMetrics().getHeight();
175 int tx = Window.Default.getLeftX();
166 int ty = Window.Default.getTopY()+fh-(SPACER/2)+y; 176 int ty = Window.Default.getTopY()+fh-(SPACER/2)+y;
167 int msgs = Math.min(messages.size(), 4); 177 int msgs = Math.min(messages.size(), 4);
168 int toPrint = upTo; 178 int toPrint = upTo;
179
180 if (hasFace)
181 {
182 g2.drawImage(face, tx+SPACER, ty-fh+SPACER, null);
183
184 tx += 48 + (SPACER*2);
185 }
186
169 for (int i=0;i<msgs;i++) 187 for (int i=0;i<msgs;i++)
170 { 188 {
171 String message = messages.get(i); 189 String message = messages.get(i);
172 int fw = g2.getFontMetrics().stringWidth(message);
173 int tx = Window.Default.getLeftX();
174
175 if (hasFace)
176 {
177 g2.drawImage(face, tx, y + ((HEIGHT/2)-24), null);
178
179 tx += 48 + SPACER;
180 }
181 190
182 g2.setPaint(new TexturePaint(SystemGraphic.getTextColor(), new Rectangle(tx, ty, fw, fh))); 191 g2.setPaint(new TexturePaint(SystemGraphic.getTextColor(), new Rectangle(tx, ty, fw, fh)));
183 g2.drawString(message.substring(0, Math.min(toPrint, message.length())), tx, ty); 192 g2.drawString(message.substring(0, Math.min(toPrint, message.length())), tx, ty);
@@ -191,7 +200,7 @@ public class MessageWindow implements Renderable {
191 { 200 {
192 upTo+=3; 201 upTo+=3;
193 } else { 202 } else {
194 g2.drawImage(SystemGraphic.getDownArrow(), (Window.Default.getFullWidth(width)/2)-5, y+HEIGHT-SPACER+(bounceArrow ? 1 : 0), null); 203 g2.drawImage(SystemGraphic.getDownArrow(), (Window.Default.getFullWidth(width)/2)-5, y+HEIGHT+SPACER+(bounceArrow ? 1 : 0), null);
195 204
196 if (in.isElapsed()) 205 if (in.isElapsed())
197 { 206 {