Mercurial > hg > ristipolku
annotate game/Engine.java @ 76:43f68fe605de
More cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 03 Mar 2011 04:14:55 +0200 |
parents | b586ce4f6d97 |
children | d17db72ac770 |
rev | line source |
---|---|
0 | 1 /* |
9 | 2 * Ristipolku Game Engine |
0 | 3 * (C) Copyright 2011 Matti 'ccr' Hämäläinen <ccr@tnsp.org> |
4 */ | |
9 | 5 package game; |
6 | |
0 | 7 import java.awt.*; |
8 import java.awt.geom.*; | |
1 | 9 import java.awt.event.*; |
7 | 10 import java.awt.image.*; |
11 import java.awt.event.*; | |
25 | 12 import java.awt.font.*; |
9 | 13 import javax.imageio.*; |
7 | 14 import javax.swing.*; |
1 | 15 import java.util.*; |
6 | 16 import java.io.*; |
1 | 17 import game.*; |
37 | 18 import javax.sound.sampled.*; |
21 | 19 |
42
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
20 |
75 | 21 class AboutBox extends IDMWidget |
8 | 22 { |
75 | 23 BufferedImage aboutImg; |
24 boolean aboutSecret; | |
25 | |
76 | 26 IDMPoint currPos, currOffs; |
27 Paint textPaint; | |
28 Font textFont; | |
29 FontMetrics textMetrics; | |
30 | |
31 | |
75 | 32 public AboutBox() |
33 { | |
34 try { | |
35 ResourceLoader res = new ResourceLoader("graphics/girl.jpg"); | |
36 aboutImg = ImageIO.read(res.getStream()); | |
37 } | |
38 catch (IOException e) | |
39 { | |
40 } | |
41 | |
42 aboutSecret = false; | |
43 | |
44 setPos(150f, 150f); | |
45 setSize(600f, 400f); | |
46 } | |
47 | |
48 public void setTextFont(Font font, FontMetrics metrics) | |
49 { | |
50 textFont = font; | |
51 textMetrics = metrics; | |
52 } | |
53 | |
54 public void setTextPaint(Paint paint) | |
8 | 55 { |
75 | 56 textPaint = paint; |
57 } | |
58 | |
59 public void setCurrPos(IDMPoint npos) | |
60 { | |
61 currPos = npos; | |
62 currOffs = new IDMPoint(0, 0); | |
63 } | |
64 | |
65 public void setCurrPos(float x, float y) | |
66 { | |
67 setCurrPos(new IDMPoint(x, y)); | |
8 | 68 } |
69 | |
75 | 70 public void drawString(Graphics2D g, String text) |
8 | 71 { |
75 | 72 Paint savePaint = g.getPaint(); |
73 g.setPaint(textPaint); | |
76 | 74 g.setFont(textFont); |
75 | 75 |
76 int i = 0; | |
77 while (i < text.length()) | |
8 | 78 { |
75 | 79 int p = text.indexOf("\n", i); |
80 boolean linefeed; | |
81 String str; | |
82 if (p > i) | |
83 { | |
84 str = text.substring(i, p); | |
85 i = p + 1; | |
86 linefeed = true; | |
87 } | |
88 else | |
89 { | |
90 str = text.substring(i); | |
91 i += str.length(); | |
92 linefeed = false; | |
93 } | |
94 | |
95 g.drawString(str, currPos.x + currOffs.x, currPos.y + currOffs.y); | |
96 | |
97 if (linefeed) | |
98 { | |
99 currOffs.x = 0; | |
76 | 100 currOffs.y += textMetrics.getHeight(); |
75 | 101 } |
102 else | |
103 { | |
104 currOffs.x += textMetrics.stringWidth(str); | |
105 } | |
8 | 106 } |
75 | 107 |
108 g.setPaint(savePaint); | |
109 } | |
110 | |
111 public void paint(Graphics2D g) | |
112 { | |
113 int x = getScaledX(), y = getScaledY(), | |
114 w = getScaledWidth(), h = getScaledHeight(); | |
115 | |
116 g.setPaint(new Color(0.0f, 0.0f, 0.0f, 0.6f)); | |
117 g.fill(new RoundRectangle2D.Float(x, y, w, h, 10, 10)); | |
118 | |
76 | 119 setTextFont(G.fonts[3], G.metrics[3]); |
75 | 120 setTextPaint(Color.white); |
8 | 121 |
76 | 122 setCurrPos(x + 20, y + 30); |
123 drawString(g, "RistiPolku (CrossPaths) v0.5\n"); | |
75 | 124 |
76 | 125 setTextFont(G.fonts[1], G.metrics[1]); |
75 | 126 if (aboutSecret) |
127 { | |
76 | 128 g.drawImage(aboutImg, x + 20, y + 55, aboutImg.getWidth(), aboutImg.getHeight(), null); |
75 | 129 |
76 | 130 setCurrPos(x + 225, y + 75); |
75 | 131 drawString(g, |
132 "Dedicated to my\n" + | |
76 | 133 "favorite woman\n" + |
75 | 134 "in the world."); |
135 | |
76 | 136 setCurrPos(x + 370, y + 175); |
75 | 137 drawString(g, "- Matti"); |
138 } | |
8 | 139 else |
140 { | |
75 | 141 setTextPaint(Color.yellow); |
142 drawString(g, "(c) Copyright 2011 Matti 'ccr' Hämäläinen\n"); | |
143 | |
144 setTextPaint(Color.white); | |
145 drawString(g, "Programming project for Java-course\n" + | |
146 "T740306 taught by Kari Laitinen."); | |
8 | 147 } |
148 } | |
75 | 149 |
150 public boolean keyPressed(KeyEvent e) | |
151 { | |
152 if (e.getKeyCode() == KeyEvent.VK_L) | |
153 { | |
154 aboutSecret = true; | |
155 } | |
156 else | |
157 { | |
158 clicked(); | |
159 aboutSecret = false; | |
160 } | |
161 return true; | |
162 } | |
8 | 163 |
75 | 164 public void clicked() |
8 | 165 { |
75 | 166 parent.remove(this); |
8 | 167 } |
168 } | |
75 | 169 |
0 | 170 |
48 | 171 class GameBoard extends IDMWidget |
0 | 172 { |
75 | 173 static final int boardSize = 9; |
174 static final int boardMiddle = 4; | |
2 | 175 Piece[][] board; |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
176 float pscale; |
42
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
177 |
8 | 178 public boolean flagGameOver; |
55 | 179 public int gameScore; |
54 | 180 |
181 public Piece currPiece, nextPiece; | |
41 | 182 int currX, currY, currPoint; |
9 | 183 |
47 | 184 Sound sndPlaced; |
185 | |
75 | 186 public GameBoard(IDMPoint pos, float ps) |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
187 { |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
188 super(pos); |
75 | 189 pscale = ps; |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
190 |
75 | 191 // sndPlaced = smgr.getSound("sounds/placed.wav"); |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
192 |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
193 startNewGame(); |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
194 } |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
195 |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
196 public void startNewGame() |
2 | 197 { |
198 board = new Piece[boardSize][boardSize]; | |
199 board[boardMiddle][boardMiddle] = new Piece(PieceType.START); | |
200 | |
41 | 201 currX = boardMiddle; |
42
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
202 currY = boardMiddle; |
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
203 currPoint = 0; |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
204 |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
205 currPiece = null; |
54 | 206 nextPiece = new Piece(PieceType.ACTIVE); |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
207 |
65
dc936dba124e
Set game over-flag correctly, so that we reset everything after a game over
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
208 flagGameOver = false; |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
209 pieceFinishTurn(); |
55 | 210 gameScore = 0; |
2 | 211 } |
0 | 212 |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
213 public void paintBackPlate(Graphics2D g) |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
214 { |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
215 g.setPaint(new Color(0.0f, 0.0f, 0.0f, 0.2f)); |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
216 g.setStroke(new BasicStroke(5.0f)); |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
217 g.draw(new RoundRectangle2D.Float(getScaledX(), getScaledY(), |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
218 boardSize * pscale, boardSize * pscale, |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
219 pscale / 5, pscale / 5)); |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
220 } |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
221 |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
222 public void paint(Graphics2D g) |
2 | 223 { |
224 for (int y = 0; y < boardSize; y++) | |
225 for (int x = 0; x < boardSize; x++) | |
226 if (board[x][y] != null) | |
227 { | |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
228 board[x][y].paint(g, |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
229 getScaledX() + (x * pscale), |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
230 getScaledY() + (y * pscale), |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
231 pscale - pscale / 10); |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
232 } |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
233 } |
75 | 234 |
235 public boolean contains(float x, float y) | |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
236 { |
76 | 237 return (x >= getScaledX() && |
75 | 238 y >= getScaledY() && |
239 x < getScaledX() + boardSize * pscale && | |
240 y < getScaledY() + boardSize * pscale); | |
2 | 241 } |
9 | 242 |
243 public void animate(float time) | |
244 { | |
245 for (int y = 0; y < boardSize; y++) | |
246 for (int x = 0; x < boardSize; x++) | |
247 if (board[x][y] != null) | |
248 { | |
249 board[x][y].animate(time); | |
250 } | |
251 } | |
1 | 252 |
32
e480579cc460
More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
253 public void pieceRotate(Piece.RotateDir dir) |
2 | 254 { |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
255 if (currPiece != null && !flagGameOver) |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
256 { |
41 | 257 currPiece.rotate(dir); |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
258 } |
2 | 259 } |
1 | 260 |
75 | 261 // Change coordinates based on the "outgoing" |
262 // piece connection point. | |
42
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
263 private void pieceMoveTo(int point) |
7 | 264 { |
46 | 265 switch (point) |
266 { | |
267 case 0: currY--; break; | |
268 case 1: currY--; break; | |
269 | |
270 case 2: currX++; break; | |
271 case 3: currX++; break; | |
272 | |
273 case 4: currY++; break; | |
274 case 5: currY++; break; | |
275 | |
276 case 6: currX--; break; | |
277 case 7: currX--; break; | |
278 } | |
42
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
279 } |
9 | 280 |
54 | 281 public void pieceCreateNew() |
282 { | |
283 currPiece = nextPiece; | |
284 nextPiece = new Piece(PieceType.ACTIVE); | |
285 } | |
286 | |
287 public void pieceSwapCurrent() | |
288 { | |
56 | 289 if (!flagGameOver) |
290 { | |
291 Piece tmp = currPiece; | |
292 currPiece = nextPiece; | |
293 nextPiece = tmp; | |
294 board[currX][currY] = currPiece; | |
295 } | |
54 | 296 } |
297 | |
75 | 298 // Check one piece, set connections, find the new placement |
299 // based on piece rotations etc. | |
300 private boolean pieceCheck(Piece piece) | |
48 | 301 { |
53 | 302 if (piece == null) |
48 | 303 { |
304 // Create new piece | |
56 | 305 pieceCreateNew(); |
48 | 306 board[currX][currY] = currPiece; |
307 return true; | |
308 } | |
309 else | |
53 | 310 if (piece.getType() == PieceType.START) |
48 | 311 { |
312 if (currPiece != null) | |
313 { | |
314 // Hit center starting piece, game over | |
315 flagGameOver = true; | |
316 return true; | |
317 } | |
318 else | |
319 { | |
320 // Start piece as first piece means game is starting | |
321 pieceMoveTo(currPoint); | |
54 | 322 pieceCreateNew(); |
48 | 323 board[currX][currY] = currPiece; |
324 return true; | |
325 } | |
326 } | |
327 | |
328 // Mark the current piece as locked | |
53 | 329 piece.setType(PieceType.LOCKED); |
48 | 330 |
331 // Solve connection (with rotations) through the piece | |
53 | 332 currPoint = piece.getRotatedPoint(piece.getMatchingPoint(currPoint)); |
48 | 333 |
334 // Mark connection as active | |
53 | 335 piece.setConnectionState(currPoint, true); |
48 | 336 |
337 // Solve exit point (with rotations) | |
53 | 338 currPoint = piece.getAntiRotatedPoint(piece.getConnection(currPoint)); |
48 | 339 |
340 // Move to next position accordingly | |
341 pieceMoveTo(currPoint); | |
342 return false; | |
343 } | |
344 | |
75 | 345 // Finish one move/turn of the game, resolve path and find placement |
346 // of the next piece, or set "game over" state if required. | |
42
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
347 public void pieceFinishTurn() |
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
348 { |
48 | 349 boolean finished = false; |
55 | 350 int connections = 0; |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
351 |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
352 if (currPiece != null) |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
353 { |
75 | 354 G.smgr.play(sndPlaced); |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
355 } |
55 | 356 |
48 | 357 while (!finished) |
7 | 358 { |
42
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
359 if (currX >= 0 && currX < boardSize && currY >= 0 && currY < boardSize) |
27 | 360 { |
55 | 361 connections++; |
48 | 362 finished = pieceCheck(board[currX][currY]); |
27 | 363 } |
364 else | |
365 { | |
46 | 366 // Outside of the board, game over |
48 | 367 finished = true; |
42
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
368 flagGameOver = true; |
7 | 369 } |
370 } | |
53 | 371 |
66 | 372 // Compute and add score |
55 | 373 gameScore += connections * connections; |
374 | |
66 | 375 // If game over, clear the game |
53 | 376 if (flagGameOver) |
377 { | |
378 currPiece = null; | |
379 } | |
42
951a4d669af0
Initially working path solving algorithm.
Matti Hamalainen <ccr@tnsp.org>
parents:
41
diff
changeset
|
380 } |
66 | 381 |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
382 public boolean mouseWheelMoved(MouseWheelEvent e) |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
383 { |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
384 int notches = e.getWheelRotation(); |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
385 |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
386 if (notches < 0) |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
387 pieceRotate(Piece.RotateDir.LEFT); |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
388 else |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
389 pieceRotate(Piece.RotateDir.RIGHT); |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
390 |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
391 return true; |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
392 } |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
393 |
75 | 394 public void clicked() |
395 { | |
76 | 396 pieceFinishTurn(); |
75 | 397 } |
47 | 398 |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
399 public boolean keyPressed(KeyEvent e) |
47 | 400 { |
54 | 401 if (flagGameOver) |
402 return false; | |
403 | |
47 | 404 switch (e.getKeyCode()) |
405 { | |
406 case KeyEvent.VK_LEFT: | |
407 case KeyEvent.VK_UP: | |
408 pieceRotate(Piece.RotateDir.LEFT); | |
409 return true; | |
410 | |
411 case KeyEvent.VK_RIGHT: | |
412 case KeyEvent.VK_DOWN: | |
413 pieceRotate(Piece.RotateDir.RIGHT); | |
414 return true; | |
415 | |
416 case KeyEvent.VK_ENTER: | |
417 pieceFinishTurn(); | |
418 return true; | |
419 } | |
420 return false; | |
421 } | |
1 | 422 } |
423 | |
424 | |
9 | 425 public class Engine extends JPanel |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
426 implements Runnable, KeyListener, |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
427 MouseListener, MouseWheelListener |
1 | 428 { |
25 | 429 long startTime; |
430 float gameClock, gameFrames; | |
75 | 431 |
8 | 432 Thread animThread; |
433 boolean animEnable = false; | |
25 | 434 |
4 | 435 GameBoard lauta = null; |
69
163232ec225b
Stream music data instead of loading to memory.
Matti Hamalainen <ccr@tnsp.org>
parents:
68
diff
changeset
|
436 InputStream musa; |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
437 IDMContainer widgets; |
75 | 438 AboutBox aboutBox; |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
439 |
9 | 440 public Engine() |
2 | 441 { |
25 | 442 // Initialize globals |
443 System.out.print("Engine() constructor\n"); | |
444 | |
37 | 445 // Sound system |
75 | 446 G.smgr = new SoundManager(new AudioFormat(22050, 16, 1, true, false), 4); |
9 | 447 |
25 | 448 // Load resources |
4 | 449 try |
450 { | |
24 | 451 ResourceLoader res = new ResourceLoader("graphics/board.jpg"); |
75 | 452 G.lautaBG = ImageIO.read(res.getStream()); |
60
4a984e3b27d2
Cleanups. Add a ad-hoc about box, it's ugly.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
453 |
25 | 454 try { |
455 res = new ResourceLoader("graphics/font.ttf"); | |
75 | 456 |
55 | 457 |
75 | 458 G.fonts = new Font[G.numFonts]; |
459 G.fonts[0] = Font.createFont(Font.TRUETYPE_FONT, res.getStream()); | |
460 G.fonts[1] = G.fonts[0].deriveFont(24f); | |
461 G.fonts[2] = G.fonts[0].deriveFont(64f); | |
76 | 462 G.fonts[3] = G.fonts[0].deriveFont(32f); |
75 | 463 |
25 | 464 } |
465 catch (FontFormatException e) | |
466 { | |
467 System.out.print("Could not initialize fonts.\n"); | |
468 } | |
37 | 469 |
69
163232ec225b
Stream music data instead of loading to memory.
Matti Hamalainen <ccr@tnsp.org>
parents:
68
diff
changeset
|
470 res = new ResourceLoader("sounds/gamemusic.wav"); |
163232ec225b
Stream music data instead of loading to memory.
Matti Hamalainen <ccr@tnsp.org>
parents:
68
diff
changeset
|
471 musa = res.getStream(); |
4 | 472 } |
473 catch (IOException e) | |
474 { | |
475 JOptionPane.showMessageDialog(null, | |
21 | 476 e.getMessage(), |
4 | 477 "Initialization error", |
478 JOptionPane.ERROR_MESSAGE); | |
37 | 479 |
21 | 480 System.out.print(e.getMessage()); |
18 | 481 } |
482 | |
52 | 483 // Create IDM GUI widgets |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
484 widgets = new IDMContainer(); |
52 | 485 |
75 | 486 widgets.add(new BtnSwapPiece(767f, 450f)); |
487 widgets.add(new BtnAbout (767f, 570f)); | |
488 widgets.add(new BtnNewGame (767f, 650f)); | |
50 | 489 |
75 | 490 lauta = new GameBoard(new IDMPoint(95, 130), 63); |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
491 widgets.add(lauta); |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
492 |
75 | 493 aboutBox = new AboutBox(); |
494 | |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
495 // Game |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
496 startNewGame(); |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
497 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
498 // Initialize event listeners |
18 | 499 addKeyListener(this); |
500 addMouseListener(this); | |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
501 addMouseWheelListener(this); |
18 | 502 |
503 // Get initial focus | |
504 if (!hasFocus()) | |
505 { | |
506 System.out.print("Engine(): requesting focus\n"); | |
507 requestFocus(); | |
4 | 508 } |
37 | 509 |
75 | 510 // G.smgr.play(musa); |
8 | 511 } |
512 | |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
513 public void startNewGame() |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
514 { |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
515 gameClock = 0; |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
516 gameFrames = 0; |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
517 startTime = new Date().getTime(); |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
518 lauta.startNewGame(); |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
519 } |
25 | 520 |
521 public void paintComponent(Graphics g) | |
522 { | |
523 Graphics2D g2 = (Graphics2D) g; | |
524 | |
525 // Use antialiasing when rendering the game elements | |
526 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, | |
527 RenderingHints.VALUE_ANTIALIAS_ON); | |
528 | |
529 g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, | |
530 RenderingHints.VALUE_TEXT_ANTIALIAS_ON); | |
531 | |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
532 |
52 | 533 // Rescale if parent component size has changed |
25 | 534 Dimension dim = getSize(); |
75 | 535 if (G.screenDim == null || !dim.equals(G.screenDim)) |
25 | 536 { |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
537 // Rescale IDM GUI widgets |
75 | 538 widgets.setScale(dim.width / 1024.0f, dim.height / 768.0f); |
539 G.screenDim = dim; | |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
540 |
52 | 541 // Rescale background image |
75 | 542 G.lautaBGScaled = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_ARGB); |
543 Graphics2D gimg = G.lautaBGScaled.createGraphics(); | |
25 | 544 gimg.setRenderingHint(RenderingHints.KEY_INTERPOLATION, |
545 RenderingHints.VALUE_INTERPOLATION_BICUBIC); | |
546 | |
75 | 547 gimg.drawImage(G.lautaBG, 0, 0, dim.width, dim.height, null); |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
548 lauta.paintBackPlate(gimg); |
25 | 549 |
550 System.out.print("scale changed\n"); | |
551 } | |
552 | |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
553 // Get font metrics against current Graphics2D context |
75 | 554 if (G.metrics == null) |
555 { | |
556 G.metrics = new FontMetrics[G.numFonts]; | |
557 for (int i = 0; i < G.numFonts; i++) | |
558 G.metrics[i] = g2.getFontMetrics(G.fonts[i]); | |
559 } | |
55 | 560 |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
561 // Draw background image, pieces, widgets |
75 | 562 g2.drawImage(G.lautaBGScaled, 0, 0, null); |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
563 widgets.paint(g2); |
55 | 564 |
565 if (!lauta.flagGameOver) | |
566 { | |
62
caf67c7e0814
Fix a possible null pointer exception under certain circumstances.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
567 if (lauta.nextPiece != null) |
caf67c7e0814
Fix a possible null pointer exception under certain circumstances.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
568 { |
caf67c7e0814
Fix a possible null pointer exception under certain circumstances.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
569 // Draw next piece |
caf67c7e0814
Fix a possible null pointer exception under certain circumstances.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
570 AffineTransform save = g2.getTransform(); |
caf67c7e0814
Fix a possible null pointer exception under certain circumstances.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
571 lauta.nextPiece.paint(g2, 830, 325, 90); |
caf67c7e0814
Fix a possible null pointer exception under certain circumstances.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
572 g2.setTransform(save); |
caf67c7e0814
Fix a possible null pointer exception under certain circumstances.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
573 } |
55 | 574 } |
575 else | |
576 { | |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
577 // Game over text |
55 | 578 String text = "Game Over!"; |
75 | 579 int textWidth = G.metrics[2].stringWidth(text); |
580 g2.setFont(G.fonts[2]); | |
55 | 581 |
582 g2.setPaint(new Color(0.0f, 0.0f, 0.0f, 0.5f)); | |
583 g2.drawString(text, (dim.width - textWidth) / 2 + 5, dim.height / 2 + 5); | |
584 | |
585 double f = Math.sin(gameClock * 0.1) * 4.0; | |
586 g2.setPaint(Color.white); | |
587 g2.drawString(text, (dim.width - textWidth) / 2 + (float) f, dim.height / 2 + (float) f); | |
588 } | |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
589 |
75 | 590 // Score |
591 g2.setFont(G.fonts[2]); | |
25 | 592 g2.setPaint(Color.white); |
55 | 593 g2.drawString(""+ String.format("%05d", lauta.gameScore), dim.width - 230, 220); |
594 | |
75 | 595 |
596 // Frames per second counter | |
597 g2.setFont(G.fonts[1]); | |
25 | 598 long currTime = new Date().getTime(); |
32
e480579cc460
More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
599 g2.drawString("fps = "+ ((gameFrames * 1000) / (currTime - startTime)), dim.width - 120, 20); |
60
4a984e3b27d2
Cleanups. Add a ad-hoc about box, it's ugly.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
600 |
75 | 601 gameFrames++; |
25 | 602 } |
603 | |
8 | 604 public void startThreads() |
605 { | |
9 | 606 System.out.print("startThreads()\n"); |
8 | 607 if (animThread == null) |
608 { | |
609 animThread = new Thread(this); | |
610 animEnable = true; | |
611 animThread.start(); | |
612 } | |
613 } | |
614 | |
615 public void stopThreads() | |
616 { | |
9 | 617 System.out.print("stopThreads()\n"); |
37 | 618 |
619 // Stop animations | |
8 | 620 if (animThread != null) |
621 { | |
622 animThread.interrupt(); | |
623 animEnable = false; | |
624 animThread = null; | |
625 } | |
22 | 626 |
37 | 627 // Shut down sound manager |
75 | 628 G.smgr.close(); |
2 | 629 } |
0 | 630 |
75 | 631 public void mouseEntered(MouseEvent e) |
632 { | |
633 widgets.mouseEntered(e); | |
634 } | |
635 public void mouseExited(MouseEvent e) | |
636 { | |
637 widgets.mouseExited(e); | |
638 } | |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
639 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
640 public void mousePressed(MouseEvent e) |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
641 { |
75 | 642 if (widgets.containsObject(aboutBox)) |
643 aboutBox.mousePressed(e); | |
644 else | |
60
4a984e3b27d2
Cleanups. Add a ad-hoc about box, it's ugly.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
645 widgets.mousePressed(e); |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
646 } |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
647 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
648 public void mouseReleased(MouseEvent e) |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
649 { |
75 | 650 if (widgets.containsObject(aboutBox)) |
651 aboutBox.mouseReleased(e); | |
652 else | |
60
4a984e3b27d2
Cleanups. Add a ad-hoc about box, it's ugly.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
653 widgets.mouseReleased(e); |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
654 } |
18 | 655 |
656 public void mouseClicked(MouseEvent e) | |
657 { | |
658 if (!hasFocus()) | |
659 { | |
60
4a984e3b27d2
Cleanups. Add a ad-hoc about box, it's ugly.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
660 System.out.print("Requesting focus\n"); |
18 | 661 requestFocus(); |
662 } | |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
663 } |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
664 |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
665 public void mouseWheelMoved(MouseWheelEvent e) |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
666 { |
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
667 lauta.mouseWheelMoved(e); |
18 | 668 } |
669 | |
75 | 670 public void keyTyped(KeyEvent e) { } |
671 public void keyReleased(KeyEvent e) { } | |
1 | 672 |
9 | 673 public void keyPressed(KeyEvent e) |
2 | 674 { |
75 | 675 // Handle keyboard input |
676 if (widgets.containsObject(aboutBox)) | |
677 aboutBox.keyPressed(e); | |
60
4a984e3b27d2
Cleanups. Add a ad-hoc about box, it's ugly.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
678 else |
4a984e3b27d2
Cleanups. Add a ad-hoc about box, it's ugly.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
679 widgets.keyPressed(e); |
2 | 680 } |
8 | 681 |
682 public void run() | |
683 { | |
684 while (animEnable) | |
685 { | |
26
3d4cc47df31a
Cleanups, fix piece rendering and rotation.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
686 // Progress game animation clock |
25 | 687 gameClock++; |
9 | 688 |
26
3d4cc47df31a
Cleanups, fix piece rendering and rotation.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
689 // Animate components |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
690 lauta.animate(gameClock); |
62
caf67c7e0814
Fix a possible null pointer exception under certain circumstances.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
691 if (lauta.nextPiece != null) |
caf67c7e0814
Fix a possible null pointer exception under certain circumstances.
Matti Hamalainen <ccr@tnsp.org>
parents:
60
diff
changeset
|
692 lauta.nextPiece.animate(gameClock); |
9 | 693 |
26
3d4cc47df31a
Cleanups, fix piece rendering and rotation.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
694 // Repaint with a frame limiter |
59
fd10a9422b60
Cleanups, bugfixes, etc etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
695 if (gameClock % 4 == 1) |
10 | 696 repaint(); |
32
e480579cc460
More work on debugging the path resolving.
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
697 |
26
3d4cc47df31a
Cleanups, fix piece rendering and rotation.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
698 // Sleep for a moment |
9 | 699 try { |
700 Thread.sleep(10); | |
701 } | |
702 catch (InterruptedException x) { | |
703 } | |
8 | 704 } |
705 } | |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
706 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
707 class BtnNewGame extends IDMButton |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
708 { |
51 | 709 public BtnNewGame(float x, float y) |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
710 { |
75 | 711 super(x, y, KeyEvent.VK_ESCAPE, G.fonts[1], "New Game"); |
49
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
712 } |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
713 |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
714 public void clicked() |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
715 { |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
716 startNewGame(); |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
717 } |
e6da5c71be28
Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
48
diff
changeset
|
718 } |
50 | 719 |
720 class BtnSwapPiece extends IDMButton | |
721 { | |
51 | 722 public BtnSwapPiece(float x, float y) |
50 | 723 { |
75 | 724 super(x, y, KeyEvent.VK_SPACE, G.fonts[1], "Swap"); |
50 | 725 } |
726 | |
727 public void clicked() | |
728 { | |
54 | 729 lauta.pieceSwapCurrent(); |
50 | 730 } |
731 } | |
60
4a984e3b27d2
Cleanups. Add a ad-hoc about box, it's ugly.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
732 |
4a984e3b27d2
Cleanups. Add a ad-hoc about box, it's ugly.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
733 class BtnAbout extends IDMButton |
4a984e3b27d2
Cleanups. Add a ad-hoc about box, it's ugly.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
734 { |
4a984e3b27d2
Cleanups. Add a ad-hoc about box, it's ugly.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
735 public BtnAbout(float x, float y) |
4a984e3b27d2
Cleanups. Add a ad-hoc about box, it's ugly.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
736 { |
75 | 737 super(x, y, KeyEvent.VK_A, G.fonts[1], "About"); |
60
4a984e3b27d2
Cleanups. Add a ad-hoc about box, it's ugly.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
738 } |
4a984e3b27d2
Cleanups. Add a ad-hoc about box, it's ugly.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
739 |
4a984e3b27d2
Cleanups. Add a ad-hoc about box, it's ugly.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
740 public void clicked() |
4a984e3b27d2
Cleanups. Add a ad-hoc about box, it's ugly.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
741 { |
75 | 742 if (!widgets.containsObject(aboutBox)) |
743 widgets.add(aboutBox); | |
60
4a984e3b27d2
Cleanups. Add a ad-hoc about box, it's ugly.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
744 } |
4a984e3b27d2
Cleanups. Add a ad-hoc about box, it's ugly.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
745 } |
0 | 746 } |