summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorStarla Insigna <hatkirby@fourisland.com>2009-02-12 16:36:07 -0500
committerStarla Insigna <hatkirby@fourisland.com>2009-02-12 16:36:07 -0500
commitbbf294dbf6b552751e5d9f3fb66188bd1bee724b (patch)
tree1e29d91a6e8a3b9d26ec874169de85928d4ec56f /src
parent3cd96daaf22236e4eb15c6422f772abf08351023 (diff)
downloadfourpuzzle-bbf294dbf6b552751e5d9f3fb66188bd1bee724b.tar.gz
fourpuzzle-bbf294dbf6b552751e5d9f3fb66188bd1bee724b.tar.bz2
fourpuzzle-bbf294dbf6b552751e5d9f3fb66188bd1bee724b.zip
Engine: Wrote Message System
MessageWindow now has a static method run by SpecialEvent that triggers the message box. This method blocks until the message is complete and renders via Display's new feature. The message box also now features the "next" arrow and the letters gradually appear.

Display has also been re-worked to have a list of a new interface called Renderable, which is any object that can be rendered. Such objects (such as MessageWindow) can register to Display, which will render them onto the game frame after the GameState has been rendered.

Closes #5.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/Display.java52
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/GameState.java18
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java9
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java12
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java6
-rw-r--r--src/com/fourisland/fourpuzzle/util/Renderable.java18
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/window/ChoiceWindow.java45
-rw-r--r--src/com/fourisland/fourpuzzle/window/MessageWindow.java99
8 files changed, 203 insertions, 56 deletions
diff --git a/src/com/fourisland/fourpuzzle/Display.java b/src/com/fourisland/fourpuzzle/Display.java index 85acaf4..ec835ab 100755 --- a/src/com/fourisland/fourpuzzle/Display.java +++ b/src/com/fourisland/fourpuzzle/Display.java
@@ -11,6 +11,7 @@ import com.fourisland.fourpuzzle.transition.OutTransition;
11import com.fourisland.fourpuzzle.transition.Transition; 11import com.fourisland.fourpuzzle.transition.Transition;
12import com.fourisland.fourpuzzle.transition.TransitionDirection; 12import com.fourisland.fourpuzzle.transition.TransitionDirection;
13import com.fourisland.fourpuzzle.transition.TransitionUnsupportedException; 13import com.fourisland.fourpuzzle.transition.TransitionUnsupportedException;
14import com.fourisland.fourpuzzle.util.Renderable;
14import java.awt.Font; 15import java.awt.Font;
15import java.awt.FontFormatException; 16import java.awt.FontFormatException;
16import java.awt.Graphics2D; 17import java.awt.Graphics2D;
@@ -20,6 +21,8 @@ import java.awt.image.BufferedImage;
20import java.awt.image.VolatileImage; 21import java.awt.image.VolatileImage;
21import java.io.IOException; 22import java.io.IOException;
22import java.io.InputStream; 23import java.io.InputStream;
24import java.util.List;
25import java.util.concurrent.CopyOnWriteArrayList;
23import java.util.concurrent.CountDownLatch; 26import java.util.concurrent.CountDownLatch;
24import java.util.logging.Level; 27import java.util.logging.Level;
25import java.util.logging.Logger; 28import java.util.logging.Logger;
@@ -33,6 +36,8 @@ import org.jdesktop.application.ResourceMap;
33public class Display { 36public class Display {
34 37
35 public static int tileAnimationFrame = 0; 38 public static int tileAnimationFrame = 0;
39
40 private static List<Renderable> renderables = new CopyOnWriteArrayList<Renderable>();
36 41
37 public static void render(JDialog gameFrame) 42 public static void render(JDialog gameFrame)
38 { 43 {
@@ -95,18 +100,37 @@ public class Display {
95 g.drawImage(midTransition, 0, 0, null); 100 g.drawImage(midTransition, 0, 0, null);
96 } 101 }
97 } else { 102 } else {
98 Game.getGameState().render(g); 103 render(g);
99 } 104 }
100 105
101 g.dispose(); 106 g.dispose();
102 } 107 }
103 108
109 private static void render(Graphics2D g)
110 {
111 Game.getGameState().render(g);
112
113 for (Renderable r : renderables)
114 {
115 r.render(g);
116 }
117 }
118
119 public static void registerRenderable(Renderable r)
120 {
121 renderables.add(r);
122 }
123
124 public static void unregisterRenderable(Renderable r)
125 {
126 renderables.remove(r);
127 }
128
104 private static boolean startedTransition = false; 129 private static boolean startedTransition = false;
105 private static Transition transition; 130 private static Transition transition;
106 private static CountDownLatch transitionWait; 131 private static CountDownLatch transitionWait;
107 private static boolean transitionRunning = false; 132 private static boolean transitionRunning = false;
108 private static BufferedImage midTransition = null; 133 private static BufferedImage midTransition = null;
109 private static BufferedImage postTransition = null;
110 public static void transition(Transition transition) throws InterruptedException 134 public static void transition(Transition transition) throws InterruptedException
111 { 135 {
112 if (transition instanceof MultidirectionalTransition) 136 if (transition instanceof MultidirectionalTransition)
@@ -125,13 +149,13 @@ public class Display {
125 { 149 {
126 temp.setPreTransition(midTransition); 150 temp.setPreTransition(midTransition);
127 151
128 postTransition = Display.createCanvas(Game.WIDTH, Game.HEIGHT); 152 BufferedImage bImg = Display.createCanvas(Game.WIDTH, Game.HEIGHT);
129 Game.getGameState().render(postTransition.createGraphics()); 153 render(bImg.createGraphics());
130 temp.setPostTransition(postTransition); 154 temp.setPostTransition(bImg);
131 } else { 155 } else {
132 BufferedImage preTransition = Display.createCanvas(Game.WIDTH, Game.HEIGHT); 156 BufferedImage bImg = Display.createCanvas(Game.WIDTH, Game.HEIGHT);
133 Game.getGameState().render(preTransition.createGraphics()); 157 render(bImg.createGraphics());
134 temp.setPreTransition(preTransition); 158 temp.setPreTransition(bImg);
135 } 159 }
136 } else { 160 } else {
137 if (startedTransition && !(transition instanceof InTransition)) 161 if (startedTransition && !(transition instanceof InTransition))
@@ -146,13 +170,13 @@ public class Display {
146 { 170 {
147 transition.setPreTransition(midTransition); 171 transition.setPreTransition(midTransition);
148 172
149 postTransition = Display.createCanvas(Game.WIDTH, Game.HEIGHT); 173 BufferedImage bImg = Display.createCanvas(Game.WIDTH, Game.HEIGHT);
150 Game.getGameState().render(postTransition.createGraphics()); 174 render(bImg.createGraphics());
151 ((InTransition) transition).setPostTransition(postTransition); 175 ((InTransition) transition).setPostTransition(bImg);
152 } else { 176 } else {
153 BufferedImage preTransition = Display.createCanvas(Game.WIDTH, Game.HEIGHT); 177 BufferedImage bImg = Display.createCanvas(Game.WIDTH, Game.HEIGHT);
154 Game.getGameState().render(preTransition.createGraphics()); 178 render(bImg.createGraphics());
155 transition.setPreTransition(preTransition); 179 transition.setPreTransition(bImg);
156 } 180 }
157 } 181 }
158 182
diff --git a/src/com/fourisland/fourpuzzle/gamestate/GameState.java b/src/com/fourisland/fourpuzzle/gamestate/GameState.java index de4d7de..e7bd783 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/GameState.java +++ b/src/com/fourisland/fourpuzzle/gamestate/GameState.java
@@ -5,30 +5,18 @@
5 5
6package com.fourisland.fourpuzzle.gamestate; 6package com.fourisland.fourpuzzle.gamestate;
7 7
8import java.awt.Graphics2D; 8import com.fourisland.fourpuzzle.util.Renderable;
9 9
10/** 10/**
11 * 11 *
12 * @author hatkirby 12 * @author hatkirby
13 */ 13 */
14public interface GameState { 14public interface GameState extends Renderable {
15 15
16 public void initalize(); 16 public void initalize();
17 public void deinitalize(); 17 public void deinitalize();
18 18
19 public void processInput(); 19 public void processInput();
20 public void doGameCycle(); 20 public void doGameCycle();
21 public void render(Graphics2D g);
22 21
23} 22} \ No newline at end of file
24
25/*
26 TitleScreen
27 MapView
28 Battle
29 GameOver
30 Menu
31 LoadFile
32 SaveFile
33 Transition
34*/ \ No newline at end of file
diff --git a/src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java b/src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java index 272c4f0..d5b4f90 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java +++ b/src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java
@@ -27,20 +27,20 @@ import java.util.Arrays;
27public class TitleScreenGameState implements GameState { 27public class TitleScreenGameState implements GameState {
28 28
29 ChoiceWindow choices; 29 ChoiceWindow choices;
30 int wx, wy;
31 30
32 public void initalize() 31 public void initalize()
33 { 32 {
34 Audio.playMusic(Database.getMusic(Music.Title)); 33 Audio.playMusic(Database.getMusic(Music.Title));
35 34
36 choices = new ChoiceWindow(Arrays.asList(Database.getVocab(Vocabulary.NewGame), Database.getVocab(Vocabulary.LoadGame), Database.getVocab(Vocabulary.EndGame)), true); 35 choices = new ChoiceWindow(Arrays.asList(Database.getVocab(Vocabulary.NewGame), Database.getVocab(Vocabulary.LoadGame), Database.getVocab(Vocabulary.EndGame)), true, ChoiceWindow.ChoiceWindowLocation.BottomLeft);
37 wx = (Game.WIDTH/5)-(choices.getWidth()/2); 36 Display.registerRenderable(choices);
38 wy = (Game.HEIGHT/4*3)-(choices.getHeight()/2);
39 } 37 }
40 38
41 public void deinitalize() 39 public void deinitalize()
42 { 40 {
43 Audio.stopMusic(); 41 Audio.stopMusic();
42
43 Display.unregisterRenderable(choices);
44 } 44 }
45 45
46 PauseTimer pt = new PauseTimer(0); 46 PauseTimer pt = new PauseTimer(0);
@@ -112,7 +112,6 @@ public class TitleScreenGameState implements GameState {
112 public void render(Graphics2D g) 112 public void render(Graphics2D g)
113 { 113 {
114 g.drawImage(ObjectLoader.getImage("Picture", "Title"), 0, 0, null); 114 g.drawImage(ObjectLoader.getImage("Picture", "Title"), 0, 0, null);
115 choices.render(g, wx, wy);
116 } 115 }
117 116
118} 117}
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java index 3ed23c3..a20062d 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/MapViewGameState.java
@@ -23,7 +23,6 @@ import com.fourisland.fourpuzzle.gamestate.mapview.event.specialmove.MoveEventTh
23import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.AutomaticViewpoint; 23import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.AutomaticViewpoint;
24import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.Viewpoint; 24import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.Viewpoint;
25import com.fourisland.fourpuzzle.util.Functions; 25import com.fourisland.fourpuzzle.util.Functions;
26import com.fourisland.fourpuzzle.window.MessageWindow;
27import java.awt.Graphics2D; 26import java.awt.Graphics2D;
28import java.awt.event.KeyEvent; 27import java.awt.event.KeyEvent;
29import java.awt.image.BufferedImage; 28import java.awt.image.BufferedImage;
@@ -229,11 +228,6 @@ public class MapViewGameState implements GameState {
229 228
230 g.drawImage(eventLayer, 0, 0, Game.WIDTH, Game.HEIGHT, x, y, x+Game.WIDTH, y+Game.HEIGHT, null); 229 g.drawImage(eventLayer, 0, 0, Game.WIDTH, Game.HEIGHT, x, y, x+Game.WIDTH, y+Game.HEIGHT, null);
231 g.drawImage(currentMap.renderUpper(), 0, 0, Game.WIDTH, Game.HEIGHT, x, y, x+Game.WIDTH, y+Game.HEIGHT, null); 230 g.drawImage(currentMap.renderUpper(), 0, 0, Game.WIDTH, Game.HEIGHT, x, y, x+Game.WIDTH, y+Game.HEIGHT, null);
232
233 if (mw != null)
234 {
235 mw.render(g);
236 }
237 } 231 }
238 232
239 public void setCurrentMap(String mapName) 233 public void setCurrentMap(String mapName)
@@ -256,11 +250,5 @@ public class MapViewGameState implements GameState {
256 { 250 {
257 currentViewpoint = viewpoint; 251 currentViewpoint = viewpoint;
258 } 252 }
259
260 volatile MessageWindow mw = null;
261 public void displayMessage(String message)
262 {
263 mw = new MessageWindow(message);
264 }
265 253
266} 254}
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java index 7ca08ff..2b54dc9 100755 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java
@@ -17,6 +17,7 @@ import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.MovingViewpoint;
17import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.Viewpoint; 17import com.fourisland.fourpuzzle.gamestate.mapview.viewpoint.Viewpoint;
18import com.fourisland.fourpuzzle.transition.InTransition; 18import com.fourisland.fourpuzzle.transition.InTransition;
19import com.fourisland.fourpuzzle.transition.OutTransition; 19import com.fourisland.fourpuzzle.transition.OutTransition;
20import com.fourisland.fourpuzzle.window.MessageWindow;
20import java.util.concurrent.CountDownLatch; 21import java.util.concurrent.CountDownLatch;
21 22
22/** 23/**
@@ -50,10 +51,11 @@ public class SpecialEvent {
50 * been read. 51 * been read.
51 * 52 *
52 * @param message The message to display 53 * @param message The message to display
54 * @throws InterruptedException
53 */ 55 */
54 public void DisplayMessage(String message) 56 public void DisplayMessage(String message) throws InterruptedException
55 { 57 {
56 mapView.displayMessage(message); 58 MessageWindow.displayMessage(message);
57 } 59 }
58 60
59 /** 61 /**
diff --git a/src/com/fourisland/fourpuzzle/util/Renderable.java b/src/com/fourisland/fourpuzzle/util/Renderable.java new file mode 100644 index 0000000..a6aeb1a --- /dev/null +++ b/src/com/fourisland/fourpuzzle/util/Renderable.java
@@ -0,0 +1,18 @@
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5
6package com.fourisland.fourpuzzle.util;
7
8import java.awt.Graphics2D;
9
10/**
11 *
12 * @author hatkirby
13 */
14public interface Renderable {
15
16 public void render(Graphics2D g);
17
18}
diff --git a/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java b/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java index ca84383..8399422 100755 --- a/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java +++ b/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java
@@ -7,8 +7,10 @@ package com.fourisland.fourpuzzle.window;
7 7
8import com.fourisland.fourpuzzle.Audio; 8import com.fourisland.fourpuzzle.Audio;
9import com.fourisland.fourpuzzle.Display; 9import com.fourisland.fourpuzzle.Display;
10import com.fourisland.fourpuzzle.Game;
10import com.fourisland.fourpuzzle.database.Database; 11import com.fourisland.fourpuzzle.database.Database;
11import com.fourisland.fourpuzzle.database.Sound; 12import com.fourisland.fourpuzzle.database.Sound;
13import com.fourisland.fourpuzzle.util.Renderable;
12import java.awt.Graphics2D; 14import java.awt.Graphics2D;
13import java.awt.Rectangle; 15import java.awt.Rectangle;
14import java.awt.TexturePaint; 16import java.awt.TexturePaint;
@@ -19,7 +21,7 @@ import java.util.List;
19 * 21 *
20 * @author hatkirby 22 * @author hatkirby
21 */ 23 */
22public class ChoiceWindow { 24public class ChoiceWindow implements Renderable {
23 25
24 private static final int SPACER = 4; 26 private static final int SPACER = 4;
25 27
@@ -29,7 +31,9 @@ public class ChoiceWindow {
29 private int width; 31 private int width;
30 private int height; 32 private int height;
31 BufferedImage cacheBase; 33 BufferedImage cacheBase;
32 public ChoiceWindow(List<String> choices, boolean center) 34 int x;
35 int y;
36 public ChoiceWindow(List<String> choices, boolean center, ChoiceWindowLocation cwl)
33 { 37 {
34 this.choices = choices; 38 this.choices = choices;
35 numChoices = choices.size(); 39 numChoices = choices.size();
@@ -52,9 +56,12 @@ public class ChoiceWindow {
52 width += SPACER*2; 56 width += SPACER*2;
53 57
54 cacheBase = Window.Default.getImage(width, height); 58 cacheBase = Window.Default.getImage(width, height);
59
60 x = cwl.getX(width);
61 y = cwl.getY(height);
55 } 62 }
56 63
57 public void render(Graphics2D g2, int x, int y) 64 public void render(Graphics2D g2)
58 { 65 {
59 Display.setFont(g2); 66 Display.setFont(g2);
60 67
@@ -119,5 +126,37 @@ public class ChoiceWindow {
119 { 126 {
120 return choices.get(selected); 127 return choices.get(selected);
121 } 128 }
129
130 public static enum ChoiceWindowLocation
131 {
132 BottomLeft
133 {
134 public int getX(int width)
135 {
136 return (Game.WIDTH/5)-(width/2);
137 }
138 },
139 BottomCenter
140 {
141 public int getX(int width)
142 {
143 return (Game.WIDTH/2)-(width/2);
144 }
145 },
146 BottomRight
147 {
148 public int getX(int width)
149 {
150 return (Game.WIDTH/5*4)-(width/2);
151 }
152 };
153
154 public abstract int getX(int width);
155
156 public int getY(int height)
157 {
158 return (Game.HEIGHT/4*3)-(height/2);
159 }
160 }
122 161
123} \ No newline at end of file 162} \ No newline at end of file
diff --git a/src/com/fourisland/fourpuzzle/window/MessageWindow.java b/src/com/fourisland/fourpuzzle/window/MessageWindow.java index deab252..3272fcc 100644 --- a/src/com/fourisland/fourpuzzle/window/MessageWindow.java +++ b/src/com/fourisland/fourpuzzle/window/MessageWindow.java
@@ -7,26 +7,36 @@ package com.fourisland.fourpuzzle.window;
7 7
8import com.fourisland.fourpuzzle.Display; 8import com.fourisland.fourpuzzle.Display;
9import com.fourisland.fourpuzzle.Game; 9import com.fourisland.fourpuzzle.Game;
10import com.fourisland.fourpuzzle.PuzzleApplication;
11import com.fourisland.fourpuzzle.util.Interval;
12import com.fourisland.fourpuzzle.util.Renderable;
10import java.awt.Graphics2D; 13import java.awt.Graphics2D;
11import java.awt.Rectangle; 14import java.awt.Rectangle;
12import java.awt.TexturePaint; 15import java.awt.TexturePaint;
16import java.awt.event.KeyAdapter;
17import java.awt.event.KeyEvent;
13import java.awt.image.BufferedImage; 18import java.awt.image.BufferedImage;
14import java.util.ArrayList; 19import java.util.ArrayList;
15import java.util.List; 20import java.util.List;
21import java.util.concurrent.CountDownLatch;
16 22
17/** 23/**
18 * 24 *
19 * @author hatkirby 25 * @author hatkirby
20 */ 26 */
21public class MessageWindow { 27public class MessageWindow implements Renderable {
22 28
23 private static final int SPACER = 4; 29 private static final int SPACER = 4;
24 private static final int HEIGHT = 4*(Display.createCanvas(1, 1).createGraphics().getFontMetrics().getHeight()+SPACER); 30 private static final int HEIGHT = 4*(Display.createCanvas(1, 1).createGraphics().getFontMetrics().getHeight()+SPACER);
25 31
26 private List<String> messages; 32 private volatile List<String> messages;
27 int width; 33 int width;
28 BufferedImage cacheBase; 34 BufferedImage cacheBase;
29 public MessageWindow(String message) 35 int num = 0;
36 int upTo = 0;
37 boolean bounceArrow = false;
38 Interval in = Interval.createTickInterval(4);
39 private MessageWindow(String message)
30 { 40 {
31 width = Game.WIDTH - Window.Default.getFullWidth(0); 41 width = Game.WIDTH - Window.Default.getFullWidth(0);
32 messages = new ArrayList<String>(); 42 messages = new ArrayList<String>();
@@ -36,6 +46,36 @@ public class MessageWindow {
36 cacheBase = Window.Default.getImage(width, HEIGHT); 46 cacheBase = Window.Default.getImage(width, HEIGHT);
37 } 47 }
38 48
49 public static void displayMessage(String message) throws InterruptedException
50 {
51 final MessageWindow mw = new MessageWindow(message);
52 final CountDownLatch cdl = new CountDownLatch(1);
53
54 Display.registerRenderable(mw);
55
56 KeyAdapter ka = new KeyAdapter() {
57 @Override
58 public void keyPressed(KeyEvent e) {
59 if ((e.getKeyCode() == KeyEvent.VK_ENTER) || (e.getKeyCode() == KeyEvent.VK_SPACE))
60 {
61 if (mw.pushEnter())
62 {
63 cdl.countDown();
64 }
65 }
66
67 Game.setKey(null);
68 }
69 };
70
71 PuzzleApplication.gameFrame.addKeyListener(ka);
72
73 cdl.await();
74
75 PuzzleApplication.gameFrame.removeKeyListener(ka);
76 Display.unregisterRenderable(mw);
77 }
78
39 private void initalizeMessages(String message, Graphics2D g) 79 private void initalizeMessages(String message, Graphics2D g)
40 { 80 {
41 Display.setFont(g); 81 Display.setFont(g);
@@ -68,12 +108,24 @@ public class MessageWindow {
68 108
69 len = 0; 109 len = 0;
70 } 110 }
111
112 setLength();
113 }
114
115 private void setLength()
116 {
117 num = 0;
118
119 for (int i=0;i<messages.size();i++)
120 {
121 num += messages.get(i).length();
122 }
71 } 123 }
72 124
73 public void render(Graphics2D g2) 125 public void render(Graphics2D g2)
74 { 126 {
75 int y = MessageWindowLocation.Bottom.getY(); 127 int y = MessageWindowLocation.Bottom.getY();
76 128
77 Display.setFont(g2); 129 Display.setFont(g2);
78 130
79 g2.drawImage(cacheBase, 0, y, null); 131 g2.drawImage(cacheBase, 0, y, null);
@@ -81,6 +133,7 @@ public class MessageWindow {
81 int fh = g2.getFontMetrics().getHeight(); 133 int fh = g2.getFontMetrics().getHeight();
82 int ty = Window.Default.getTopY()+fh-(SPACER/2)+y; 134 int ty = Window.Default.getTopY()+fh-(SPACER/2)+y;
83 int msgs = Math.min(messages.size(), 4); 135 int msgs = Math.min(messages.size(), 4);
136 int toPrint = upTo;
84 for (int i=0;i<msgs;i++) 137 for (int i=0;i<msgs;i++)
85 { 138 {
86 String message = messages.get(i); 139 String message = messages.get(i);
@@ -88,10 +141,46 @@ public class MessageWindow {
88 int tx = Window.Default.getLeftX(); 141 int tx = Window.Default.getLeftX();
89 142
90 g2.setPaint(new TexturePaint(SystemGraphic.getTextColor(), new Rectangle(tx, ty, fw, fh))); 143 g2.setPaint(new TexturePaint(SystemGraphic.getTextColor(), new Rectangle(tx, ty, fw, fh)));
91 g2.drawString(message, tx, ty); 144 g2.drawString(message.substring(0, Math.min(toPrint, message.length())), tx, ty);
92 145
93 ty+=(SPACER+g2.getFontMetrics().getHeight()); 146 ty+=(SPACER+g2.getFontMetrics().getHeight());
147
148 toPrint -= Math.min(toPrint, message.length());
149 }
150
151 if (upTo < num)
152 {
153 upTo+=3;
154 } else {
155 g2.drawImage(SystemGraphic.getDownArrow(), (Window.Default.getFullWidth(width)/2)-5, y+HEIGHT-SPACER+(bounceArrow ? 1 : 0), null);
156
157 if (in.isElapsed())
158 {
159 bounceArrow = !bounceArrow;
160 }
161 }
162 }
163
164 private synchronized boolean pushEnter()
165 {
166 if (upTo >= num)
167 {
168 int msgs = messages.size();
169 for (int i=0;i<Math.min(4, msgs);i++)
170 {
171 messages.remove(0);
172 }
173
174 if (messages.size() > 0)
175 {
176 upTo = 0;
177 setLength();
178 } else {
179 return true;
180 }
94 } 181 }
182
183 return false;
95 } 184 }
96 185
97 public static enum MessageWindowLocation 186 public static enum MessageWindowLocation