From 67890906cf4c4aa2967bdc50cd947335e6fafb5c Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Sat, 14 Feb 2009 09:18:53 -0500 Subject: Engine: Compacted MessageWindow MessageWindow is now shorter, and more compact. The font size has also been decreased to allow for more text. Closes #5 --- src/com/fourisland/fourpuzzle/Display.java | 2 +- .../fourpuzzle/window/MessageWindow.java | 33 ++++++++++++++-------- 2 files changed, 22 insertions(+), 13 deletions(-) (limited to 'src/com') diff --git a/src/com/fourisland/fourpuzzle/Display.java b/src/com/fourisland/fourpuzzle/Display.java index ec835ab..0a9bfe1 100755 --- a/src/com/fourisland/fourpuzzle/Display.java +++ b/src/com/fourisland/fourpuzzle/Display.java @@ -214,7 +214,7 @@ public class Display { Logger.getLogger(Display.class.getName()).log(Level.SEVERE, null, ex); } - theFont = theFont.deriveFont(Font.PLAIN, 10); + theFont = theFont.deriveFont(Font.PLAIN, 9); } public static void setFont(Graphics2D g) 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; public class MessageWindow implements Renderable { private static final int SPACER = 4; - private static final int HEIGHT = 4*(Display.createCanvas(1, 1).createGraphics().getFontMetrics().getHeight()+SPACER); + private static final int HEIGHT; + + static + { + BufferedImage d = Display.createCanvas(1, 1); + Display.setFont(d.createGraphics()); + + HEIGHT = 3*(d.createGraphics().getFontMetrics().getHeight()+SPACER); + } String message; private volatile List messages; @@ -104,7 +112,7 @@ public class MessageWindow implements Renderable { int length = width - SPACER; if (hasFace) { - length -= (48 + (SPACER*2)); + length -= (48 + (SPACER*3)); } String temp = message; @@ -162,22 +170,23 @@ public class MessageWindow implements Renderable { g2.drawImage(cacheBase, 0, y, null); + int fw = g2.getFontMetrics().stringWidth(message); int fh = g2.getFontMetrics().getHeight(); + int tx = Window.Default.getLeftX(); int ty = Window.Default.getTopY()+fh-(SPACER/2)+y; int msgs = Math.min(messages.size(), 4); int toPrint = upTo; + + if (hasFace) + { + g2.drawImage(face, tx+SPACER, ty-fh+SPACER, null); + + tx += 48 + (SPACER*2); + } + for (int i=0;i