changeset 76:43f68fe605de

More cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 03 Mar 2011 04:14:55 +0200
parents b586ce4f6d97
children d17db72ac770
files game/Engine.java game/G.java
diffstat 2 files changed, 20 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/game/Engine.java	Thu Mar 03 04:04:57 2011 +0200
+++ b/game/Engine.java	Thu Mar 03 04:14:55 2011 +0200
@@ -23,6 +23,12 @@
     BufferedImage aboutImg;
     boolean aboutSecret;
 
+    IDMPoint currPos, currOffs;
+    Paint textPaint;
+    Font textFont;
+    FontMetrics textMetrics;
+    
+
     public AboutBox()
     {
         try {
@@ -39,11 +45,6 @@
         setSize(600f, 400f);
     }
 
-    IDMPoint currPos, currOffs;
-    Paint textPaint;
-    Font textFont;
-    FontMetrics textMetrics;
-    
     public void setTextFont(Font font, FontMetrics metrics)
     {
         textFont = font;
@@ -70,6 +71,7 @@
     {
         Paint savePaint = g.getPaint();
         g.setPaint(textPaint);
+        g.setFont(textFont);
         
         int i = 0;
         while (i < text.length())
@@ -95,7 +97,7 @@
             if (linefeed)
             {
                 currOffs.x = 0;
-                currOffs.y += textMetrics.getMaxDescent();;
+                currOffs.y += textMetrics.getHeight();
             }
             else
             {
@@ -114,23 +116,24 @@
         g.setPaint(new Color(0.0f, 0.0f, 0.0f, 0.6f));
         g.fill(new RoundRectangle2D.Float(x, y, w, h, 10, 10));
 
-        setTextFont(G.fonts[1], G.metrics[1]);
+        setTextFont(G.fonts[3], G.metrics[3]);
         setTextPaint(Color.white);
         
-        setCurrPos(x + 15, y + 15);
-        drawString(g, "RistiPolku (CrossPaths) v0.5");
+        setCurrPos(x + 20, y + 30);
+        drawString(g, "RistiPolku (CrossPaths) v0.5\n");
 
+        setTextFont(G.fonts[1], G.metrics[1]);
         if (aboutSecret)
         {
-            g.drawImage(aboutImg, x + 15, y + 35, aboutImg.getWidth(), aboutImg.getHeight(), null); 
+            g.drawImage(aboutImg, x + 20, y + 55, aboutImg.getWidth(), aboutImg.getHeight(), null); 
 
-            setCurrPos(x + 225, y + 55);
+            setCurrPos(x + 225, y + 75);
             drawString(g,
                 "Dedicated to my\n" +
-                "favorite woman" +
+                "favorite woman\n" +
                 "in the world.");
             
-            setCurrPos(x + 350, y + 155);
+            setCurrPos(x + 370, y + 175);
             drawString(g, "- Matti");
         }
         else
@@ -231,12 +234,10 @@
     
     public boolean contains(float x, float y)
     {
-        boolean foo = (x >= getScaledX() &&
+        return (x >= getScaledX() &&
                 y >= getScaledY() &&
                 x < getScaledX() + boardSize * pscale &&
                 y < getScaledY() + boardSize * pscale);
-        System.out.print("contains "+x+", "+y+" ("+getScaledX()+", "+getScaledY()+", "+(getScaledX() + boardSize * pscale)+"): "+foo+"\n");
-        return foo;
     }
     
     public void animate(float time)
@@ -390,25 +391,9 @@
         return true;
     }
     
-/*
-    public boolean mouseClicked(MouseEvent e)
-    {
-        if (flagGameOver)
-            return false;
-
-        if (contains(e.getPoint()))
-        {
-            pieceFinishTurn();
-            return true;
-        }
-        else
-            return false;
-    }
-*/
-
     public void clicked()
     {
-            pieceFinishTurn();
+        pieceFinishTurn();
     }
 
     public boolean keyPressed(KeyEvent e)
@@ -474,6 +459,7 @@
                 G.fonts[0] = Font.createFont(Font.TRUETYPE_FONT, res.getStream());
                 G.fonts[1] = G.fonts[0].deriveFont(24f);
                 G.fonts[2] = G.fonts[0].deriveFont(64f);
+                G.fonts[3] = G.fonts[0].deriveFont(32f);
                 
             }
             catch (FontFormatException e)
--- a/game/G.java	Thu Mar 03 04:04:57 2011 +0200
+++ b/game/G.java	Thu Mar 03 04:14:55 2011 +0200
@@ -15,7 +15,7 @@
 
 public class G
 {
-    public static final int numFonts = 3;
+    public static final int numFonts = 4;
     public static Font fonts[];
     public static FontMetrics metrics[];