summaryrefslogtreecommitdiff
authorcniehaus <cniehaus>2002-09-03 19:00:18 (UTC)
committer cniehaus <cniehaus>2002-09-03 19:00:18 (UTC)
commitcf317ab123c51fb957ec35d44431e77a8b76c279 (patch) (unidiff)
treecb81fa703851995a6beb2c8b562da4d2344da47b
parentd9186e958c93df6d6363e2dc0af704e93eb0c06e (diff)
downloadopie-cf317ab123c51fb957ec35d44431e77a8b76c279.zip
opie-cf317ab123c51fb957ec35d44431e77a8b76c279.tar.gz
opie-cf317ab123c51fb957ec35d44431e77a8b76c279.tar.bz2
As KPacman didn't use tr() but KDE's i18n() is did a simple
perl -pi~ -e 's/i18n/tr/g' *.cpp
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/kpacman/board.cpp6
-rw-r--r--noncore/games/kpacman/keys.cpp10
-rw-r--r--noncore/games/kpacman/kpacman.cpp30
-rw-r--r--noncore/games/kpacman/kpacmanwidget.cpp4
-rw-r--r--noncore/games/kpacman/painter.cpp6
-rw-r--r--noncore/games/kpacman/referee.cpp54
-rw-r--r--noncore/games/kpacman/score.cpp48
-rw-r--r--noncore/games/kpacman/status.cpp4
8 files changed, 81 insertions, 81 deletions
diff --git a/noncore/games/kpacman/board.cpp b/noncore/games/kpacman/board.cpp
index 849e75b..f95f699 100644
--- a/noncore/games/kpacman/board.cpp
+++ b/noncore/games/kpacman/board.cpp
@@ -1,425 +1,425 @@
1 1
2#include "portable.h" 2#include "portable.h"
3 3
4#if defined( KDE2_PORT ) 4#if defined( KDE2_PORT )
5#include <kapp.h> 5#include <kapp.h>
6#include <klocale.h> 6#include <klocale.h>
7#endif 7#endif
8 8
9#include <qrect.h> 9#include <qrect.h>
10#include <qregexp.h> 10#include <qregexp.h>
11#include <qmessagebox.h> 11#include <qmessagebox.h>
12#include <qfile.h> 12#include <qfile.h>
13#include <qtextstream.h> 13#include <qtextstream.h>
14 14
15#include "board.h" 15#include "board.h"
16#include "bitmaps.h" 16#include "bitmaps.h"
17 17
18Board::Board(int size) : QArray<int> (size) 18Board::Board(int size) : QArray<int> (size)
19{ 19{
20 sz = size; // set size of board 20 sz = size; // set size of board
21 21
22 map = ""; 22 map = "";
23 mapName = ""; // no map loaded so far 23 mapName = ""; // no map loaded so far
24 24
25 init(None); // initialize varibales 25 init(None); // initialize varibales
26} 26}
27 27
28void Board::init(Image image, QString levelName) 28void Board::init(Image image, QString levelName)
29{ 29{
30 prisonEntry = OUT; 30 prisonEntry = OUT;
31 prisonExit = OUT; 31 prisonExit = OUT;
32 fruitHome = OUT; 32 fruitHome = OUT;
33 fruitPosition = OUT; 33 fruitPosition = OUT;
34 pacmanHome = OUT; 34 pacmanHome = OUT;
35 pacmanPosition = OUT; 35 pacmanPosition = OUT;
36 for (int m = 0; m < 8; m++) { 36 for (int m = 0; m < 8; m++) {
37 monsterHome[m] = OUT; 37 monsterHome[m] = OUT;
38 monsterPosition[m] = OUT; 38 monsterPosition[m] = OUT;
39 } 39 }
40 for (int e = 0; e < 8; e++) { 40 for (int e = 0; e < 8; e++) {
41 energizerPosition[e] = OUT; 41 energizerPosition[e] = OUT;
42 } 42 }
43 for (int e = 0; e < 8; e++) { 43 for (int e = 0; e < 8; e++) {
44 tunnelPosition[e] = OUT; 44 tunnelPosition[e] = OUT;
45 } 45 }
46 46
47 fill(0); 47 fill(0);
48 numPoints = 0; 48 numPoints = 0;
49 numEnergizers = 0; 49 numEnergizers = 0;
50 numMonsters = 0; 50 numMonsters = 0;
51 numTunnels = 0; 51 numTunnels = 0;
52 52
53 if (!levelName.isNull() && !levelName.isEmpty()) 53 if (!levelName.isNull() && !levelName.isEmpty())
54 if (mapName == levelName) 54 if (mapName == levelName)
55 image = File; 55 image = File;
56 else { 56 else {
57 QFile levelFile(levelName); 57 QFile levelFile(levelName);
58 if (!levelFile.open(IO_ReadOnly)) { 58 if (!levelFile.open(IO_ReadOnly)) {
59 59
60 QString msg = i18n("The levelmap could not be constructed.\n\n" 60 QString msg = "The levelmap could not be constructed.\n\n"
61 "The file '@LEVELNAME@' does not exist,\n" 61 "The file '@LEVELNAME@' does not exist,\n"
62 "or could not be opened for reading."); 62 "or could not be opened for reading.";
63 msg.replace(QRegExp("@LEVELNAME@"), levelName); 63 msg.replace(QRegExp("@LEVELNAME@"), levelName);
64 // QMessageBox::information(0, i18n("Initialization Error"), msg); 64 // QMessageBox::information(0, tr("Initialization Error"), msg);
65 printf("%s\n", msg.data()); 65 printf("%s\n", msg.data());
66 } else { 66 } else {
67 map.fill(' ', BoardHeight*BoardWidth); 67 map.fill(' ', BoardHeight*BoardWidth);
68 int height = 0; 68 int height = 0;
69 69
70 QTextStream levelStream(&levelFile); 70 QTextStream levelStream(&levelFile);
71 while (!levelStream.eof() && height < BoardHeight) { 71 while (!levelStream.eof() && height < BoardHeight) {
72 QString line = levelStream.readLine(); 72 QString line = levelStream.readLine();
73 73
74 if (line.find(QRegExp("^ *;")) == -1) { 74 if (line.find(QRegExp("^ *;")) == -1) {
75 75
76 line.replace(QRegExp(";.*"), ""); // strip off comments 76 line.replace(QRegExp(";.*"), ""); // strip off comments
77 line.replace(QRegExp("\" *$"), ""); // strip off trailing " 77 line.replace(QRegExp("\" *$"), ""); // strip off trailing "
78 line.replace(QRegExp("^ *\""), ""); // strip off leading " 78 line.replace(QRegExp("^ *\""), ""); // strip off leading "
79 79
80 map.replace(height*BoardWidth, 80 map.replace(height*BoardWidth,
81 (line.length() > BoardWidth) ? BoardWidth : line.length(), 81 (line.length() > BoardWidth) ? BoardWidth : line.length(),
82 line.data()); 82 line.data());
83 83
84 height++; 84 height++;
85 } 85 }
86 } 86 }
87 mapName = levelName; 87 mapName = levelName;
88 levelFile.close(); 88 levelFile.close();
89 image = File; 89 image = File;
90 } 90 }
91 } 91 }
92 92
93 switch (image) { 93 switch (image) {
94 case Intro : // setup(demo_bits); 94 case Intro : // setup(demo_bits);
95 break; 95 break;
96 case Demo : setup(demo_bits); 96 case Demo : setup(demo_bits);
97 break; 97 break;
98 case Level : setup(demo_bits); 98 case Level : setup(demo_bits);
99 break; 99 break;
100 case File : setup((uchar *) map.data()); 100 case File : setup((uchar *) map.data());
101 break; 101 break;
102 default : break; 102 default : break;
103 } 103 }
104} 104}
105 105
106void Board::setup(const uchar *buf) 106void Board::setup(const uchar *buf)
107{ 107{
108 for ( int index = 0; buf[index] != 0 && index < BoardWidth*BoardHeight; index++ ) { 108 for ( int index = 0; buf[index] != 0 && index < BoardWidth*BoardHeight; index++ ) {
109 switch (buf[index]) { 109 switch (buf[index]) {
110 case '*' : set(index, brick); break; 110 case '*' : set(index, brick); break;
111 case '+' : set(index, out); break; 111 case '+' : set(index, out); break;
112 case '#' : set(index, prison); break; 112 case '#' : set(index, prison); break;
113 case '-' : set(index, gate); break; 113 case '-' : set(index, gate); break;
114 case 'E' : set(index, tunnel); break; 114 case 'E' : set(index, tunnel); break;
115 case '.' : set(index, Point); break; 115 case '.' : set(index, Point); break;
116 case 'o' : set(index, energizer); break; 116 case 'o' : set(index, energizer); break;
117 case 'I' : set(index, prisonentry); break; 117 case 'I' : set(index, prisonentry); break;
118 case 'O' : set(index, prisonexit); break; 118 case 'O' : set(index, prisonexit); break;
119 case 'F' : set(index, fruithome); break; 119 case 'F' : set(index, fruithome); break;
120 case 'P' : set(index, pacmanhome); break; 120 case 'P' : set(index, pacmanhome); break;
121 default : if (buf[index] >= '0' && buf[index] <= '7') { 121 default : if (buf[index] >= '0' && buf[index] <= '7') {
122 set(index, monsterhome, buf[index]-(uchar)'0'); 122 set(index, monsterhome, buf[index]-(uchar)'0');
123 } 123 }
124 } 124 }
125 } 125 }
126} 126}
127 127
128bool Board::inBounds(int pos) 128bool Board::inBounds(int pos)
129{ 129{
130 return ( pos < 0 || pos > sz-1 ? FALSE : TRUE); 130 return ( pos < 0 || pos > sz-1 ? FALSE : TRUE);
131} 131}
132 132
133void Board::set(int pos, Square sq, int m) 133void Board::set(int pos, Square sq, int m)
134{ 134{
135 if (inBounds(pos)) 135 if (inBounds(pos))
136 switch (sq) { 136 switch (sq) {
137 case out : at(pos) = OUT; break; 137 case out : at(pos) = OUT; break;
138 case Point : at(pos) |= pointBit; numPoints++; break; 138 case Point : at(pos) |= pointBit; numPoints++; break;
139 case tunnel : at(pos) = sq; 139 case tunnel : at(pos) = sq;
140 for (int e = 0; e < numTunnels; e++) { // if tunnel is already on board 140 for (int e = 0; e < numTunnels; e++) { // if tunnel is already on board
141 if (tunnelPosition[e] == pos) // don't do it again. 141 if (tunnelPosition[e] == pos) // don't do it again.
142 pos = OUT; 142 pos = OUT;
143 } 143 }
144 if (pos != OUT) { 144 if (pos != OUT) {
145 tunnelPosition[numTunnels] = pos; 145 tunnelPosition[numTunnels] = pos;
146 numTunnels++; 146 numTunnels++;
147 } 147 }
148 break; 148 break;
149 case energizer : at(pos) |= energizerBit; 149 case energizer : at(pos) |= energizerBit;
150 for (int e = 0; e < numEnergizers; e++) { 150 for (int e = 0; e < numEnergizers; e++) {
151 if (energizerPosition[e] == pos) 151 if (energizerPosition[e] == pos)
152 pos = OUT; 152 pos = OUT;
153 } 153 }
154 if (pos != OUT) { 154 if (pos != OUT) {
155 energizerPosition[numEnergizers] = pos; 155 energizerPosition[numEnergizers] = pos;
156 numEnergizers++; 156 numEnergizers++;
157 } 157 }
158 break; 158 break;
159 case fruit : at(pos) |= fruitBit; fruitPosition = pos; break; 159 case fruit : at(pos) |= fruitBit; fruitPosition = pos; break;
160 case pacman : at(pos) |= pacmanBit; pacmanPosition = pos; break; 160 case pacman : at(pos) |= pacmanBit; pacmanPosition = pos; break;
161 case monster : at(pos) |= (monsterBit << m); 161 case monster : at(pos) |= (monsterBit << m);
162 monsterPosition[m] = pos; break; 162 monsterPosition[m] = pos; break;
163 case prisonentry : prisonEntry = pos; at(pos) = empty; break; 163 case prisonentry : prisonEntry = pos; at(pos) = empty; break;
164 case prisonexit : prisonExit = pos; at(pos) = empty; break; 164 case prisonexit : prisonExit = pos; at(pos) = empty; break;
165 case fruithome : fruitHome = pos; at(pos) = empty; break; 165 case fruithome : fruitHome = pos; at(pos) = empty; break;
166 case pacmanhome : pacmanHome = pos; at(pos) = empty; break; 166 case pacmanhome : pacmanHome = pos; at(pos) = empty; break;
167 case monsterhome : monsterHome[m] = pos; at(pos) = empty; 167 case monsterhome : monsterHome[m] = pos; at(pos) = empty;
168 if (m == 0 && prisonExit == OUT) 168 if (m == 0 && prisonExit == OUT)
169 prisonExit = pos; 169 prisonExit = pos;
170 if (m == 1 && prisonEntry == OUT) 170 if (m == 1 && prisonEntry == OUT)
171 prisonEntry = pos; 171 prisonEntry = pos;
172 numMonsters++; 172 numMonsters++;
173 break; 173 break;
174 default : at(pos) = sq; 174 default : at(pos) = sq;
175 } 175 }
176} 176}
177 177
178void Board::reset(int pos, Square sq, int m) 178void Board::reset(int pos, Square sq, int m)
179{ 179{
180 bool found = FALSE; 180 bool found = FALSE;
181 if (inBounds(pos)) 181 if (inBounds(pos))
182 switch (sq) { 182 switch (sq) {
183 case out : at(pos) = empty; break; 183 case out : at(pos) = empty; break;
184 case Point : at(pos) &= ~ pointBit; numPoints--; break; 184 case Point : at(pos) &= ~ pointBit; numPoints--; break;
185 case energizer : at(pos) &= ~ energizerBit; 185 case energizer : at(pos) &= ~ energizerBit;
186 for (int e = 0; e < numEnergizers; e++) { // delete the position of the eaten 186 for (int e = 0; e < numEnergizers; e++) { // delete the position of the eaten
187 if (found) // energizer in the position array 187 if (found) // energizer in the position array
188 energizerPosition[e-1] = energizerPosition[e]; 188 energizerPosition[e-1] = energizerPosition[e];
189 if (energizerPosition[e] == pos) 189 if (energizerPosition[e] == pos)
190 found = TRUE; 190 found = TRUE;
191 } 191 }
192 energizerPosition[numEnergizers--] = OUT; 192 energizerPosition[numEnergizers--] = OUT;
193 break; 193 break;
194 case fruit : at(pos) &= ~ fruitBit; fruitPosition = OUT; break; 194 case fruit : at(pos) &= ~ fruitBit; fruitPosition = OUT; break;
195 case pacman : at(pos) &= ~ pacmanBit; pacmanPosition = OUT; break; 195 case pacman : at(pos) &= ~ pacmanBit; pacmanPosition = OUT; break;
196 case monster : at(pos) &= ~ (monsterBit << m); 196 case monster : at(pos) &= ~ (monsterBit << m);
197 monsterPosition[m] = OUT; break; 197 monsterPosition[m] = OUT; break;
198 default : at(pos) = at(pos) & varBits; 198 default : at(pos) = at(pos) & varBits;
199 } 199 }
200} 200}
201 201
202int Board::position(Square sq, int m) 202int Board::position(Square sq, int m)
203{ 203{
204 switch(sq) { 204 switch(sq) {
205 case prisonentry : return prisonEntry; 205 case prisonentry : return prisonEntry;
206 case prisonexit : return prisonExit; 206 case prisonexit : return prisonExit;
207 case fruit : return fruitPosition; 207 case fruit : return fruitPosition;
208 case fruithome : return fruitHome; 208 case fruithome : return fruitHome;
209 case pacman : return pacmanPosition; 209 case pacman : return pacmanPosition;
210 case pacmanhome : return pacmanHome; 210 case pacmanhome : return pacmanHome;
211 case monster : return monsterPosition[m]; 211 case monster : return monsterPosition[m];
212 case monsterhome : return monsterHome[m]; 212 case monsterhome : return monsterHome[m];
213 case energizer : return energizerPosition[m]; 213 case energizer : return energizerPosition[m];
214 case tunnel : return tunnelPosition[m]; 214 case tunnel : return tunnelPosition[m];
215 default : return OUT; 215 default : return OUT;
216 } 216 }
217} 217}
218 218
219bool Board::isOut(int pos) 219bool Board::isOut(int pos)
220{ 220{
221 if (inBounds(pos)) 221 if (inBounds(pos))
222 return (at(pos) == OUT ? TRUE : FALSE); 222 return (at(pos) == OUT ? TRUE : FALSE);
223 return TRUE; 223 return TRUE;
224} 224}
225 225
226bool Board::isEmpty(int pos) 226bool Board::isEmpty(int pos)
227{ 227{
228 if (inBounds(pos)) 228 if (inBounds(pos))
229 return ((at(pos) & fixBits) == empty ? TRUE : FALSE); 229 return ((at(pos) & fixBits) == empty ? TRUE : FALSE);
230 return TRUE; 230 return TRUE;
231} 231}
232 232
233bool Board::isBrick(int pos) 233bool Board::isBrick(int pos)
234{ 234{
235 if (inBounds(pos)) 235 if (inBounds(pos))
236 return ((at(pos) & fixBits) == brick ? TRUE : FALSE); 236 return ((at(pos) & fixBits) == brick ? TRUE : FALSE);
237 return FALSE; 237 return FALSE;
238} 238}
239 239
240bool Board::isPrison(int pos) 240bool Board::isPrison(int pos)
241{ 241{
242 if (inBounds(pos)) 242 if (inBounds(pos))
243 return ((at(pos) & fixBits) == prison ? TRUE : FALSE); 243 return ((at(pos) & fixBits) == prison ? TRUE : FALSE);
244 return FALSE; 244 return FALSE;
245} 245}
246 246
247bool Board::isGate(int pos) 247bool Board::isGate(int pos)
248{ 248{
249 if (inBounds(pos)) 249 if (inBounds(pos))
250 return ((at(pos) & fixBits) == gate ? TRUE : FALSE); 250 return ((at(pos) & fixBits) == gate ? TRUE : FALSE);
251 return FALSE; 251 return FALSE;
252} 252}
253 253
254bool Board::isTunnel(int pos) 254bool Board::isTunnel(int pos)
255{ 255{
256 if (inBounds(pos)) 256 if (inBounds(pos))
257 return ((at(pos) & fixBits) == tunnel ? TRUE : FALSE); 257 return ((at(pos) & fixBits) == tunnel ? TRUE : FALSE);
258 return FALSE; 258 return FALSE;
259} 259}
260 260
261bool Board::isPoint(int pos) 261bool Board::isPoint(int pos)
262{ 262{
263 if (inBounds(pos) && at(pos) != OUT) 263 if (inBounds(pos) && at(pos) != OUT)
264 return ((at(pos) & pointBit) != 0 ? TRUE : FALSE); 264 return ((at(pos) & pointBit) != 0 ? TRUE : FALSE);
265 return FALSE; 265 return FALSE;
266} 266}
267 267
268bool Board::isEnergizer(int pos) 268bool Board::isEnergizer(int pos)
269{ 269{
270 if (inBounds(pos) && at(pos) != OUT) 270 if (inBounds(pos) && at(pos) != OUT)
271 return ((at(pos) & energizerBit) != 0 ? TRUE : FALSE); 271 return ((at(pos) & energizerBit) != 0 ? TRUE : FALSE);
272 return FALSE; 272 return FALSE;
273} 273}
274 274
275bool Board::isFruit(int pos) 275bool Board::isFruit(int pos)
276{ 276{
277 if (inBounds(pos) && at(pos) != OUT) 277 if (inBounds(pos) && at(pos) != OUT)
278 return ((at(pos) & fruitBit) != 0 ? TRUE : FALSE); 278 return ((at(pos) & fruitBit) != 0 ? TRUE : FALSE);
279 return FALSE; 279 return FALSE;
280} 280}
281 281
282bool Board::isPacman(int pos) 282bool Board::isPacman(int pos)
283{ 283{
284 if (inBounds(pos) && at(pos) != OUT) 284 if (inBounds(pos) && at(pos) != OUT)
285 return ((at(pos) & pacmanBit) != 0 ? TRUE : FALSE); 285 return ((at(pos) & pacmanBit) != 0 ? TRUE : FALSE);
286 return FALSE; 286 return FALSE;
287} 287}
288 288
289bool Board::isMonster(int pos) 289bool Board::isMonster(int pos)
290{ 290{
291 if (inBounds(pos) && at(pos) != OUT) 291 if (inBounds(pos) && at(pos) != OUT)
292 return ((at(pos) & monsterBits) != 0 ? TRUE : FALSE); 292 return ((at(pos) & monsterBits) != 0 ? TRUE : FALSE);
293 return FALSE; 293 return FALSE;
294} 294}
295 295
296bool Board::isWay(int pos, int dir, Square sq) { 296bool Board::isWay(int pos, int dir, Square sq) {
297 int p1 = move(pos, dir, 2); 297 int p1 = move(pos, dir, 2);
298 if (p1 == OUT) 298 if (p1 == OUT)
299 return (sq == out ? TRUE : FALSE); 299 return (sq == out ? TRUE : FALSE);
300 int p2, p3; 300 int p2, p3;
301 if (dir == N || dir == S) { 301 if (dir == N || dir == S) {
302 p2 = move(p1, E); 302 p2 = move(p1, E);
303 p3 = move(p1, W); 303 p3 = move(p1, W);
304 } else { 304 } else {
305 p2 = move(p1, N); 305 p2 = move(p1, N);
306 p3 = move(p1, S); 306 p3 = move(p1, S);
307 } 307 }
308 switch (sq) { 308 switch (sq) {
309 case out : return isOut(p1) | isOut(p2) | isOut(p3); 309 case out : return isOut(p1) | isOut(p2) | isOut(p3);
310 case empty : return isEmpty(p1) & isEmpty(p2) & isEmpty(p3); 310 case empty : return isEmpty(p1) & isEmpty(p2) & isEmpty(p3);
311 case brick : return isBrick(p1) | isBrick(p2) | isBrick(p3); 311 case brick : return isBrick(p1) | isBrick(p2) | isBrick(p3);
312 case prison : return isPrison(p1) | isPrison(p2) | isPrison(p3); 312 case prison : return isPrison(p1) | isPrison(p2) | isPrison(p3);
313 case gate : return isGate(p1) & isGate(p2) & isGate(p3); 313 case gate : return isGate(p1) & isGate(p2) & isGate(p3);
314 case tunnel : return isTunnel(p1) & 314 case tunnel : return isTunnel(p1) &
315 (isTunnel(p2) || isEmpty(p2)) & 315 (isTunnel(p2) || isEmpty(p2)) &
316 (isTunnel(p3) || isEmpty(p3)); 316 (isTunnel(p3) || isEmpty(p3));
317 default : return FALSE; 317 default : return FALSE;
318 } 318 }
319} 319}
320 320
321bool Board::isJump(int pos, int dir) { 321bool Board::isJump(int pos, int dir) {
322 switch (dir) { 322 switch (dir) {
323 case NW: return pos < BoardWidth || x(pos) == 0; 323 case NW: return pos < BoardWidth || x(pos) == 0;
324 case N: return pos < BoardWidth; 324 case N: return pos < BoardWidth;
325 case NE: return pos < BoardWidth || x(pos) == BoardWidth-1; 325 case NE: return pos < BoardWidth || x(pos) == BoardWidth-1;
326 case W: return x(pos) == 0; 326 case W: return x(pos) == 0;
327 case E: return x(pos) == BoardWidth-1; 327 case E: return x(pos) == BoardWidth-1;
328 case SW: return pos >= sz-BoardWidth || x(pos) == 0; 328 case SW: return pos >= sz-BoardWidth || x(pos) == 0;
329 case S: return pos >= sz-BoardWidth; 329 case S: return pos >= sz-BoardWidth;
330 case SE: return pos >= sz-BoardWidth || x(pos) == BoardWidth-1; 330 case SE: return pos >= sz-BoardWidth || x(pos) == BoardWidth-1;
331 } 331 }
332 return FALSE; 332 return FALSE;
333} 333}
334 334
335int Board::move(int pos, int dir, int steps) 335int Board::move(int pos, int dir, int steps)
336{ 336{
337 if (steps < 0) { // move backwards 337 if (steps < 0) { // move backwards
338 dir = turn(dir); // turn around and do your steps 338 dir = turn(dir); // turn around and do your steps
339 steps *= -1; 339 steps *= -1;
340 } 340 }
341 341
342 while (steps-- != 0) { // until all steps are gone 342 while (steps-- != 0) { // until all steps are gone
343 switch (dir) { 343 switch (dir) {
344 case NW: pos = pos >= BoardWidth && x(pos) > 0 ? (pos-BoardWidth)-1 : sz-1; 344 case NW: pos = pos >= BoardWidth && x(pos) > 0 ? (pos-BoardWidth)-1 : sz-1;
345 break; 345 break;
346 case N: pos = pos >= BoardWidth ? pos-BoardWidth : (sz-BoardWidth)+x(pos); 346 case N: pos = pos >= BoardWidth ? pos-BoardWidth : (sz-BoardWidth)+x(pos);
347 break; 347 break;
348 case NE: pos = pos >= BoardWidth && x(pos) < BoardWidth-1 ? 348 case NE: pos = pos >= BoardWidth && x(pos) < BoardWidth-1 ?
349 (pos-BoardWidth)+1 : sz-BoardWidth; 349 (pos-BoardWidth)+1 : sz-BoardWidth;
350 break; 350 break;
351 case W: pos = x(pos) > 0 ? pos-1 : pos+(BoardWidth-1); 351 case W: pos = x(pos) > 0 ? pos-1 : pos+(BoardWidth-1);
352 break; 352 break;
353 case E: pos = x(pos) < BoardWidth-1 ? pos+1 : pos-(BoardWidth-1); 353 case E: pos = x(pos) < BoardWidth-1 ? pos+1 : pos-(BoardWidth-1);
354 break; 354 break;
355 case SW: pos = pos < sz-BoardWidth && x(pos) > 0 ? (pos+BoardWidth)-1 : BoardWidth-1; 355 case SW: pos = pos < sz-BoardWidth && x(pos) > 0 ? (pos+BoardWidth)-1 : BoardWidth-1;
356 break; 356 break;
357 case S: pos = pos < sz-BoardWidth ? pos+BoardWidth : x(pos); 357 case S: pos = pos < sz-BoardWidth ? pos+BoardWidth : x(pos);
358 break; 358 break;
359 case SE: pos = pos < sz-BoardWidth && x(pos) < BoardWidth-1 ? (pos+BoardWidth)+1 : 0; 359 case SE: pos = pos < sz-BoardWidth && x(pos) < BoardWidth-1 ? (pos+BoardWidth)+1 : 0;
360 break; 360 break;
361 } 361 }
362 } 362 }
363 return pos; // here we are 363 return pos; // here we are
364} 364}
365 365
366int Board::closeup(int pos, int dir, int target) 366int Board::closeup(int pos, int dir, int target)
367{ 367{
368 if (dir == N || dir == S) { 368 if (dir == N || dir == S) {
369 if (x(target) < x(pos)) 369 if (x(target) < x(pos))
370 return W; 370 return W;
371 if (x(target) > x(pos)) 371 if (x(target) > x(pos))
372 return E; 372 return E;
373 } else { 373 } else {
374 if (y(target) < y(pos)) 374 if (y(target) < y(pos))
375 return N; 375 return N;
376 if (y(target) > y(pos)) 376 if (y(target) > y(pos))
377 return S; 377 return S;
378 } 378 }
379 return dir; 379 return dir;
380} 380}
381 381
382int Board::x(int pos) 382int Board::x(int pos)
383{ 383{
384 return pos % BoardWidth; 384 return pos % BoardWidth;
385} 385}
386 386
387int Board::y(int pos) 387int Board::y(int pos)
388{ 388{
389 return pos/BoardWidth; 389 return pos/BoardWidth;
390} 390}
391 391
392int Board::turn(int dir) 392int Board::turn(int dir)
393{ 393{
394 switch (dir) { 394 switch (dir) {
395 case N : return S; 395 case N : return S;
396 case NE : return SW; 396 case NE : return SW;
397 case E : return W; 397 case E : return W;
398 case SE : return NW; 398 case SE : return NW;
399 case S : return N; 399 case S : return N;
400 case SW : return NE; 400 case SW : return NE;
401 case W : return E; 401 case W : return E;
402 case NW : return SE; 402 case NW : return SE;
403 default : return dir; 403 default : return dir;
404 } 404 }
405} 405}
406 406
407int Board::points() 407int Board::points()
408{ 408{
409 return numPoints; 409 return numPoints;
410} 410}
411 411
412int Board::energizers() 412int Board::energizers()
413{ 413{
414 return numEnergizers; 414 return numEnergizers;
415} 415}
416 416
417int Board::monsters() 417int Board::monsters()
418{ 418{
419 return numMonsters; 419 return numMonsters;
420} 420}
421 421
422int Board::tunnels() 422int Board::tunnels()
423{ 423{
424 return numTunnels; 424 return numTunnels;
425} 425}
diff --git a/noncore/games/kpacman/keys.cpp b/noncore/games/kpacman/keys.cpp
index c609373..8b17785 100644
--- a/noncore/games/kpacman/keys.cpp
+++ b/noncore/games/kpacman/keys.cpp
@@ -1,203 +1,203 @@
1 1
2#include "portable.h" 2#include "portable.h"
3 3
4#if defined( KDE2_PORT ) 4#if defined( KDE2_PORT )
5#include <kapp.h> 5#include <kapp.h>
6#include <kconfig.h> 6#include <kconfig.h>
7#include <klocale.h> 7#include <klocale.h>
8#include <kstddirs.h> 8#include <kstddirs.h>
9#include <kaccel.h> 9#include <kaccel.h>
10 10
11#include <keys.h> 11#include <keys.h>
12#include <keys.moc> 12#include <keys.moc>
13#elif defined( QPE_PORT ) 13#elif defined( QPE_PORT )
14#include <qaccel.h> 14#include <qaccel.h>
15#include <qpe/qpeapplication.h> 15#include <qpe/qpeapplication.h>
16#include "config.h" 16#include "config.h"
17#include "keys.h" 17#include "keys.h"
18#endif 18#endif
19 19
20#include <qpushbt.h> 20#include <qpushbt.h>
21#include <qlabel.h> 21#include <qlabel.h>
22#include <qframe.h> 22#include <qframe.h>
23#include <qkeycode.h> 23#include <qkeycode.h>
24#include <qpixmap.h> 24#include <qpixmap.h>
25#include <qstring.h> 25#include <qstring.h>
26 26
27Keys::Keys( QWidget *parent, const char *name) 27Keys::Keys( QWidget *parent, const char *name)
28 : QDialog( parent, name, TRUE ) 28 : QDialog( parent, name, TRUE )
29{ 29{
30 //KStandardDirs *dirs = KGlobal::dirs(); 30 //KStandardDirs *dirs = KGlobal::dirs();
31 31
32 QPushButton *okButton = new QPushButton(this); 32 QPushButton *okButton = new QPushButton(this);
33 okButton->setText(i18n("Ok")); 33 okButton->setText(tr("Ok"));
34 okButton->setFixedSize(okButton->size()); 34 okButton->setFixedSize(okButton->size());
35 connect( okButton, SIGNAL(clicked()),this, SLOT(ok()) ); 35 connect( okButton, SIGNAL(clicked()),this, SLOT(ok()) );
36 okButton->move(20,210); 36 okButton->move(20,210);
37 37
38 QPushButton *defaultButton = new QPushButton(this); 38 QPushButton *defaultButton = new QPushButton(this);
39 defaultButton->setText(i18n("Defaults")); 39 defaultButton->setText(tr("Defaults"));
40 defaultButton->setFixedSize(defaultButton->size()); 40 defaultButton->setFixedSize(defaultButton->size());
41 connect( defaultButton, SIGNAL(clicked()),this, SLOT(defaults()) ); 41 connect( defaultButton, SIGNAL(clicked()),this, SLOT(defaults()) );
42 defaultButton->move(140,210); 42 defaultButton->move(140,210);
43 43
44 QPushButton *cancelButton = new QPushButton(this); 44 QPushButton *cancelButton = new QPushButton(this);
45 cancelButton->setText(i18n("Cancel")); 45 cancelButton->setText(tr("Cancel"));
46 cancelButton->setFixedSize(cancelButton->size()); 46 cancelButton->setFixedSize(cancelButton->size());
47 connect( cancelButton, SIGNAL(clicked()),this, SLOT(reject()) ); 47 connect( cancelButton, SIGNAL(clicked()),this, SLOT(reject()) );
48 cancelButton->move(260,210); 48 cancelButton->move(260,210);
49 49
50 QFrame *separator = new QFrame(this); 50 QFrame *separator = new QFrame(this);
51 separator->setFrameStyle( QFrame::HLine | QFrame::Sunken ); 51 separator->setFrameStyle( QFrame::HLine | QFrame::Sunken );
52 separator->setGeometry( 20, 190, 340, 4 ); 52 separator->setGeometry( 20, 190, 340, 4 );
53 53
54 for ( int x = 0; x < 4; x++) { 54 for ( int x = 0; x < 4; x++) {
55 QLabel *l = new QLabel(this); 55 QLabel *l = new QLabel(this);
56 l->setAlignment(AlignCenter); 56 l->setAlignment(AlignCenter);
57 labels[x] = l; 57 labels[x] = l;
58 } 58 }
59 59
60 labels[0]->setGeometry(120, 20, 140, 20 ); 60 labels[0]->setGeometry(120, 20, 140, 20 );
61 labels[1]->setGeometry(120,160, 140, 20 ); 61 labels[1]->setGeometry(120,160, 140, 20 );
62 labels[2]->setGeometry( 20, 92, 100, 20 ); 62 labels[2]->setGeometry( 20, 92, 100, 20 );
63 labels[3]->setGeometry(265, 92, 100, 20 ); 63 labels[3]->setGeometry(265, 92, 100, 20 );
64 64
65 QString pixPath; 65 QString pixPath;
66 66
67 QPushButton *up = new QPushButton(this); 67 QPushButton *up = new QPushButton(this);
68 pixPath = FIND_APP_DATA( "pics/up.xpm" ); 68 pixPath = FIND_APP_DATA( "pics/up.xpm" );
69 up->setPixmap( QPixmap(pixPath)); 69 up->setPixmap( QPixmap(pixPath));
70 up->setFixedSize(up->pixmap()->size()); 70 up->setFixedSize(up->pixmap()->size());
71 connect( up, SIGNAL(clicked()),this, SLOT(butUp()) ); 71 connect( up, SIGNAL(clicked()),this, SLOT(butUp()) );
72 up->move(180, 50); 72 up->move(180, 50);
73 73
74 QPushButton *down = new QPushButton(this); 74 QPushButton *down = new QPushButton(this);
75 pixPath = FIND_APP_DATA( "pics/down.xpm"); 75 pixPath = FIND_APP_DATA( "pics/down.xpm");
76 down->setPixmap( QPixmap(pixPath)); 76 down->setPixmap( QPixmap(pixPath));
77 down->setFixedSize(down->pixmap()->size()); 77 down->setFixedSize(down->pixmap()->size());
78 connect( down, SIGNAL(clicked()),this, SLOT(butDown()) ); 78 connect( down, SIGNAL(clicked()),this, SLOT(butDown()) );
79 down->move(180, 130); 79 down->move(180, 130);
80 80
81 QPushButton *left = new QPushButton(this); 81 QPushButton *left = new QPushButton(this);
82 pixPath = FIND_APP_DATA( "pics/left.xpm"); 82 pixPath = FIND_APP_DATA( "pics/left.xpm");
83 left->setPixmap( QPixmap(pixPath)); 83 left->setPixmap( QPixmap(pixPath));
84 left->setFixedSize(left->pixmap()->size()); 84 left->setFixedSize(left->pixmap()->size());
85 connect( left, SIGNAL(clicked()),this, SLOT(butLeft()) ); 85 connect( left, SIGNAL(clicked()),this, SLOT(butLeft()) );
86 left->move(140, 90); 86 left->move(140, 90);
87 87
88 QPushButton *right = new QPushButton(this); 88 QPushButton *right = new QPushButton(this);
89 pixPath = FIND_APP_DATA( "pics/right.xpm"); 89 pixPath = FIND_APP_DATA( "pics/right.xpm");
90 right->setPixmap( QPixmap(pixPath)); 90 right->setPixmap( QPixmap(pixPath));
91 right->setFixedSize(right->pixmap()->size()); 91 right->setFixedSize(right->pixmap()->size());
92 connect( right, SIGNAL(clicked()),this, SLOT(butRight()) ); 92 connect( right, SIGNAL(clicked()),this, SLOT(butRight()) );
93 right->move(220, 90); 93 right->move(220, 90);
94 94
95 95
96 setCaption(i18n("Change Direction Keys")); 96 setCaption(tr("Change Direction Keys"));
97 setFixedSize(380, 260); 97 setFixedSize(380, 260);
98 lab = 0; 98 lab = 0;
99 init(); 99 init();
100} 100}
101 101
102void Keys::keyPressEvent( QKeyEvent *e ) 102void Keys::keyPressEvent( QKeyEvent *e )
103{ 103{
104 uint kCode = e->key() & ~(SHIFT | CTRL | ALT); 104 uint kCode = e->key() & ~(SHIFT | CTRL | ALT);
105 QString string = KAccel::keyToString(kCode); 105 QString string = KAccel::keyToString(kCode);
106 106
107 if (lab != 0) { 107 if (lab != 0) {
108 if ( string.isNull() ) 108 if ( string.isNull() )
109 lab->setText(i18n("Undefined key")); 109 lab->setText(tr("Undefined key"));
110 else 110 else
111 lab->setText(string); 111 lab->setText(string);
112 } 112 }
113 else if ( lab == 0 && e->key() == Key_Escape) 113 else if ( lab == 0 && e->key() == Key_Escape)
114 reject(); 114 reject();
115} 115}
116 116
117void Keys::butUp() 117void Keys::butUp()
118{ 118{
119 getKey(0); 119 getKey(0);
120} 120}
121 121
122void Keys::butDown() 122void Keys::butDown()
123{ 123{
124 getKey(1); 124 getKey(1);
125} 125}
126 126
127void Keys::butLeft() 127void Keys::butLeft()
128{ 128{
129 getKey(2); 129 getKey(2);
130} 130}
131 131
132void Keys::butRight() 132void Keys::butRight()
133{ 133{
134 getKey(3); 134 getKey(3);
135} 135}
136 136
137void Keys::getKey(int i) 137void Keys::getKey(int i)
138{ 138{
139 if ( lab != 0) 139 if ( lab != 0)
140 focusOut(lab); 140 focusOut(lab);
141 141
142 focusIn(labels[i]); 142 focusIn(labels[i]);
143} 143}
144 144
145void Keys::focusOut(QLabel *l) 145void Keys::focusOut(QLabel *l)
146{ 146{
147 l->setFrameStyle( QFrame::NoFrame ); 147 l->setFrameStyle( QFrame::NoFrame );
148 l->setBackgroundColor(backgroundColor()); 148 l->setBackgroundColor(backgroundColor());
149 l->repaint(); 149 l->repaint();
150} 150}
151 151
152void Keys::focusIn(QLabel *l) 152void Keys::focusIn(QLabel *l)
153{ 153{
154 lab = l; 154 lab = l;
155 lab->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 155 lab->setFrameStyle( QFrame::Panel | QFrame::Sunken );
156 lab->setBackgroundColor(white); 156 lab->setBackgroundColor(white);
157 lab->repaint(); 157 lab->repaint();
158} 158}
159 159
160void Keys::defaults() 160void Keys::defaults()
161{ 161{
162 if ( lab != 0) 162 if ( lab != 0)
163 focusOut(lab); 163 focusOut(lab);
164 164
165 lab = 0; 165 lab = 0;
166 166
167 labels[0]->setText("Up"); 167 labels[0]->setText("Up");
168 labels[1]->setText("Down"); 168 labels[1]->setText("Down");
169 labels[2]->setText("Left"); 169 labels[2]->setText("Left");
170 labels[3]->setText("Right"); 170 labels[3]->setText("Right");
171} 171}
172 172
173void Keys::init() 173void Keys::init()
174{ 174{
175 APP_CONFIG_BEGIN( cfg ); 175 APP_CONFIG_BEGIN( cfg );
176 QString up("Up"); 176 QString up("Up");
177 up = cfg->readEntry("upKey", (const char*) up); 177 up = cfg->readEntry("upKey", (const char*) up);
178 labels[0]->setText(up); 178 labels[0]->setText(up);
179 179
180 QString down("Down"); 180 QString down("Down");
181 down = cfg->readEntry("downKey", (const char*) down); 181 down = cfg->readEntry("downKey", (const char*) down);
182 labels[1]->setText(down); 182 labels[1]->setText(down);
183 183
184 QString left("Left"); 184 QString left("Left");
185 left = cfg->readEntry("leftKey", (const char*) left); 185 left = cfg->readEntry("leftKey", (const char*) left);
186 labels[2]->setText(left); 186 labels[2]->setText(left);
187 187
188 QString right("Right"); 188 QString right("Right");
189 right = cfg->readEntry("rightKey", (const char*) right); 189 right = cfg->readEntry("rightKey", (const char*) right);
190 labels[3]->setText(right); 190 labels[3]->setText(right);
191 APP_CONFIG_END( cfg ); 191 APP_CONFIG_END( cfg );
192} 192}
193 193
194void Keys::ok() 194void Keys::ok()
195{ 195{
196 APP_CONFIG_BEGIN( cfg ); 196 APP_CONFIG_BEGIN( cfg );
197 cfg->writeEntry("upKey", (const char*) labels[0]->text() ); 197 cfg->writeEntry("upKey", (const char*) labels[0]->text() );
198 cfg->writeEntry("downKey", (const char*) labels[1]->text() ); 198 cfg->writeEntry("downKey", (const char*) labels[1]->text() );
199 cfg->writeEntry("leftKey", (const char*) labels[2]->text() ); 199 cfg->writeEntry("leftKey", (const char*) labels[2]->text() );
200 cfg->writeEntry("rightKey",(const char*) labels[3]->text() ); 200 cfg->writeEntry("rightKey",(const char*) labels[3]->text() );
201 APP_CONFIG_END( cfg ); 201 APP_CONFIG_END( cfg );
202 accept(); 202 accept();
203} 203}
diff --git a/noncore/games/kpacman/kpacman.cpp b/noncore/games/kpacman/kpacman.cpp
index 4077085..7df6ef0 100644
--- a/noncore/games/kpacman/kpacman.cpp
+++ b/noncore/games/kpacman/kpacman.cpp
@@ -1,369 +1,369 @@
1 1
2#include "portable.h" 2#include "portable.h"
3 3
4#if defined( KDE2_PORT ) 4#if defined( KDE2_PORT )
5#include <kpacman.h> 5#include <kpacman.h>
6#include <kpacman.moc> 6#include <kpacman.moc>
7#include <kcolordlg.h> 7#include <kcolordlg.h>
8#elif defined( QPE_PORT ) 8#elif defined( QPE_PORT )
9#include <qmenubar.h> 9#include <qmenubar.h>
10#include "config.h" 10#include "config.h"
11#include <qapplication.h> 11#include <qapplication.h>
12#include "kpacman.h" 12#include "kpacman.h"
13#endif 13#endif
14 14
15#include <qkeycode.h> 15#include <qkeycode.h>
16#include <qcolor.h> 16#include <qcolor.h>
17#include <qstring.h> 17#include <qstring.h>
18#include <qpopmenu.h> 18#include <qpopmenu.h>
19#include <qmsgbox.h> 19#include <qmsgbox.h>
20 20
21Kpacman::Kpacman(QWidget *parent, const char *name) 21Kpacman::Kpacman(QWidget *parent, const char *name)
22 : KTMainWindow(parent, name) 22 : KTMainWindow(parent, name)
23{ 23{
24 schemesPopup = new QList<QPopupMenu>; 24 schemesPopup = new QList<QPopupMenu>;
25 schemesPopup->setAutoDelete(TRUE); 25 schemesPopup->setAutoDelete(TRUE);
26 26
27 menu(); 27 menu();
28 28
29 view = new KpacmanWidget( this, QString(name)+"widget"); 29 view = new KpacmanWidget( this, QString(name)+"widget");
30 30
31#ifndef QWS 31#ifndef QWS
32 setFixedSize(view->width(), view->height()); 32 setFixedSize(view->width(), view->height());
33#else 33#else
34 setCaption( "Kpacman" ); 34 setCaption( "Kpacman" );
35#endif 35#endif
36 36
37 view->referee->setFocus(); 37 view->referee->setFocus();
38 38
39 connect(view->referee, SIGNAL(setScore(int, int)), 39 connect(view->referee, SIGNAL(setScore(int, int)),
40 view->score, SLOT(setScore(int, int))); 40 view->score, SLOT(setScore(int, int)));
41 connect(view->referee, SIGNAL(setPoints(int)), 41 connect(view->referee, SIGNAL(setPoints(int)),
42 view->score, SLOT(set(int))); 42 view->score, SLOT(set(int)));
43 connect(view->referee, SIGNAL(setLifes(int)), 43 connect(view->referee, SIGNAL(setLifes(int)),
44 view->status, SLOT(setLifes(int))); 44 view->status, SLOT(setLifes(int)));
45 connect(view->referee, SIGNAL(setLevel(int)), 45 connect(view->referee, SIGNAL(setLevel(int)),
46 view->status, SLOT(setLevel(int))); 46 view->status, SLOT(setLevel(int)));
47 connect(view->referee, SIGNAL(forcedHallOfFame(bool)), 47 connect(view->referee, SIGNAL(forcedHallOfFame(bool)),
48 this, SLOT(forcedHallOfFame(bool))); 48 this, SLOT(forcedHallOfFame(bool)));
49 connect(view->referee, SIGNAL(togglePaused()), this, SLOT(togglePaused())); 49 connect(view->referee, SIGNAL(togglePaused()), this, SLOT(togglePaused()));
50 connect(view->referee, SIGNAL(toggleNew()), this, SLOT(toggleNew())); 50 connect(view->referee, SIGNAL(toggleNew()), this, SLOT(toggleNew()));
51 51
52 connect(view->score, SIGNAL(toggleNew()), this, SLOT(toggleNew())); 52 connect(view->score, SIGNAL(toggleNew()), this, SLOT(toggleNew()));
53 connect(view->score, SIGNAL(forcedHallOfFame(bool)), 53 connect(view->score, SIGNAL(forcedHallOfFame(bool)),
54 this, SLOT(forcedHallOfFame(bool))); 54 this, SLOT(forcedHallOfFame(bool)));
55 55
56 APP_CONFIG_BEGIN( cfg ); 56 APP_CONFIG_BEGIN( cfg );
57 focusOutPause = !cfg->readBoolEntry("FocusOutPause", TRUE); 57 focusOutPause = !cfg->readBoolEntry("FocusOutPause", TRUE);
58 focusInContinue = !cfg->readBoolEntry("FocusInContinue", TRUE); 58 focusInContinue = !cfg->readBoolEntry("FocusInContinue", TRUE);
59 hideMouseCursor = !cfg->readBoolEntry("HideMouseCursor", TRUE); 59 hideMouseCursor = !cfg->readBoolEntry("HideMouseCursor", TRUE);
60 APP_CONFIG_END( cfg ); 60 APP_CONFIG_END( cfg );
61 61
62 toggleFocusOutPause(); 62 toggleFocusOutPause();
63 toggleFocusInContinue(); 63 toggleFocusInContinue();
64 toggleHideMouseCursor(); 64 toggleHideMouseCursor();
65 65
66#ifndef QWS 66#ifndef QWS
67 menuBar->show(); 67 menuBar->show();
68 view->show(); 68 view->show();
69 setMenu(menuBar); 69 setMenu(menuBar);
70 setView(view); 70 setView(view);
71#else 71#else
72 setCentralWidget( view ); 72 setCentralWidget( view );
73#endif 73#endif
74} 74}
75 75
76Kpacman::~Kpacman() 76Kpacman::~Kpacman()
77{ 77{
78 APP_CONFIG_BEGIN( cfg ); 78 APP_CONFIG_BEGIN( cfg );
79 cfg->writeEntry("FocusOutPause", focusOutPause); 79 cfg->writeEntry("FocusOutPause", focusOutPause);
80 cfg->writeEntry("FocusInContinue", focusInContinue); 80 cfg->writeEntry("FocusInContinue", focusInContinue);
81 cfg->writeEntry("HideMouseCursor", hideMouseCursor); 81 cfg->writeEntry("HideMouseCursor", hideMouseCursor);
82 APP_CONFIG_END( cfg ); 82 APP_CONFIG_END( cfg );
83 delete _menuBar; 83 delete _menuBar;
84} 84}
85 85
86void Kpacman::menu() 86void Kpacman::menu()
87{ 87{
88 gamePopup = new QPopupMenu(); 88 gamePopup = new QPopupMenu();
89 CHECK_PTR( gamePopup ); 89 CHECK_PTR( gamePopup );
90 newID = gamePopup->insertItem(i18n("&New"), this, SLOT(newKpacman()),Key_F2); 90 newID = gamePopup->insertItem(tr("&New"), this, SLOT(newKpacman()),Key_F2);
91 pauseID = gamePopup->insertItem(i18n("&Pause"), 91 pauseID = gamePopup->insertItem(tr("&Pause"),
92 this, SLOT(pauseKpacman()), Key_F3); 92 this, SLOT(pauseKpacman()), Key_F3);
93 hofID = gamePopup->insertItem(i18n("&Hall of fame"), 93 hofID = gamePopup->insertItem(tr("&Hall of fame"),
94 this, SLOT(toggleHallOfFame()), Key_F4); 94 this, SLOT(toggleHallOfFame()), Key_F4);
95 gamePopup->insertSeparator(); 95 gamePopup->insertSeparator();
96 gamePopup->insertItem(i18n("&Quit"), this, SLOT(quitKpacman()), CTRL+Key_Q); 96 gamePopup->insertItem(tr("&Quit"), this, SLOT(quitKpacman()), CTRL+Key_Q);
97 gamePopup->setCheckable(TRUE); 97 gamePopup->setCheckable(TRUE);
98 98
99 optionsPopup = new QPopupMenu(); 99 optionsPopup = new QPopupMenu();
100 CHECK_PTR(optionsPopup); 100 CHECK_PTR(optionsPopup);
101 101
102 modesPopup = new QPopupMenu(); 102 modesPopup = new QPopupMenu();
103 CHECK_PTR(modesPopup); 103 CHECK_PTR(modesPopup);
104 104
105 hideMouseCursorID = optionsPopup->insertItem(i18n("&Hide Mousecursor"), 105 hideMouseCursorID = optionsPopup->insertItem(tr("&Hide Mousecursor"),
106 this, SLOT(toggleHideMouseCursor()), 106 this, SLOT(toggleHideMouseCursor()),
107 CTRL+Key_H); 107 CTRL+Key_H);
108 optionsPopup->insertSeparator(); 108 optionsPopup->insertSeparator();
109 109
110 if (lookupSchemes() > 0) { 110 if (lookupSchemes() > 0) {
111 optionsPopup->insertItem(i18n("&Select graphic scheme"), modesPopup); 111 optionsPopup->insertItem(tr("&Select graphic scheme"), modesPopup);
112 optionsPopup->insertSeparator(); 112 optionsPopup->insertSeparator();
113 } 113 }
114 114
115 focusOutPauseID = optionsPopup->insertItem(i18n("&Pause in Background"), 115 focusOutPauseID = optionsPopup->insertItem(tr("&Pause in Background"),
116 this, SLOT(toggleFocusOutPause())); 116 this, SLOT(toggleFocusOutPause()));
117 focusInContinueID = optionsPopup->insertItem(i18n("&Continue in Foreground"), 117 focusInContinueID = optionsPopup->insertItem(tr("&Continue in Foreground"),
118 this, SLOT(toggleFocusInContinue())); 118 this, SLOT(toggleFocusInContinue()));
119 optionsPopup->insertSeparator(); 119 optionsPopup->insertSeparator();
120 120
121 optionsPopup->insertItem(i18n("Change &keys..."), this, SLOT(confKeys())); 121 optionsPopup->insertItem(tr("Change &keys..."), this, SLOT(confKeys()));
122 122
123#ifndef QWS 123#ifndef QWS
124 QString aboutText = i18n("@PACKAGE@ - @VERSION@\n\n" 124 QString aboutText = tr("@PACKAGE@ - @VERSION@\n\n"
125 "Joerg Thoennissen (joe@dsite.de)\n\n" 125 "Joerg Thoennissen (joe@dsite.de)\n\n"
126 "A pacman game for the KDE Desktop\n\n" 126 "A pacman game for the KDE Desktop\n\n"
127 "The program based on the source of ksnake\n" 127 "The program based on the source of ksnake\n"
128 "by Michel Filippi (mfilippi@sade.rhein-main.de).\n" 128 "by Michel Filippi (mfilippi@sade.rhein-main.de).\n"
129 "The design was strongly influenced by the pacman\n" 129 "The design was strongly influenced by the pacman\n"
130 "(c) 1980 MIDWAY MFG.CO.\n\n" 130 "(c) 1980 MIDWAY MFG.CO.\n\n"
131 "I like to thank my girlfriend Elke Krueers for\n" 131 "I like to thank my girlfriend Elke Krueers for\n"
132 "the last 10 years of her friendship.\n"); 132 "the last 10 years of her friendship.\n");
133 aboutText.replace(QRegExp("@PACKAGE@"), PACKAGE); 133 aboutText.replace(QRegExp("@PACKAGE@"), PACKAGE);
134 aboutText.replace(QRegExp("@VERSION@"), VERSION); 134 aboutText.replace(QRegExp("@VERSION@"), VERSION);
135 QPopupMenu *helpPopup = helpMenu(aboutText, FALSE); 135 QPopupMenu *helpPopup = helpMenu(aboutText, FALSE);
136#endif 136#endif
137 137
138 //_menuBar = new KMenuBar(this); 138 //_menuBar = new KMenuBar(this);
139 //CHECK_PTR( _menuBar ); 139 //CHECK_PTR( _menuBar );
140 //_menuBar->insertItem(i18n("&Game"), gamePopup); 140 //_menuBar->insertItem(tr("&Game"), gamePopup);
141 //_menuBar->insertItem(i18n("&Options"), optionsPopup); 141 //_menuBar->insertItem(tr("&Options"), optionsPopup);
142 //_menuBar->insertSeparator(); 142 //_menuBar->insertSeparator();
143#ifndef QWS 143#ifndef QWS
144 _menuBar->insertItem(i18n("&Help"), helpPopup); 144 _menuBar->insertItem(tr("&Help"), helpPopup);
145#endif 145#endif
146} 146}
147 147
148int Kpacman::lookupSchemes() 148int Kpacman::lookupSchemes()
149{ 149{
150 APP_CONFIG_BEGIN( cfg ); 150 APP_CONFIG_BEGIN( cfg );
151 int ModeCount = cfg->readNumEntry("ModeCount", -1); 151 int ModeCount = cfg->readNumEntry("ModeCount", -1);
152 int Mode = cfg->readNumEntry("Mode", -1); 152 int Mode = cfg->readNumEntry("Mode", -1);
153 int SchemeCount = cfg->readNumEntry("SchemeCount"); 153 int SchemeCount = cfg->readNumEntry("SchemeCount");
154 int Scheme = cfg->readNumEntry("Scheme", -1); 154 int Scheme = cfg->readNumEntry("Scheme", -1);
155 155
156 if (SchemeCount == 0 || Scheme == -1) { 156 if (SchemeCount == 0 || Scheme == -1) {
157 QMessageBox::warning(this, i18n("Configuration Error"), 157 QMessageBox::warning(this, tr("Configuration Error"),
158 i18n("There are no schemes defined,\n" 158 tr("There are no schemes defined,\n"
159 "or no scheme is selected.")); 159 "or no scheme is selected."));
160 APP_CONFIG_END( cfg ); 160 APP_CONFIG_END( cfg );
161 return 0; 161 return 0;
162 } 162 }
163 163
164 connect(modesPopup, SIGNAL(activated(int)), this, SLOT(schemeChecked(int))); 164 connect(modesPopup, SIGNAL(activated(int)), this, SLOT(schemeChecked(int)));
165 modeID.resize(ModeCount > 0 ? ModeCount : 0); 165 modeID.resize(ModeCount > 0 ? ModeCount : 0);
166 166
167 if (!schemesPopup->isEmpty()) 167 if (!schemesPopup->isEmpty())
168 schemesPopup->clear(); 168 schemesPopup->clear();
169 169
170 SAVE_CONFIG_GROUP( cfg, oldgroup ); 170 SAVE_CONFIG_GROUP( cfg, oldgroup );
171 171
172 QString ModeGroup; 172 QString ModeGroup;
173 QString ModeName; 173 QString ModeName;
174 174
175 for (int m = 0; m < ModeCount; m++) { 175 for (int m = 0; m < ModeCount; m++) {
176 ModeGroup.sprintf("Mode %d", m); 176 ModeGroup.sprintf("Mode %d", m);
177 cfg->setGroup(ModeGroup); 177 cfg->setGroup(ModeGroup);
178 178
179 ModeName = cfg->readEntry("Description", ModeGroup); 179 ModeName = cfg->readEntry("Description", ModeGroup);
180 180
181 QPopupMenu *p = new QPopupMenu; 181 QPopupMenu *p = new QPopupMenu;
182 p->setCheckable(TRUE); 182 p->setCheckable(TRUE);
183 connect(p, SIGNAL(activated(int)), this, SLOT(schemeChecked(int))); 183 connect(p, SIGNAL(activated(int)), this, SLOT(schemeChecked(int)));
184 schemesPopup->append(p); 184 schemesPopup->append(p);
185 185
186 modeID[m] = modesPopup->insertItem(ModeName, schemesPopup->at(m)); 186 modeID[m] = modesPopup->insertItem(ModeName, schemesPopup->at(m));
187 modesPopup->setItemEnabled(modeID[m], FALSE); 187 modesPopup->setItemEnabled(modeID[m], FALSE);
188 modesPopup->setItemChecked(modeID[m], m == Mode); 188 modesPopup->setItemChecked(modeID[m], m == Mode);
189 } 189 }
190 190
191 schemeID.resize(SchemeCount); 191 schemeID.resize(SchemeCount);
192 schemeMode.resize(SchemeCount); 192 schemeMode.resize(SchemeCount);
193 193
194 QString SchemeGroup; 194 QString SchemeGroup;
195 QString SchemeName; 195 QString SchemeName;
196 int SchemeMode; 196 int SchemeMode;
197 197
198 for (int i = 0; i < SchemeCount; i++) { 198 for (int i = 0; i < SchemeCount; i++) {
199 SchemeGroup.sprintf("Scheme %d", i); 199 SchemeGroup.sprintf("Scheme %d", i);
200 cfg->setGroup(SchemeGroup); 200 cfg->setGroup(SchemeGroup);
201 201
202 SchemeName = cfg->readEntry("Description", SchemeGroup); 202 SchemeName = cfg->readEntry("Description", SchemeGroup);
203 SchemeMode = cfg->readNumEntry("Mode", -1); 203 SchemeMode = cfg->readNumEntry("Mode", -1);
204 204
205 schemeMode[i] = SchemeMode; 205 schemeMode[i] = SchemeMode;
206 if (SchemeMode == -1) { 206 if (SchemeMode == -1) {
207 schemeID[i] = modesPopup->insertItem(SchemeName); 207 schemeID[i] = modesPopup->insertItem(SchemeName);
208 modesPopup->setItemChecked(schemeID[i], i == Scheme); 208 modesPopup->setItemChecked(schemeID[i], i == Scheme);
209 } else { 209 } else {
210 schemeID[i] = schemesPopup->at(SchemeMode)->insertItem(SchemeName); 210 schemeID[i] = schemesPopup->at(SchemeMode)->insertItem(SchemeName);
211 schemesPopup->at(SchemeMode)-> 211 schemesPopup->at(SchemeMode)->
212 setItemChecked(schemeID[i], i == Scheme); 212 setItemChecked(schemeID[i], i == Scheme);
213 modesPopup->setItemEnabled(modeID[SchemeMode], TRUE); 213 modesPopup->setItemEnabled(modeID[SchemeMode], TRUE);
214 } 214 }
215 } 215 }
216 216
217 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 217 RESTORE_CONFIG_GROUP( cfg, oldgroup );
218 218
219 APP_CONFIG_END( cfg ); 219 APP_CONFIG_END( cfg );
220 return SchemeCount; 220 return SchemeCount;
221} 221}
222 222
223void Kpacman::quitKpacman() 223void Kpacman::quitKpacman()
224{ 224{
225 APP_QUIT(); 225 APP_QUIT();
226} 226}
227 227
228void Kpacman::newKpacman() 228void Kpacman::newKpacman()
229{ 229{
230 if (!gamePopup->isItemEnabled(hofID)) 230 if (!gamePopup->isItemEnabled(hofID))
231 gamePopup->setItemEnabled(hofID, TRUE); 231 gamePopup->setItemEnabled(hofID, TRUE);
232 232
233 if (gamePopup->isItemChecked(hofID)) 233 if (gamePopup->isItemChecked(hofID))
234 toggleHallOfFame(); 234 toggleHallOfFame();
235 235
236 if (gamePopup->isItemChecked(pauseID)) 236 if (gamePopup->isItemChecked(pauseID))
237 pauseKpacman(); 237 pauseKpacman();
238 238
239 view->referee->play(); 239 view->referee->play();
240} 240}
241 241
242void Kpacman::pauseKpacman() 242void Kpacman::pauseKpacman()
243{ 243{
244 view->referee->pause(); 244 view->referee->pause();
245 view->score->setPause(gamePopup->isItemChecked(pauseID)); 245 view->score->setPause(gamePopup->isItemChecked(pauseID));
246} 246}
247 247
248void Kpacman::toggleHallOfFame() 248void Kpacman::toggleHallOfFame()
249{ 249{
250 gamePopup->setItemChecked(hofID, !gamePopup->isItemChecked(hofID)); 250 gamePopup->setItemChecked(hofID, !gamePopup->isItemChecked(hofID));
251 view->referee->toggleHallOfFame(); 251 view->referee->toggleHallOfFame();
252 252
253 if (gamePopup->isItemChecked(hofID)) { 253 if (gamePopup->isItemChecked(hofID)) {
254 view->referee->lower(); 254 view->referee->lower();
255 view->status->lower(); 255 view->status->lower();
256 } else { 256 } else {
257 view->status->raise(); 257 view->status->raise();
258 view->referee->raise(); 258 view->referee->raise();
259 view->referee->setFocus(); 259 view->referee->setFocus();
260 } 260 }
261} 261}
262 262
263/* 263/*
264 * Disable or enable the "Hall of fame"-menuitem if the referee says so. 264 * Disable or enable the "Hall of fame"-menuitem if the referee says so.
265 * This is done, to disable turning off the "hall of fame"-display, in the automated 265 * This is done, to disable turning off the "hall of fame"-display, in the automated
266 * sequence of displaying the introduction, the demonstration (or playing) and the 266 * sequence of displaying the introduction, the demonstration (or playing) and the
267 * hall of fame. 267 * hall of fame.
268 * If on == TRUE then also lower the referee and the status widgets. 268 * If on == TRUE then also lower the referee and the status widgets.
269 */ 269 */
270void Kpacman::forcedHallOfFame(bool on) 270void Kpacman::forcedHallOfFame(bool on)
271{ 271{
272 if (!on && !gamePopup->isItemChecked(hofID)) 272 if (!on && !gamePopup->isItemChecked(hofID))
273 return; 273 return;
274 274
275 gamePopup->setItemEnabled(hofID, !on); 275 gamePopup->setItemEnabled(hofID, !on);
276 gamePopup->setItemChecked(hofID, on); 276 gamePopup->setItemChecked(hofID, on);
277 277
278 view->referee->toggleHallOfFame(); 278 view->referee->toggleHallOfFame();
279 if (on) { 279 if (on) {
280 view->referee->lower(); 280 view->referee->lower();
281 view->status->lower(); 281 view->status->lower();
282 } else { 282 } else {
283 view->status->raise(); 283 view->status->raise();
284 view->referee->raise(); 284 view->referee->raise();
285 view->referee->setFocus(); 285 view->referee->setFocus();
286 view->referee->intro(); 286 view->referee->intro();
287 } 287 }
288} 288}
289 289
290void Kpacman::togglePaused() 290void Kpacman::togglePaused()
291{ 291{
292 static bool checked = FALSE; 292 static bool checked = FALSE;
293 checked = !checked; 293 checked = !checked;
294 gamePopup->setItemChecked( pauseID, checked ); 294 gamePopup->setItemChecked( pauseID, checked );
295 view->score->setPause(gamePopup->isItemChecked(pauseID)); 295 view->score->setPause(gamePopup->isItemChecked(pauseID));
296} 296}
297 297
298/* 298/*
299 * This disables the "New Game" menuitem to prevent interruptions of the current 299 * This disables the "New Game" menuitem to prevent interruptions of the current
300 * play. 300 * play.
301 */ 301 */
302void Kpacman::toggleNew() 302void Kpacman::toggleNew()
303{ 303{
304 gamePopup->setItemEnabled(newID, !gamePopup->isItemEnabled(newID)); 304 gamePopup->setItemEnabled(newID, !gamePopup->isItemEnabled(newID));
305} 305}
306 306
307void Kpacman::toggleHideMouseCursor() 307void Kpacman::toggleHideMouseCursor()
308{ 308{
309 hideMouseCursor = !hideMouseCursor; 309 hideMouseCursor = !hideMouseCursor;
310 optionsPopup->setItemChecked(hideMouseCursorID, hideMouseCursor); 310 optionsPopup->setItemChecked(hideMouseCursorID, hideMouseCursor);
311 if (hideMouseCursor) 311 if (hideMouseCursor)
312 view->setCursor(blankCursor); 312 view->setCursor(blankCursor);
313 else 313 else
314 view->setCursor(arrowCursor); 314 view->setCursor(arrowCursor);
315} 315}
316 316
317void Kpacman::toggleFocusOutPause() 317void Kpacman::toggleFocusOutPause()
318{ 318{
319 focusOutPause = !focusOutPause; 319 focusOutPause = !focusOutPause;
320 optionsPopup->setItemChecked(focusOutPauseID, focusOutPause); 320 optionsPopup->setItemChecked(focusOutPauseID, focusOutPause);
321 view->referee->setFocusOutPause(focusOutPause); 321 view->referee->setFocusOutPause(focusOutPause);
322} 322}
323 323
324void Kpacman::toggleFocusInContinue() 324void Kpacman::toggleFocusInContinue()
325{ 325{
326 focusInContinue = !focusInContinue; 326 focusInContinue = !focusInContinue;
327 optionsPopup->setItemChecked(focusInContinueID, focusInContinue); 327 optionsPopup->setItemChecked(focusInContinueID, focusInContinue);
328 view->referee->setFocusInContinue(focusInContinue); 328 view->referee->setFocusInContinue(focusInContinue);
329} 329}
330 330
331void Kpacman::confKeys() 331void Kpacman::confKeys()
332{ 332{
333 Keys *keys = new Keys(); 333 Keys *keys = new Keys();
334 if (keys->exec() == QDialog::Accepted) { 334 if (keys->exec() == QDialog::Accepted) {
335 view->referee->initKeys(); 335 view->referee->initKeys();
336 view->score->initKeys(); 336 view->score->initKeys();
337 } 337 }
338 delete keys; 338 delete keys;
339} 339}
340 340
341void Kpacman::schemeChecked(int id) 341void Kpacman::schemeChecked(int id)
342{ 342{
343 int mode = 0, scheme = -1; 343 int mode = 0, scheme = -1;
344 344
345 for (uint s = 0; s < schemeID.size(); s++) { 345 for (uint s = 0; s < schemeID.size(); s++) {
346 if (schemeID[s] == id) { 346 if (schemeID[s] == id) {
347 scheme = s; 347 scheme = s;
348 mode = schemeMode[s]; 348 mode = schemeMode[s];
349 } 349 }
350 if (schemeMode[s] == -1) { 350 if (schemeMode[s] == -1) {
351 modesPopup->setItemChecked(schemeID[s], schemeID[s] == id); 351 modesPopup->setItemChecked(schemeID[s], schemeID[s] == id);
352 } else { 352 } else {
353 modesPopup->setItemChecked(modeID[schemeMode[s]], schemeMode[s] == mode); 353 modesPopup->setItemChecked(modeID[schemeMode[s]], schemeMode[s] == mode);
354 schemesPopup->at(schemeMode[s])->setItemChecked(schemeID[s], schemeID[s] == id); 354 schemesPopup->at(schemeMode[s])->setItemChecked(schemeID[s], schemeID[s] == id);
355 } 355 }
356 } 356 }
357 357
358 APP_CONFIG_BEGIN( cfg ); 358 APP_CONFIG_BEGIN( cfg );
359 cfg->writeEntry("Scheme", scheme); 359 cfg->writeEntry("Scheme", scheme);
360 cfg->writeEntry("Mode", mode); 360 cfg->writeEntry("Mode", mode);
361 APP_CONFIG_END( cfg ); 361 APP_CONFIG_END( cfg );
362 362
363 view->setScheme(scheme, mode); 363 view->setScheme(scheme, mode);
364 view->updateGeometry(); 364 view->updateGeometry();
365 updateGeometry(); 365 updateGeometry();
366 update(); 366 update();
367 repaint(TRUE); 367 repaint(TRUE);
368 show(); 368 show();
369} 369}
diff --git a/noncore/games/kpacman/kpacmanwidget.cpp b/noncore/games/kpacman/kpacmanwidget.cpp
index 330c88e..215dcda 100644
--- a/noncore/games/kpacman/kpacmanwidget.cpp
+++ b/noncore/games/kpacman/kpacmanwidget.cpp
@@ -1,162 +1,162 @@
1 1
2#include "portable.h" 2#include "portable.h"
3 3
4#if defined( KDE2_PORT ) 4#if defined( KDE2_PORT )
5#include <kapp.h> 5#include <kapp.h>
6#include <kconfig.h> 6#include <kconfig.h>
7#include <kstddirs.h> 7#include <kstddirs.h>
8#include <kpacmanwidget.h> 8#include <kpacmanwidget.h>
9#include <kpacmanwidget.moc> 9#include <kpacmanwidget.moc>
10#elif defined( QPE_PORT ) 10#elif defined( QPE_PORT )
11#include <qpe/qpeapplication.h> 11#include <qpe/qpeapplication.h>
12#include "config.h" 12#include "config.h"
13#include "kpacmanwidget.h" 13#include "kpacmanwidget.h"
14#endif 14#endif
15 15
16#include <qmessagebox.h> 16#include <qmessagebox.h>
17 17
18#include "bitfont.h" 18#include "bitfont.h"
19#include "score.h" 19#include "score.h"
20#include "referee.h" 20#include "referee.h"
21#include "status.h" 21#include "status.h"
22 22
23KpacmanWidget::KpacmanWidget( QWidget *parent, const char *name) 23KpacmanWidget::KpacmanWidget( QWidget *parent, const char *name)
24 : QWidget( parent, name ) 24 : QWidget( parent, name )
25{ 25{
26 bitfont = NULL; 26 bitfont = NULL;
27 fontName = ""; 27 fontName = "";
28 28
29 scheme = mode = -1; 29 scheme = mode = -1;
30 confScheme(); 30 confScheme();
31 31
32 score = new Score(this, name, scheme, mode, bitfont); 32 score = new Score(this, name, scheme, mode, bitfont);
33 referee = new Referee( this, name, scheme, mode, bitfont); 33 referee = new Referee( this, name, scheme, mode, bitfont);
34 status = new Status(this, name, scheme, mode); 34 status = new Status(this, name, scheme, mode);
35 35
36#ifndef QWS 36#ifndef QWS
37 setFixedSize(referee->width(), bitfont->height()*3 + referee->height() + status->height()); 37 setFixedSize(referee->width(), bitfont->height()*3 + referee->height() + status->height());
38#else 38#else
39 setBackgroundColor( black ); 39 setBackgroundColor( black );
40#endif 40#endif
41} 41}
42 42
43KpacmanWidget::~KpacmanWidget() 43KpacmanWidget::~KpacmanWidget()
44{ 44{
45} 45}
46 46
47void KpacmanWidget::confMisc(bool defGroup) 47void KpacmanWidget::confMisc(bool defGroup)
48{ 48{
49 APP_CONFIG_BEGIN( cfg ); 49 APP_CONFIG_BEGIN( cfg );
50 //KStandardDirs *dirs = KGlobal::dirs(); 50 //KStandardDirs *dirs = KGlobal::dirs();
51 QString findPath; 51 QString findPath;
52 52
53 if (defGroup || cfg->hasKey("Font")) { 53 if (defGroup || cfg->hasKey("Font")) {
54 fontName = cfg->readEntry("Font"); 54 fontName = cfg->readEntry("Font");
55 55
56 if (fontName.left(1) != "/" && fontName.left(1) != "~") 56 if (fontName.left(1) != "/" && fontName.left(1) != "~")
57 fontName.insert(0, "fonts/"); 57 fontName.insert(0, "fonts/");
58 if (fontName.right(1) == "/") 58 if (fontName.right(1) == "/")
59 fontName.append("font.xbm"); 59 fontName.append("font.xbm");
60 60
61 //findPath = dirs->findResource("appdata", fontName); 61 //findPath = dirs->findResource("appdata", fontName);
62 findPath = FIND_APP_DATA( fontName ); 62 findPath = FIND_APP_DATA( fontName );
63 if (!findPath.isEmpty()) 63 if (!findPath.isEmpty())
64 fontName = findPath; 64 fontName = findPath;
65 65
66 bitfontFirstChar = cfg->readNumEntry("FontFirstChar", 0x0e); 66 bitfontFirstChar = cfg->readNumEntry("FontFirstChar", 0x0e);
67 bitfontLastChar = cfg->readNumEntry("FontLastChar", 0x5f); 67 bitfontLastChar = cfg->readNumEntry("FontLastChar", 0x5f);
68 } 68 }
69 APP_CONFIG_END( cfg ); 69 APP_CONFIG_END( cfg );
70} 70}
71 71
72void KpacmanWidget::confScheme() 72void KpacmanWidget::confScheme()
73{ 73{
74 APP_CONFIG_BEGIN( cfg ); 74 APP_CONFIG_BEGIN( cfg );
75 QString lastFontName = fontName; 75 QString lastFontName = fontName;
76 SAVE_CONFIG_GROUP( cfg, oldgroup ); 76 SAVE_CONFIG_GROUP( cfg, oldgroup );
77 QString newgroup; 77 QString newgroup;
78 78
79 // if not set, read mode and scheme from the configfile 79 // if not set, read mode and scheme from the configfile
80 if (mode == -1 && scheme == -1) { 80 if (mode == -1 && scheme == -1) {
81 scheme = cfg->readNumEntry("Scheme", -1); 81 scheme = cfg->readNumEntry("Scheme", -1);
82 mode = cfg->readNumEntry("Mode", -1); 82 mode = cfg->readNumEntry("Mode", -1);
83 83
84 // if mode is not set in the defGroup-group, lookup the scheme group 84 // if mode is not set in the defGroup-group, lookup the scheme group
85 if (scheme != -1 || mode == -1) { 85 if (scheme != -1 || mode == -1) {
86 newgroup.sprintf("Scheme %d", scheme); 86 newgroup.sprintf("Scheme %d", scheme);
87 cfg->setGroup(newgroup); 87 cfg->setGroup(newgroup);
88 88
89 mode = cfg->readNumEntry("Mode", -1); 89 mode = cfg->readNumEntry("Mode", -1);
90 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 90 RESTORE_CONFIG_GROUP( cfg, oldgroup );
91 } 91 }
92 } 92 }
93 93
94 confMisc(); 94 confMisc();
95 95
96 if (mode != -1) { 96 if (mode != -1) {
97 newgroup.sprintf("Mode %d", mode); 97 newgroup.sprintf("Mode %d", mode);
98 cfg->setGroup(newgroup); 98 cfg->setGroup(newgroup);
99 99
100 confMisc(FALSE); 100 confMisc(FALSE);
101 } 101 }
102 102
103 if (scheme != -1) { 103 if (scheme != -1) {
104 newgroup.sprintf("Scheme %d", scheme); 104 newgroup.sprintf("Scheme %d", scheme);
105 cfg->setGroup(newgroup); 105 cfg->setGroup(newgroup);
106 106
107 confMisc(FALSE); 107 confMisc(FALSE);
108 } 108 }
109 109
110 if (lastFontName != fontName) { 110 if (lastFontName != fontName) {
111 111
112 if (bitfont != 0) 112 if (bitfont != 0)
113 delete bitfont; 113 delete bitfont;
114 114
115 bitfont = new Bitfont(fontName, bitfontFirstChar, bitfontLastChar); 115 bitfont = new Bitfont(fontName, bitfontFirstChar, bitfontLastChar);
116 if (bitfont->width() == 0 || bitfont->height() == 0) { 116 if (bitfont->width() == 0 || bitfont->height() == 0) {
117 QString msg = i18n("The bitfont could not be contructed.\n\n" 117 QString msg = tr("The bitfont could not be contructed.\n\n"
118 "The file '@FONTNAME@' does not exist,\n" 118 "The file '@FONTNAME@' does not exist,\n"
119 "or is of an unknown format."); 119 "or is of an unknown format.");
120 msg.replace(QRegExp("@FONTNAME@"), fontName); 120 msg.replace(QRegExp("@FONTNAME@"), fontName);
121 // QMessageBox::critical(this, i18n("Initialization Error"), msg); 121 // QMessageBox::critical(this, tr("Initialization Error"), msg);
122 printf("%s\n", msg.data()); 122 printf("%s\n", msg.data());
123 } 123 }
124 } 124 }
125 125
126 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 126 RESTORE_CONFIG_GROUP( cfg, oldgroup );
127 APP_CONFIG_END( cfg ); 127 APP_CONFIG_END( cfg );
128} 128}
129 129
130void KpacmanWidget::setScheme(int Scheme, int Mode) 130void KpacmanWidget::setScheme(int Scheme, int Mode)
131{ 131{
132 mode = Mode; 132 mode = Mode;
133 scheme = Scheme; 133 scheme = Scheme;
134 134
135 confScheme(); 135 confScheme();
136 136
137 score->setScheme(Scheme, Mode, bitfont); 137 score->setScheme(Scheme, Mode, bitfont);
138 referee->setScheme(Scheme, Mode, bitfont); 138 referee->setScheme(Scheme, Mode, bitfont);
139 status->setScheme(Scheme, Mode); 139 status->setScheme(Scheme, Mode);
140 140
141#ifndef QWS 141#ifndef QWS
142 setFixedSize(referee->width(), 142 setFixedSize(referee->width(),
143 bitfont->height()*3 + referee->height() + status->height()); 143 bitfont->height()*3 + referee->height() + status->height());
144#endif 144#endif
145 145
146 score->repaint(FALSE); 146 score->repaint(FALSE);
147 referee->repaint(FALSE); 147 referee->repaint(FALSE);
148 status->repaint(FALSE); 148 status->repaint(FALSE);
149} 149}
150 150
151void KpacmanWidget::resizeEvent( QResizeEvent * ) 151void KpacmanWidget::resizeEvent( QResizeEvent * )
152{ 152{
153 referee->setGeometry(0, bitfont->height()*3, referee->width(), referee->height()); 153 referee->setGeometry(0, bitfont->height()*3, referee->width(), referee->height());
154 referee->setBackgroundColor(BLACK); 154 referee->setBackgroundColor(BLACK);
155 155
156 status->setGeometry(0, bitfont->height()*3+referee->height(), referee->width(), 156 status->setGeometry(0, bitfont->height()*3+referee->height(), referee->width(),
157 status->height()); 157 status->height());
158 status->setBackgroundColor(BLACK); 158 status->setBackgroundColor(BLACK);
159 159
160 score->setGeometry(0, 0, referee->width(), bitfont->height()*3+referee->height()+status->height()); 160 score->setGeometry(0, 0, referee->width(), bitfont->height()*3+referee->height()+status->height());
161 score->setBackgroundColor(BLACK); 161 score->setBackgroundColor(BLACK);
162} 162}
diff --git a/noncore/games/kpacman/painter.cpp b/noncore/games/kpacman/painter.cpp
index 16fed55..80aeab0 100644
--- a/noncore/games/kpacman/painter.cpp
+++ b/noncore/games/kpacman/painter.cpp
@@ -1,465 +1,465 @@
1 1
2#include "portable.h" 2#include "portable.h"
3 3
4#if defined( KDE2_PORT ) 4#if defined( KDE2_PORT )
5#include <kapp.h> 5#include <kapp.h>
6#include <kconfig.h> 6#include <kconfig.h>
7#include <kstddirs.h> 7#include <kstddirs.h>
8#elif defined( QPE_PORT ) 8#elif defined( QPE_PORT )
9#include <qpe/qpeapplication.h> 9#include <qpe/qpeapplication.h>
10#include "config.h" 10#include "config.h"
11#endif 11#endif
12 12
13#include <qcolor.h> 13#include <qcolor.h>
14#include <qpainter.h> 14#include <qpainter.h>
15#include <qpixmap.h> 15#include <qpixmap.h>
16#include <qbitmap.h> 16#include <qbitmap.h>
17#include <qrect.h> 17#include <qrect.h>
18#include <qstring.h> 18#include <qstring.h>
19 19
20#include <qmessagebox.h> 20#include <qmessagebox.h>
21#include <qfileinfo.h> 21#include <qfileinfo.h>
22 22
23#include "painter.h" 23#include "painter.h"
24#include "board.h" 24#include "board.h"
25 25
26Painter::Painter( Board *b, QWidget *parent, int Scheme, int Mode, Bitfont *font) 26Painter::Painter( Board *b, QWidget *parent, int Scheme, int Mode, Bitfont *font)
27{ 27{
28 w = parent; 28 w = parent;
29 board = b; 29 board = b;
30 30
31 pointPix = NULL; 31 pointPix = NULL;
32 wallPix = NULL; 32 wallPix = NULL;
33 prisonPix = NULL; 33 prisonPix = NULL;
34 energizerPix = NULL; 34 energizerPix = NULL;
35 fruitPix = NULL; 35 fruitPix = NULL;
36 pacmanPix = NULL; 36 pacmanPix = NULL;
37 dyingPix = NULL; 37 dyingPix = NULL;
38 eyesPix = NULL; 38 eyesPix = NULL;
39 monsterPix = NULL; 39 monsterPix = NULL;
40 fruitScorePix = NULL; 40 fruitScorePix = NULL;
41 monsterScorePix = NULL; 41 monsterScorePix = NULL;
42 42
43 lastPointPixmapName = ""; 43 lastPointPixmapName = "";
44 lastWallPixmapName = ""; 44 lastWallPixmapName = "";
45 lastPrisonPixmapName = ""; 45 lastPrisonPixmapName = "";
46 lastEnergizerPixmapName = ""; 46 lastEnergizerPixmapName = "";
47 lastFruitPixmapName = ""; 47 lastFruitPixmapName = "";
48 lastPacmanPixmapName = ""; 48 lastPacmanPixmapName = "";
49 lastDyingPixmapName = ""; 49 lastDyingPixmapName = "";
50 lastEyesPixmapName = ""; 50 lastEyesPixmapName = "";
51 lastMonsterPixmapName = ""; 51 lastMonsterPixmapName = "";
52 lastFruitScorePixmapName = ""; 52 lastFruitScorePixmapName = "";
53 lastMonsterScorePixmapName = ""; 53 lastMonsterScorePixmapName = "";
54 54
55 bitfont = font; 55 bitfont = font;
56 56
57 scheme = Scheme; 57 scheme = Scheme;
58 mode = Mode; 58 mode = Mode;
59 level = 0; 59 level = 0;
60 60
61 confScheme(); 61 confScheme();
62} 62}
63 63
64QList<QPixmap> *Painter::loadPixmap(QWidget*, QString pixmapName, 64QList<QPixmap> *Painter::loadPixmap(QWidget*, QString pixmapName,
65 QList<QPixmap> *pixmaps) 65 QList<QPixmap> *pixmaps)
66{ 66{
67 if (pixmaps == NULL) { 67 if (pixmaps == NULL) {
68 pixmaps = new QList<QPixmap>; 68 pixmaps = new QList<QPixmap>;
69 pixmaps->setAutoDelete(TRUE); 69 pixmaps->setAutoDelete(TRUE);
70 } 70 }
71 71
72 if (!pixmaps->isEmpty()) 72 if (!pixmaps->isEmpty())
73 pixmaps->clear(); 73 pixmaps->clear();
74 74
75 QPixmap PIXMAP(pixmapName); 75 QPixmap PIXMAP(pixmapName);
76 if (PIXMAP.isNull() || PIXMAP.mask() == NULL) { 76 if (PIXMAP.isNull() || PIXMAP.mask() == NULL) {
77 QString msg = i18n("The pixmap could not be contructed.\n\n" 77 QString msg = "The pixmap could not be contructed.\n\n"
78 "The file '@PIXMAPNAME@' does not exist,\n" 78 "The file '@PIXMAPNAME@' does not exist,\n"
79 "or is of an unknown format."); 79 "or is of an unknown format.";
80 msg.replace(QRegExp("@PIXMAPNAME@"), pixmapName); 80 msg.replace(QRegExp("@PIXMAPNAME@"), pixmapName);
81 // QMessageBox::critical(parent, i18n("Initialization Error"), msg); 81 // QMessageBox::critical(parent, tr("Initialization Error"), msg);
82 printf("%s\n", msg.data()); 82 printf("%s\n", msg.data());
83 return 0; 83 return 0;
84 } 84 }
85 85
86 int height = PIXMAP.height(); 86 int height = PIXMAP.height();
87 int width = (height == 0) ? 0 : PIXMAP.width()/(PIXMAP.width()/height); 87 int width = (height == 0) ? 0 : PIXMAP.width()/(PIXMAP.width()/height);
88 88
89 QBitmap BITMAP; 89 QBitmap BITMAP;
90 QBitmap MASK; 90 QBitmap MASK;
91 91
92 BITMAP = *PIXMAP.mask(); 92 BITMAP = *PIXMAP.mask();
93 MASK.resize(width, height); 93 MASK.resize(width, height);
94 94
95 for (int x = 0; x < PIXMAP.width()/width; x++) { 95 for (int x = 0; x < PIXMAP.width()/width; x++) {
96 QPixmap *pixmap = new QPixmap(width, height); 96 QPixmap *pixmap = new QPixmap(width, height);
97 pixmaps->append(pixmap); 97 pixmaps->append(pixmap);
98 bitBlt(pixmap, 0, 0, &PIXMAP, x*width, 0, width, height, QPixmap::CopyROP, TRUE); 98 bitBlt(pixmap, 0, 0, &PIXMAP, x*width, 0, width, height, QPixmap::CopyROP, TRUE);
99 bitBlt(&MASK, 0, 0, &BITMAP, x*width, 0, width, height, QPixmap::CopyROP, TRUE); 99 bitBlt(&MASK, 0, 0, &BITMAP, x*width, 0, width, height, QPixmap::CopyROP, TRUE);
100 pixmap->setMask(MASK); 100 pixmap->setMask(MASK);
101 } 101 }
102 102
103 return pixmaps; 103 return pixmaps;
104} 104}
105 105
106QList<QPixmap> *Painter::textPixmap(QStrList &str, QList<QPixmap> *pixmaps, 106QList<QPixmap> *Painter::textPixmap(QStrList &str, QList<QPixmap> *pixmaps,
107 QColor fg, QColor bg) 107 QColor fg, QColor bg)
108{ 108{
109 if (pixmaps == NULL) { 109 if (pixmaps == NULL) {
110 pixmaps = new QList<QPixmap>; 110 pixmaps = new QList<QPixmap>;
111 pixmaps->setAutoDelete(TRUE); 111 pixmaps->setAutoDelete(TRUE);
112 } 112 }
113 113
114 if (!pixmaps->isEmpty()) 114 if (!pixmaps->isEmpty())
115 pixmaps->clear(); 115 pixmaps->clear();
116 116
117 for (uint s = 0; s < str.count(); s++) { 117 for (uint s = 0; s < str.count(); s++) {
118 QPixmap *pixmap = new QPixmap(bitfont->text(str.at(s), fg, bg)); 118 QPixmap *pixmap = new QPixmap(bitfont->text(str.at(s), fg, bg));
119 pixmaps->append(pixmap); 119 pixmaps->append(pixmap);
120 } 120 }
121 121
122 return pixmaps; 122 return pixmaps;
123} 123}
124 124
125QList<QPixmap> *Painter::textPixmap(QString str, QList<QPixmap> *pixmaps, 125QList<QPixmap> *Painter::textPixmap(QString str, QList<QPixmap> *pixmaps,
126 QColor fg, QColor bg) 126 QColor fg, QColor bg)
127{ 127{
128 if (pixmaps == NULL) { 128 if (pixmaps == NULL) {
129 pixmaps = new QList<QPixmap>; 129 pixmaps = new QList<QPixmap>;
130 pixmaps->setAutoDelete(TRUE); 130 pixmaps->setAutoDelete(TRUE);
131 } 131 }
132 132
133 if (!pixmaps->isEmpty()) 133 if (!pixmaps->isEmpty())
134 pixmaps->clear(); 134 pixmaps->clear();
135 135
136 QPixmap *pixmap = new QPixmap(bitfont->text(str, fg, bg)); 136 QPixmap *pixmap = new QPixmap(bitfont->text(str, fg, bg));
137 pixmaps->append(pixmap); 137 pixmaps->append(pixmap);
138 138
139 return pixmaps; 139 return pixmaps;
140} 140}
141 141
142/* Return the point of the upperleft pixel of the block representing that position 142/* Return the point of the upperleft pixel of the block representing that position
143 * on the board. 143 * on the board.
144 */ 144 */
145QPoint Painter::point(int pos) 145QPoint Painter::point(int pos)
146{ 146{
147 return QPoint((board->x(pos)-1)*BlockWidth, (board->y(pos)-1)*BlockHeight); 147 return QPoint((board->x(pos)-1)*BlockWidth, (board->y(pos)-1)*BlockHeight);
148} 148}
149 149
150 150
151QRect Painter::rect(int pos, PixMap pix, uint i) 151QRect Painter::rect(int pos, PixMap pix, uint i)
152{ 152{
153 if (pos == OUT) 153 if (pos == OUT)
154 return QRect(); 154 return QRect();
155 155
156 QPixmap *PIXMAP = NULL; 156 QPixmap *PIXMAP = NULL;
157 switch (pix) { 157 switch (pix) {
158 case PacmanPix : PIXMAP = pacmanPix-> 158 case PacmanPix : PIXMAP = pacmanPix->
159 at(checkRange(i, pacmanPix->count()-1)); 159 at(checkRange(i, pacmanPix->count()-1));
160 break; 160 break;
161 case DyingPix : PIXMAP = dyingPix-> 161 case DyingPix : PIXMAP = dyingPix->
162 at(checkRange(i, dyingPix->count()-1)); 162 at(checkRange(i, dyingPix->count()-1));
163 break; 163 break;
164 case MonsterPix : PIXMAP = monsterPix-> 164 case MonsterPix : PIXMAP = monsterPix->
165 at(checkRange(i, monsterPix->count()-1)); 165 at(checkRange(i, monsterPix->count()-1));
166 break; 166 break;
167 case EyesPix : PIXMAP = eyesPix-> 167 case EyesPix : PIXMAP = eyesPix->
168 at(checkRange(i, eyesPix->count()-1)); 168 at(checkRange(i, eyesPix->count()-1));
169 break; 169 break;
170 case FruitPix : PIXMAP = fruitPix-> 170 case FruitPix : PIXMAP = fruitPix->
171 at(checkRange(i, fruitPix->count()-1)); 171 at(checkRange(i, fruitPix->count()-1));
172 break; 172 break;
173 case PointPix : PIXMAP = pointPix-> 173 case PointPix : PIXMAP = pointPix->
174 at(checkRange(i, pointPix->count()-1)); 174 at(checkRange(i, pointPix->count()-1));
175 break; 175 break;
176 case EnergizerPix : PIXMAP = energizerPix-> 176 case EnergizerPix : PIXMAP = energizerPix->
177 at(checkRange(i, energizerPix->count()-1)); 177 at(checkRange(i, energizerPix->count()-1));
178 break; 178 break;
179 case FruitScorePix : PIXMAP = fruitScorePix-> 179 case FruitScorePix : PIXMAP = fruitScorePix->
180 at(checkRange(i, fruitScorePix->count()-1)); 180 at(checkRange(i, fruitScorePix->count()-1));
181 break; 181 break;
182 case MonsterScorePix : PIXMAP = monsterScorePix-> 182 case MonsterScorePix : PIXMAP = monsterScorePix->
183 at(checkRange(i,monsterScorePix->count()-1)); 183 at(checkRange(i,monsterScorePix->count()-1));
184 break; 184 break;
185 default : PIXMAP = wallPix-> 185 default : PIXMAP = wallPix->
186 at(checkRange(i, wallPix->count()-1)); 186 at(checkRange(i, wallPix->count()-1));
187 } 187 }
188 if (PIXMAP == NULL) 188 if (PIXMAP == NULL)
189 return QRect(); 189 return QRect();
190 190
191 QRect rect = PIXMAP->rect(); 191 QRect rect = PIXMAP->rect();
192 QPoint point = this->point(pos); 192 QPoint point = this->point(pos);
193 rect.moveCenter(QPoint(point.x()-1, point.y()-1)); 193 rect.moveCenter(QPoint(point.x()-1, point.y()-1));
194 194
195 return rect; 195 return rect;
196} 196}
197 197
198QRect Painter::rect(int pos, QString str, int align) 198QRect Painter::rect(int pos, QString str, int align)
199{ 199{
200 if (pos == OUT) // return an empty rect if the position 200 if (pos == OUT) // return an empty rect if the position
201 return QRect(); // is invalid 201 return QRect(); // is invalid
202 QPoint point = this->point(pos); 202 QPoint point = this->point(pos);
203 QRect rect = bitfont->rect(str); 203 QRect rect = bitfont->rect(str);
204 204
205 rect.moveCenter(QPoint(point.x()-1, point.y()-1)); 205 rect.moveCenter(QPoint(point.x()-1, point.y()-1));
206 206
207 int dx = 0; 207 int dx = 0;
208 int dy = 0; 208 int dy = 0;
209 209
210 if (align & QLabel::AlignLeft || align & QLabel::AlignRight) { 210 if (align & QLabel::AlignLeft || align & QLabel::AlignRight) {
211 dx = (str.length()-1) * (bitfont->width()/2); 211 dx = (str.length()-1) * (bitfont->width()/2);
212 if (align & QLabel::AlignRight) 212 if (align & QLabel::AlignRight)
213 dx *= -1; 213 dx *= -1;
214 } 214 }
215 215
216 if (align & QLabel::AlignTop || align & QLabel::AlignBottom) { 216 if (align & QLabel::AlignTop || align & QLabel::AlignBottom) {
217 dy = bitfont->height()/2; 217 dy = bitfont->height()/2;
218 if (align & QLabel::AlignBottom) 218 if (align & QLabel::AlignBottom)
219 dy *= -1; 219 dy *= -1;
220 } 220 }
221 221
222 if (dx != 0 || dy != 0) 222 if (dx != 0 || dy != 0)
223 rect.moveBy(dx, dy); 223 rect.moveBy(dx, dy);
224 224
225 return rect; 225 return rect;
226} 226}
227 227
228QRect Painter::rect(QRect r1, QRect r2) 228QRect Painter::rect(QRect r1, QRect r2)
229{ 229{
230 QRect rect; 230 QRect rect;
231 rect.setLeft(r1.left() < r2.left() ? r1.left() : r2.left()); 231 rect.setLeft(r1.left() < r2.left() ? r1.left() : r2.left());
232 rect.setTop(r1.top() < r2.top() ? r1.top() : r2.top()); 232 rect.setTop(r1.top() < r2.top() ? r1.top() : r2.top());
233 rect.setRight(r1.right() > r2.right() ? r1.right() : r2.right()); 233 rect.setRight(r1.right() > r2.right() ? r1.right() : r2.right());
234 rect.setBottom(r1.bottom() > r2.bottom() ? r1.bottom() : r2.bottom()); 234 rect.setBottom(r1.bottom() > r2.bottom() ? r1.bottom() : r2.bottom());
235 235
236 return rect; 236 return rect;
237} 237}
238 238
239void Painter::erase(int pos, PixMap pix, uint i) 239void Painter::erase(int pos, PixMap pix, uint i)
240{ 240{
241 if (pos == OUT) 241 if (pos == OUT)
242 return; 242 return;
243 QRect rect = this->rect(pos, pix, i); 243 QRect rect = this->rect(pos, pix, i);
244 bitBlt(&roomPix, rect.x(), rect.y(), &backPix, 244 bitBlt(&roomPix, rect.x(), rect.y(), &backPix,
245 rect.x(), rect.y(), rect.width(), rect.height()); 245 rect.x(), rect.y(), rect.width(), rect.height());
246} 246}
247 247
248int Painter::maxPixmaps(PixMap pix) 248int Painter::maxPixmaps(PixMap pix)
249{ 249{
250 switch (pix) { 250 switch (pix) {
251 case WallPix : return (int) wallPix->count(); 251 case WallPix : return (int) wallPix->count();
252 case PrisonPix : return (int) prisonPix->count(); 252 case PrisonPix : return (int) prisonPix->count();
253 case PointPix : return (int) pointPix->count(); 253 case PointPix : return (int) pointPix->count();
254 case EnergizerPix : return (int) energizerPix->count(); 254 case EnergizerPix : return (int) energizerPix->count();
255 case FruitPix : return (int) fruitPix->count(); 255 case FruitPix : return (int) fruitPix->count();
256 case PacmanPix : return (int) pacmanPix->count(); 256 case PacmanPix : return (int) pacmanPix->count();
257 case DyingPix : return (int) dyingPix->count(); 257 case DyingPix : return (int) dyingPix->count();
258 case EyesPix : return (int) eyesPix->count(); 258 case EyesPix : return (int) eyesPix->count();
259 case MonsterPix : return (int) monsterPix->count(); 259 case MonsterPix : return (int) monsterPix->count();
260 case FruitScorePix : return (int) fruitScorePix->count(); 260 case FruitScorePix : return (int) fruitScorePix->count();
261 case MonsterScorePix : return (int) monsterScorePix->count(); 261 case MonsterScorePix : return (int) monsterScorePix->count();
262 default : return 0; 262 default : return 0;
263 } 263 }
264} 264}
265 265
266void Painter::draw(QPoint point, DrawWidget where, QPixmap pix) 266void Painter::draw(QPoint point, DrawWidget where, QPixmap pix)
267{ 267{
268 switch (where) { 268 switch (where) {
269 case Widget : bitBlt(w, point.x(), point.y(), &pix); 269 case Widget : bitBlt(w, point.x(), point.y(), &pix);
270 break; 270 break;
271 case RoomPix : bitBlt(&roomPix, point.x(), point.y(), &pix); 271 case RoomPix : bitBlt(&roomPix, point.x(), point.y(), &pix);
272 break; 272 break;
273 case BackPix : bitBlt(&backPix, point.x(), point.y(), &pix); 273 case BackPix : bitBlt(&backPix, point.x(), point.y(), &pix);
274 break; 274 break;
275 } 275 }
276} 276}
277 277
278void Painter::draw(QRect rect, DrawWidget where, QPixmap pix) 278void Painter::draw(QRect rect, DrawWidget where, QPixmap pix)
279{ 279{
280 draw(QPoint(rect.x(), rect.y()), where, pix); 280 draw(QPoint(rect.x(), rect.y()), where, pix);
281} 281}
282 282
283void Painter::draw(int pos, DrawWidget where, PixMap pix, uint i) 283void Painter::draw(int pos, DrawWidget where, PixMap pix, uint i)
284{ 284{
285 QPixmap *PIXMAP = NULL; 285 QPixmap *PIXMAP = NULL;
286 switch (pix) { 286 switch (pix) {
287 case PacmanPix : PIXMAP = pacmanPix-> 287 case PacmanPix : PIXMAP = pacmanPix->
288 at(checkRange(i, pacmanPix->count()-1)); 288 at(checkRange(i, pacmanPix->count()-1));
289 break; 289 break;
290 case DyingPix : PIXMAP = dyingPix-> 290 case DyingPix : PIXMAP = dyingPix->
291 at(checkRange(i, dyingPix->count()-1)); 291 at(checkRange(i, dyingPix->count()-1));
292 break; 292 break;
293 case MonsterPix : PIXMAP = monsterPix-> 293 case MonsterPix : PIXMAP = monsterPix->
294 at(checkRange(i, monsterPix->count()-1)); 294 at(checkRange(i, monsterPix->count()-1));
295 break; 295 break;
296 case EyesPix : PIXMAP = eyesPix-> 296 case EyesPix : PIXMAP = eyesPix->
297 at(checkRange(i, eyesPix->count()-1)); 297 at(checkRange(i, eyesPix->count()-1));
298 break; 298 break;
299 case FruitPix : PIXMAP = fruitPix-> 299 case FruitPix : PIXMAP = fruitPix->
300 at(checkRange(i, fruitPix->count()-1)); 300 at(checkRange(i, fruitPix->count()-1));
301 break; 301 break;
302 case EnergizerPix : PIXMAP = energizerPix-> 302 case EnergizerPix : PIXMAP = energizerPix->
303 at(checkRange(i, energizerPix->count()-1)); 303 at(checkRange(i, energizerPix->count()-1));
304 break; 304 break;
305 case FruitScorePix : PIXMAP = fruitScorePix-> 305 case FruitScorePix : PIXMAP = fruitScorePix->
306 at(checkRange(i, fruitScorePix->count()-1)); 306 at(checkRange(i, fruitScorePix->count()-1));
307 break; 307 break;
308 case MonsterScorePix : PIXMAP = monsterScorePix-> 308 case MonsterScorePix : PIXMAP = monsterScorePix->
309 at(checkRange(i,monsterScorePix->count()-1)); 309 at(checkRange(i,monsterScorePix->count()-1));
310 break; 310 break;
311 default : ; 311 default : ;
312 } 312 }
313 313
314 if (PIXMAP == NULL) 314 if (PIXMAP == NULL)
315 return; 315 return;
316 316
317 QRect rect = PIXMAP->rect(); 317 QRect rect = PIXMAP->rect();
318 QPoint point = this->point(pos); 318 QPoint point = this->point(pos);
319 rect.moveCenter(QPoint(point.x()-1, point.y()-1)); 319 rect.moveCenter(QPoint(point.x()-1, point.y()-1));
320 320
321 switch (where) { 321 switch (where) {
322 case Widget : bitBlt(w, rect.x(), rect.y(), PIXMAP); 322 case Widget : bitBlt(w, rect.x(), rect.y(), PIXMAP);
323 break; 323 break;
324 case RoomPix : bitBlt(&roomPix, rect.x(), rect.y(), PIXMAP); 324 case RoomPix : bitBlt(&roomPix, rect.x(), rect.y(), PIXMAP);
325 break; 325 break;
326 case BackPix : bitBlt(&backPix, rect.x(), rect.y(), PIXMAP); 326 case BackPix : bitBlt(&backPix, rect.x(), rect.y(), PIXMAP);
327 break; 327 break;
328 } 328 }
329} 329}
330 330
331QPixmap Painter::draw(int pos, DrawWidget where, 331QPixmap Painter::draw(int pos, DrawWidget where,
332 QString str, QColor fg, QColor bg, int align) 332 QString str, QColor fg, QColor bg, int align)
333{ 333{
334 QPixmap TEXT = bitfont->text(str, fg, bg); 334 QPixmap TEXT = bitfont->text(str, fg, bg);
335 335
336 QRect rect = this->rect(pos, str, align); 336 QRect rect = this->rect(pos, str, align);
337 QPixmap SAVE = QPixmap(rect.width(), rect.height()); 337 QPixmap SAVE = QPixmap(rect.width(), rect.height());
338 338
339 switch (where) { 339 switch (where) {
340 case Widget : bitBlt(&SAVE, 0, 0, w, rect.x(), rect.y()); 340 case Widget : bitBlt(&SAVE, 0, 0, w, rect.x(), rect.y());
341 bitBlt(w, rect.x(), rect.y(), &TEXT); 341 bitBlt(w, rect.x(), rect.y(), &TEXT);
342 break; 342 break;
343 case RoomPix : bitBlt(&SAVE, 0, 0, &roomPix, rect.x(), rect.y()); 343 case RoomPix : bitBlt(&SAVE, 0, 0, &roomPix, rect.x(), rect.y());
344 bitBlt(&roomPix, rect.x(), rect.y(), &TEXT); 344 bitBlt(&roomPix, rect.x(), rect.y(), &TEXT);
345 break; 345 break;
346 case BackPix : bitBlt(&SAVE, 0, 0, &backPix, rect.x(), rect.y()); 346 case BackPix : bitBlt(&SAVE, 0, 0, &backPix, rect.x(), rect.y());
347 bitBlt(&backPix, rect.x(), rect.y(), &TEXT); 347 bitBlt(&backPix, rect.x(), rect.y(), &TEXT);
348 break; 348 break;
349 } 349 }
350 350
351 return SAVE; 351 return SAVE;
352} 352}
353 353
354QRect Painter::draw(int col, int row, DrawWidget where, 354QRect Painter::draw(int col, int row, DrawWidget where,
355 QString str, QColor fg, QColor bg, int align) 355 QString str, QColor fg, QColor bg, int align)
356{ 356{
357 QPixmap TEXT = bitfont->text(str, fg, bg); 357 QPixmap TEXT = bitfont->text(str, fg, bg);
358 358
359 QRect rect = this->rect(row*BoardWidth+col, str, align); 359 QRect rect = this->rect(row*BoardWidth+col, str, align);
360 draw(rect, where, TEXT); 360 draw(rect, where, TEXT);
361 361
362 return rect; 362 return rect;
363} 363}
364 364
365void Painter::initPixmaps() 365void Painter::initPixmaps()
366{ 366{
367 if (lastPointPixmapName != pointPixmapName.at(level)) { 367 if (lastPointPixmapName != pointPixmapName.at(level)) {
368 pointPix = loadPixmap(w, pointPixmapName.at(level), pointPix); 368 pointPix = loadPixmap(w, pointPixmapName.at(level), pointPix);
369 lastPointPixmapName = pointPixmapName.at(level); 369 lastPointPixmapName = pointPixmapName.at(level);
370 } 370 }
371 if (lastPrisonPixmapName != prisonPixmapName.at(level)) { 371 if (lastPrisonPixmapName != prisonPixmapName.at(level)) {
372 prisonPix = loadPixmap(w, prisonPixmapName.at(level), prisonPix); 372 prisonPix = loadPixmap(w, prisonPixmapName.at(level), prisonPix);
373 lastPrisonPixmapName = prisonPixmapName.at(level); 373 lastPrisonPixmapName = prisonPixmapName.at(level);
374 } 374 }
375 if (lastEnergizerPixmapName != energizerPixmapName.at(level)) { 375 if (lastEnergizerPixmapName != energizerPixmapName.at(level)) {
376 energizerPix = loadPixmap(w, energizerPixmapName.at(level), energizerPix); 376 energizerPix = loadPixmap(w, energizerPixmapName.at(level), energizerPix);
377 lastEnergizerPixmapName = energizerPixmapName.at(level); 377 lastEnergizerPixmapName = energizerPixmapName.at(level);
378 } 378 }
379 if (lastFruitPixmapName != fruitPixmapName.at(level)) { 379 if (lastFruitPixmapName != fruitPixmapName.at(level)) {
380 fruitPix = loadPixmap(w, fruitPixmapName.at(level), fruitPix); 380 fruitPix = loadPixmap(w, fruitPixmapName.at(level), fruitPix);
381 lastFruitPixmapName = fruitPixmapName.at(level); 381 lastFruitPixmapName = fruitPixmapName.at(level);
382 } 382 }
383 if (lastPacmanPixmapName != pacmanPixmapName.at(level)) { 383 if (lastPacmanPixmapName != pacmanPixmapName.at(level)) {
384 pacmanPix = loadPixmap(w, pacmanPixmapName.at(level), pacmanPix); 384 pacmanPix = loadPixmap(w, pacmanPixmapName.at(level), pacmanPix);
385 lastPacmanPixmapName = pacmanPixmapName.at(level); 385 lastPacmanPixmapName = pacmanPixmapName.at(level);
386 } 386 }
387 if (lastDyingPixmapName != dyingPixmapName.at(level)) { 387 if (lastDyingPixmapName != dyingPixmapName.at(level)) {
388 dyingPix = loadPixmap(w, dyingPixmapName.at(level), dyingPix); 388 dyingPix = loadPixmap(w, dyingPixmapName.at(level), dyingPix);
389 lastDyingPixmapName = dyingPixmapName.at(level); 389 lastDyingPixmapName = dyingPixmapName.at(level);
390 } 390 }
391 if (lastEyesPixmapName != eyesPixmapName.at(level)) { 391 if (lastEyesPixmapName != eyesPixmapName.at(level)) {
392 eyesPix = loadPixmap(w, eyesPixmapName.at(level), eyesPix); 392 eyesPix = loadPixmap(w, eyesPixmapName.at(level), eyesPix);
393 lastEyesPixmapName = eyesPixmapName.at(level); 393 lastEyesPixmapName = eyesPixmapName.at(level);
394 } 394 }
395 if (lastMonsterPixmapName != monsterPixmapName.at(level)) { 395 if (lastMonsterPixmapName != monsterPixmapName.at(level)) {
396 monsterPix = loadPixmap(w, monsterPixmapName.at(level), monsterPix); 396 monsterPix = loadPixmap(w, monsterPixmapName.at(level), monsterPix);
397 lastMonsterPixmapName = monsterPixmapName.at(level); 397 lastMonsterPixmapName = monsterPixmapName.at(level);
398 } 398 }
399 399
400 if (lastFruitScorePixmapName != fruitScorePixmapName.at(level) || 400 if (lastFruitScorePixmapName != fruitScorePixmapName.at(level) ||
401 (const char *) *fruitScorePixmapName.at(level) == '\0') { 401 (const char *) *fruitScorePixmapName.at(level) == '\0') {
402 if ((const char *) *fruitScorePixmapName.at(level) == '\0') { 402 if ((const char *) *fruitScorePixmapName.at(level) == '\0') {
403 fruitScorePix = textPixmap(fruitScoreString, fruitScorePix, PINK); 403 fruitScorePix = textPixmap(fruitScoreString, fruitScorePix, PINK);
404 } else { 404 } else {
405 fruitScorePix = loadPixmap(w, fruitScorePixmapName.at(level), 405 fruitScorePix = loadPixmap(w, fruitScorePixmapName.at(level),
406 fruitScorePix); 406 fruitScorePix);
407 lastFruitScorePixmapName = fruitScorePixmapName.at(level); 407 lastFruitScorePixmapName = fruitScorePixmapName.at(level);
408 } 408 }
409 } 409 }
410 410
411 if (lastMonsterScorePixmapName != monsterScorePixmapName.at(level) || 411 if (lastMonsterScorePixmapName != monsterScorePixmapName.at(level) ||
412 (const char *) *monsterScorePixmapName.at(level) == '\0') { 412 (const char *) *monsterScorePixmapName.at(level) == '\0') {
413 if ((const char *) *monsterScorePixmapName.at(level) == '\0') { 413 if ((const char *) *monsterScorePixmapName.at(level) == '\0') {
414 monsterScorePix = textPixmap(monsterScoreString, monsterScorePix, CYAN); 414 monsterScorePix = textPixmap(monsterScoreString, monsterScorePix, CYAN);
415 } else { 415 } else {
416 monsterScorePix = loadPixmap(w, monsterScorePixmapName.at(level), 416 monsterScorePix = loadPixmap(w, monsterScorePixmapName.at(level),
417 monsterScorePix); 417 monsterScorePix);
418 lastMonsterScorePixmapName = monsterScorePixmapName.at(level); 418 lastMonsterScorePixmapName = monsterScorePixmapName.at(level);
419 } 419 }
420 } 420 }
421 421
422 if (lastWallPixmapName != wallPixmapName.at(level)) { 422 if (lastWallPixmapName != wallPixmapName.at(level)) {
423 wallPix = loadPixmap(w, wallPixmapName.at(level), wallPix); 423 wallPix = loadPixmap(w, wallPixmapName.at(level), wallPix);
424 if (wallPix->isEmpty()) { 424 if (wallPix->isEmpty()) {
425 BlockWidth = 0; 425 BlockWidth = 0;
426 BlockHeight = 0; 426 BlockHeight = 0;
427 } else { 427 } else {
428 BlockWidth = wallPix->at(0)->width(); 428 BlockWidth = wallPix->at(0)->width();
429 BlockHeight = wallPix->at(0)->height(); 429 BlockHeight = wallPix->at(0)->height();
430 } 430 }
431 lastWallPixmapName = wallPixmapName.at(level); 431 lastWallPixmapName = wallPixmapName.at(level);
432 } 432 }
433} 433}
434 434
435void Painter::initbackPixmaps() 435void Painter::initbackPixmaps()
436{ 436{
437 backgroundColor = BLACK; 437 backgroundColor = BLACK;
438 438
439 backPix.resize((BoardWidth-3)*BlockWidth, (BoardHeight-3)*BlockHeight ); 439 backPix.resize((BoardWidth-3)*BlockWidth, (BoardHeight-3)*BlockHeight );
440 backPix.fill(backgroundColor); 440 backPix.fill(backgroundColor);
441} 441}
442 442
443void Painter::initRoomPixmap() 443void Painter::initRoomPixmap()
444{ 444{
445 roomPix.resize((BoardWidth-3)*BlockWidth, (BoardHeight-3)*BlockHeight ); 445 roomPix.resize((BoardWidth-3)*BlockWidth, (BoardHeight-3)*BlockHeight );
446 bitBlt(&roomPix,0,0, &backPix); 446 bitBlt(&roomPix,0,0, &backPix);
447 447
448 for (unsigned int x = 0; x < board->size(); x++) { 448 for (unsigned int x = 0; x < board->size(); x++) {
449 if (board->isBrick(x)) 449 if (board->isBrick(x))
450 drawBrick(x); 450 drawBrick(x);
451 if (board->isPrison(x) || board->isGate(x)) 451 if (board->isPrison(x) || board->isGate(x))
452 drawPrison(x); 452 drawPrison(x);
453 if (board->isPoint(x)) 453 if (board->isPoint(x))
454 drawPoint(x); 454 drawPoint(x);
455 } 455 }
456} 456}
457 457
458void Painter::drawBrick(int pos) 458void Painter::drawBrick(int pos)
459{ 459{
460 int border = 0; 460 int border = 0;
461 if (board->isBrick(board->move(pos, N ))) border |= (1 << 0); 461 if (board->isBrick(board->move(pos, N ))) border |= (1 << 0);
462 if (board->isBrick(board->move(pos, NE))) border |= (1 << 1); 462 if (board->isBrick(board->move(pos, NE))) border |= (1 << 1);
463 if (board->isBrick(board->move(pos, E ))) border |= (1 << 2); 463 if (board->isBrick(board->move(pos, E ))) border |= (1 << 2);
464 if (board->isBrick(board->move(pos, SE))) border |= (1 << 3); 464 if (board->isBrick(board->move(pos, SE))) border |= (1 << 3);
465 if (board->isBrick(board->move(pos, S ))) border |= (1 << 4); 465 if (board->isBrick(board->move(pos, S ))) border |= (1 << 4);
diff --git a/noncore/games/kpacman/referee.cpp b/noncore/games/kpacman/referee.cpp
index 567a8ed..9edaabd 100644
--- a/noncore/games/kpacman/referee.cpp
+++ b/noncore/games/kpacman/referee.cpp
@@ -1,1426 +1,1426 @@
1 1
2#include "portable.h" 2#include "portable.h"
3 3
4#if defined( KDE2_PORT ) 4#if defined( KDE2_PORT )
5#include <kapp.h> 5#include <kapp.h>
6#include <kconfig.h> 6#include <kconfig.h>
7#include <kstddirs.h> 7#include <kstddirs.h>
8#include <kaccel.h> 8#include <kaccel.h>
9#include <referee.h> 9#include <referee.h>
10#include <referee.moc> 10#include <referee.moc>
11#elif defined( QPE_PORT ) 11#elif defined( QPE_PORT )
12#include <qaccel.h> 12#include <qaccel.h>
13#include <qpe/qpeapplication.h> 13#include <qpe/qpeapplication.h>
14#include "config.h" 14#include "config.h"
15#include "referee.h" 15#include "referee.h"
16#endif 16#endif
17 17
18#include <qdatetm.h> 18#include <qdatetm.h>
19#include <stdlib.h> 19#include <stdlib.h>
20#include <qtimer.h> 20#include <qtimer.h>
21#include <qevent.h> 21#include <qevent.h>
22#include <qcolor.h> 22#include <qcolor.h>
23#include <qkeycode.h> 23#include <qkeycode.h>
24#include <qfileinfo.h> 24#include <qfileinfo.h>
25 25
26#include "board.h" 26#include "board.h"
27#include "pacman.h" 27#include "pacman.h"
28#include "monster.h" 28#include "monster.h"
29#include "fruit.h" 29#include "fruit.h"
30#include "painter.h" 30#include "painter.h"
31 31
32Referee::Referee( QWidget *parent, const char *name, int Scheme, int Mode, Bitfont *font) 32Referee::Referee( QWidget *parent, const char *name, int Scheme, int Mode, Bitfont *font)
33 : QWidget( parent, name ) 33 : QWidget( parent, name )
34{ 34{
35 gameState.resize(12); 35 gameState.resize(12);
36 gameTimer = 0; 36 gameTimer = 0;
37 energizerTimer = 0; 37 energizerTimer = 0;
38 38
39 focusedPause = FALSE; 39 focusedPause = FALSE;
40 setFocusPolicy(QWidget::StrongFocus); 40 setFocusPolicy(QWidget::StrongFocus);
41 41
42 initKeys(); 42 initKeys();
43 43
44 scheme = Scheme; 44 scheme = Scheme;
45 mode = Mode; 45 mode = Mode;
46 confScheme(); 46 confScheme();
47 47
48 board = new Board(BoardWidth*BoardHeight); 48 board = new Board(BoardWidth*BoardHeight);
49 49
50 pix = new Painter(board, this, scheme, mode, font); 50 pix = new Painter(board, this, scheme, mode, font);
51 setFixedSize(pix->levelPix().size()); 51 setFixedSize(pix->levelPix().size());
52 52
53 pacman = new Pacman(board); 53 pacman = new Pacman(board);
54 54
55 fruit = new Fruit(board); 55 fruit = new Fruit(board);
56 56
57 monsters = new QList<Monster>; 57 monsters = new QList<Monster>;
58 monsters->setAutoDelete(TRUE); 58 monsters->setAutoDelete(TRUE);
59 59
60 monsterRect = new QList<QRect>; 60 monsterRect = new QList<QRect>;
61 monsterRect->setAutoDelete(TRUE); 61 monsterRect->setAutoDelete(TRUE);
62 62
63 energizers = new QList<Energizer>; 63 energizers = new QList<Energizer>;
64 energizers->setAutoDelete(TRUE); 64 energizers->setAutoDelete(TRUE);
65 65
66 energizerRect = new QList<QRect>; 66 energizerRect = new QList<QRect>;
67 energizerRect->setAutoDelete(TRUE); 67 energizerRect->setAutoDelete(TRUE);
68 68
69 pacmanRect.setRect(0, 0, 0, 0); 69 pacmanRect.setRect(0, 0, 0, 0);
70 fruitRect.setRect(0, 0, 0, 0); 70 fruitRect.setRect(0, 0, 0, 0);
71 71
72 QTime midnight( 0, 0, 0 ); 72 QTime midnight( 0, 0, 0 );
73 srand( midnight.secsTo(QTime::currentTime()) ); 73 srand( midnight.secsTo(QTime::currentTime()) );
74 74
75 lifes = 0; 75 lifes = 0;
76 points = 0; 76 points = 0;
77 77
78 emit setLifes(lifes); 78 emit setLifes(lifes);
79 emit setPoints(points); 79 emit setPoints(points);
80 80
81 intro(); 81 intro();
82} 82}
83 83
84void Referee::paintEvent( QPaintEvent *e) 84void Referee::paintEvent( QPaintEvent *e)
85{ 85{
86 if (gameState.testBit(HallOfFame)) 86 if (gameState.testBit(HallOfFame))
87 return; 87 return;
88 88
89 QRect rect = e->rect(); 89 QRect rect = e->rect();
90 90
91 if (!rect.isEmpty()) { 91 if (!rect.isEmpty()) {
92 QPixmap p = pix->levelPix(); 92 QPixmap p = pix->levelPix();
93 bitBlt(this, rect.x(), rect.y(), 93 bitBlt(this, rect.x(), rect.y(),
94 &p, rect.x(), rect.y(), rect.width(), rect.height()); 94 &p, rect.x(), rect.y(), rect.width(), rect.height());
95 } 95 }
96 96
97 if ((gameState.testBit(GameOver) || gameState.testBit(Demonstration)) && 97 if ((gameState.testBit(GameOver) || gameState.testBit(Demonstration)) &&
98 rect.intersects(pix->rect(board->position(fruithome), i18n("GAME OVER")))) 98 rect.intersects(pix->rect(board->position(fruithome), tr("GAME OVER"))))
99 pix->draw(board->position(fruithome), Widget, i18n("GAME OVER"), RED); 99 pix->draw(board->position(fruithome), Widget, tr("GAME OVER"), RED);
100 100
101 for (Energizer *e = energizers->first(); e != 0; e = energizers->next()) { 101 for (Energizer *e = energizers->first(); e != 0; e = energizers->next()) {
102 if (e && e->state() == on && 102 if (e && e->state() == on &&
103 rect.intersects(pix->rect(e->position(), EnergizerPix)) && 103 rect.intersects(pix->rect(e->position(), EnergizerPix)) &&
104 !(e->position() == pacman->position() && gameState.testBit(Scoring))) { 104 !(e->position() == pacman->position() && gameState.testBit(Scoring))) {
105 if (e->pix() != -1) 105 if (e->pix() != -1)
106 pix->draw(e->position(), Widget, EnergizerPix, e->pix()); 106 pix->draw(e->position(), Widget, EnergizerPix, e->pix());
107 } 107 }
108 } 108 }
109 109
110 if (!gameState.testBit(Init)) { 110 if (!gameState.testBit(Init)) {
111 111
112 if (!gameState.testBit(Dying) && (fruit->pix() != -1)) 112 if (!gameState.testBit(Dying) && (fruit->pix() != -1))
113 if (fruit->state() != active) { 113 if (fruit->state() != active) {
114 if (rect.intersects(pix->rect(fruit->position(), FruitScorePix, fruit->pix()))) 114 if (rect.intersects(pix->rect(fruit->position(), FruitScorePix, fruit->pix())))
115 pix->draw(fruit->position(), Widget, FruitScorePix, fruit->pix()); 115 pix->draw(fruit->position(), Widget, FruitScorePix, fruit->pix());
116 } else { 116 } else {
117 if (rect.intersects(pix->rect(fruit->position(), FruitPix, fruit->pix()))) 117 if (rect.intersects(pix->rect(fruit->position(), FruitPix, fruit->pix())))
118 pix->draw(fruit->position(), Widget, FruitPix, fruit->pix()); 118 pix->draw(fruit->position(), Widget, FruitPix, fruit->pix());
119 } 119 }
120 120
121 for (Monster *m = monsters->first(); m != 0; m = monsters->next()) 121 for (Monster *m = monsters->first(); m != 0; m = monsters->next())
122 if (m && m->state() == harmless && 122 if (m && m->state() == harmless &&
123 rect.intersects(pix->rect(m->position(), MonsterPix)) && 123 rect.intersects(pix->rect(m->position(), MonsterPix)) &&
124 !(m->position() == pacman->position() && gameState.testBit(Scoring))) { 124 !(m->position() == pacman->position() && gameState.testBit(Scoring))) {
125 if (m->body() != -1) 125 if (m->body() != -1)
126 pix->draw(m->position(), Widget, MonsterPix, m->body()); 126 pix->draw(m->position(), Widget, MonsterPix, m->body());
127 if (m->eyes() != -1) 127 if (m->eyes() != -1)
128 pix->draw(m->position(), Widget, EyesPix, m->eyes()); 128 pix->draw(m->position(), Widget, EyesPix, m->eyes());
129 } 129 }
130 130
131 if (!gameState.testBit(Scoring) && !gameState.testBit(LevelDone) && 131 if (!gameState.testBit(Scoring) && !gameState.testBit(LevelDone) &&
132 rect.intersects(pix->rect(pacman->position(), PacmanPix)) && pacman->pix() != -1) 132 rect.intersects(pix->rect(pacman->position(), PacmanPix)) && pacman->pix() != -1)
133 pix->draw(pacman->position(), Widget, PacmanPix, pacman->pix()); 133 pix->draw(pacman->position(), Widget, PacmanPix, pacman->pix());
134 134
135 for (Monster *m = monsters->first(); m != 0; m = monsters->next()) 135 for (Monster *m = monsters->first(); m != 0; m = monsters->next())
136 if (m && m->state() != harmless && 136 if (m && m->state() != harmless &&
137 rect.intersects(pix->rect(m->position(), MonsterPix)) && 137 rect.intersects(pix->rect(m->position(), MonsterPix)) &&
138 !(m->position() == pacman->position() && gameState.testBit(Scoring))) { 138 !(m->position() == pacman->position() && gameState.testBit(Scoring))) {
139 if (m->body() != -1) 139 if (m->body() != -1)
140 pix->draw(m->position(), Widget, MonsterPix, m->body()); 140 pix->draw(m->position(), Widget, MonsterPix, m->body());
141 if (m->eyes() != -1) 141 if (m->eyes() != -1)
142 pix->draw(m->position(), Widget, EyesPix, m->eyes()); 142 pix->draw(m->position(), Widget, EyesPix, m->eyes());
143 } 143 }
144 } 144 }
145 145
146 if (gameState.testBit(Scoring) && 146 if (gameState.testBit(Scoring) &&
147 rect.intersects(pix->rect(pacman->position(), MonsterScorePix, monstersEaten-1))) 147 rect.intersects(pix->rect(pacman->position(), MonsterScorePix, monstersEaten-1)))
148 pix->draw(pacman->position(), Widget, MonsterScorePix, monstersEaten-1); 148 pix->draw(pacman->position(), Widget, MonsterScorePix, monstersEaten-1);
149 149
150 if (gameState.testBit(Init) && gameState.testBit(Dying) && 150 if (gameState.testBit(Init) && gameState.testBit(Dying) &&
151 timerCount < pix->maxPixmaps(DyingPix) && 151 timerCount < pix->maxPixmaps(DyingPix) &&
152 rect.intersects(pix->rect(pacman->position(), PacmanPix))) 152 rect.intersects(pix->rect(pacman->position(), PacmanPix)))
153 pix->draw(pacman->position(), Widget, DyingPix, timerCount); 153 pix->draw(pacman->position(), Widget, DyingPix, timerCount);
154 154
155 if (gameState.testBit(LevelDone) && 155 if (gameState.testBit(LevelDone) &&
156 rect.intersects(pix->rect(pacman->position(), PacmanPix))) 156 rect.intersects(pix->rect(pacman->position(), PacmanPix)))
157 pix->draw(pacman->position(), Widget, PacmanPix, pacman->pix()); 157 pix->draw(pacman->position(), Widget, PacmanPix, pacman->pix());
158 158
159 if (gameState.testBit(Player) && 159 if (gameState.testBit(Player) &&
160 rect.intersects(pix->rect(board->position(monsterhome, 0), i18n("PLAYER ONE")))) 160 rect.intersects(pix->rect(board->position(monsterhome, 0), tr("PLAYER ONE"))))
161 pix->draw(board->position(monsterhome, 0), Widget, i18n("PLAYER ONE"), CYAN); 161 pix->draw(board->position(monsterhome, 0), Widget, tr("PLAYER ONE"), CYAN);
162 162
163 if (gameState.testBit(Ready) && 163 if (gameState.testBit(Ready) &&
164 rect.intersects(pix->rect(board->position(fruithome), i18n("READY!")))) 164 rect.intersects(pix->rect(board->position(fruithome), tr("READY!"))))
165 pix->draw(board->position(fruithome), Widget, i18n("READY!"), YELLOW); 165 pix->draw(board->position(fruithome), Widget, tr("READY!"), YELLOW);
166 166
167 if (gameState.testBit(Paused) && 167 if (gameState.testBit(Paused) &&
168 rect.intersects(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, i18n("PAUSED")))) 168 rect.intersects(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, tr("PAUSED"))))
169 pix->draw((BoardWidth*BoardHeight)/2-BoardWidth, Widget, i18n("PAUSED"), RED, BLACK); 169 pix->draw((BoardWidth*BoardHeight)/2-BoardWidth, Widget, tr("PAUSED"), RED, BLACK);
170} 170}
171 171
172void Referee::timerEvent( QTimerEvent *e ) 172void Referee::timerEvent( QTimerEvent *e )
173{ 173{
174 if (gameState.testBit(HallOfFame)) 174 if (gameState.testBit(HallOfFame))
175 return; 175 return;
176 176
177 QRect lastRect; 177 QRect lastRect;
178 int lastPix; 178 int lastPix;
179 bool moved = FALSE; 179 bool moved = FALSE;
180 int eated = 0; 180 int eated = 0;
181 181
182 if (e->timerId() == energizerTimer) { 182 if (e->timerId() == energizerTimer) {
183 for (int e = 0; e < board->energizers(); e++) { 183 for (int e = 0; e < board->energizers(); e++) {
184 lastRect = pix->rect(energizers->at(e)->position(), EnergizerPix); 184 lastRect = pix->rect(energizers->at(e)->position(), EnergizerPix);
185 lastPix = energizers->at(e)->pix(); 185 lastPix = energizers->at(e)->pix();
186 if (energizers->at(e)->move()) { 186 if (energizers->at(e)->move()) {
187 moved = TRUE; 187 moved = TRUE;
188 *energizerRect->at(e) = pix->rect(energizers->at(e)->position(), EnergizerPix); 188 *energizerRect->at(e) = pix->rect(energizers->at(e)->position(), EnergizerPix);
189 if (lastPix == energizers->at(e)->pix() && 189 if (lastPix == energizers->at(e)->pix() &&
190 lastRect == pix->rect(energizers->at(e)->position(), EnergizerPix)) 190 lastRect == pix->rect(energizers->at(e)->position(), EnergizerPix))
191 energizerRect->at(e)->setRect(0, 0, 0, 0); 191 energizerRect->at(e)->setRect(0, 0, 0, 0);
192 else 192 else
193 *energizerRect->at(e) = pix->rect(*energizerRect->at(e), lastRect); 193 *energizerRect->at(e) = pix->rect(*energizerRect->at(e), lastRect);
194 } 194 }
195 } 195 }
196 196
197 for (int e = 0; e < board->energizers(); e++) 197 for (int e = 0; e < board->energizers(); e++)
198 if (!energizerRect->at(e)->isNull()) 198 if (!energizerRect->at(e)->isNull())
199 repaint(*energizerRect->at(e), FALSE); 199 repaint(*energizerRect->at(e), FALSE);
200 200
201 return; 201 return;
202 } 202 }
203 203
204 timerCount++; 204 timerCount++;
205 205
206 lastRect = pix->rect(pacman->position(), PacmanPix); 206 lastRect = pix->rect(pacman->position(), PacmanPix);
207 lastPix = pacman->pix(); 207 lastPix = pacman->pix();
208 208
209 if (moved = pacman->move()) { // pacman really moved 209 if (moved = pacman->move()) { // pacman really moved
210 pacmanRect = pix->rect(pacman->position(), PacmanPix); 210 pacmanRect = pix->rect(pacman->position(), PacmanPix);
211 if (lastPix == pacman->pix() && 211 if (lastPix == pacman->pix() &&
212 lastRect == pix->rect(pacman->position(), PacmanPix)) 212 lastRect == pix->rect(pacman->position(), PacmanPix))
213 pacmanRect.setRect(0, 0, 0, 0); // nothing to do, because the pixmap 213 pacmanRect.setRect(0, 0, 0, 0); // nothing to do, because the pixmap
214 else // and the position isn't changed. 214 else // and the position isn't changed.
215 pacmanRect = pix->rect(pacmanRect, lastRect); 215 pacmanRect = pix->rect(pacmanRect, lastRect);
216 } else 216 } else
217 pacmanRect.setRect(0, 0, 0, 0); 217 pacmanRect.setRect(0, 0, 0, 0);
218 218
219 int pos = pacman->position(); 219 int pos = pacman->position();
220 220
221 if (moved && board->isMonster(pos) && !gameState.testBit(Dying)) { 221 if (moved && board->isMonster(pos) && !gameState.testBit(Dying)) {
222 for (Monster *m = monsters->first(); m != 0; m = monsters->next()) 222 for (Monster *m = monsters->first(); m != 0; m = monsters->next())
223 if (m && m->position() == pos) { 223 if (m && m->position() == pos) {
224 if (m->state() == harmless && !gameState.testBit(Dying)) { 224 if (m->state() == harmless && !gameState.testBit(Dying)) {
225 m->setREM(remTicks[level]); 225 m->setREM(remTicks[level]);
226 m->setDirection(X); // prevent movement before eaten() 226 m->setDirection(X); // prevent movement before eaten()
227 eated++; 227 eated++;
228 if (gameState.testBit(Introducing)) 228 if (gameState.testBit(Introducing))
229 m->setPosition(OUT); 229 m->setPosition(OUT);
230 } 230 }
231 if (m->state() == dangerous && !gameState.testBit(Dying)) 231 if (m->state() == dangerous && !gameState.testBit(Dying))
232 killed(); 232 killed();
233 } 233 }
234 } 234 }
235 235
236 if (moved && !gameState.testBit(Dying)) { 236 if (moved && !gameState.testBit(Dying)) {
237 if (board->isPoint(pos)) { 237 if (board->isPoint(pos)) {
238 board->reset(pos, Point); 238 board->reset(pos, Point);
239 score(pointScore); 239 score(pointScore);
240 pix->erase(pos, PointPix); 240 pix->erase(pos, PointPix);
241 } 241 }
242 if (board->isEnergizer(pos)) { 242 if (board->isEnergizer(pos)) {
243 for (int e = 0; e < board->energizers();e++) { 243 for (int e = 0; e < board->energizers();e++) {
244 if (energizers->at(e)->position() == pos) { 244 if (energizers->at(e)->position() == pos) {
245 energizers->at(e)->setOff(); 245 energizers->at(e)->setOff();
246 energizers->remove(e); 246 energizers->remove(e);
247 energizerRect->remove(e); 247 energizerRect->remove(e);
248 e = board->energizers(); 248 e = board->energizers();
249 } 249 }
250 } 250 }
251 board->reset(pos, energizer); 251 board->reset(pos, energizer);
252 score(energizerScore); 252 score(energizerScore);
253 monstersEaten = 0; 253 monstersEaten = 0;
254 for (Monster *m = monsters->first(); m != 0; m = monsters->next()) 254 for (Monster *m = monsters->first(); m != 0; m = monsters->next())
255 if (m && m->state() != rem) { 255 if (m && m->state() != rem) {
256 m->setHarmless(harmlessTicks[level], harmlessDurTicks[level], 256 m->setHarmless(harmlessTicks[level], harmlessDurTicks[level],
257 harmlessWarnTicks[level]); 257 harmlessWarnTicks[level]);
258 if (gameState.testBit(Introducing)) 258 if (gameState.testBit(Introducing))
259 m->setDirection(board->turn(m->direction())); 259 m->setDirection(board->turn(m->direction()));
260 } 260 }
261 } 261 }
262 if (pos == fruit->position() && fruit->state() == active) { 262 if (pos == fruit->position() && fruit->state() == active) {
263 fruit->setEaten(fruitScoreDurTicks[level]); 263 fruit->setEaten(fruitScoreDurTicks[level]);
264 initFruit(FALSE); 264 initFruit(FALSE);
265 score(fruitScore[fruit->pix()]); 265 score(fruitScore[fruit->pix()]);
266 } 266 }
267 } 267 }
268 268
269 if (!gameState.testBit(Introducing)) { 269 if (!gameState.testBit(Introducing)) {
270 if (fruit->state() != active && fruit->pix() >= 0) 270 if (fruit->state() != active && fruit->pix() >= 0)
271 lastRect = pix->rect(fruit->position(), FruitScorePix, fruit->pix()); 271 lastRect = pix->rect(fruit->position(), FruitScorePix, fruit->pix());
272 else 272 else
273 lastRect = pix->rect(fruit->position(), FruitPix, fruit->pix()); 273 lastRect = pix->rect(fruit->position(), FruitPix, fruit->pix());
274 274
275 lastPix = fruit->pix(); 275 lastPix = fruit->pix();
276 if (fruit->move()) { 276 if (fruit->move()) {
277 if (pos == fruit->position() && fruit->state() == active) { 277 if (pos == fruit->position() && fruit->state() == active) {
278 fruit->setEaten(fruitScoreDurTicks[level]); 278 fruit->setEaten(fruitScoreDurTicks[level]);
279 initFruit(FALSE); 279 initFruit(FALSE);
280 score(fruitScore[fruit->pix()]); 280 score(fruitScore[fruit->pix()]);
281 } 281 }
282 if (fruit->state() != active && fruit->pix() >= 0) 282 if (fruit->state() != active && fruit->pix() >= 0)
283 fruitRect = pix->rect(fruit->position(), FruitScorePix, fruit->pix()); 283 fruitRect = pix->rect(fruit->position(), FruitScorePix, fruit->pix());
284 else 284 else
285 fruitRect = pix->rect(fruit->position(), FruitPix, fruit->pix()); 285 fruitRect = pix->rect(fruit->position(), FruitPix, fruit->pix());
286 if (lastPix == fruit->pix() && lastRect == fruitRect) 286 if (lastPix == fruit->pix() && lastRect == fruitRect)
287 fruitRect.setRect(0, 0, 0, 0); 287 fruitRect.setRect(0, 0, 0, 0);
288 else 288 else
289 fruitRect = pix->rect(fruitRect, lastRect); 289 fruitRect = pix->rect(fruitRect, lastRect);
290 } else 290 } else
291 fruitRect.setRect(0, 0, 0, 0); 291 fruitRect.setRect(0, 0, 0, 0);
292 } else 292 } else
293 fruitRect.setRect(0, 0, 0, 0); 293 fruitRect.setRect(0, 0, 0, 0);
294 294
295 int lastBodyPix; 295 int lastBodyPix;
296 int lastEyesPix; 296 int lastEyesPix;
297 297
298 for (Monster *m = monsters->first(); m != 0; m = monsters->next()) 298 for (Monster *m = monsters->first(); m != 0; m = monsters->next())
299 if (m) { 299 if (m) {
300 lastRect = pix->rect(m->position(), MonsterPix); 300 lastRect = pix->rect(m->position(), MonsterPix);
301 lastBodyPix = m->body(); 301 lastBodyPix = m->body();
302 lastEyesPix = m->eyes(); 302 lastEyesPix = m->eyes();
303 if (m->move()) { 303 if (m->move()) {
304 moved = TRUE; 304 moved = TRUE;
305 *monsterRect->at(m->id()) = pix->rect(m->position(), MonsterPix); 305 *monsterRect->at(m->id()) = pix->rect(m->position(), MonsterPix);
306 if (lastBodyPix == m->body() && lastEyesPix == m->eyes() && 306 if (lastBodyPix == m->body() && lastEyesPix == m->eyes() &&
307 lastRect == pix->rect(m->position(), MonsterPix)) 307 lastRect == pix->rect(m->position(), MonsterPix))
308 monsterRect->at(m->id())->setRect(0, 0, 0, 0); 308 monsterRect->at(m->id())->setRect(0, 0, 0, 0);
309 else 309 else
310 *monsterRect->at(m->id()) = pix->rect(*monsterRect->at(m->id()), lastRect); 310 *monsterRect->at(m->id()) = pix->rect(*monsterRect->at(m->id()), lastRect);
311 if (m->position() == pos && !gameState.testBit(Dying)) { 311 if (m->position() == pos && !gameState.testBit(Dying)) {
312 if (m->state() == harmless && !gameState.testBit(Dying)) { 312 if (m->state() == harmless && !gameState.testBit(Dying)) {
313 m->setREM(remTicks[level]); 313 m->setREM(remTicks[level]);
314 eated++; 314 eated++;
315 if (gameState.testBit(Introducing)) { 315 if (gameState.testBit(Introducing)) {
316 m->setPosition(OUT); 316 m->setPosition(OUT);
317 m->setDirection(X); 317 m->setDirection(X);
318 } 318 }
319 } 319 }
320 if (m->state() == dangerous && !gameState.testBit(Dying)) 320 if (m->state() == dangerous && !gameState.testBit(Dying))
321 killed(); 321 killed();
322 } 322 }
323 } else 323 } else
324 monsterRect->at(m->id())->setRect(0, 0, 0, 0); 324 monsterRect->at(m->id())->setRect(0, 0, 0, 0);
325 } 325 }
326 326
327 for (int m = 0; m < board->monsters(); m++) 327 for (int m = 0; m < board->monsters(); m++)
328 if (pacmanRect.intersects(*monsterRect->at(m))) { 328 if (pacmanRect.intersects(*monsterRect->at(m))) {
329 pacmanRect = pix->rect(pacmanRect, *monsterRect->at(m)); 329 pacmanRect = pix->rect(pacmanRect, *monsterRect->at(m));
330 monsterRect->at(m)->setRect(0, 0, 0, 0); 330 monsterRect->at(m)->setRect(0, 0, 0, 0);
331 } else 331 } else
332 for (int im = m+1; im < board->monsters(); im++) 332 for (int im = m+1; im < board->monsters(); im++)
333 if (monsterRect->at(m)->intersects(*monsterRect->at(im))) { 333 if (monsterRect->at(m)->intersects(*monsterRect->at(im))) {
334 *monsterRect->at(m) = pix->rect(*monsterRect->at(m), *monsterRect->at(im)); 334 *monsterRect->at(m) = pix->rect(*monsterRect->at(m), *monsterRect->at(im));
335 monsterRect->at(im)->setRect(0, 0, 0, 0); 335 monsterRect->at(im)->setRect(0, 0, 0, 0);
336 } 336 }
337 337
338 if (!pacmanRect.isNull()) 338 if (!pacmanRect.isNull())
339 repaint(pacmanRect, FALSE); 339 repaint(pacmanRect, FALSE);
340 340
341 if (!fruitRect.isNull()) 341 if (!fruitRect.isNull())
342 repaint(fruitRect, FALSE); 342 repaint(fruitRect, FALSE);
343 343
344 for (int m = 0; m < board->monsters(); m++) 344 for (int m = 0; m < board->monsters(); m++)
345 if (!monsterRect->at(m)->isNull()) 345 if (!monsterRect->at(m)->isNull())
346 repaint(*monsterRect->at(m), FALSE); 346 repaint(*monsterRect->at(m), FALSE);
347 347
348 if (board->points() == 0 && !gameState.testBit(Dying)) 348 if (board->points() == 0 && !gameState.testBit(Dying))
349 levelUp(); 349 levelUp();
350 350
351 if (eated > 0 && !gameState.testBit(Dying)) { 351 if (eated > 0 && !gameState.testBit(Dying)) {
352 timerCount = eated; 352 timerCount = eated;
353 eaten(); 353 eaten();
354 } 354 }
355 355
356 if (gameState.testBit(Introducing) && moved) 356 if (gameState.testBit(Introducing) && moved)
357 introPlay(); 357 introPlay();
358} 358}
359 359
360void Referee::repaintFigures() 360void Referee::repaintFigures()
361{ 361{
362 pacmanRect = pix->rect(pacman->position(), PacmanPix); 362 pacmanRect = pix->rect(pacman->position(), PacmanPix);
363 363
364 for (int e = 0; e < board->energizers(); e++) { 364 for (int e = 0; e < board->energizers(); e++) {
365 *energizerRect->at(e) = pix->rect(board->position(energizer, e), EnergizerPix); 365 *energizerRect->at(e) = pix->rect(board->position(energizer, e), EnergizerPix);
366 366
367 if (pacmanRect.intersects(*energizerRect->at(e))) { 367 if (pacmanRect.intersects(*energizerRect->at(e))) {
368 pacmanRect = pix->rect(pacmanRect, *energizerRect->at(e)); 368 pacmanRect = pix->rect(pacmanRect, *energizerRect->at(e));
369 energizerRect->at(e)->setRect(0, 0, 0, 0); 369 energizerRect->at(e)->setRect(0, 0, 0, 0);
370 } else 370 } else
371 for (int ie = e+1; ie < board->energizers(); ie++) 371 for (int ie = e+1; ie < board->energizers(); ie++)
372 if (energizerRect->at(e)->intersects(*energizerRect->at(ie))) { 372 if (energizerRect->at(e)->intersects(*energizerRect->at(ie))) {
373 *energizerRect->at(e) = pix->rect(*energizerRect->at(e), *energizerRect->at(ie)); 373 *energizerRect->at(e) = pix->rect(*energizerRect->at(e), *energizerRect->at(ie));
374 energizerRect->at(ie)->setRect(0, 0, 0, 0); 374 energizerRect->at(ie)->setRect(0, 0, 0, 0);
375 } 375 }
376 } 376 }
377 377
378 if (fruit->pix() != -1 && fruit->state() != active) 378 if (fruit->pix() != -1 && fruit->state() != active)
379 fruitRect = pix->rect(fruit->position(), FruitScorePix, fruit->pix()); 379 fruitRect = pix->rect(fruit->position(), FruitScorePix, fruit->pix());
380 else 380 else
381 fruitRect = pix->rect(fruit->position(), FruitPix, fruit->pix()); 381 fruitRect = pix->rect(fruit->position(), FruitPix, fruit->pix());
382 382
383 if (pacmanRect.intersects(fruitRect)) { 383 if (pacmanRect.intersects(fruitRect)) {
384 pacmanRect = pix->rect(pacmanRect, fruitRect); 384 pacmanRect = pix->rect(pacmanRect, fruitRect);
385 fruitRect.setRect(0, 0, 0, 0); 385 fruitRect.setRect(0, 0, 0, 0);
386 } 386 }
387 387
388 for (int m = 0; m < board->monsters(); m++) { 388 for (int m = 0; m < board->monsters(); m++) {
389 *monsterRect->at(m) = pix->rect(board->position(monster, m), MonsterPix); 389 *monsterRect->at(m) = pix->rect(board->position(monster, m), MonsterPix);
390 390
391 if (pacmanRect.intersects(*monsterRect->at(m))) { 391 if (pacmanRect.intersects(*monsterRect->at(m))) {
392 pacmanRect = pix->rect(pacmanRect, *monsterRect->at(m)); 392 pacmanRect = pix->rect(pacmanRect, *monsterRect->at(m));
393 monsterRect->at(m)->setRect(0, 0, 0, 0); 393 monsterRect->at(m)->setRect(0, 0, 0, 0);
394 } else 394 } else
395 for (int im = m+1; im < board->monsters(); im++) 395 for (int im = m+1; im < board->monsters(); im++)
396 if (monsterRect->at(m)->intersects(*monsterRect->at(im))) { 396 if (monsterRect->at(m)->intersects(*monsterRect->at(im))) {
397 *monsterRect->at(m) = pix->rect(*monsterRect->at(m), *monsterRect->at(im)); 397 *monsterRect->at(m) = pix->rect(*monsterRect->at(m), *monsterRect->at(im));
398 monsterRect->at(im)->setRect(0, 0, 0, 0); 398 monsterRect->at(im)->setRect(0, 0, 0, 0);
399 } 399 }
400 } 400 }
401 401
402 if (!pacmanRect.isNull()) 402 if (!pacmanRect.isNull())
403 repaint(pacmanRect, FALSE); 403 repaint(pacmanRect, FALSE);
404 404
405 if (!fruitRect.isNull()) 405 if (!fruitRect.isNull())
406 repaint(fruitRect, FALSE); 406 repaint(fruitRect, FALSE);
407 407
408 for (int m = 0; m < board->monsters(); m++) 408 for (int m = 0; m < board->monsters(); m++)
409 if (!monsterRect->at(m)->isNull()) 409 if (!monsterRect->at(m)->isNull())
410 repaint(*monsterRect->at(m), FALSE); 410 repaint(*monsterRect->at(m), FALSE);
411 411
412 for (int e = 0; e < board->energizers(); e++) 412 for (int e = 0; e < board->energizers(); e++)
413 if (!energizerRect->at(e)->isNull()) 413 if (!energizerRect->at(e)->isNull())
414 repaint(*energizerRect->at(e), FALSE); 414 repaint(*energizerRect->at(e), FALSE);
415 415
416} 416}
417 417
418void Referee::initKeys() 418void Referee::initKeys()
419{ 419{
420 APP_CONFIG_BEGIN( cfg ); 420 APP_CONFIG_BEGIN( cfg );
421 QString up("Up"); 421 QString up("Up");
422 up = cfg->readEntry("upKey", (const char*) up); 422 up = cfg->readEntry("upKey", (const char*) up);
423 UpKey = KAccel::stringToKey(up); 423 UpKey = KAccel::stringToKey(up);
424 424
425 QString down("Down"); 425 QString down("Down");
426 down = cfg->readEntry("downKey", (const char*) down); 426 down = cfg->readEntry("downKey", (const char*) down);
427 DownKey = KAccel::stringToKey(down); 427 DownKey = KAccel::stringToKey(down);
428 428
429 QString left("Left"); 429 QString left("Left");
430 left = cfg->readEntry("leftKey", (const char*) left); 430 left = cfg->readEntry("leftKey", (const char*) left);
431 LeftKey = KAccel::stringToKey(left); 431 LeftKey = KAccel::stringToKey(left);
432 432
433 QString right("Right"); 433 QString right("Right");
434 right = cfg->readEntry("rightKey", (const char*) right); 434 right = cfg->readEntry("rightKey", (const char*) right);
435 RightKey = KAccel::stringToKey(right); 435 RightKey = KAccel::stringToKey(right);
436 APP_CONFIG_END( cfg ); 436 APP_CONFIG_END( cfg );
437} 437}
438 438
439void Referee::fillArray(QArray<int> &array, QString values, int max) 439void Referee::fillArray(QArray<int> &array, QString values, int max)
440{ 440{
441 if (max < 0) 441 if (max < 0)
442 max = values.contains(',')+1; 442 max = values.contains(',')+1;
443 443
444 array.resize(max); 444 array.resize(max);
445 int last = 0; 445 int last = 0;
446 bool ok; 446 bool ok;
447 QString value; 447 QString value;
448 448
449 for (uint i = 0; i < array.size(); i++) { 449 for (uint i = 0; i < array.size(); i++) {
450 if (values.find(',') < 0 && values.length() > 0) { 450 if (values.find(',') < 0 && values.length() > 0) {
451 value = values; 451 value = values;
452 values = ""; 452 values = "";
453 } 453 }
454 if (values.find(',') >= 0) { 454 if (values.find(',') >= 0) {
455 value = values.left(values.find(',')); 455 value = values.left(values.find(','));
456 values.remove(0,values.find(',')+1); 456 values.remove(0,values.find(',')+1);
457 } 457 }
458 array[i] = value.toInt(&ok); 458 array[i] = value.toInt(&ok);
459 if (ok) 459 if (ok)
460 last = array[i]; 460 last = array[i];
461 else 461 else
462 array[i] = last; 462 array[i] = last;
463 } 463 }
464} 464}
465 465
466void Referee::fillStrList(QStrList &list, QString values, int max) 466void Referee::fillStrList(QStrList &list, QString values, int max)
467{ 467{
468 if (!list.isEmpty()) 468 if (!list.isEmpty())
469 list.clear(); 469 list.clear();
470 470
471 QString last = ""; 471 QString last = "";
472 QString value; 472 QString value;
473 473
474 for (uint i = 0; i < (uint) max; i++) { 474 for (uint i = 0; i < (uint) max; i++) {
475 if (values.find(',') < 0 && values.length() > 0) { 475 if (values.find(',') < 0 && values.length() > 0) {
476 value = values; 476 value = values;
477 values = ""; 477 values = "";
478 } 478 }
479 if (values.find(',') >= 0) { 479 if (values.find(',') >= 0) {
480 value = values.left(values.find(',')); 480 value = values.left(values.find(','));
481 values.remove(0,values.find(',')+1); 481 values.remove(0,values.find(',')+1);
482 } 482 }
483 if (!value.isEmpty()) 483 if (!value.isEmpty())
484 last = value; 484 last = value;
485 485
486 list.append(last); 486 list.append(last);
487 } 487 }
488} 488}
489 489
490void Referee::fillMapName() 490void Referee::fillMapName()
491{ 491{
492 QStrList list = mapName; 492 QStrList list = mapName;
493 493
494 if (!mapName.isEmpty()) 494 if (!mapName.isEmpty())
495 mapName.clear(); 495 mapName.clear();
496 496
497 QString map; 497 QString map;
498 498
499 QFileInfo fileInfo; 499 QFileInfo fileInfo;
500 500
501 for (uint i = 0; i < list.count(); i++) { 501 for (uint i = 0; i < list.count(); i++) {
502 map = list.at(i); 502 map = list.at(i);
503 503
504 if (map.left(1) != "/" && map.left(1) != "~") 504 if (map.left(1) != "/" && map.left(1) != "~")
505 map = FIND_APP_DATA( mapDirectory+map ); 505 map = FIND_APP_DATA( mapDirectory+map );
506 506
507 fileInfo.setFile(map); 507 fileInfo.setFile(map);
508 if (!fileInfo.isReadable()) 508 if (!fileInfo.isReadable())
509 map = ""; 509 map = "";
510 510
511 mapName.append(map); 511 mapName.append(map);
512 } 512 }
513} 513}
514 514
515void Referee::confLevels(bool defGroup) 515void Referee::confLevels(bool defGroup)
516{ 516{
517 APP_CONFIG_BEGIN( cfg ); 517 APP_CONFIG_BEGIN( cfg );
518 if (defGroup || cfg->hasKey("Levels")) 518 if (defGroup || cfg->hasKey("Levels"))
519 maxLevel = cfg->readNumEntry("Levels", 13); 519 maxLevel = cfg->readNumEntry("Levels", 13);
520 APP_CONFIG_END( cfg ); 520 APP_CONFIG_END( cfg );
521} 521}
522 522
523void Referee::confMisc(bool defGroup) 523void Referee::confMisc(bool defGroup)
524{ 524{
525 APP_CONFIG_BEGIN( cfg ); 525 APP_CONFIG_BEGIN( cfg );
526 if (defGroup || cfg->hasKey("PixmapDirectory")) { 526 if (defGroup || cfg->hasKey("PixmapDirectory")) {
527 pixmapDirectory = cfg->readEntry("PixmapDirectory"); 527 pixmapDirectory = cfg->readEntry("PixmapDirectory");
528 528
529 if (pixmapDirectory.left(1) != "/" && pixmapDirectory.left(1) != "~") 529 if (pixmapDirectory.left(1) != "/" && pixmapDirectory.left(1) != "~")
530 pixmapDirectory.insert(0, "pics/"); 530 pixmapDirectory.insert(0, "pics/");
531 if (pixmapDirectory.right(1) != "/") 531 if (pixmapDirectory.right(1) != "/")
532 pixmapDirectory.append("/"); 532 pixmapDirectory.append("/");
533 } 533 }
534 534
535 if (defGroup || cfg->hasKey("MapDirectory")) { 535 if (defGroup || cfg->hasKey("MapDirectory")) {
536 mapDirectory = cfg->readEntry("MapDirectory"); 536 mapDirectory = cfg->readEntry("MapDirectory");
537 537
538 if (mapDirectory.left(1) != "/" && mapDirectory.left(1) != "~") 538 if (mapDirectory.left(1) != "/" && mapDirectory.left(1) != "~")
539 mapDirectory.insert(0, "maps/"); 539 mapDirectory.insert(0, "maps/");
540 if (mapDirectory.right(1) != "/") 540 if (mapDirectory.right(1) != "/")
541 mapDirectory.append("/"); 541 mapDirectory.append("/");
542 } 542 }
543 543
544 if (defGroup || cfg->hasKey("MapName")) 544 if (defGroup || cfg->hasKey("MapName"))
545 fillStrList(mapName, cfg->readEntry("MapName", "map"), maxLevel+1); 545 fillStrList(mapName, cfg->readEntry("MapName", "map"), maxLevel+1);
546 546
547 if (defGroup || cfg->hasKey("MonsterIQ")) 547 if (defGroup || cfg->hasKey("MonsterIQ"))
548 fillArray(monsterIQ, cfg->readEntry("MonsterIQ", "0,170,180,170,180,170,180"), maxLevel+1); 548 fillArray(monsterIQ, cfg->readEntry("MonsterIQ", "0,170,180,170,180,170,180"), maxLevel+1);
549 if (defGroup || cfg->hasKey("FruitIQ")) 549 if (defGroup || cfg->hasKey("FruitIQ"))
550 fillArray(fruitIQ, cfg->readEntry("FruitIQ", "0,170,180,170,180,170,180"), maxLevel+1); 550 fillArray(fruitIQ, cfg->readEntry("FruitIQ", "0,170,180,170,180,170,180"), maxLevel+1);
551 if (defGroup || cfg->hasKey("FruitIndex")) 551 if (defGroup || cfg->hasKey("FruitIndex"))
552 fillArray(fruitIndex, cfg->readEntry("FruitIndex", "0"), maxLevel+1); 552 fillArray(fruitIndex, cfg->readEntry("FruitIndex", "0"), maxLevel+1);
553 APP_CONFIG_END( cfg ); 553 APP_CONFIG_END( cfg );
554} 554}
555 555
556void Referee::confTiming(bool defGroup) 556void Referee::confTiming(bool defGroup)
557{ 557{
558 APP_CONFIG_BEGIN( cfg ); 558 APP_CONFIG_BEGIN( cfg );
559 if (defGroup || cfg->hasKey("SpeedMS")) 559 if (defGroup || cfg->hasKey("SpeedMS"))
560 fillArray(speed, cfg->readEntry("SpeedMS", "20"), maxLevel+1); 560 fillArray(speed, cfg->readEntry("SpeedMS", "20"), maxLevel+1);
561 if (defGroup || cfg->hasKey("PacmanTicks")) 561 if (defGroup || cfg->hasKey("PacmanTicks"))
562 fillArray(pacmanTicks,cfg->readEntry("PacmanTicks", "3"), maxLevel+1); 562 fillArray(pacmanTicks,cfg->readEntry("PacmanTicks", "3"), maxLevel+1);
563 if (defGroup || cfg->hasKey("RemTicks")) 563 if (defGroup || cfg->hasKey("RemTicks"))
564 fillArray(remTicks, cfg->readEntry("RemTicks", "1"), maxLevel+1); 564 fillArray(remTicks, cfg->readEntry("RemTicks", "1"), maxLevel+1);
565 if (defGroup || cfg->hasKey("DangerousTicks")) 565 if (defGroup || cfg->hasKey("DangerousTicks"))
566 fillArray(dangerousTicks, cfg->readEntry("DangerousTicks", "3"), maxLevel+1); 566 fillArray(dangerousTicks, cfg->readEntry("DangerousTicks", "3"), maxLevel+1);
567 if (defGroup || cfg->hasKey("HarmlessTicks")) 567 if (defGroup || cfg->hasKey("HarmlessTicks"))
568 fillArray(harmlessTicks, cfg->readEntry("HarmlessTicks", "7,6,,5,,4"), maxLevel+1); 568 fillArray(harmlessTicks, cfg->readEntry("HarmlessTicks", "7,6,,5,,4"), maxLevel+1);
569 if (defGroup || cfg->hasKey("HarmlessDurationTicks")) 569 if (defGroup || cfg->hasKey("HarmlessDurationTicks"))
570 fillArray(harmlessDurTicks, cfg->readEntry("HarmlessDurationTicks", "375,,,300,,250,200,150"), maxLevel+1); 570 fillArray(harmlessDurTicks, cfg->readEntry("HarmlessDurationTicks", "375,,,300,,250,200,150"), maxLevel+1);
571 if (defGroup || cfg->hasKey("HarmlessWarningTicks")) 571 if (defGroup || cfg->hasKey("HarmlessWarningTicks"))
572 fillArray(harmlessWarnTicks, cfg->readEntry("HarmlessWarningTicks", "135"), maxLevel+1); 572 fillArray(harmlessWarnTicks, cfg->readEntry("HarmlessWarningTicks", "135"), maxLevel+1);
573 if (defGroup || cfg->hasKey("ArrestTicks")) 573 if (defGroup || cfg->hasKey("ArrestTicks"))
574 fillArray(arrestTicks, cfg->readEntry("ArrestTicks", "6"), maxLevel+1); 574 fillArray(arrestTicks, cfg->readEntry("ArrestTicks", "6"), maxLevel+1);
575 if (defGroup || cfg->hasKey("ArrestDurationTicks")) 575 if (defGroup || cfg->hasKey("ArrestDurationTicks"))
576 fillArray(arrestDurTicks, cfg->readEntry("ArrestDurationTicks", "200,,,150"), maxLevel+1); 576 fillArray(arrestDurTicks, cfg->readEntry("ArrestDurationTicks", "200,,,150"), maxLevel+1);
577 if (defGroup || cfg->hasKey("FruitTicks")) 577 if (defGroup || cfg->hasKey("FruitTicks"))
578 fillArray(fruitTicks, cfg->readEntry("FruitTicks", "7,6,,5,,4"), maxLevel+1); 578 fillArray(fruitTicks, cfg->readEntry("FruitTicks", "7,6,,5,,4"), maxLevel+1);
579 if (defGroup || cfg->hasKey("FruitAppearsTicks")) 579 if (defGroup || cfg->hasKey("FruitAppearsTicks"))
580 fillArray(fruitAppearsTicks, cfg->readEntry("FruitAppearsTicks", "1000,,1500,2000,2500,3000,3500,4000"), maxLevel+1); 580 fillArray(fruitAppearsTicks, cfg->readEntry("FruitAppearsTicks", "1000,,1500,2000,2500,3000,3500,4000"), maxLevel+1);
581 if (defGroup || cfg->hasKey("FruitDurationTicks")) 581 if (defGroup || cfg->hasKey("FruitDurationTicks"))
582 fillArray(fruitDurTicks, cfg->readEntry("FruitDurationTicks", "500,,,400,350,300,,250,200,150"), maxLevel+1); 582 fillArray(fruitDurTicks, cfg->readEntry("FruitDurationTicks", "500,,,400,350,300,,250,200,150"), maxLevel+1);
583 if (defGroup || cfg->hasKey("FruitScoreDurationTicks")) 583 if (defGroup || cfg->hasKey("FruitScoreDurationTicks"))
584 fillArray(fruitScoreDurTicks, cfg->readEntry("FruitScoreDurationTicks", "150"), maxLevel+1); 584 fillArray(fruitScoreDurTicks, cfg->readEntry("FruitScoreDurationTicks", "150"), maxLevel+1);
585 585
586 if (defGroup || cfg->hasKey("MonsterScoreDurationMS")) 586 if (defGroup || cfg->hasKey("MonsterScoreDurationMS"))
587 monsterScoreDurMS = cfg->readNumEntry("MonsterScoreDurationMS", 1000); 587 monsterScoreDurMS = cfg->readNumEntry("MonsterScoreDurationMS", 1000);
588 if (defGroup || cfg->hasKey("PlayerDurationMS")) 588 if (defGroup || cfg->hasKey("PlayerDurationMS"))
589 playerDurMS = cfg->readNumEntry("PlayerDurationMS", 3000); 589 playerDurMS = cfg->readNumEntry("PlayerDurationMS", 3000);
590 if (defGroup || cfg->hasKey("ReadyDurationMS")) 590 if (defGroup || cfg->hasKey("ReadyDurationMS"))
591 readyDurMS = cfg->readNumEntry("ReadyDurationMS", 2000); 591 readyDurMS = cfg->readNumEntry("ReadyDurationMS", 2000);
592 if (defGroup || cfg->hasKey("GameOverDurationMS")) 592 if (defGroup || cfg->hasKey("GameOverDurationMS"))
593 gameOverDurMS = cfg->readNumEntry("GameOverDurationMS", 3000); 593 gameOverDurMS = cfg->readNumEntry("GameOverDurationMS", 3000);
594 if (defGroup || cfg->hasKey("AfterPauseMS")) 594 if (defGroup || cfg->hasKey("AfterPauseMS"))
595 afterPauseMS = cfg->readNumEntry("AfterPauseMS", 1000); 595 afterPauseMS = cfg->readNumEntry("AfterPauseMS", 1000);
596 if (defGroup || cfg->hasKey("DyingPreAnimationMS")) 596 if (defGroup || cfg->hasKey("DyingPreAnimationMS"))
597 dyingPreAnimationMS = cfg->readNumEntry("DyingPreAnimationMS", 1000); 597 dyingPreAnimationMS = cfg->readNumEntry("DyingPreAnimationMS", 1000);
598 if (defGroup || cfg->hasKey("DyingAnimationMS")) 598 if (defGroup || cfg->hasKey("DyingAnimationMS"))
599 dyingAnimationMS = cfg->readNumEntry("DyingAnimationMS", 100); 599 dyingAnimationMS = cfg->readNumEntry("DyingAnimationMS", 100);
600 if (defGroup || cfg->hasKey("DyingPostAnimationMS")) 600 if (defGroup || cfg->hasKey("DyingPostAnimationMS"))
601 dyingPostAnimationMS = cfg->readNumEntry("DyingPostAnimationMS", 500); 601 dyingPostAnimationMS = cfg->readNumEntry("DyingPostAnimationMS", 500);
602 if (defGroup || cfg->hasKey("IntroAnimationMS")) 602 if (defGroup || cfg->hasKey("IntroAnimationMS"))
603 introAnimationMS = cfg->readNumEntry("IntroAnimationMS", 800); 603 introAnimationMS = cfg->readNumEntry("IntroAnimationMS", 800);
604 if (defGroup || cfg->hasKey("IntroPostAnimationMS")) 604 if (defGroup || cfg->hasKey("IntroPostAnimationMS"))
605 introPostAnimationMS = cfg->readNumEntry("IntroPostAnimationMS", 1000); 605 introPostAnimationMS = cfg->readNumEntry("IntroPostAnimationMS", 1000);
606 if (defGroup || cfg->hasKey("LevelUpPreAnimationMS")) 606 if (defGroup || cfg->hasKey("LevelUpPreAnimationMS"))
607 levelUpPreAnimationMS = cfg->readNumEntry("LevelUpPreAnimationMS", 2000); 607 levelUpPreAnimationMS = cfg->readNumEntry("LevelUpPreAnimationMS", 2000);
608 if (defGroup || cfg->hasKey("LevelUpAnimationMS")) 608 if (defGroup || cfg->hasKey("LevelUpAnimationMS"))
609 levelUpAnimationMS = cfg->readNumEntry("LevelUpAnimationMS", 2000); 609 levelUpAnimationMS = cfg->readNumEntry("LevelUpAnimationMS", 2000);
610 if (defGroup || cfg->hasKey("EnergizerAnimationMS")) 610 if (defGroup || cfg->hasKey("EnergizerAnimationMS"))
611 energizerAnimationMS = cfg->readNumEntry("EnergizerAnimationMS", 200); 611 energizerAnimationMS = cfg->readNumEntry("EnergizerAnimationMS", 200);
612 APP_CONFIG_END( cfg ); 612 APP_CONFIG_END( cfg );
613} 613}
614 614
615void Referee::confScoring(bool defGroup) 615void Referee::confScoring(bool defGroup)
616{ 616{
617 APP_CONFIG_BEGIN( cfg ); 617 APP_CONFIG_BEGIN( cfg );
618 if (defGroup || cfg->hasKey("PointScore")) 618 if (defGroup || cfg->hasKey("PointScore"))
619 pointScore = cfg->readNumEntry("PointScore", 10); 619 pointScore = cfg->readNumEntry("PointScore", 10);
620 if (defGroup || cfg->hasKey("EnergizerScore")) 620 if (defGroup || cfg->hasKey("EnergizerScore"))
621 energizerScore = cfg->readNumEntry("EnergizerScore", 50); 621 energizerScore = cfg->readNumEntry("EnergizerScore", 50);
622 if (defGroup || cfg->hasKey("FruitScore")) 622 if (defGroup || cfg->hasKey("FruitScore"))
623 fillArray(fruitScore, cfg->readEntry("FruitScore", "100,300,500,,700,,1000,,2000,,3000,,5000"), maxLevel+1); 623 fillArray(fruitScore, cfg->readEntry("FruitScore", "100,300,500,,700,,1000,,2000,,3000,,5000"), maxLevel+1);
624 if (defGroup || cfg->hasKey("MonsterScore")) 624 if (defGroup || cfg->hasKey("MonsterScore"))
625 fillArray(monsterScore, cfg->readEntry("MonsterScore", "200,400,800,1600"), 4); 625 fillArray(monsterScore, cfg->readEntry("MonsterScore", "200,400,800,1600"), 4);
626 if (defGroup || cfg->hasKey("ExtraLifeScore")) 626 if (defGroup || cfg->hasKey("ExtraLifeScore"))
627 fillArray(extraLifeScore, cfg->readEntry("ExtraLifeScore", "10000"), -1); 627 fillArray(extraLifeScore, cfg->readEntry("ExtraLifeScore", "10000"), -1);
628 APP_CONFIG_END( cfg ); 628 APP_CONFIG_END( cfg );
629} 629}
630 630
631void Referee::confScheme() 631void Referee::confScheme()
632{ 632{
633 APP_CONFIG_BEGIN( cfg ); 633 APP_CONFIG_BEGIN( cfg );
634 SAVE_CONFIG_GROUP( cfg, oldgroup ); 634 SAVE_CONFIG_GROUP( cfg, oldgroup );
635 QString newgroup; 635 QString newgroup;
636 636
637 // if not set, read mode and scheme from the configfile 637 // if not set, read mode and scheme from the configfile
638 if (mode == -1 && scheme == -1) { 638 if (mode == -1 && scheme == -1) {
639 scheme = cfg->readNumEntry("Scheme", -1); 639 scheme = cfg->readNumEntry("Scheme", -1);
640 mode = cfg->readNumEntry("Mode", -1); 640 mode = cfg->readNumEntry("Mode", -1);
641 641
642 // if mode is not set in the defGroup-group, lookup the scheme group 642 // if mode is not set in the defGroup-group, lookup the scheme group
643 if (scheme != -1 || mode == -1) { 643 if (scheme != -1 || mode == -1) {
644 newgroup.sprintf("Scheme %d", scheme); 644 newgroup.sprintf("Scheme %d", scheme);
645 cfg->setGroup(newgroup); 645 cfg->setGroup(newgroup);
646 646
647 mode = cfg->readNumEntry("Mode", -1); 647 mode = cfg->readNumEntry("Mode", -1);
648 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 648 RESTORE_CONFIG_GROUP( cfg, oldgroup );
649 } 649 }
650 } 650 }
651 651
652 confLevels(); 652 confLevels();
653 653
654 if (mode != -1) { 654 if (mode != -1) {
655 newgroup.sprintf("Mode %d", mode); 655 newgroup.sprintf("Mode %d", mode);
656 cfg->setGroup(newgroup); 656 cfg->setGroup(newgroup);
657 657
658 confLevels(FALSE); 658 confLevels(FALSE);
659 } 659 }
660 660
661 if (scheme != -1) { 661 if (scheme != -1) {
662 newgroup.sprintf("Scheme %d", scheme); 662 newgroup.sprintf("Scheme %d", scheme);
663 cfg->setGroup(newgroup); 663 cfg->setGroup(newgroup);
664 664
665 confLevels(FALSE); 665 confLevels(FALSE);
666 } 666 }
667 667
668 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 668 RESTORE_CONFIG_GROUP( cfg, oldgroup );
669 669
670 confMisc(); 670 confMisc();
671 confTiming(); 671 confTiming();
672 confScoring(); 672 confScoring();
673 673
674 if (mode != -1) { 674 if (mode != -1) {
675 newgroup.sprintf("Mode %d", mode); 675 newgroup.sprintf("Mode %d", mode);
676 cfg->setGroup(newgroup); 676 cfg->setGroup(newgroup);
677 677
678 confMisc(FALSE); 678 confMisc(FALSE);
679 confTiming(FALSE); 679 confTiming(FALSE);
680 confScoring(FALSE); 680 confScoring(FALSE);
681 } 681 }
682 682
683 if (scheme != -1) { 683 if (scheme != -1) {
684 newgroup.sprintf("Scheme %d", scheme); 684 newgroup.sprintf("Scheme %d", scheme);
685 cfg->setGroup(newgroup); 685 cfg->setGroup(newgroup);
686 686
687 confMisc(FALSE); 687 confMisc(FALSE);
688 confTiming(FALSE); 688 confTiming(FALSE);
689 confScoring(FALSE); 689 confScoring(FALSE);
690 } 690 }
691 691
692 fillMapName(); 692 fillMapName();
693 693
694 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 694 RESTORE_CONFIG_GROUP( cfg, oldgroup );
695 APP_CONFIG_END( cfg ); 695 APP_CONFIG_END( cfg );
696} 696}
697 697
698void Referee::setScheme(int Scheme, int Mode, Bitfont *font) 698void Referee::setScheme(int Scheme, int Mode, Bitfont *font)
699{ 699{
700 mode = Mode; 700 mode = Mode;
701 scheme = Scheme; 701 scheme = Scheme;
702 702
703 confScheme(); 703 confScheme();
704 704
705 pix->setScheme(scheme, mode, font); 705 pix->setScheme(scheme, mode, font);
706 706
707 pacman->setMaxPixmaps(pix->maxPixmaps(PacmanPix)); 707 pacman->setMaxPixmaps(pix->maxPixmaps(PacmanPix));
708 fruit->setMaxPixmaps(pix->maxPixmaps(FruitPix)); 708 fruit->setMaxPixmaps(pix->maxPixmaps(FruitPix));
709 709
710 for (Monster *m = monsters->first(); m != 0; m = monsters->next()) 710 for (Monster *m = monsters->first(); m != 0; m = monsters->next())
711 if (m) 711 if (m)
712 m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix)); 712 m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix));
713 713
714 for (Energizer *e = energizers->first(); e != 0; e = energizers->next()) 714 for (Energizer *e = energizers->first(); e != 0; e = energizers->next())
715 if (e) 715 if (e)
716 e->setMaxPixmaps(pix->maxPixmaps(EnergizerPix)); 716 e->setMaxPixmaps(pix->maxPixmaps(EnergizerPix));
717 717
718 if (gameState.testBit(Introducing)) 718 if (gameState.testBit(Introducing))
719 for (int i = 0; i < (gameState.testBit(Init) ? timerCount : 15); i++) 719 for (int i = 0; i < (gameState.testBit(Init) ? timerCount : 15); i++)
720 introPaint(i); 720 introPaint(i);
721 721
722 setFixedSize(pix->levelPix().size()); 722 setFixedSize(pix->levelPix().size());
723 repaint(); 723 repaint();
724} 724}
725 725
726void Referee::keyPressEvent( QKeyEvent *k ) 726void Referee::keyPressEvent( QKeyEvent *k )
727{ 727{
728 uint key = k->key(); 728 uint key = k->key();
729#ifdef QWS 729#ifdef QWS
730 // "OK" => new game 730 // "OK" => new game
731 if ( key == Key_F33 || key == Key_F2 || key == Key_Enter ) 731 if ( key == Key_F33 || key == Key_F2 || key == Key_Enter )
732 play(); 732 play();
733 else if ( !gameState.testBit(Playing) && key == Key_Space ) 733 else if ( !gameState.testBit(Playing) && key == Key_Space )
734 play(); 734 play();
735 // "Space" => pause 735 // "Space" => pause
736 //else if ( key == Key_Space || key == Key_F3 ) 736 //else if ( key == Key_Space || key == Key_F3 )
737 // pause(); 737 // pause();
738 // "Menu" => hall of fame 738 // "Menu" => hall of fame
739 //else if ( key == Key_F11 || key == Key_F4 ) 739 //else if ( key == Key_F11 || key == Key_F4 )
740 // toggleHallOfFame(); 740 // toggleHallOfFame();
741#endif 741#endif
742 742
743 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame) || 743 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame) ||
744 gameState.testBit(Demonstration) || gameState.testBit(Dying) || 744 gameState.testBit(Demonstration) || gameState.testBit(Dying) ||
745 gameState.testBit(Ready) || gameState.testBit(LevelDone) || 745 gameState.testBit(Ready) || gameState.testBit(LevelDone) ||
746 !gameState.testBit(Playing)) 746 !gameState.testBit(Playing))
747 return; 747 return;
748 748
749 if (key == UpKey) 749 if (key == UpKey)
750 pacman->setDirection(N); 750 pacman->setDirection(N);
751 else if (key == DownKey) 751 else if (key == DownKey)
752 pacman->setDirection(S); 752 pacman->setDirection(S);
753 else if (key == RightKey) 753 else if (key == RightKey)
754 pacman->setDirection(E); 754 pacman->setDirection(E);
755 else if (key == LeftKey) 755 else if (key == LeftKey)
756 pacman->setDirection(W); 756 pacman->setDirection(W);
757 757
758#ifdef CHEATS 758#ifdef CHEATS
759 else if (key == Key_L) { printf("levelUp()\n"); levelUp(); } 759 else if (key == Key_L) { printf("levelUp()\n"); levelUp(); }
760 else if (key == Key_F) { printf("fruit->move(TRUE)\n"); fruit->move(TRUE); repaint(FALSE); } 760 else if (key == Key_F) { printf("fruit->move(TRUE)\n"); fruit->move(TRUE); repaint(FALSE); }
761 else if (key == Key_E) { printf("setLifes(++lifes)\n"); emit setLifes(++lifes); } 761 else if (key == Key_E) { printf("setLifes(++lifes)\n"); emit setLifes(++lifes); }
762#endif 762#endif
763 763
764 else { 764 else {
765 k->ignore(); 765 k->ignore();
766 return; 766 return;
767 } 767 }
768 k->accept(); 768 k->accept();
769} 769}
770 770
771void Referee::score(int p) 771void Referee::score(int p)
772{ 772{
773 if (!gameState.testBit(Playing)) 773 if (!gameState.testBit(Playing))
774 return; 774 return;
775 775
776 if ((points += p) < 0) 776 if ((points += p) < 0)
777 points = 0; 777 points = 0;
778 778
779 emit setPoints(points); 779 emit setPoints(points);
780 780
781 if (points >= nextExtraLifeScore) { 781 if (points >= nextExtraLifeScore) {
782 emit setLifes(++lifes); 782 emit setLifes(++lifes);
783 if (extraLifeScoreIndex < (int) extraLifeScore.size()-1) 783 if (extraLifeScoreIndex < (int) extraLifeScore.size()-1)
784 extraLifeScoreIndex++; 784 extraLifeScoreIndex++;
785 if (extraLifeScore[extraLifeScoreIndex] < 0) 785 if (extraLifeScore[extraLifeScoreIndex] < 0)
786 nextExtraLifeScore = extraLifeScore[extraLifeScoreIndex] * -1; 786 nextExtraLifeScore = extraLifeScore[extraLifeScoreIndex] * -1;
787 else 787 else
788 nextExtraLifeScore += extraLifeScore[extraLifeScoreIndex]; 788 nextExtraLifeScore += extraLifeScore[extraLifeScoreIndex];
789 } 789 }
790} 790}
791 791
792void Referee::eaten() 792void Referee::eaten()
793{ 793{
794 if (gameState.testBit(Ready)) 794 if (gameState.testBit(Ready))
795 return; 795 return;
796 796
797 stop(); 797 stop();
798 798
799 if (monstersEaten < 4) 799 if (monstersEaten < 4)
800 monstersEaten++; 800 monstersEaten++;
801 801
802 gameState.setBit(Scoring); 802 gameState.setBit(Scoring);
803 score(monsterScore[monstersEaten-1]); 803 score(monsterScore[monstersEaten-1]);
804 804
805 repaint(pix->rect(pix->rect(pacman->position(), MonsterPix), 805 repaint(pix->rect(pix->rect(pacman->position(), MonsterPix),
806 pix->rect(pacman->position(), MonsterScorePix, monstersEaten-1))); 806 pix->rect(pacman->position(), MonsterScorePix, monstersEaten-1)));
807 807
808 if (--timerCount > 0) 808 if (--timerCount > 0)
809 QTimer::singleShot( monsterScoreDurMS, this, SLOT(eaten())); 809 QTimer::singleShot( monsterScoreDurMS, this, SLOT(eaten()));
810 else { 810 else {
811 for (Monster *m = monsters->first(); m != 0; m = monsters->next()) 811 for (Monster *m = monsters->first(); m != 0; m = monsters->next())
812 if (m && m->direction() == X && !gameState.testBit(Introducing)) 812 if (m && m->direction() == X && !gameState.testBit(Introducing))
813 m->setDirection(N); 813 m->setDirection(N);
814 if (monstersEaten != 4 || !gameState.testBit(Introducing)) 814 if (monstersEaten != 4 || !gameState.testBit(Introducing))
815 QTimer::singleShot( monsterScoreDurMS, this, SLOT(start())); 815 QTimer::singleShot( monsterScoreDurMS, this, SLOT(start()));
816 } 816 }
817} 817}
818 818
819void Referee::toggleHallOfFame() 819void Referee::toggleHallOfFame()
820{ 820{
821 gameState.toggleBit(HallOfFame); 821 gameState.toggleBit(HallOfFame);
822} 822}
823 823
824void Referee::hallOfFame() 824void Referee::hallOfFame()
825{ 825{
826 if (gameState.testBit(HallOfFame)) // If the HallOfFame is switched on manually, toggle the 826 if (gameState.testBit(HallOfFame)) // If the HallOfFame is switched on manually, toggle the
827 toggleHallOfFame(); // bit twice. 827 toggleHallOfFame(); // bit twice.
828 828
829 emit setLevel(0); // Clear status display for hall of fame 829 emit setLevel(0); // Clear status display for hall of fame
830 emit setScore(level, 0); 830 emit setScore(level, 0);
831 emit forcedHallOfFame(TRUE); 831 emit forcedHallOfFame(TRUE);
832} 832}
833 833
834void Referee::pause() 834void Referee::pause()
835{ 835{
836 static int pausedTimer = 0; 836 static int pausedTimer = 0;
837 837
838 if (!gameState.testBit(Paused)) { 838 if (!gameState.testBit(Paused)) {
839 pausedTimer = gameTimer; 839 pausedTimer = gameTimer;
840 stop(); 840 stop();
841 stopEnergizer(); 841 stopEnergizer();
842 gameState.setBit(Paused); 842 gameState.setBit(Paused);
843 repaint(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, i18n("PAUSED")), FALSE); 843 repaint(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, tr("PAUSED")), FALSE);
844 } else { 844 } else {
845 gameState.clearBit(Paused); 845 gameState.clearBit(Paused);
846 repaint(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, i18n("PAUSED")), FALSE); 846 repaint(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, tr("PAUSED")), FALSE);
847 if (pausedTimer) { 847 if (pausedTimer) {
848 pausedTimer = 0; 848 pausedTimer = 0;
849 start(); 849 start();
850 } 850 }
851 } 851 }
852 emit togglePaused(); 852 emit togglePaused();
853} 853}
854 854
855void Referee::intro() 855void Referee::intro()
856{ 856{
857 stop(); 857 stop();
858 stopEnergizer(); 858 stopEnergizer();
859 bool paused = gameState.testBit(Paused); 859 bool paused = gameState.testBit(Paused);
860 860
861 gameState.fill(FALSE); 861 gameState.fill(FALSE);
862 gameState.setBit(Introducing); 862 gameState.setBit(Introducing);
863 gameState.setBit(Init); 863 gameState.setBit(Init);
864 864
865 if (paused) 865 if (paused)
866 gameState.setBit(Paused); 866 gameState.setBit(Paused);
867 867
868 level = 0; 868 level = 0;
869 emit setLevel(level); 869 emit setLevel(level);
870 870
871 board->init(Intro); 871 board->init(Intro);
872 pix->setLevel(level); 872 pix->setLevel(level);
873 873
874 initPacman(); 874 initPacman();
875 initFruit(); 875 initFruit();
876 initMonsters(); 876 initMonsters();
877 initEnergizers(); 877 initEnergizers();
878 878
879 repaint(); 879 repaint();
880 880
881 monstersEaten = 0; 881 monstersEaten = 0;
882 timerCount = 0; 882 timerCount = 0;
883 introPlay(); 883 introPlay();
884} 884}
885 885
886void Referee::introMonster(int id) 886void Referee::introMonster(int id)
887{ 887{
888 Monster *m = new Monster(board, id); 888 Monster *m = new Monster(board, id);
889 889
890 m->setPosition((10+id*6)*BoardWidth+10); 890 m->setPosition((10+id*6)*BoardWidth+10);
891 m->setDirection(E); 891 m->setDirection(E);
892 m->setDangerous(dangerousTicks[level], monsterIQ[level]); 892 m->setDangerous(dangerousTicks[level], monsterIQ[level]);
893 m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix)); 893 m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix));
894 894
895 if (m->body() != -1) 895 if (m->body() != -1)
896 pix->draw(m->position(), RoomPix, MonsterPix, m->body()); 896 pix->draw(m->position(), RoomPix, MonsterPix, m->body());
897 if (m->eyes() != -1) 897 if (m->eyes() != -1)
898 pix->draw(m->position(), RoomPix, EyesPix, m->eyes()); 898 pix->draw(m->position(), RoomPix, EyesPix, m->eyes());
899 899
900 repaint(pix->rect(m->position(), MonsterPix), FALSE); 900 repaint(pix->rect(m->position(), MonsterPix), FALSE);
901 m->setPosition(OUT); 901 m->setPosition(OUT);
902} 902}
903 903
904void Referee::introPaint(int t) 904void Referee::introPaint(int t)
905{ 905{
906 QString pts; 906 QString pts;
907 907
908 switch (t) { 908 switch (t) {
909 case 0 : repaint(pix->draw(16, 6, RoomPix, i18n("CHARACTER"), WHITE, QColor(), AlignLeft), FALSE); 909 case 0 : repaint(pix->draw(16, 6, RoomPix, tr("CHARACTER"), WHITE, QColor(), AlignLeft), FALSE);
910 repaint(pix->draw(36, 6, RoomPix, i18n("/"), WHITE, QColor(), AlignLeft), FALSE); 910 repaint(pix->draw(36, 6, RoomPix, tr("/"), WHITE, QColor(), AlignLeft), FALSE);
911 repaint(pix->draw(40, 6, RoomPix, i18n("NICKNAME"), WHITE, QColor(), AlignLeft), FALSE); 911 repaint(pix->draw(40, 6, RoomPix, tr("NICKNAME"), WHITE, QColor(), AlignLeft), FALSE);
912 break; 912 break;
913 case 1 : introMonster(0); 913 case 1 : introMonster(0);
914 break; 914 break;
915 case 2 : repaint(pix->draw(16, 10, RoomPix, i18n("-SHADOW"), RED, QColor(), AlignLeft), FALSE); 915 case 2 : repaint(pix->draw(16, 10, RoomPix, tr("-SHADOW"), RED, QColor(), AlignLeft), FALSE);
916 break; 916 break;
917 case 3 : repaint(pix->draw(38, 10, RoomPix, i18n("\"BLINKY\""), RED, QColor(), AlignLeft), FALSE); 917 case 3 : repaint(pix->draw(38, 10, RoomPix, tr("\"BLINKY\""), RED, QColor(), AlignLeft), FALSE);
918 break; 918 break;
919 case 4 : introMonster(1); 919 case 4 : introMonster(1);
920 break; 920 break;
921 case 5 : repaint(pix->draw(16, 16, RoomPix, i18n("-SPEEDY"), PINK, QColor(), AlignLeft), FALSE); 921 case 5 : repaint(pix->draw(16, 16, RoomPix, tr("-SPEEDY"), PINK, QColor(), AlignLeft), FALSE);
922 break; 922 break;
923 case 6 : repaint(pix->draw(38, 16, RoomPix, i18n("\"PINKY\""), PINK, QColor(), AlignLeft), FALSE); 923 case 6 : repaint(pix->draw(38, 16, RoomPix, tr("\"PINKY\""), PINK, QColor(), AlignLeft), FALSE);
924 break; 924 break;
925 case 7 : introMonster(2); 925 case 7 : introMonster(2);
926 break; 926 break;
927 case 8 : repaint(pix->draw(16, 22, RoomPix, i18n("-BASHFUL"), CYAN, QColor(), AlignLeft), FALSE); 927 case 8 : repaint(pix->draw(16, 22, RoomPix, tr("-BASHFUL"), CYAN, QColor(), AlignLeft), FALSE);
928 break; 928 break;
929 case 9 : repaint(pix->draw(38, 22, RoomPix, i18n("\"INKY\""), CYAN, QColor(), AlignLeft), FALSE); 929 case 9 : repaint(pix->draw(38, 22, RoomPix, tr("\"INKY\""), CYAN, QColor(), AlignLeft), FALSE);
930 break; 930 break;
931 case 10 : introMonster(3); 931 case 10 : introMonster(3);
932 break; 932 break;
933 case 11 : repaint(pix->draw(16, 28, RoomPix, i18n("-POKEY"), ORANGE, QColor(), AlignLeft), FALSE); 933 case 11 : repaint(pix->draw(16, 28, RoomPix, tr("-POKEY"), ORANGE, QColor(), AlignLeft), FALSE);
934 break; 934 break;
935 case 12 : repaint(pix->draw(38, 28, RoomPix, i18n("\"CLYDE\""), ORANGE, QColor(), AlignLeft), FALSE); 935 case 12 : repaint(pix->draw(38, 28, RoomPix, tr("\"CLYDE\""), ORANGE, QColor(), AlignLeft), FALSE);
936 break; 936 break;
937 case 13 : pts.sprintf("%d", pointScore); 937 case 13 : pts.sprintf("%d", pointScore);
938 repaint(pix->draw(28, 44, RoomPix, pts.data(), WHITE, QColor(), AlignRight), FALSE); 938 repaint(pix->draw(28, 44, RoomPix, pts.data(), WHITE, QColor(), AlignRight), FALSE);
939 repaint(pix->draw(31, 44, RoomPix, "\x1C\x1D\x1E", WHITE, QColor(), AlignLeft), FALSE); 939 repaint(pix->draw(31, 44, RoomPix, "\x1C\x1D\x1E", WHITE, QColor(), AlignLeft), FALSE);
940 pts.sprintf("%d", energizerScore); 940 pts.sprintf("%d", energizerScore);
941 repaint(pix->draw(28, 48, RoomPix, pts.data(), WHITE, QColor(), AlignRight), FALSE); 941 repaint(pix->draw(28, 48, RoomPix, pts.data(), WHITE, QColor(), AlignRight), FALSE);
942 repaint(pix->draw(31, 48, RoomPix, "\x1C\x1D\x1E", WHITE, QColor(), AlignLeft), FALSE); 942 repaint(pix->draw(31, 48, RoomPix, "\x1C\x1D\x1E", WHITE, QColor(), AlignLeft), FALSE);
943 break; 943 break;
944 case 14 : // "@ 1980 MIDWAY MFG.CO." 944 case 14 : // "@ 1980 MIDWAY MFG.CO."
945#if defined( KDE2_PORT ) 945#if defined( KDE2_PORT )
946 repaint(pix->draw(30, 58, RoomPix, "© 1998-2002 J.THÖNNISSEN", PINK), FALSE); 946 repaint(pix->draw(30, 58, RoomPix, "© 1998-2002 J.THÖNNISSEN", PINK), FALSE);
947#elif defined( QPE_PORT ) 947#elif defined( QPE_PORT )
948 repaint(pix->draw(30, 55, RoomPix, "© 1998-2002 J.THÖNNISSEN", PINK), FALSE); 948 repaint(pix->draw(30, 55, RoomPix, "© 1998-2002 J.THÖNNISSEN", PINK), FALSE);
949 repaint(pix->draw(29, 60, RoomPix, "Qtopia port: Catalin CLIMOV", GREEN), FALSE); 949 repaint(pix->draw(29, 60, RoomPix, "Qtopia port: Catalin CLIMOV", GREEN), FALSE);
950#endif 950#endif
951 break; 951 break;
952 } 952 }
953} 953}
954 954
955void Referee::introPlay() 955void Referee::introPlay()
956{ 956{
957 if (!gameState.testBit(Introducing) || gameState.testBit(Ready)) 957 if (!gameState.testBit(Introducing) || gameState.testBit(Ready))
958 return; 958 return;
959 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { 959 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) {
960 QTimer::singleShot(afterPauseMS, this, SLOT(introPlay())); 960 QTimer::singleShot(afterPauseMS, this, SLOT(introPlay()));
961 return; 961 return;
962 } 962 }
963 963
964 if (!gameState.testBit(Init)) { 964 if (!gameState.testBit(Init)) {
965 if (monstersEaten == 4) { 965 if (monstersEaten == 4) {
966 stop(); 966 stop();
967 QTimer::singleShot(introPostAnimationMS, this, SLOT(demo())); 967 QTimer::singleShot(introPostAnimationMS, this, SLOT(demo()));
968 } 968 }
969 if (pacman->direction() == W) { 969 if (pacman->direction() == W) {
970 int id = -1; 970 int id = -1;
971 if (pacman->position() == 37*BoardWidth-6) 971 if (pacman->position() == 37*BoardWidth-6)
972 id = 0; 972 id = 0;
973 else 973 else
974 if (board->isMonster(37*BoardWidth-6)) 974 if (board->isMonster(37*BoardWidth-6))
975 for (Monster *m = monsters->first(); m != 0; m = monsters->next()) 975 for (Monster *m = monsters->first(); m != 0; m = monsters->next())
976 if (m && m->position() == 37*BoardWidth-6) { 976 if (m && m->position() == 37*BoardWidth-6) {
977 id = m->id(); 977 id = m->id();
978 id++; 978 id++;
979 break; 979 break;
980 } 980 }
981 981
982 if (id >= 0 && id <= 4) 982 if (id >= 0 && id <= 4)
983 for (Monster *m = monsters->first(); m != 0; m = monsters->next()) 983 for (Monster *m = monsters->first(); m != 0; m = monsters->next())
984 if (m && m->id() == id && m->position() == OUT) { 984 if (m && m->id() == id && m->position() == OUT) {
985 m->setPosition(37*BoardWidth-1); 985 m->setPosition(37*BoardWidth-1);
986 m->setDirection(W); 986 m->setDirection(W);
987 m->setDangerous(dangerousTicks[level], monsterIQ[level]); 987 m->setDangerous(dangerousTicks[level], monsterIQ[level]);
988 board->set(37*BoardWidth-1, monsterhome, id); 988 board->set(37*BoardWidth-1, monsterhome, id);
989 repaint(pix->rect(m->position(), MonsterPix)); 989 repaint(pix->rect(m->position(), MonsterPix));
990 break; 990 break;
991 } 991 }
992 } 992 }
993 return; 993 return;
994 } 994 }
995 995
996 if (timerCount < 15) 996 if (timerCount < 15)
997 introPaint(timerCount); 997 introPaint(timerCount);
998 998
999 switch (timerCount) { 999 switch (timerCount) {
1000 case 13 : board->set(44*BoardWidth+22, Point); 1000 case 13 : board->set(44*BoardWidth+22, Point);
1001 pix->drawPoint(44*BoardWidth+22); 1001 pix->drawPoint(44*BoardWidth+22);
1002 repaint(pix->rect(44*BoardWidth+22, PointPix), FALSE); 1002 repaint(pix->rect(44*BoardWidth+22, PointPix), FALSE);
1003 energizers->at(0)->setPosition(48*BoardWidth+22); 1003 energizers->at(0)->setPosition(48*BoardWidth+22);
1004 energizers->at(0)->setOn(); 1004 energizers->at(0)->setOn();
1005 repaint(pix->rect(48*BoardWidth+22, EnergizerPix), FALSE); 1005 repaint(pix->rect(48*BoardWidth+22, EnergizerPix), FALSE);
1006 break; 1006 break;
1007 case 14 : energizers->at(1)->setPosition(36*BoardWidth+10); 1007 case 14 : energizers->at(1)->setPosition(36*BoardWidth+10);
1008 energizers->at(1)->setOn(); 1008 energizers->at(1)->setOn();
1009 repaint(pix->rect(36*BoardWidth+10, EnergizerPix), FALSE); 1009 repaint(pix->rect(36*BoardWidth+10, EnergizerPix), FALSE);
1010 for (int pos = 8; pos < BoardWidth; pos++) { 1010 for (int pos = 8; pos < BoardWidth; pos++) {
1011 board->set(34*BoardWidth+pos, out); 1011 board->set(34*BoardWidth+pos, out);
1012 board->set(38*BoardWidth+pos, out); 1012 board->set(38*BoardWidth+pos, out);
1013 } 1013 }
1014 board->set(36*BoardWidth+8, out); 1014 board->set(36*BoardWidth+8, out);
1015 break; 1015 break;
1016 case 15 : gameState.clearBit(Init); 1016 case 15 : gameState.clearBit(Init);
1017 initPacman(); 1017 initPacman();
1018 pacman->setDemo(TRUE); 1018 pacman->setDemo(TRUE);
1019 pacman->setPosition(37*BoardWidth-1); 1019 pacman->setPosition(37*BoardWidth-1);
1020 repaintFigures(); 1020 repaintFigures();
1021 start(); 1021 start();
1022 return; 1022 return;
1023 } 1023 }
1024 1024
1025 if (timerCount++ < 15) 1025 if (timerCount++ < 15)
1026 QTimer::singleShot(introAnimationMS, this, SLOT(introPlay())); 1026 QTimer::singleShot(introAnimationMS, this, SLOT(introPlay()));
1027} 1027}
1028 1028
1029void Referee::demo() 1029void Referee::demo()
1030{ 1030{
1031 if (gameState.testBit(Ready)) 1031 if (gameState.testBit(Ready))
1032 return; 1032 return;
1033 1033
1034 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { 1034 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) {
1035 QTimer::singleShot(afterPauseMS, this, SLOT(demo())); 1035 QTimer::singleShot(afterPauseMS, this, SLOT(demo()));
1036 return; 1036 return;
1037 } 1037 }
1038 1038
1039 stop(); 1039 stop();
1040 stopEnergizer(); 1040 stopEnergizer();
1041 1041
1042 gameState.fill(FALSE); 1042 gameState.fill(FALSE);
1043 gameState.setBit(Init); 1043 gameState.setBit(Init);
1044 gameState.setBit(Demonstration); 1044 gameState.setBit(Demonstration);
1045 1045
1046 level = 0; 1046 level = 0;
1047 emit setLevel(level); 1047 emit setLevel(level);
1048 1048
1049 board->init(Demo, mapName.at(0)); 1049 board->init(Demo, mapName.at(0));
1050 pix->setLevel(level); 1050 pix->setLevel(level);
1051 1051
1052 initPacman(); 1052 initPacman();
1053 initFruit(); 1053 initFruit();
1054 initMonsters(); 1054 initMonsters();
1055 initEnergizers(); 1055 initEnergizers();
1056 1056
1057 gameState.clearBit(Init); 1057 gameState.clearBit(Init);
1058 1058
1059 repaint(); 1059 repaint();
1060 1060
1061 timerCount = 0; 1061 timerCount = 0;
1062 QTimer::singleShot(playerDurMS, this, SLOT(start())); 1062 QTimer::singleShot(playerDurMS, this, SLOT(start()));
1063} 1063}
1064 1064
1065void Referee::play() 1065void Referee::play()
1066{ 1066{
1067 stop(); 1067 stop();
1068 stopEnergizer(); 1068 stopEnergizer();
1069 1069
1070 gameState.fill(FALSE); 1070 gameState.fill(FALSE);
1071 gameState.setBit(Init); 1071 gameState.setBit(Init);
1072 gameState.setBit(Playing); 1072 gameState.setBit(Playing);
1073 gameState.setBit(Player); 1073 gameState.setBit(Player);
1074 gameState.setBit(Ready); 1074 gameState.setBit(Ready);
1075 1075
1076 lifes = 3; 1076 lifes = 3;
1077 level = 1; 1077 level = 1;
1078 points = 0; 1078 points = 0;
1079 1079
1080 extraLifeScoreIndex = 0; 1080 extraLifeScoreIndex = 0;
1081 nextExtraLifeScore = extraLifeScore[extraLifeScoreIndex]; 1081 nextExtraLifeScore = extraLifeScore[extraLifeScoreIndex];
1082 if (nextExtraLifeScore < 0) 1082 if (nextExtraLifeScore < 0)
1083 nextExtraLifeScore *= -1; 1083 nextExtraLifeScore *= -1;
1084 1084
1085 board->init(Level, mapName.at(level)); 1085 board->init(Level, mapName.at(level));
1086 pix->setLevel(level); 1086 pix->setLevel(level);
1087 1087
1088 initPacman(); 1088 initPacman();
1089 initFruit(); 1089 initFruit();
1090 initMonsters(); 1090 initMonsters();
1091 initEnergizers(); 1091 initEnergizers();
1092 1092
1093 repaint(); 1093 repaint();
1094 emit toggleNew(); 1094 emit toggleNew();
1095 emit setLifes(lifes); 1095 emit setLifes(lifes);
1096 emit setLevel(level); 1096 emit setLevel(level);
1097 emit setPoints(points); 1097 emit setPoints(points);
1098 1098
1099 repaint(pix->rect(board->position(monsterhome, 0), i18n("PLAYER ONE")), FALSE); 1099 repaint(pix->rect(board->position(monsterhome, 0), tr("PLAYER ONE")), FALSE);
1100 repaint(pix->rect(board->position(fruithome), i18n("READY!")), FALSE); 1100 repaint(pix->rect(board->position(fruithome), tr("READY!")), FALSE);
1101 1101
1102 timerCount = 0; 1102 timerCount = 0;
1103 QTimer::singleShot(playerDurMS, this, SLOT(ready())); 1103 QTimer::singleShot(playerDurMS, this, SLOT(ready()));
1104} 1104}
1105 1105
1106void Referee::ready() 1106void Referee::ready()
1107{ 1107{
1108 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { 1108 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) {
1109 QTimer::singleShot(afterPauseMS, this, SLOT(ready())); 1109 QTimer::singleShot(afterPauseMS, this, SLOT(ready()));
1110 return; 1110 return;
1111 } 1111 }
1112 1112
1113 if (gameState.testBit(Player)) { 1113 if (gameState.testBit(Player)) {
1114 emit setLifes(--lifes); 1114 emit setLifes(--lifes);
1115 gameState.clearBit(Player); 1115 gameState.clearBit(Player);
1116 gameState.clearBit(Init); 1116 gameState.clearBit(Init);
1117 repaint(pix->rect(board->position(monsterhome, 0), i18n("PLAYER ONE")), FALSE); 1117 repaint(pix->rect(board->position(monsterhome, 0), tr("PLAYER ONE")), FALSE);
1118 repaintFigures(); 1118 repaintFigures();
1119 QTimer::singleShot(playerDurMS, this, SLOT(ready())); 1119 QTimer::singleShot(playerDurMS, this, SLOT(ready()));
1120 return; 1120 return;
1121 } 1121 }
1122 1122
1123 if (gameState.testBit(Ready)) { 1123 if (gameState.testBit(Ready)) {
1124 gameState.clearBit(Ready); 1124 gameState.clearBit(Ready);
1125 repaint(pix->rect(board->position(fruithome), i18n("READY!")), FALSE); 1125 repaint(pix->rect(board->position(fruithome), tr("READY!")), FALSE);
1126 start(); 1126 start();
1127 } else { 1127 } else {
1128 gameState.setBit(Ready); 1128 gameState.setBit(Ready);
1129 gameState.clearBit(Init); 1129 gameState.clearBit(Init);
1130 repaint(pix->rect(board->position(fruithome), i18n("READY!")), FALSE); 1130 repaint(pix->rect(board->position(fruithome), tr("READY!")), FALSE);
1131 QTimer::singleShot(readyDurMS, this, SLOT(ready())); 1131 QTimer::singleShot(readyDurMS, this, SLOT(ready()));
1132 } 1132 }
1133} 1133}
1134 1134
1135 1135
1136void Referee::levelUp() 1136void Referee::levelUp()
1137{ 1137{
1138 stop(); 1138 stop();
1139 stopEnergizer(); 1139 stopEnergizer();
1140 1140
1141 gameState.setBit(LevelDone); 1141 gameState.setBit(LevelDone);
1142 pacman->setPosition(pacman->position()); // set mouthPosition to "0" 1142 pacman->setPosition(pacman->position()); // set mouthPosition to "0"
1143 repaint(pix->rect(pacman->position(), PacmanPix)); 1143 repaint(pix->rect(pacman->position(), PacmanPix));
1144 1144
1145 timerCount = 0; 1145 timerCount = 0;
1146 QTimer::singleShot(levelUpPreAnimationMS, this, SLOT(levelUpPlay())); 1146 QTimer::singleShot(levelUpPreAnimationMS, this, SLOT(levelUpPlay()));
1147} 1147}
1148 1148
1149void Referee::levelUpPlay() 1149void Referee::levelUpPlay()
1150{ 1150{
1151 if (gameState.testBit(Ready)) 1151 if (gameState.testBit(Ready))
1152 return; 1152 return;
1153 1153
1154 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { 1154 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) {
1155 QTimer::singleShot(afterPauseMS, this, SLOT(levelUpPlay())); 1155 QTimer::singleShot(afterPauseMS, this, SLOT(levelUpPlay()));
1156 return; 1156 return;
1157 } 1157 }
1158 1158
1159 switch (timerCount) { 1159 switch (timerCount) {
1160 case 0 : gameState.setBit(Init); 1160 case 0 : gameState.setBit(Init);
1161 setOnEnergizers(); 1161 setOnEnergizers();
1162 repaintFigures(); 1162 repaintFigures();
1163 break; 1163 break;
1164 case 1 : gameState.clearBit(LevelDone); 1164 case 1 : gameState.clearBit(LevelDone);
1165 repaint(pix->rect(pacman->position(), PacmanPix)); 1165 repaint(pix->rect(pacman->position(), PacmanPix));
1166 break; 1166 break;
1167 } 1167 }
1168 1168
1169 if (timerCount++ < 2) { 1169 if (timerCount++ < 2) {
1170 QTimer::singleShot(levelUpAnimationMS, this, SLOT(levelUpPlay())); 1170 QTimer::singleShot(levelUpAnimationMS, this, SLOT(levelUpPlay()));
1171 return; 1171 return;
1172 } 1172 }
1173 1173
1174 gameState.clearBit(Init); 1174 gameState.clearBit(Init);
1175 1175
1176 if (gameState.testBit(Demonstration)) { 1176 if (gameState.testBit(Demonstration)) {
1177 hallOfFame(); 1177 hallOfFame();
1178 return; 1178 return;
1179 } 1179 }
1180 1180
1181 if (level < maxLevel) 1181 if (level < maxLevel)
1182 level++; 1182 level++;
1183 1183
1184 board->init(Level, mapName.at(level)); 1184 board->init(Level, mapName.at(level));
1185 pix->setLevel(level); 1185 pix->setLevel(level);
1186 1186
1187 initPacman(); 1187 initPacman();
1188 initFruit(); 1188 initFruit();
1189 initMonsters(); 1189 initMonsters();
1190 initEnergizers(); 1190 initEnergizers();
1191 1191
1192 repaint(); 1192 repaint();
1193 emit setLevel(level); 1193 emit setLevel(level);
1194 1194
1195 ready(); 1195 ready();
1196} 1196}
1197 1197
1198void Referee::start() 1198void Referee::start()
1199{ 1199{
1200 if (gameState.testBit(Ready)) 1200 if (gameState.testBit(Ready))
1201 return; 1201 return;
1202 1202
1203 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { 1203 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) {
1204 QTimer::singleShot(afterPauseMS, this, SLOT(start())); 1204 QTimer::singleShot(afterPauseMS, this, SLOT(start()));
1205 return; 1205 return;
1206 } 1206 }
1207 1207
1208 if (gameState.testBit(Scoring)) { 1208 if (gameState.testBit(Scoring)) {
1209 gameState.clearBit(Scoring); 1209 gameState.clearBit(Scoring);
1210 repaint(pix->rect(pix->rect(pacman->position(), MonsterPix), 1210 repaint(pix->rect(pix->rect(pacman->position(), MonsterPix),
1211 pix->rect(pacman->position(), MonsterScorePix, monstersEaten-1))); 1211 pix->rect(pacman->position(), MonsterScorePix, monstersEaten-1)));
1212 } 1212 }
1213 1213
1214 if (!gameTimer) 1214 if (!gameTimer)
1215 gameTimer = startTimer( speed [level] ); 1215 gameTimer = startTimer( speed [level] );
1216 1216
1217 if (!energizerTimer) 1217 if (!energizerTimer)
1218 energizerTimer = startTimer( energizerAnimationMS ); 1218 energizerTimer = startTimer( energizerAnimationMS );
1219} 1219}
1220 1220
1221void Referee::start(int t) 1221void Referee::start(int t)
1222{ 1222{
1223 gameTimer = startTimer(t); 1223 gameTimer = startTimer(t);
1224} 1224}
1225 1225
1226void Referee::stop() 1226void Referee::stop()
1227{ 1227{
1228 if (gameTimer) { 1228 if (gameTimer) {
1229 killTimer (gameTimer); 1229 killTimer (gameTimer);
1230 gameTimer = 0; 1230 gameTimer = 0;
1231 } 1231 }
1232} 1232}
1233 1233
1234void Referee::stopEnergizer() 1234void Referee::stopEnergizer()
1235{ 1235{
1236 if (energizerTimer) { 1236 if (energizerTimer) {
1237 killTimer (energizerTimer); 1237 killTimer (energizerTimer);
1238 energizerTimer = 0; 1238 energizerTimer = 0;
1239 } 1239 }
1240} 1240}
1241 1241
1242void Referee::killed() 1242void Referee::killed()
1243{ 1243{
1244 if (gameState.testBit(Ready)) 1244 if (gameState.testBit(Ready))
1245 return; 1245 return;
1246 1246
1247 if (!gameState.testBit(Dying)) { 1247 if (!gameState.testBit(Dying)) {
1248 gameState.setBit(Dying); 1248 gameState.setBit(Dying);
1249 1249
1250 pacman->setDirection(X, TRUE); 1250 pacman->setDirection(X, TRUE);
1251 for (Monster *m = monsters->first(); m != 0; m = monsters->next()) 1251 for (Monster *m = monsters->first(); m != 0; m = monsters->next())
1252 if (m) 1252 if (m)
1253 m->setDirection(X); 1253 m->setDirection(X);
1254 QTimer::singleShot(dyingPreAnimationMS, this, SLOT(killed())); 1254 QTimer::singleShot(dyingPreAnimationMS, this, SLOT(killed()));
1255 } else { 1255 } else {
1256 stop(); 1256 stop();
1257 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { 1257 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) {
1258 QTimer::singleShot(afterPauseMS, this, SLOT(killed())); 1258 QTimer::singleShot(afterPauseMS, this, SLOT(killed()));
1259 return; 1259 return;
1260 } 1260 }
1261 1261
1262 gameState.setBit(Init); 1262 gameState.setBit(Init);
1263 1263
1264 repaintFigures(); 1264 repaintFigures();
1265 1265
1266 timerCount = 0; 1266 timerCount = 0;
1267 killedPlay(); 1267 killedPlay();
1268 } 1268 }
1269} 1269}
1270 1270
1271void Referee::killedPlay() 1271void Referee::killedPlay()
1272{ 1272{
1273 if (!gameState.testBit(Dying) || gameState.testBit(Ready)) 1273 if (!gameState.testBit(Dying) || gameState.testBit(Ready))
1274 return; 1274 return;
1275 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { 1275 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) {
1276 QTimer::singleShot(afterPauseMS, this, SLOT(killedPlay())); 1276 QTimer::singleShot(afterPauseMS, this, SLOT(killedPlay()));
1277 return; 1277 return;
1278 } 1278 }
1279 1279
1280 if (timerCount <= pix->maxPixmaps(DyingPix)) { 1280 if (timerCount <= pix->maxPixmaps(DyingPix)) {
1281 repaint(pix->rect(pacman->position(), PacmanPix), FALSE); 1281 repaint(pix->rect(pacman->position(), PacmanPix), FALSE);
1282 if (timerCount >= pix->maxPixmaps(DyingPix)-1 || timerCount == 0) 1282 if (timerCount >= pix->maxPixmaps(DyingPix)-1 || timerCount == 0)
1283 QTimer::singleShot(dyingPostAnimationMS, this, SLOT(killedPlay())); 1283 QTimer::singleShot(dyingPostAnimationMS, this, SLOT(killedPlay()));
1284 else 1284 else
1285 QTimer::singleShot(dyingAnimationMS, this, SLOT(killedPlay())); 1285 QTimer::singleShot(dyingAnimationMS, this, SLOT(killedPlay()));
1286 timerCount++; 1286 timerCount++;
1287 } else { 1287 } else {
1288 gameState.clearBit(Dying); 1288 gameState.clearBit(Dying);
1289 stopEnergizer(); 1289 stopEnergizer();
1290 if (lifes == 0) { 1290 if (lifes == 0) {
1291 gameState.setBit(GameOver); 1291 gameState.setBit(GameOver);
1292 gameState.clearBit(Playing); 1292 gameState.clearBit(Playing);
1293 for (int e = 0; e < board->energizers(); e++) { 1293 for (int e = 0; e < board->energizers(); e++) {
1294 energizers->at(e)->setOff(); 1294 energizers->at(e)->setOff();
1295 repaint(pix->rect(board->position(energizer, e), EnergizerPix), FALSE); 1295 repaint(pix->rect(board->position(energizer, e), EnergizerPix), FALSE);
1296 } 1296 }
1297 repaint(pix->rect(board->position(fruithome), i18n("GAME OVER")), FALSE); 1297 repaint(pix->rect(board->position(fruithome), tr("GAME OVER")), FALSE);
1298 QTimer::singleShot(gameOverDurMS, this, SLOT(hallOfFame())); 1298 QTimer::singleShot(gameOverDurMS, this, SLOT(hallOfFame()));
1299 } else { 1299 } else {
1300 gameState.clearBit(Init); 1300 gameState.clearBit(Init);
1301 initPacman(); 1301 initPacman();
1302 initFruit(); 1302 initFruit();
1303 initMonsters(); 1303 initMonsters();
1304 initEnergizers(); 1304 initEnergizers();
1305 emit setLifes(--lifes); 1305 emit setLifes(--lifes);
1306 repaintFigures(); 1306 repaintFigures();
1307 ready(); 1307 ready();
1308 } 1308 }
1309 } 1309 }
1310} 1310}
1311 1311
1312void Referee::initPacman() 1312void Referee::initPacman()
1313{ 1313{
1314 pacman->setMaxPixmaps(pix->maxPixmaps(PacmanPix)); 1314 pacman->setMaxPixmaps(pix->maxPixmaps(PacmanPix));
1315 pacman->setDemo(gameState.testBit(Demonstration)); 1315 pacman->setDemo(gameState.testBit(Demonstration));
1316 pacman->setPosition(board->position(pacmanhome)); 1316 pacman->setPosition(board->position(pacmanhome));
1317 pacman->setDirection(W, TRUE); 1317 pacman->setDirection(W, TRUE);
1318 pacman->setAlive(pacmanTicks[level]); 1318 pacman->setAlive(pacmanTicks[level]);
1319} 1319}
1320 1320
1321void Referee::initFruit(bool fullInitialization) 1321void Referee::initFruit(bool fullInitialization)
1322{ 1322{
1323 if (fullInitialization) { 1323 if (fullInitialization) {
1324 fruit->setMaxPixmaps(pix->maxPixmaps(FruitPix)); 1324 fruit->setMaxPixmaps(pix->maxPixmaps(FruitPix));
1325 if (fruitIndex[level] == 0) 1325 if (fruitIndex[level] == 0)
1326 fruit->setLevel(level, fruitAppearsTicks[level], 1326 fruit->setLevel(level, fruitAppearsTicks[level],
1327 fruitDurTicks[level], fruitTicks[level]); 1327 fruitDurTicks[level], fruitTicks[level]);
1328 else if (fruitIndex[level] < 0) 1328 else if (fruitIndex[level] < 0)
1329 fruit->setLevel(pix->maxPixmaps(FruitPix)+1, 1329 fruit->setLevel(pix->maxPixmaps(FruitPix)+1,
1330 fruitAppearsTicks[level], 1330 fruitAppearsTicks[level],
1331 fruitDurTicks[level], fruitTicks[level]); 1331 fruitDurTicks[level], fruitTicks[level]);
1332 else 1332 else
1333 fruit->setLevel(fruitIndex[level], fruitAppearsTicks[level], 1333 fruit->setLevel(fruitIndex[level], fruitAppearsTicks[level],
1334 fruitDurTicks[level], fruitTicks[level]); 1334 fruitDurTicks[level], fruitTicks[level]);
1335 } 1335 }
1336 1336
1337 if (board->tunnels() > 0) 1337 if (board->tunnels() > 0)
1338 fruit->setMovement(board->position(tunnel, rand() % board->tunnels()), 1338 fruit->setMovement(board->position(tunnel, rand() % board->tunnels()),
1339 board->position(tunnel, rand() % board->tunnels()), 1339 board->position(tunnel, rand() % board->tunnels()),
1340 fruitIQ[level]); 1340 fruitIQ[level]);
1341} 1341}
1342 1342
1343void Referee::initMonsters() 1343void Referee::initMonsters()
1344{ 1344{
1345 if( !monsters->isEmpty()) 1345 if( !monsters->isEmpty())
1346 monsters->clear(); 1346 monsters->clear();
1347 if( !monsterRect->isEmpty()) 1347 if( !monsterRect->isEmpty())
1348 monsterRect->clear(); 1348 monsterRect->clear();
1349 1349
1350 for (int id = 0; id < (gameState.testBit(Introducing) ? 4 : board->monsters()); id++) { 1350 for (int id = 0; id < (gameState.testBit(Introducing) ? 4 : board->monsters()); id++) {
1351 Monster *m = new Monster(board, id); 1351 Monster *m = new Monster(board, id);
1352 monsters->append(m); 1352 monsters->append(m);
1353 QRect *r = new QRect(); 1353 QRect *r = new QRect();
1354 monsterRect->append(r); 1354 monsterRect->append(r);
1355 if (!gameState.testBit(Introducing)) { 1355 if (!gameState.testBit(Introducing)) {
1356 m->setFreedom(board->position(prisonexit)); 1356 m->setFreedom(board->position(prisonexit));
1357 m->setDangerous(dangerousTicks[level], monsterIQ[level]); 1357 m->setDangerous(dangerousTicks[level], monsterIQ[level]);
1358 if (id == 0) 1358 if (id == 0)
1359 m->setPrison(board->position(prisonentry)); 1359 m->setPrison(board->position(prisonentry));
1360 else { 1360 else {
1361 m->setPrison(board->position(monsterhome, id)); 1361 m->setPrison(board->position(monsterhome, id));
1362 m->setArrested(arrestTicks[level], arrestDurTicks[level]*id); 1362 m->setArrested(arrestTicks[level], arrestDurTicks[level]*id);
1363 } 1363 }
1364 m->setPosition(board->position(monsterhome, id)); 1364 m->setPosition(board->position(monsterhome, id));
1365 switch(id) { 1365 switch(id) {
1366 case 0 : m->setDirection(W); break; 1366 case 0 : m->setDirection(W); break;
1367 case 1 : m->setDirection(N); break; 1367 case 1 : m->setDirection(N); break;
1368 default : m->setDirection(S); 1368 default : m->setDirection(S);
1369 } 1369 }
1370 } 1370 }
1371 m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix)); 1371 m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix));
1372 } 1372 }
1373} 1373}
1374 1374
1375void Referee::initEnergizers() 1375void Referee::initEnergizers()
1376{ 1376{
1377 if( !energizers->isEmpty()) 1377 if( !energizers->isEmpty())
1378 energizers->clear(); 1378 energizers->clear();
1379 if( !energizerRect->isEmpty()) 1379 if( !energizerRect->isEmpty())
1380 energizerRect->clear(); 1380 energizerRect->clear();
1381 1381
1382 for (int id = 0; id < (gameState.testBit(Introducing) ? 2 : board->energizers()); id++) { 1382 for (int id = 0; id < (gameState.testBit(Introducing) ? 2 : board->energizers()); id++) {
1383 Energizer *e = new Energizer(board); 1383 Energizer *e = new Energizer(board);
1384 energizers->append(e); 1384 energizers->append(e);
1385 QRect *r = new QRect(); 1385 QRect *r = new QRect();
1386 energizerRect->append(r); 1386 energizerRect->append(r);
1387 if (!gameState.testBit(Introducing)) { 1387 if (!gameState.testBit(Introducing)) {
1388 e->setPosition(board->position(energizer, id)); 1388 e->setPosition(board->position(energizer, id));
1389 e->setOn(); 1389 e->setOn();
1390 } 1390 }
1391 e->setMaxPixmaps(pix->maxPixmaps(EnergizerPix)); 1391 e->setMaxPixmaps(pix->maxPixmaps(EnergizerPix));
1392 } 1392 }
1393} 1393}
1394 1394
1395void Referee::setOnEnergizers() 1395void Referee::setOnEnergizers()
1396{ 1396{
1397 for (int e = 0; e < board->energizers(); e++) { 1397 for (int e = 0; e < board->energizers(); e++) {
1398 energizers->at(e)->setOn(); 1398 energizers->at(e)->setOn();
1399 } 1399 }
1400} 1400}
1401 1401
1402void Referee::setFocusOutPause(bool FocusOutPause) 1402void Referee::setFocusOutPause(bool FocusOutPause)
1403{ 1403{
1404 focusOutPause = FocusOutPause; 1404 focusOutPause = FocusOutPause;
1405} 1405}
1406 1406
1407void Referee::setFocusInContinue(bool FocusInContinue) 1407void Referee::setFocusInContinue(bool FocusInContinue)
1408{ 1408{
1409 focusInContinue = FocusInContinue; 1409 focusInContinue = FocusInContinue;
1410} 1410}
1411 1411
1412void Referee::focusInEvent(QFocusEvent *) 1412void Referee::focusInEvent(QFocusEvent *)
1413{ 1413{
1414 if (focusInContinue && focusedPause && 1414 if (focusInContinue && focusedPause &&
1415 gameState.testBit(Paused) && gameState.testBit(Playing)) { 1415 gameState.testBit(Paused) && gameState.testBit(Playing)) {
1416 pause(); 1416 pause();
1417 } 1417 }
1418} 1418}
1419 1419
1420void Referee::focusOutEvent(QFocusEvent *) 1420void Referee::focusOutEvent(QFocusEvent *)
1421{ 1421{
1422 if (focusOutPause && !gameState.testBit(Paused) && gameState.testBit(Playing)) { 1422 if (focusOutPause && !gameState.testBit(Paused) && gameState.testBit(Playing)) {
1423 focusedPause = TRUE; 1423 focusedPause = TRUE;
1424 pause(); 1424 pause();
1425 } 1425 }
1426} 1426}
diff --git a/noncore/games/kpacman/score.cpp b/noncore/games/kpacman/score.cpp
index 6e660e8..17dbf0a 100644
--- a/noncore/games/kpacman/score.cpp
+++ b/noncore/games/kpacman/score.cpp
@@ -1,642 +1,642 @@
1 1
2#include "portable.h" 2#include "portable.h"
3 3
4#if defined( KDE2_PORT ) 4#if defined( KDE2_PORT )
5#include <score.h> 5#include <score.h>
6#include <score.moc> 6#include <score.moc>
7 7
8#include <kaccel.h> 8#include <kaccel.h>
9#include <kapp.h> 9#include <kapp.h>
10#include <kconfig.h> 10#include <kconfig.h>
11#include <kstddirs.h> 11#include <kstddirs.h>
12#include <kmessagebox.h> 12#include <kmessagebox.h>
13#elif defined( QPE_PORT ) 13#elif defined( QPE_PORT )
14#include <qaccel.h> 14#include <qaccel.h>
15#include "config.h" 15#include "config.h"
16#include "score.h" 16#include "score.h"
17#endif 17#endif
18 18
19#include <stdlib.h> 19#include <stdlib.h>
20#include <ctype.h> 20#include <ctype.h>
21 21
22#include <qpixmap.h> 22#include <qpixmap.h>
23#include <qstring.h> 23#include <qstring.h>
24#include <qdstream.h> 24#include <qdstream.h>
25#include <qkeycode.h> 25#include <qkeycode.h>
26#include <qtimer.h> 26#include <qtimer.h>
27#include <qfileinfo.h> 27#include <qfileinfo.h>
28 28
29#include "bitfont.h" 29#include "bitfont.h"
30 30
31Score::Score(QWidget *parent, const char *name, int Scheme, int Mode, Bitfont *font) : QWidget(parent, name) 31Score::Score(QWidget *parent, const char *name, int Scheme, int Mode, Bitfont *font) : QWidget(parent, name)
32{ 32{
33 setFocusPolicy(QWidget::StrongFocus); 33 setFocusPolicy(QWidget::StrongFocus);
34 34
35 paused = FALSE; 35 paused = FALSE;
36 36
37 lastScore = -1; 37 lastScore = -1;
38 lastPlayer = -1; 38 lastPlayer = -1;
39 39
40 cursorBlinkTimer = 0; 40 cursorBlinkTimer = 0;
41 cursorBlinkMS = -1; 41 cursorBlinkMS = -1;
42 cursor.x = -1; 42 cursor.x = -1;
43 cursor.y = -1; 43 cursor.y = -1;
44 cursor.on = FALSE; 44 cursor.on = FALSE;
45 cursor.chr = QChar('?'); 45 cursor.chr = QChar('?');
46 46
47 initKeys(); 47 initKeys();
48 48
49 scheme = Scheme; 49 scheme = Scheme;
50 mode = Mode; 50 mode = Mode;
51 confScheme(); 51 confScheme();
52 52
53 bitfont = font; 53 bitfont = font;
54 54
55 highscoreFile.setName(locateHighscoreFilePath().filePath()); 55 highscoreFile.setName(locateHighscoreFilePath().filePath());
56 read(); 56 read();
57 57
58 for (int p = 0; p < maxPlayer; p++) { 58 for (int p = 0; p < maxPlayer; p++) {
59 playerScore[p] = 0; 59 playerScore[p] = 0;
60 playerName[p] = getenv("LOGNAME"); 60 playerName[p] = getenv("LOGNAME");
61 if (playerName[p].length() < minPlayerNameLength) 61 if (playerName[p].length() < minPlayerNameLength)
62 playerName[p].setExpand(minPlayerNameLength-1, ' '); 62 playerName[p].setExpand(minPlayerNameLength-1, ' ');
63 63
64 for (uint i = 0; i < playerName[p].length(); i++) 64 for (uint i = 0; i < playerName[p].length(); i++)
65 if (playerName[p].at(i) < bitfont->firstChar() || 65 if (playerName[p].at(i) < bitfont->firstChar() ||
66 playerName[p].at(i) > bitfont->lastChar()) 66 playerName[p].at(i) > bitfont->lastChar())
67 playerName[p].at(i) = playerName[p].at(i).upper(); 67 playerName[p].at(i) = playerName[p].at(i).upper();
68 } 68 }
69} 69}
70 70
71Score::~Score() 71Score::~Score()
72{ 72{
73 // write(); 73 // write();
74} 74}
75 75
76void Score::paintEvent( QPaintEvent *e) 76void Score::paintEvent( QPaintEvent *e)
77{ 77{
78 if (rect(1, 0, i18n(" 1UP ")).intersects(e->rect())) { 78 if (rect(1, 0, tr(" 1UP ")).intersects(e->rect())) {
79 QPixmap pix; 79 QPixmap pix;
80 QColor fg = BLACK; 80 QColor fg = BLACK;
81 if (cursor.on || paused || lastPlayer != 0) 81 if (cursor.on || paused || lastPlayer != 0)
82 fg = WHITE; 82 fg = WHITE;
83 pix = bitfont->text(i18n(" 1UP "), fg, BLACK); 83 pix = bitfont->text(tr(" 1UP "), fg, BLACK);
84 bitBlt(this, x(1), y(0), &pix); 84 bitBlt(this, x(1), y(0), &pix);
85 } 85 }
86 86
87 if (rect(8, 0, i18n(" HIGH SCORE ")).intersects(e->rect())) { 87 if (rect(8, 0, tr(" HIGH SCORE ")).intersects(e->rect())) {
88 QPixmap pix = bitfont->text(i18n(" HIGH SCORE "), WHITE, BLACK); 88 QPixmap pix = bitfont->text(tr(" HIGH SCORE "), WHITE, BLACK);
89 bitBlt(this, x(8), y(0), &pix); 89 bitBlt(this, x(8), y(0), &pix);
90 } 90 }
91 91
92 if (maxPlayer > 1 && rect(21, 0, i18n(" 2UP ")).intersects(e->rect())) { 92 if (maxPlayer > 1 && rect(21, 0, tr(" 2UP ")).intersects(e->rect())) {
93 QPixmap pix; 93 QPixmap pix;
94 QColor fg = BLACK; 94 QColor fg = BLACK;
95 if (cursor.on || paused || lastPlayer != 1) 95 if (cursor.on || paused || lastPlayer != 1)
96 fg = WHITE; 96 fg = WHITE;
97 pix = bitfont->text(i18n(" 2UP "), fg, BLACK); 97 pix = bitfont->text(tr(" 2UP "), fg, BLACK);
98 bitBlt(this, x(21), y(0), &pix); 98 bitBlt(this, x(21), y(0), &pix);
99 } 99 }
100 100
101 QString s; 101 QString s;
102 102
103 s.sprintf("%6d0", playerScore[0]/10); 103 s.sprintf("%6d0", playerScore[0]/10);
104 if (rect(0, 1, s).intersects(e->rect())) { 104 if (rect(0, 1, s).intersects(e->rect())) {
105 QPixmap pix = bitfont->text(s, WHITE, BLACK); 105 QPixmap pix = bitfont->text(s, WHITE, BLACK);
106 bitBlt(this, x(0), y(1), &pix); 106 bitBlt(this, x(0), y(1), &pix);
107 } 107 }
108 108
109 s.sprintf("%8d0", HighScore/10); 109 s.sprintf("%8d0", HighScore/10);
110 if (rect(8, 1, s).intersects(e->rect())) { 110 if (rect(8, 1, s).intersects(e->rect())) {
111 QPixmap pix = bitfont->text(s, WHITE, BLACK); 111 QPixmap pix = bitfont->text(s, WHITE, BLACK);
112 bitBlt(this, x(8), y(1), &pix); 112 bitBlt(this, x(8), y(1), &pix);
113 } 113 }
114 114
115 if (lastScore >= 0) { 115 if (lastScore >= 0) {
116 if (rect(1, 4*1.25, i18n(" CONGRATULATIONS ")).intersects(e->rect())) { 116 if (rect(1, 4*1.25, tr(" CONGRATULATIONS ")).intersects(e->rect())) {
117 QPixmap pix = bitfont->text(i18n(" CONGRATULATIONS "), YELLOW, BLACK); 117 QPixmap pix = bitfont->text(tr(" CONGRATULATIONS "), YELLOW, BLACK);
118 bitBlt(this, x(1), y(4*1.25), &pix); 118 bitBlt(this, x(1), y(4*1.25), &pix);
119 } 119 }
120 if (rect(1, 6*1.25, i18n(" YOU HAVE ARCHIEVED ")).intersects(e->rect())) { 120 if (rect(1, 6*1.25, tr(" YOU HAVE ARCHIEVED ")).intersects(e->rect())) {
121 QPixmap pix = bitfont->text(i18n(" YOU HAVE ARCHIEVED "), CYAN, BLACK); 121 QPixmap pix = bitfont->text(tr(" YOU HAVE ARCHIEVED "), CYAN, BLACK);
122 bitBlt(this, x(1), y(6*1.25), &pix); 122 bitBlt(this, x(1), y(6*1.25), &pix);
123 } 123 }
124 if (rect(1, 7*1.25, i18n(" A SCORE IN THE TOP 10. ")).intersects(e->rect())) { 124 if (rect(1, 7*1.25, tr(" A SCORE IN THE TOP 10. ")).intersects(e->rect())) {
125 QPixmap pix = bitfont->text(i18n(" A SCORE IN THE TOP 10. "), CYAN, BLACK); 125 QPixmap pix = bitfont->text(tr(" A SCORE IN THE TOP 10. "), CYAN, BLACK);
126 bitBlt(this, x(1), y(7*1.25), &pix); 126 bitBlt(this, x(1), y(7*1.25), &pix);
127 } 127 }
128 if (rect(1, 8*1.25, i18n(" ")).intersects(e->rect())) { 128 if (rect(1, 8*1.25, tr(" ")).intersects(e->rect())) {
129 QPixmap pix = bitfont->text(i18n(" "), CYAN, BLACK); 129 QPixmap pix = bitfont->text(tr(" "), CYAN, BLACK);
130 bitBlt(this, x(1), y(8*1.25), &pix); 130 bitBlt(this, x(1), y(8*1.25), &pix);
131 } 131 }
132 } 132 }
133 133
134 if (rect(1, 9.5*1.25, i18n("RNK SCORE NAME DATE")).intersects(e->rect())) { 134 if (rect(1, 9.5*1.25, tr("RNK SCORE NAME DATE")).intersects(e->rect())) {
135 QPixmap pix = bitfont->text(i18n("RNK SCORE NAME DATE"), WHITE, BLACK); 135 QPixmap pix = bitfont->text(tr("RNK SCORE NAME DATE"), WHITE, BLACK);
136 bitBlt(this, x(1), y(9.5*1.25), &pix); 136 bitBlt(this, x(1), y(9.5*1.25), &pix);
137 } 137 }
138 138
139 for (int i = 0; i < 10; i++) { 139 for (int i = 0; i < 10; i++) {
140 s.sprintf("%2d%9d %-3.3s %-8.8s", 140 s.sprintf("%2d%9d %-3.3s %-8.8s",
141 i+1, hallOfFame[i].points, hallOfFame[i].name.utf8().data(), 141 i+1, hallOfFame[i].points, hallOfFame[i].name.utf8().data(),
142 formatDate(hallOfFame[i].moment.date()).data()); 142 formatDate(hallOfFame[i].moment.date()).data());
143 if (rect(1, (11+i)*1.25, s).intersects(e->rect())) { 143 if (rect(1, (11+i)*1.25, s).intersects(e->rect())) {
144 QPixmap pix = bitfont->text(s, (i == lastScore) ? YELLOW : WHITE, BLACK); 144 QPixmap pix = bitfont->text(s, (i == lastScore) ? YELLOW : WHITE, BLACK);
145 bitBlt(this, x(1), y((11+i)*1.25), &pix); 145 bitBlt(this, x(1), y((11+i)*1.25), &pix);
146 } 146 }
147 } 147 }
148 148
149 if (cursor.x != -1 && cursor.y != -1 && cursor.on) { 149 if (cursor.x != -1 && cursor.y != -1 && cursor.on) {
150 if (rect(cursor.x, (cursor.y*1.25), cursor.chr).intersects(e->rect())) { 150 if (rect(cursor.x, (cursor.y*1.25), cursor.chr).intersects(e->rect())) {
151 QPixmap pix = bitfont->text(cursor.chr, BLACK, YELLOW); 151 QPixmap pix = bitfont->text(cursor.chr, BLACK, YELLOW);
152 bitBlt(this, x(cursor.x), y(cursor.y*1.25), &pix); 152 bitBlt(this, x(cursor.x), y(cursor.y*1.25), &pix);
153 } 153 }
154 } 154 }
155 155
156 if (paused) { 156 if (paused) {
157 157
158 QPixmap pix = bitfont->text(i18n("PAUSED"), RED, BLACK); 158 QPixmap pix = bitfont->text(tr("PAUSED"), RED, BLACK);
159 QRect r = bitfont->rect(i18n("PAUSED")); 159 QRect r = bitfont->rect(tr("PAUSED"));
160 r.moveCenter(QPoint(this->width()/2, this->height()/2)); 160 r.moveCenter(QPoint(this->width()/2, this->height()/2));
161 161
162 bitBlt(this, r.x(), r.y(), &pix); 162 bitBlt(this, r.x(), r.y(), &pix);
163 } 163 }
164} 164}
165 165
166void Score::timerEvent(QTimerEvent*) 166void Score::timerEvent(QTimerEvent*)
167{ 167{
168 cursor.on = !cursor.on; 168 cursor.on = !cursor.on;
169 169
170 if (paused) 170 if (paused)
171 return; 171 return;
172 172
173 if (cursor.x != -1 && cursor.y != -1) 173 if (cursor.x != -1 && cursor.y != -1)
174 repaint(rect(cursor.x, cursor.y*1.25, cursor.chr), FALSE); 174 repaint(rect(cursor.x, cursor.y*1.25, cursor.chr), FALSE);
175 scrollRepeat = FALSE; 175 scrollRepeat = FALSE;
176 176
177 if (lastPlayer == 0) 177 if (lastPlayer == 0)
178 repaint(rect(1, 0, i18n(" 1UP ")), FALSE); 178 repaint(rect(1, 0, tr(" 1UP ")), FALSE);
179 179
180 if (lastPlayer == 1) 180 if (lastPlayer == 1)
181 repaint(rect(21, 0, i18n(" 2UP ")), FALSE); 181 repaint(rect(21, 0, tr(" 2UP ")), FALSE);
182} 182}
183 183
184void Score::keyPressEvent(QKeyEvent *k) 184void Score::keyPressEvent(QKeyEvent *k)
185{ 185{
186 if (lastScore < 0 || lastPlayer < 0 || lastPlayer >= maxPlayer || paused) { 186 if (lastScore < 0 || lastPlayer < 0 || lastPlayer >= maxPlayer || paused) {
187 k->ignore(); 187 k->ignore();
188 return; 188 return;
189 } 189 }
190 190
191 int x = cursor.x; 191 int x = cursor.x;
192 int y = cursor.y; 192 int y = cursor.y;
193 193
194 uint key = k->key(); 194 uint key = k->key();
195 195
196 if (scrollRepeat && (key == UpKey || key == Key_Up || key == DownKey || key == Key_Down)) { 196 if (scrollRepeat && (key == UpKey || key == Key_Up || key == DownKey || key == Key_Down)) {
197 k->ignore(); 197 k->ignore();
198 return; 198 return;
199 } 199 }
200 200
201 if (key != Key_Return) { 201 if (key != Key_Return) {
202 if (key == RightKey || key == Key_Right) 202 if (key == RightKey || key == Key_Right)
203 if (++cursor.x > 16) 203 if (++cursor.x > 16)
204 cursor.x = 14; 204 cursor.x = 14;
205 if (key == LeftKey || key == Key_Left) 205 if (key == LeftKey || key == Key_Left)
206 if (--cursor.x < 14) 206 if (--cursor.x < 14)
207 cursor.x = 16; 207 cursor.x = 16;
208 if (key == UpKey || key == Key_Up) 208 if (key == UpKey || key == Key_Up)
209 if (cursor.chr.unicode() < bitfont->lastChar()) 209 if (cursor.chr.unicode() < bitfont->lastChar())
210 cursor.chr = cursor.chr.unicode()+1; 210 cursor.chr = cursor.chr.unicode()+1;
211 else 211 else
212 cursor.chr = bitfont->firstChar(); 212 cursor.chr = bitfont->firstChar();
213 if (key == DownKey || key == Key_Down) 213 if (key == DownKey || key == Key_Down)
214 if (cursor.chr.unicode() > bitfont->firstChar()) 214 if (cursor.chr.unicode() > bitfont->firstChar())
215 cursor.chr = cursor.chr.unicode()-1; 215 cursor.chr = cursor.chr.unicode()-1;
216 else 216 else
217 cursor.chr = bitfont->lastChar(); 217 cursor.chr = bitfont->lastChar();
218 218
219 if (cursor.x == x && cursor.y == y && 219 if (cursor.x == x && cursor.y == y &&
220 cursor.chr == hallOfFame[lastScore].name.at(cursor.x-14)) { 220 cursor.chr == hallOfFame[lastScore].name.at(cursor.x-14)) {
221 uint ascii = k->ascii(); 221 uint ascii = k->ascii();
222 222
223 if (ascii < bitfont->firstChar() || ascii > bitfont->lastChar()) 223 if (ascii < bitfont->firstChar() || ascii > bitfont->lastChar())
224 ascii = toupper(ascii); 224 ascii = toupper(ascii);
225 225
226 if (ascii >= bitfont->firstChar() && ascii <= bitfont->lastChar()) { 226 if (ascii >= bitfont->firstChar() && ascii <= bitfont->lastChar()) {
227 cursor.chr = ascii; 227 cursor.chr = ascii;
228 hallOfFame[lastScore].name.at(cursor.x-14) = cursor.chr; 228 hallOfFame[lastScore].name.at(cursor.x-14) = cursor.chr;
229 if (++cursor.x > 16) 229 if (++cursor.x > 16)
230 cursor.x = 14; 230 cursor.x = 14;
231 } 231 }
232 } 232 }
233 } 233 }
234 234
235 if (key == Key_Return) { 235 if (key == Key_Return) {
236 playerName[lastPlayer] = hallOfFame[lastScore].name; 236 playerName[lastPlayer] = hallOfFame[lastScore].name;
237 write(); 237 write();
238 read(); 238 read();
239 lastScore = -1; 239 lastScore = -1;
240 cursor.x = -1; 240 cursor.x = -1;
241 cursor.y = -1; 241 cursor.y = -1;
242// killTimers(); 242// killTimers();
243 emit toggleNew(); 243 emit toggleNew();
244 end(); 244 end();
245 } 245 }
246 246
247 if (x != cursor.x || y != cursor.y) { 247 if (x != cursor.x || y != cursor.y) {
248 if (cursor.x != -1) 248 if (cursor.x != -1)
249 cursor.chr = hallOfFame[lastScore].name.at(cursor.x-14); 249 cursor.chr = hallOfFame[lastScore].name.at(cursor.x-14);
250 scrollRepeat = FALSE; 250 scrollRepeat = FALSE;
251 repaint(rect(x, y*1.25, cursor.chr), FALSE); 251 repaint(rect(x, y*1.25, cursor.chr), FALSE);
252 } else 252 } else
253 hallOfFame[lastScore].name.at(cursor.x-14) = cursor.chr; 253 hallOfFame[lastScore].name.at(cursor.x-14) = cursor.chr;
254 254
255 if (key == UpKey || key == Key_Up || key == DownKey || key == Key_Down) 255 if (key == UpKey || key == Key_Up || key == DownKey || key == Key_Down)
256 scrollRepeat = TRUE; 256 scrollRepeat = TRUE;
257 else 257 else
258 repaint(rect(cursor.x, cursor.y*1.25, cursor.chr), FALSE); 258 repaint(rect(cursor.x, cursor.y*1.25, cursor.chr), FALSE);
259} 259}
260 260
261void Score::initKeys() 261void Score::initKeys()
262{ 262{
263 APP_CONFIG_BEGIN( cfg ); 263 APP_CONFIG_BEGIN( cfg );
264 QString up("Up"); 264 QString up("Up");
265 up = cfg->readEntry("upKey", (const char*) up); 265 up = cfg->readEntry("upKey", (const char*) up);
266 UpKey = KAccel::stringToKey(up); 266 UpKey = KAccel::stringToKey(up);
267 267
268 QString down("Down"); 268 QString down("Down");
269 down = cfg->readEntry("downKey", (const char*) down); 269 down = cfg->readEntry("downKey", (const char*) down);
270 DownKey = KAccel::stringToKey(down); 270 DownKey = KAccel::stringToKey(down);
271 271
272 QString left("Left"); 272 QString left("Left");
273 left = cfg->readEntry("leftKey", (const char*) left); 273 left = cfg->readEntry("leftKey", (const char*) left);
274 LeftKey = KAccel::stringToKey(left); 274 LeftKey = KAccel::stringToKey(left);
275 275
276 QString right("Right"); 276 QString right("Right");
277 right = cfg->readEntry("rightKey", (const char*) right); 277 right = cfg->readEntry("rightKey", (const char*) right);
278 RightKey = KAccel::stringToKey(right); 278 RightKey = KAccel::stringToKey(right);
279 APP_CONFIG_END( cfg ); 279 APP_CONFIG_END( cfg );
280} 280}
281 281
282void Score::confTiming(bool defGroup) 282void Score::confTiming(bool defGroup)
283{ 283{
284 APP_CONFIG_BEGIN( cfg ); 284 APP_CONFIG_BEGIN( cfg );
285 if (defGroup || cfg->hasKey("CursorBlinkMS")) 285 if (defGroup || cfg->hasKey("CursorBlinkMS"))
286 cursorBlinkMS = cfg->readNumEntry("CursorBlinkMS", 250); 286 cursorBlinkMS = cfg->readNumEntry("CursorBlinkMS", 250);
287 if (defGroup || cfg->hasKey("HallOfFameMS")) 287 if (defGroup || cfg->hasKey("HallOfFameMS"))
288 hallOfFameMS = cfg->readNumEntry("HallOfFameMS", 7000); 288 hallOfFameMS = cfg->readNumEntry("HallOfFameMS", 7000);
289 if (defGroup || cfg->hasKey("AfterPauseMS")) 289 if (defGroup || cfg->hasKey("AfterPauseMS"))
290 afterPauseMS = cfg->readNumEntry("AfterPauseMS", 1000); 290 afterPauseMS = cfg->readNumEntry("AfterPauseMS", 1000);
291 APP_CONFIG_END( cfg ); 291 APP_CONFIG_END( cfg );
292} 292}
293 293
294void Score::confScheme() 294void Score::confScheme()
295{ 295{
296 APP_CONFIG_BEGIN( cfg ); 296 APP_CONFIG_BEGIN( cfg );
297 SAVE_CONFIG_GROUP( cfg, oldgroup ); 297 SAVE_CONFIG_GROUP( cfg, oldgroup );
298 QString newgroup; 298 QString newgroup;
299 299
300 // if not set, read mode and scheme from the configfile 300 // if not set, read mode and scheme from the configfile
301 if (mode == -1 && scheme == -1) { 301 if (mode == -1 && scheme == -1) {
302 scheme = cfg->readNumEntry("Scheme", -1); 302 scheme = cfg->readNumEntry("Scheme", -1);
303 mode = cfg->readNumEntry("Mode", -1); 303 mode = cfg->readNumEntry("Mode", -1);
304 304
305 // if mode is not set in the defGroup-group, lookup the scheme group 305 // if mode is not set in the defGroup-group, lookup the scheme group
306 if (scheme != -1 || mode == -1) { 306 if (scheme != -1 || mode == -1) {
307 newgroup.sprintf("Scheme %d", scheme); 307 newgroup.sprintf("Scheme %d", scheme);
308 cfg->setGroup(newgroup); 308 cfg->setGroup(newgroup);
309 309
310 mode = cfg->readNumEntry("Mode", -1); 310 mode = cfg->readNumEntry("Mode", -1);
311 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 311 RESTORE_CONFIG_GROUP( cfg, oldgroup );
312 } 312 }
313 } 313 }
314 314
315 int oldCursorBlinkMS = cursorBlinkMS; 315 int oldCursorBlinkMS = cursorBlinkMS;
316 316
317 confTiming(); 317 confTiming();
318 318
319 if (mode != -1) { 319 if (mode != -1) {
320 newgroup.sprintf("Mode %d", mode); 320 newgroup.sprintf("Mode %d", mode);
321 cfg->setGroup(newgroup); 321 cfg->setGroup(newgroup);
322 322
323 confTiming(FALSE); 323 confTiming(FALSE);
324 } 324 }
325 325
326 if (scheme != -1) { 326 if (scheme != -1) {
327 newgroup.sprintf("Scheme %d", scheme); 327 newgroup.sprintf("Scheme %d", scheme);
328 cfg->setGroup(newgroup); 328 cfg->setGroup(newgroup);
329 329
330 confTiming(FALSE); 330 confTiming(FALSE);
331 } 331 }
332 332
333 if (cursorBlinkMS != oldCursorBlinkMS) { 333 if (cursorBlinkMS != oldCursorBlinkMS) {
334 if (cursorBlinkTimer) 334 if (cursorBlinkTimer)
335 killTimer(cursorBlinkTimer); 335 killTimer(cursorBlinkTimer);
336 cursorBlinkTimer = startTimer(cursorBlinkMS); 336 cursorBlinkTimer = startTimer(cursorBlinkMS);
337 } 337 }
338 338
339 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 339 RESTORE_CONFIG_GROUP( cfg, oldgroup );
340 APP_CONFIG_END( cfg ); 340 APP_CONFIG_END( cfg );
341} 341}
342 342
343void Score::setScheme(int Scheme, int Mode, Bitfont *font) 343void Score::setScheme(int Scheme, int Mode, Bitfont *font)
344{ 344{
345 mode = Mode; 345 mode = Mode;
346 scheme = Scheme; 346 scheme = Scheme;
347 347
348 confScheme(); 348 confScheme();
349 349
350 bitfont = font; 350 bitfont = font;
351 351
352 for (int p = 0; p < maxPlayer; p++) 352 for (int p = 0; p < maxPlayer; p++)
353 for (uint i = 0; i < playerName[p].length(); i++) 353 for (uint i = 0; i < playerName[p].length(); i++)
354 if (playerName[p].at(i) < bitfont->firstChar() || 354 if (playerName[p].at(i) < bitfont->firstChar() ||
355 playerName[p].at(i) > bitfont->lastChar()) 355 playerName[p].at(i) > bitfont->lastChar())
356 playerName[p].at(i) = playerName[p].at(i).upper(); 356 playerName[p].at(i) = playerName[p].at(i).upper();
357 357
358 for (int i = 0; i < 10; i++) 358 for (int i = 0; i < 10; i++)
359 for (uint j = 0; j < hallOfFame[i].name.length(); j++) 359 for (uint j = 0; j < hallOfFame[i].name.length(); j++)
360 if (hallOfFame[i].name.at(j) < bitfont->firstChar() || 360 if (hallOfFame[i].name.at(j) < bitfont->firstChar() ||
361 hallOfFame[i].name.at(j) > bitfont->lastChar()) 361 hallOfFame[i].name.at(j) > bitfont->lastChar())
362 hallOfFame[i].name.at(j) = hallOfFame[i].name.at(j).upper(); 362 hallOfFame[i].name.at(j) = hallOfFame[i].name.at(j).upper();
363 363
364 if (cursor.chr.unicode() < bitfont->firstChar() || 364 if (cursor.chr.unicode() < bitfont->firstChar() ||
365 cursor.chr.unicode() > bitfont->lastChar()) 365 cursor.chr.unicode() > bitfont->lastChar())
366 cursor.chr = cursor.chr.upper(); 366 cursor.chr = cursor.chr.upper();
367} 367}
368 368
369void Score::set(int score) 369void Score::set(int score)
370{ 370{
371 set(score, 0); 371 set(score, 0);
372} 372}
373 373
374void Score::set(int score, int player) 374void Score::set(int score, int player)
375{ 375{
376 if (player < 0 || player >= maxPlayer) 376 if (player < 0 || player >= maxPlayer)
377 return; 377 return;
378 378
379 lastPlayer = player; 379 lastPlayer = player;
380 playerScore[lastPlayer] = score; 380 playerScore[lastPlayer] = score;
381 381
382 QString s; 382 QString s;
383 383
384 s.sprintf("%6d0", playerScore[lastPlayer]/10); 384 s.sprintf("%6d0", playerScore[lastPlayer]/10);
385 repaint(rect(0, 1, s), FALSE); 385 repaint(rect(0, 1, s), FALSE);
386 386
387 if (score > HighScore) { 387 if (score > HighScore) {
388 HighScore = score; 388 HighScore = score;
389 s.sprintf("%8d0", HighScore/10); 389 s.sprintf("%8d0", HighScore/10);
390 repaint(rect(8, 1, s), FALSE); 390 repaint(rect(8, 1, s), FALSE);
391 } 391 }
392} 392}
393 393
394/* 394/*
395 * Set the score for player after the game if over. If the score is in the 395 * Set the score for player after the game if over. If the score is in the
396 * high scores then the hall of fame is updated (shifted) and the scoreboard 396 * high scores then the hall of fame is updated (shifted) and the scoreboard
397 * is shown. 397 * is shown.
398 */ 398 */
399 399
400void Score::setScore(int level, int player) 400void Score::setScore(int level, int player)
401{ 401{
402 lastScore = -1; 402 lastScore = -1;
403 403
404 if (player < 0 || player >= maxPlayer || level == 0) { 404 if (player < 0 || player >= maxPlayer || level == 0) {
405 if (level != 0) 405 if (level != 0)
406 emit toggleNew(); 406 emit toggleNew();
407 QTimer::singleShot(hallOfFameMS, this, SLOT(end())); 407 QTimer::singleShot(hallOfFameMS, this, SLOT(end()));
408 return; 408 return;
409 } 409 }
410 410
411 lastPlayer = player; 411 lastPlayer = player;
412 412
413 for (int i = 0; i < 10; i++) 413 for (int i = 0; i < 10; i++)
414 if ( playerScore[lastPlayer] > hallOfFame[i].points) { 414 if ( playerScore[lastPlayer] > hallOfFame[i].points) {
415 lastScore = i; 415 lastScore = i;
416 break; 416 break;
417 } 417 }
418 418
419 if (lastScore < 0) { 419 if (lastScore < 0) {
420 emit toggleNew(); 420 emit toggleNew();
421 QTimer::singleShot(hallOfFameMS, this, SLOT(end())); 421 QTimer::singleShot(hallOfFameMS, this, SLOT(end()));
422 return; 422 return;
423 } 423 }
424 424
425 for (int i = 9; i > lastScore && i > 0; i--) 425 for (int i = 9; i > lastScore && i > 0; i--)
426 hallOfFame[i] = hallOfFame[i-1]; 426 hallOfFame[i] = hallOfFame[i-1];
427 427
428 hallOfFame[lastScore].points = playerScore[lastPlayer]; 428 hallOfFame[lastScore].points = playerScore[lastPlayer];
429 hallOfFame[lastScore].levels = level; 429 hallOfFame[lastScore].levels = level;
430 hallOfFame[lastScore].moment = QDateTime::currentDateTime(); 430 hallOfFame[lastScore].moment = QDateTime::currentDateTime();
431 hallOfFame[lastScore].name = playerName[lastPlayer]; 431 hallOfFame[lastScore].name = playerName[lastPlayer];
432 432
433 cursor.x = 14; 433 cursor.x = 14;
434 cursor.y = 11+lastScore; 434 cursor.y = 11+lastScore;
435 cursor.chr = hallOfFame[lastScore].name.at(cursor.x-14); 435 cursor.chr = hallOfFame[lastScore].name.at(cursor.x-14);
436 436
437// startTimer(cursorBlinkMS); 437// startTimer(cursorBlinkMS);
438 setFocus(); 438 setFocus();
439} 439}
440 440
441/* 441/*
442 * Read the highscores, if no file or a file shorter than 4 bytes (versions before 0.2.4 stores only 442 * Read the highscores, if no file or a file shorter than 4 bytes (versions before 0.2.4 stores only
443 * the points of one highscore) exists - the highscores were initialized with default values. 443 * the points of one highscore) exists - the highscores were initialized with default values.
444 */ 444 */
445void Score::read() 445void Score::read()
446{ 446{
447 if (highscoreFile.exists() && highscoreFile.size() > 4) { 447 if (highscoreFile.exists() && highscoreFile.size() > 4) {
448 if (highscoreFile.open(IO_ReadOnly)) { 448 if (highscoreFile.open(IO_ReadOnly)) {
449 QDataStream s(&highscoreFile); 449 QDataStream s(&highscoreFile);
450 char *name; 450 char *name;
451 for (int i = 0; i < 10; i++) { 451 for (int i = 0; i < 10; i++) {
452 s >> hallOfFame[i].points >> hallOfFame[i].levels >> hallOfFame[i].duration >> 452 s >> hallOfFame[i].points >> hallOfFame[i].levels >> hallOfFame[i].duration >>
453 hallOfFame[i].moment >> name; 453 hallOfFame[i].moment >> name;
454 hallOfFame[i].name = QString::fromLatin1(name); 454 hallOfFame[i].name = QString::fromLatin1(name);
455 delete(name); 455 delete(name);
456 } 456 }
457 highscoreFile.close(); 457 highscoreFile.close();
458 } 458 }
459 } else { 459 } else {
460 for (int i = 0; i < 10; i++) { 460 for (int i = 0; i < 10; i++) {
461 hallOfFame[i].points = 5000; 461 hallOfFame[i].points = 5000;
462 hallOfFame[i].levels = 0; 462 hallOfFame[i].levels = 0;
463 hallOfFame[i].duration = QTime(); 463 hallOfFame[i].duration = QTime();
464 hallOfFame[i].moment = QDateTime(); 464 hallOfFame[i].moment = QDateTime();
465 hallOfFame[i].name = "???"; 465 hallOfFame[i].name = "???";
466 } 466 }
467 // write(); 467 // write();
468 } 468 }
469 469
470 for (int i = 0; i < 10; i++) 470 for (int i = 0; i < 10; i++)
471 for (uint j = 0; j < hallOfFame[i].name.length(); j++) 471 for (uint j = 0; j < hallOfFame[i].name.length(); j++)
472 if (hallOfFame[i].name.at(j) < bitfont->firstChar() || 472 if (hallOfFame[i].name.at(j) < bitfont->firstChar() ||
473 hallOfFame[i].name.at(j) > bitfont->lastChar()) 473 hallOfFame[i].name.at(j) > bitfont->lastChar())
474 hallOfFame[i].name.at(j) = hallOfFame[i].name.at(j).upper(); 474 hallOfFame[i].name.at(j) = hallOfFame[i].name.at(j).upper();
475 475
476 HighScore = hallOfFame[0].points; 476 HighScore = hallOfFame[0].points;
477} 477}
478 478
479void Score::write() 479void Score::write()
480{ 480{
481#ifndef QWS 481#ifndef QWS
482 if (!highscoreFile.exists() && highscoreFile.name() == systemHighscoreFileInfo.filePath()) 482 if (!highscoreFile.exists() && highscoreFile.name() == systemHighscoreFileInfo.filePath())
483 KMessageBox::information(0, 483 KMessageBox::information(0,
484 i18n("You're going to create the highscore-file\n" 484 tr("You're going to create the highscore-file\n"
485 "'%1'\n" 485 "'%1'\n"
486 "for your maschine, that should be used systemwide.\n" 486 "for your maschine, that should be used systemwide.\n"
487 "\n" 487 "\n"
488 "To grant access to the other users, set the appropriate rights (a+w)\n" 488 "To grant access to the other users, set the appropriate rights (a+w)\n"
489 "on that file or ask your systemadministator for that favor.\n" 489 "on that file or ask your systemadministator for that favor.\n"
490 "\n" 490 "\n"
491 "To use a different directory or filename for the highscores," 491 "To use a different directory or filename for the highscores,"
492 "specify them in the configfile (kpacmanrc:highscoreFilePath)." 492 "specify them in the configfile (kpacmanrc:highscoreFilePath)."
493 ).arg(systemHighscoreFileInfo.filePath())); 493 ).arg(systemHighscoreFileInfo.filePath()));
494 494
495 if (highscoreFile.name() == privateHighscoreFileInfo.filePath()) 495 if (highscoreFile.name() == privateHighscoreFileInfo.filePath())
496 KMessageBox::information(0, 496 KMessageBox::information(0,
497 i18n("You're using a private highscore-file, that's mostly because of\n" 497 tr("You're using a private highscore-file, that's mostly because of\n"
498 "missing write-access to the systemwide file\n" 498 "missing write-access to the systemwide file\n"
499 "'%1' .\n" 499 "'%1' .\n"
500 "\n" 500 "\n"
501 "Ask your systemadministrator for granting you access to that file,\n" 501 "Ask your systemadministrator for granting you access to that file,\n"
502 "by setting the appropriate rights (a+w) on it.\n" 502 "by setting the appropriate rights (a+w) on it.\n"
503 "\n" 503 "\n"
504 "To use a different directory or filename for the highscores," 504 "To use a different directory or filename for the highscores,"
505 "specify them in the configfile (kpacmanrc:highscoreFilePath)." 505 "specify them in the configfile (kpacmanrc:highscoreFilePath)."
506 ).arg(systemHighscoreFileInfo.filePath()), 506 ).arg(systemHighscoreFileInfo.filePath()),
507 QString::null, "PrivateHighscore"); 507 QString::null, "PrivateHighscore");
508#endif 508#endif
509 if (highscoreFile.open(IO_WriteOnly)) { 509 if (highscoreFile.open(IO_WriteOnly)) {
510 QDataStream s(&highscoreFile); 510 QDataStream s(&highscoreFile);
511 for (int i = 0; i < 10; i++) 511 for (int i = 0; i < 10; i++)
512 s << hallOfFame[i].points << hallOfFame[i].levels << hallOfFame[i].duration << 512 s << hallOfFame[i].points << hallOfFame[i].levels << hallOfFame[i].duration <<
513 hallOfFame[i].moment << hallOfFame[i].name.latin1(); 513 hallOfFame[i].moment << hallOfFame[i].name.latin1();
514 highscoreFile.close(); 514 highscoreFile.close();
515 } 515 }
516} 516}
517 517
518void Score::setPause(bool Paused) 518void Score::setPause(bool Paused)
519{ 519{
520 paused = Paused; 520 paused = Paused;
521 521
522 QRect r = bitfont->rect(i18n("PAUSED")); 522 QRect r = bitfont->rect(tr("PAUSED"));
523 r.moveCenter(QPoint(this->width()/2, this->height()/2)); 523 r.moveCenter(QPoint(this->width()/2, this->height()/2));
524 repaint(r, TRUE); 524 repaint(r, TRUE);
525 525
526 // repaint 1UP or 2UP 526 // repaint 1UP or 2UP
527 repaint(FALSE); 527 repaint(FALSE);
528} 528}
529 529
530void Score::end() 530void Score::end()
531{ 531{
532 if (paused) { 532 if (paused) {
533 QTimer::singleShot(afterPauseMS, this, SLOT(end())); 533 QTimer::singleShot(afterPauseMS, this, SLOT(end()));
534 return; 534 return;
535 } 535 }
536 536
537 // repaint 1UP or 2UP 537 // repaint 1UP or 2UP
538 lastPlayer = -1; 538 lastPlayer = -1;
539 repaint(FALSE); 539 repaint(FALSE);
540 540
541 emit forcedHallOfFame(FALSE); 541 emit forcedHallOfFame(FALSE);
542} 542}
543 543
544/* 544/*
545 * Return the date in a formatted QString. The format can be changed using internationalization 545 * Return the date in a formatted QString. The format can be changed using internationalization
546 * of the string "YY/MM/DD". Invalid QDate's where returned as "00/00/00". 546 * of the string "YY/MM/DD". Invalid QDate's where returned as "00/00/00".
547 */ 547 */
548QString Score::formatDate(QDate date) 548QString Score::formatDate(QDate date)
549{ 549{
550 QString s = i18n("@YY@/@MM@/@DD@"); 550 QString s = tr("@YY@/@MM@/@DD@");
551 551
552 QString dd; 552 QString dd;
553 dd.sprintf("%02d", date.isValid() ? date.year() % 100 : 0); 553 dd.sprintf("%02d", date.isValid() ? date.year() % 100 : 0);
554 s.replace(QRegExp("@YY@"), dd); 554 s.replace(QRegExp("@YY@"), dd);
555 dd.sprintf("%02d", date.isValid() ? date.month() : 0); 555 dd.sprintf("%02d", date.isValid() ? date.month() : 0);
556 s.replace(QRegExp("@MM@"), dd); 556 s.replace(QRegExp("@MM@"), dd);
557 dd.sprintf("%02d", date.isValid() ? date.day() : 0); 557 dd.sprintf("%02d", date.isValid() ? date.day() : 0);
558 s.replace(QRegExp("@DD@"), dd); 558 s.replace(QRegExp("@DD@"), dd);
559 559
560 return s; 560 return s;
561} 561}
562 562
563QRect Score::rect(int col, float row, QString str, int align) 563QRect Score::rect(int col, float row, QString str, int align)
564{ 564{
565 QRect r = bitfont->rect(str); 565 QRect r = bitfont->rect(str);
566 r.moveBy(x(col), y(row)); 566 r.moveBy(x(col), y(row));
567 567
568 int dx = 0; 568 int dx = 0;
569 int dy = 0; 569 int dy = 0;
570 570
571 if (align & AlignLeft || align & AlignRight) { 571 if (align & AlignLeft || align & AlignRight) {
572 dx = (str.length()-1) * (bitfont->width()/2); 572 dx = (str.length()-1) * (bitfont->width()/2);
573 if (align & AlignRight) 573 if (align & AlignRight)
574 dx *= -1; 574 dx *= -1;
575 } 575 }
576 576
577 if (align & AlignTop || align & AlignBottom) { 577 if (align & AlignTop || align & AlignBottom) {
578 dy = bitfont->height()/2; 578 dy = bitfont->height()/2;
579 if (align & AlignBottom) 579 if (align & AlignBottom)
580 dy *= -1; 580 dy *= -1;
581 } 581 }
582 582
583 if (dx != 0 || dy != 0) 583 if (dx != 0 || dy != 0)
584 r.moveBy(dx, dy); 584 r.moveBy(dx, dy);
585 585
586 return r; 586 return r;
587} 587}
588 588
589int Score::x(int col) 589int Score::x(int col)
590{ 590{
591 return col*bitfont->width(); 591 return col*bitfont->width();
592} 592}
593 593
594int Score::y(float row) 594int Score::y(float row)
595{ 595{
596 return (int) (row*(bitfont->height()+bitfont->height()/4)); 596 return (int) (row*(bitfont->height()+bitfont->height()/4));
597} 597}
598 598
599/** 599/**
600 * Ermittelt die zu benutzende "highscore"-Datei, in die auch geschrieben werden kann. 600 * Ermittelt die zu benutzende "highscore"-Datei, in die auch geschrieben werden kann.
601 * Über den "highscoreFilePath"-KConfig-Eintrag, kann abweichend von der Standardlokation 601 * Über den "highscoreFilePath"-KConfig-Eintrag, kann abweichend von der Standardlokation
602 * der Standort der "highscore"-Datei spezifiziert werden. 602 * der Standort der "highscore"-Datei spezifiziert werden.
603 * Wenn die systemweite "highscore"-Datei nicht beschrieben werden kann, wird mit einer 603 * Wenn die systemweite "highscore"-Datei nicht beschrieben werden kann, wird mit einer
604 * privaten Datei gearbeitet. 604 * privaten Datei gearbeitet.
605 */ 605 */
606QFileInfo Score::locateHighscoreFilePath() 606QFileInfo Score::locateHighscoreFilePath()
607{ 607{
608#ifndef QWS 608#ifndef QWS
609 QFileInfo systemHighscoreDirPath; 609 QFileInfo systemHighscoreDirPath;
610 QStringList systemHighscoreDirs; 610 QStringList systemHighscoreDirs;
611 611
612 // Schreibfähige "private" highscore-Datei ermitteln für den fallback. 612 // Schreibfähige "private" highscore-Datei ermitteln für den fallback.
613 privateHighscoreFileInfo.setFile(KGlobal::dirs()->saveLocation("appdata")+highscoreName); 613 privateHighscoreFileInfo.setFile(KGlobal::dirs()->saveLocation("appdata")+highscoreName);
614 614
615 // FilePath aus der Konfigurationsdatei benutzen 615 // FilePath aus der Konfigurationsdatei benutzen
616 systemHighscoreFileInfo.setFile(cfg->readEntry("HighscoreFilePath")); 616 systemHighscoreFileInfo.setFile(cfg->readEntry("HighscoreFilePath"));
617 617
618 // Kein Wert aus der Konfiguration erhalten, dann die "system"-Datei suchen. 618 // Kein Wert aus der Konfiguration erhalten, dann die "system"-Datei suchen.
619 if (systemHighscoreFileInfo.filePath().isEmpty()) 619 if (systemHighscoreFileInfo.filePath().isEmpty())
620 systemHighscoreDirs = KGlobal::dirs()->resourceDirs("appdata"); 620 systemHighscoreDirs = KGlobal::dirs()->resourceDirs("appdata");
621 else 621 else
622 systemHighscoreDirs = QStringList(systemHighscoreFileInfo.filePath()); 622 systemHighscoreDirs = QStringList(systemHighscoreFileInfo.filePath());
623 623
624 for (QStringList::Iterator i = systemHighscoreDirs.begin(); i != systemHighscoreDirs.end(); ++i) { 624 for (QStringList::Iterator i = systemHighscoreDirs.begin(); i != systemHighscoreDirs.end(); ++i) {
625 625
626 systemHighscoreFileInfo.setFile(*i); 626 systemHighscoreFileInfo.setFile(*i);
627 if (systemHighscoreFileInfo.fileName().isEmpty()) 627 if (systemHighscoreFileInfo.fileName().isEmpty())
628 systemHighscoreFileInfo.setFile(systemHighscoreFileInfo.dirPath()+"/"+highscoreName); 628 systemHighscoreFileInfo.setFile(systemHighscoreFileInfo.dirPath()+"/"+highscoreName);
629 629
630 // privateHighscoreFileInfo für die "system" Suche ignorieren 630 // privateHighscoreFileInfo für die "system" Suche ignorieren
631 if (systemHighscoreFileInfo.filePath() != privateHighscoreFileInfo.filePath()) 631 if (systemHighscoreFileInfo.filePath() != privateHighscoreFileInfo.filePath())
632 if (!systemHighscoreFileInfo.exists()) { 632 if (!systemHighscoreFileInfo.exists()) {
633 systemHighscoreDirPath.setFile(systemHighscoreFileInfo.dirPath()); 633 systemHighscoreDirPath.setFile(systemHighscoreFileInfo.dirPath());
634 if (systemHighscoreDirPath.exists() && systemHighscoreDirPath.isWritable()) 634 if (systemHighscoreDirPath.exists() && systemHighscoreDirPath.isWritable())
635 return systemHighscoreFileInfo; 635 return systemHighscoreFileInfo;
636 } else 636 } else
637 if (systemHighscoreFileInfo.isWritable()) 637 if (systemHighscoreFileInfo.isWritable())
638 return systemHighscoreFileInfo; 638 return systemHighscoreFileInfo;
639 } 639 }
640#endif 640#endif
641 return privateHighscoreFileInfo; 641 return privateHighscoreFileInfo;
642} 642}
diff --git a/noncore/games/kpacman/status.cpp b/noncore/games/kpacman/status.cpp
index 00d1f22..3453d37 100644
--- a/noncore/games/kpacman/status.cpp
+++ b/noncore/games/kpacman/status.cpp
@@ -1,367 +1,367 @@
1 1
2#include "portable.h" 2#include "portable.h"
3 3
4#if defined( KDE2_PORT ) 4#if defined( KDE2_PORT )
5#include <kapp.h> 5#include <kapp.h>
6#include <klocale.h> 6#include <klocale.h>
7#include <kstddirs.h> 7#include <kstddirs.h>
8#include <status.h> 8#include <status.h>
9#include <status.moc> 9#include <status.moc>
10#elif defined( QPE_PORT ) 10#elif defined( QPE_PORT )
11#include <qpe/qpeapplication.h> 11#include <qpe/qpeapplication.h>
12#include "config.h" 12#include "config.h"
13#include "status.h" 13#include "status.h"
14#endif 14#endif
15 15
16#include <qpixmap.h> 16#include <qpixmap.h>
17#include <qbitmap.h> 17#include <qbitmap.h>
18#include <qstring.h> 18#include <qstring.h>
19#include <qmsgbox.h> 19#include <qmsgbox.h>
20#include <qfileinfo.h> 20#include <qfileinfo.h>
21 21
22Status::Status( QWidget *parent, const char *name, int Scheme, int Mode ) : 22Status::Status( QWidget *parent, const char *name, int Scheme, int Mode ) :
23 QWidget( parent, name ) 23 QWidget( parent, name )
24{ 24{
25 actualLifes = 0; 25 actualLifes = 0;
26 actualLevel = 0; 26 actualLevel = 0;
27 27
28 lifesPix = NULL; 28 lifesPix = NULL;
29 levelPix = NULL; 29 levelPix = NULL;
30 30
31 scheme = Scheme; 31 scheme = Scheme;
32 mode = Mode; 32 mode = Mode;
33 level = 0; 33 level = 0;
34 34
35 confScheme(); 35 confScheme();
36} 36}
37 37
38QList<QPixmap> *Status::loadPixmap(QWidget *parent, QString pixmapName, 38QList<QPixmap> *Status::loadPixmap(QWidget *parent, QString pixmapName,
39 QList<QPixmap> *pixmaps) 39 QList<QPixmap> *pixmaps)
40{ 40{
41 if (pixmaps == NULL) { 41 if (pixmaps == NULL) {
42 pixmaps = new QList<QPixmap>; 42 pixmaps = new QList<QPixmap>;
43 pixmaps->setAutoDelete(TRUE); 43 pixmaps->setAutoDelete(TRUE);
44 } 44 }
45 45
46 if (!pixmaps->isEmpty()) 46 if (!pixmaps->isEmpty())
47 pixmaps->clear(); 47 pixmaps->clear();
48 48
49 QPixmap PIXMAP(pixmapName); 49 QPixmap PIXMAP(pixmapName);
50 if (PIXMAP.isNull() || PIXMAP.mask() == NULL) { 50 if (PIXMAP.isNull() || PIXMAP.mask() == NULL) {
51 QString msg = i18n("The pixmap could not be contructed.\n\n" 51 QString msg = tr("The pixmap could not be contructed.\n\n"
52 "The file '@PIXMAPNAME@' does not exist,\n" 52 "The file '@PIXMAPNAME@' does not exist,\n"
53 "or is of an unknown format."); 53 "or is of an unknown format.");
54 msg.replace(QRegExp("@PIXMAPNAME@"), pixmapName); 54 msg.replace(QRegExp("@PIXMAPNAME@"), pixmapName);
55 QMessageBox::information(parent, i18n("Initialization Error"), 55 QMessageBox::information(parent, tr("Initialization Error"),
56 (const char *) msg); 56 (const char *) msg);
57 return 0; 57 return 0;
58 } 58 }
59 59
60 int height = PIXMAP.height(); 60 int height = PIXMAP.height();
61 int width = (height == 0) ? 0 : PIXMAP.width()/(PIXMAP.width()/height); 61 int width = (height == 0) ? 0 : PIXMAP.width()/(PIXMAP.width()/height);
62 62
63 QBitmap BITMAP; 63 QBitmap BITMAP;
64 QBitmap MASK; 64 QBitmap MASK;
65 65
66 BITMAP = *PIXMAP.mask(); 66 BITMAP = *PIXMAP.mask();
67 MASK.resize(width, height); 67 MASK.resize(width, height);
68 68
69 for (int x = 0; x < PIXMAP.width()/width; x++) { 69 for (int x = 0; x < PIXMAP.width()/width; x++) {
70 QPixmap *pixmap = new QPixmap(width, height); 70 QPixmap *pixmap = new QPixmap(width, height);
71 pixmaps->append(pixmap); 71 pixmaps->append(pixmap);
72 bitBlt(pixmap, 0, 0, &PIXMAP, x*width, 0, width, height, CopyROP, TRUE); 72 bitBlt(pixmap, 0, 0, &PIXMAP, x*width, 0, width, height, CopyROP, TRUE);
73 bitBlt(&MASK, 0, 0, &BITMAP, x*width, 0, width, height, CopyROP, TRUE); 73 bitBlt(&MASK, 0, 0, &BITMAP, x*width, 0, width, height, CopyROP, TRUE);
74 pixmap->setMask(MASK); 74 pixmap->setMask(MASK);
75 } 75 }
76 76
77 return pixmaps; 77 return pixmaps;
78} 78}
79 79
80void Status::paintEvent( QPaintEvent *) 80void Status::paintEvent( QPaintEvent *)
81{ 81{
82 for (int x = 0; x < actualLifes && !lifesPix->isEmpty(); x++) 82 for (int x = 0; x < actualLifes && !lifesPix->isEmpty(); x++)
83 bitBlt(this, lifesPix->at(0)->width()+(lifesPix->at(0)->width()*x), 83 bitBlt(this, lifesPix->at(0)->width()+(lifesPix->at(0)->width()*x),
84 (height()-lifesPix->at(0)->height())/2, 84 (height()-lifesPix->at(0)->height())/2,
85 lifesPix->at(0), 0, 0, 85 lifesPix->at(0), 0, 0,
86 lifesPix->at(0)->width(), lifesPix->at(0)->height()); 86 lifesPix->at(0)->width(), lifesPix->at(0)->height());
87 87
88 for (int x = 0; x < actualLevel && !levelPix->isEmpty(); x++) { 88 for (int x = 0; x < actualLevel && !levelPix->isEmpty(); x++) {
89 erase((width()-levelPix->at(x)->width()*2)-(levelPix->at(x)->width()*levelPos[x]), 89 erase((width()-levelPix->at(x)->width()*2)-(levelPix->at(x)->width()*levelPos[x]),
90 (height()-levelPix->at(x)->height())/2, 90 (height()-levelPix->at(x)->height())/2,
91 levelPix->at(x)->width(), levelPix->at(x)->height()); 91 levelPix->at(x)->width(), levelPix->at(x)->height());
92 bitBlt(this, (width()-levelPix->at(x)->width()*2)-(levelPix->at(x)->width()*levelPos[x]), 92 bitBlt(this, (width()-levelPix->at(x)->width()*2)-(levelPix->at(x)->width()*levelPos[x]),
93 (height()-levelPix->at(x)->height())/2, 93 (height()-levelPix->at(x)->height())/2,
94 levelPix->at(x), 0, 0, 94 levelPix->at(x), 0, 0,
95 levelPix->at(x)->width(), levelPix->at(x)->height()); 95 levelPix->at(x)->width(), levelPix->at(x)->height());
96 } 96 }
97} 97}
98 98
99void Status::initPixmaps() 99void Status::initPixmaps()
100{ 100{
101 if (lastLifesPixmapName != lifesPixmapName.at(level)) { 101 if (lastLifesPixmapName != lifesPixmapName.at(level)) {
102 lifesPix = loadPixmap(this, lifesPixmapName.at(level), lifesPix); 102 lifesPix = loadPixmap(this, lifesPixmapName.at(level), lifesPix);
103 lastLifesPixmapName = lifesPixmapName.at(level); 103 lastLifesPixmapName = lifesPixmapName.at(level);
104 } 104 }
105 if (lastLevelPixmapName != levelPixmapName.at(level)) { 105 if (lastLevelPixmapName != levelPixmapName.at(level)) {
106 levelPix = loadPixmap(this, levelPixmapName.at(level), levelPix); 106 levelPix = loadPixmap(this, levelPixmapName.at(level), levelPix);
107 lastLevelPixmapName = levelPixmapName.at(level); 107 lastLevelPixmapName = levelPixmapName.at(level);
108 } 108 }
109} 109}
110 110
111QString Status::decodeHexOctString(QString s) 111QString Status::decodeHexOctString(QString s)
112{ 112{
113 QString value; 113 QString value;
114 QString valids; 114 QString valids;
115 int pos, xpos = 0, opos = 0; 115 int pos, xpos = 0, opos = 0;
116 int v, len, leadin; 116 int v, len, leadin;
117 const char *ptr; 117 const char *ptr;
118 uchar c; 118 uchar c;
119 119
120 while (((xpos = s.find(QRegExp("\\\\x[0-9a-fA-F]+"), xpos)) != -1) || 120 while (((xpos = s.find(QRegExp("\\\\x[0-9a-fA-F]+"), xpos)) != -1) ||
121 ((opos = s.find(QRegExp("\\\\[0-7]+"), opos)) != -1)) { 121 ((opos = s.find(QRegExp("\\\\[0-7]+"), opos)) != -1)) {
122 if (xpos != -1) { 122 if (xpos != -1) {
123 valids = "0123456789abcdef"; 123 valids = "0123456789abcdef";
124 leadin = 2; 124 leadin = 2;
125 pos = xpos; 125 pos = xpos;
126 } else { 126 } else {
127 valids = "01234567"; 127 valids = "01234567";
128 leadin = 1; 128 leadin = 1;
129 pos = opos; 129 pos = opos;
130 } 130 }
131 131
132 c = '\0'; 132 c = '\0';
133 len = 0; 133 len = 0;
134 value = s.mid(pos+leadin, 3); 134 value = s.mid(pos+leadin, 3);
135 ptr = (const char *) value; 135 ptr = (const char *) value;
136 136
137 while (*ptr != '\0' && (v = valids.find(*ptr++, 0, FALSE)) != -1) { 137 while (*ptr != '\0' && (v = valids.find(*ptr++, 0, FALSE)) != -1) {
138 c = (c * valids.length()) + v; 138 c = (c * valids.length()) + v;
139 len++; 139 len++;
140 } 140 }
141 141
142 value.fill(c, 1); 142 value.fill(c, 1);
143 s.replace(pos, len+leadin, value); 143 s.replace(pos, len+leadin, value);
144 } 144 }
145 145
146 return s; 146 return s;
147} 147}
148 148
149void Status::fillArray(QArray<int> &array, QString values, int max) 149void Status::fillArray(QArray<int> &array, QString values, int max)
150{ 150{
151 array.resize(max); 151 array.resize(max);
152 int last = 0; 152 int last = 0;
153 bool ok; 153 bool ok;
154 QString value; 154 QString value;
155 155
156 for (uint i = 0; i < array.size(); i++) { 156 for (uint i = 0; i < array.size(); i++) {
157 if (values.find(',') < 0 && values.length() > 0) { 157 if (values.find(',') < 0 && values.length() > 0) {
158 value = values; 158 value = values;
159 values = ""; 159 values = "";
160 } 160 }
161 if (values.find(',') >= 0) { 161 if (values.find(',') >= 0) {
162 value = values.left(values.find(',')); 162 value = values.left(values.find(','));
163 values.remove(0,values.find(',')+1); 163 values.remove(0,values.find(',')+1);
164 } 164 }
165 array[i] = value.toInt(&ok); 165 array[i] = value.toInt(&ok);
166 if (ok) 166 if (ok)
167 last = array[i]; 167 last = array[i];
168 else 168 else
169 array[i] = last; 169 array[i] = last;
170 } 170 }
171} 171}
172 172
173void Status::fillStrList(QStrList &list, QString values, int max) 173void Status::fillStrList(QStrList &list, QString values, int max)
174{ 174{
175 if (!list.isEmpty()) 175 if (!list.isEmpty())
176 list.clear(); 176 list.clear();
177 177
178 QString last = ""; 178 QString last = "";
179 QString value; 179 QString value;
180 180
181 for (uint i = 0; i < (uint) max; i++) { 181 for (uint i = 0; i < (uint) max; i++) {
182 if (values.find(',') < 0 && values.length() > 0) { 182 if (values.find(',') < 0 && values.length() > 0) {
183 value = values; 183 value = values;
184 values = ""; 184 values = "";
185 } 185 }
186 if (values.find(',') >= 0) { 186 if (values.find(',') >= 0) {
187 value = values.left(values.find(',')); 187 value = values.left(values.find(','));
188 values.remove(0,values.find(',')+1); 188 values.remove(0,values.find(',')+1);
189 } 189 }
190 if (!value.isEmpty()) 190 if (!value.isEmpty())
191 last = decodeHexOctString(value); 191 last = decodeHexOctString(value);
192 list.append(last); 192 list.append(last);
193 } 193 }
194} 194}
195 195
196void Status::fillPixmapName(QStrList &pixmapName) 196void Status::fillPixmapName(QStrList &pixmapName)
197{ 197{
198 QStrList list = pixmapName; 198 QStrList list = pixmapName;
199 199
200 if (!pixmapName.isEmpty()) 200 if (!pixmapName.isEmpty())
201 pixmapName.clear(); 201 pixmapName.clear();
202 202
203 QString pixmap; 203 QString pixmap;
204 204
205 QFileInfo fileInfo; 205 QFileInfo fileInfo;
206 206
207 for (uint i = 0; i < list.count(); i++) { 207 for (uint i = 0; i < list.count(); i++) {
208 pixmap = list.at(i); 208 pixmap = list.at(i);
209 209
210 if (pixmap.left(1) != "/" && pixmap.left(1) != "~") 210 if (pixmap.left(1) != "/" && pixmap.left(1) != "~")
211 pixmap = FIND_APP_DATA( pixmapDirectory+pixmap ); 211 pixmap = FIND_APP_DATA( pixmapDirectory+pixmap );
212 212
213 fileInfo.setFile(pixmap); 213 fileInfo.setFile(pixmap);
214 if (!fileInfo.isReadable() || !fileInfo.isFile()) 214 if (!fileInfo.isReadable() || !fileInfo.isFile())
215 pixmap = ""; 215 pixmap = "";
216 216
217 pixmapName.append(pixmap); 217 pixmapName.append(pixmap);
218 } 218 }
219} 219}
220 220
221void Status::confLevels(bool defGroup) 221void Status::confLevels(bool defGroup)
222{ 222{
223 APP_CONFIG_BEGIN( cfg ); 223 APP_CONFIG_BEGIN( cfg );
224 if (defGroup || cfg->hasKey("Levels")) 224 if (defGroup || cfg->hasKey("Levels"))
225 maxLevel = cfg->readNumEntry("Levels", 13); 225 maxLevel = cfg->readNumEntry("Levels", 13);
226 APP_CONFIG_END( cfg ); 226 APP_CONFIG_END( cfg );
227} 227}
228 228
229void Status::confMisc(bool defGroup) 229void Status::confMisc(bool defGroup)
230{ 230{
231 APP_CONFIG_BEGIN( cfg ); 231 APP_CONFIG_BEGIN( cfg );
232 if (defGroup || cfg->hasKey("LevelPosition")) 232 if (defGroup || cfg->hasKey("LevelPosition"))
233 fillArray(levelPos, cfg->readEntry("LevelPosition", "0,1,2,3,,4,,5,,6,,7"), maxLevel); 233 fillArray(levelPos, cfg->readEntry("LevelPosition", "0,1,2,3,,4,,5,,6,,7"), maxLevel);
234 234
235 if (defGroup || cfg->hasKey("PixmapDirectory")) { 235 if (defGroup || cfg->hasKey("PixmapDirectory")) {
236 pixmapDirectory = cfg->readEntry("PixmapDirectory"); 236 pixmapDirectory = cfg->readEntry("PixmapDirectory");
237 237
238 if (pixmapDirectory.left(1) != "/" && pixmapDirectory.left(1) != "~") 238 if (pixmapDirectory.left(1) != "/" && pixmapDirectory.left(1) != "~")
239 pixmapDirectory.insert(0, "pics/"); 239 pixmapDirectory.insert(0, "pics/");
240 if (pixmapDirectory.right(1) != "/") 240 if (pixmapDirectory.right(1) != "/")
241 pixmapDirectory.append("/"); 241 pixmapDirectory.append("/");
242 } 242 }
243 243
244 if (defGroup || cfg->hasKey("LifesPixmapName")) 244 if (defGroup || cfg->hasKey("LifesPixmapName"))
245 fillStrList(lifesPixmapName, 245 fillStrList(lifesPixmapName,
246 cfg->readEntry("LifesPixmapName", "lifes.xpm"), maxLevel+1); 246 cfg->readEntry("LifesPixmapName", "lifes.xpm"), maxLevel+1);
247 if (defGroup || cfg->hasKey("LevelPixmapName")) 247 if (defGroup || cfg->hasKey("LevelPixmapName"))
248 fillStrList(levelPixmapName, 248 fillStrList(levelPixmapName,
249 cfg->readEntry("LevelPixmapName", "level.xpm"), maxLevel+1); 249 cfg->readEntry("LevelPixmapName", "level.xpm"), maxLevel+1);
250 APP_CONFIG_END( cfg ); 250 APP_CONFIG_END( cfg );
251} 251}
252 252
253void Status::confScheme() 253void Status::confScheme()
254{ 254{
255 APP_CONFIG_BEGIN( cfg ); 255 APP_CONFIG_BEGIN( cfg );
256 SAVE_CONFIG_GROUP( cfg, oldgroup ); 256 SAVE_CONFIG_GROUP( cfg, oldgroup );
257 QString newgroup; 257 QString newgroup;
258 258
259 // if not set, read mode and scheme from the configfile 259 // if not set, read mode and scheme from the configfile
260 if (mode == -1 && scheme == -1) { 260 if (mode == -1 && scheme == -1) {
261 scheme = cfg->readNumEntry("Scheme", -1); 261 scheme = cfg->readNumEntry("Scheme", -1);
262 mode = cfg->readNumEntry("Mode", -1); 262 mode = cfg->readNumEntry("Mode", -1);
263 263
264 // if mode is not set in the defGroup-group, lookup the scheme group 264 // if mode is not set in the defGroup-group, lookup the scheme group
265 if (scheme != -1 || mode == -1) { 265 if (scheme != -1 || mode == -1) {
266 newgroup.sprintf("Scheme %d", scheme); 266 newgroup.sprintf("Scheme %d", scheme);
267 cfg->setGroup(newgroup); 267 cfg->setGroup(newgroup);
268 268
269 mode = cfg->readNumEntry("Mode", -1); 269 mode = cfg->readNumEntry("Mode", -1);
270 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 270 RESTORE_CONFIG_GROUP( cfg, oldgroup );
271 } 271 }
272 } 272 }
273 273
274 confLevels(); 274 confLevels();
275 275
276 if (mode != -1) { 276 if (mode != -1) {
277 newgroup.sprintf("Mode %d", mode); 277 newgroup.sprintf("Mode %d", mode);
278 cfg->setGroup(newgroup); 278 cfg->setGroup(newgroup);
279 279
280 confLevels(FALSE); 280 confLevels(FALSE);
281 } 281 }
282 282
283 if (scheme != -1) { 283 if (scheme != -1) {
284 newgroup.sprintf("Scheme %d", scheme); 284 newgroup.sprintf("Scheme %d", scheme);
285 cfg->setGroup(newgroup); 285 cfg->setGroup(newgroup);
286 286
287 confLevels(FALSE); 287 confLevels(FALSE);
288 } 288 }
289 289
290 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 290 RESTORE_CONFIG_GROUP( cfg, oldgroup );
291 291
292 confMisc(); 292 confMisc();
293 293
294 if (mode != -1) { 294 if (mode != -1) {
295 newgroup.sprintf("Mode %d", mode); 295 newgroup.sprintf("Mode %d", mode);
296 cfg->setGroup(newgroup); 296 cfg->setGroup(newgroup);
297 297
298 confMisc(FALSE); 298 confMisc(FALSE);
299 } 299 }
300 300
301 if (scheme != -1) { 301 if (scheme != -1) {
302 newgroup.sprintf("Scheme %d", scheme); 302 newgroup.sprintf("Scheme %d", scheme);
303 cfg->setGroup(newgroup); 303 cfg->setGroup(newgroup);
304 304
305 confMisc(FALSE); 305 confMisc(FALSE);
306 } 306 }
307 307
308 fillPixmapName(lifesPixmapName); 308 fillPixmapName(lifesPixmapName);
309 fillPixmapName(levelPixmapName); 309 fillPixmapName(levelPixmapName);
310 310
311 initPixmaps(); 311 initPixmaps();
312 312
313 setFixedHeight(minHeight()); 313 setFixedHeight(minHeight());
314 314
315 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 315 RESTORE_CONFIG_GROUP( cfg, oldgroup );
316 APP_CONFIG_END( cfg ); 316 APP_CONFIG_END( cfg );
317} 317}
318 318
319void Status::setScheme(int Scheme, int Mode) 319void Status::setScheme(int Scheme, int Mode)
320{ 320{
321 mode = Mode; 321 mode = Mode;
322 scheme = Scheme; 322 scheme = Scheme;
323 323
324 confScheme(); 324 confScheme();
325 325
326 repaint(); 326 repaint();
327} 327}
328 328
329int Status::minHeight() 329int Status::minHeight()
330{ 330{
331 if (lifesPix->isEmpty() && levelPix->isEmpty()) 331 if (lifesPix->isEmpty() && levelPix->isEmpty())
332 return 0; 332 return 0;
333 if (levelPix->isEmpty()) 333 if (levelPix->isEmpty())
334 return lifesPix->at(0)->height(); 334 return lifesPix->at(0)->height();
335 if (lifesPix->isEmpty()) 335 if (lifesPix->isEmpty())
336 return levelPix->at(0)->height(); 336 return levelPix->at(0)->height();
337 return (lifesPix->at(0)->height() > levelPix->at(0)->height()) ? 337 return (lifesPix->at(0)->height() > levelPix->at(0)->height()) ?
338 lifesPix->at(0)->height() : levelPix->at(0)->height(); 338 lifesPix->at(0)->height() : levelPix->at(0)->height();
339} 339}
340 340
341int Status::minWidth() 341int Status::minWidth()
342{ 342{
343 if (lifesPix->isEmpty() && levelPix->isEmpty()) 343 if (lifesPix->isEmpty() && levelPix->isEmpty())
344 return 0; 344 return 0;
345 if (levelPix->isEmpty()) 345 if (levelPix->isEmpty())
346 return lifesPix->at(0)->width(); 346 return lifesPix->at(0)->width();
347 if (lifesPix->isEmpty()) 347 if (lifesPix->isEmpty())
348 return levelPix->at(0)->width(); 348 return levelPix->at(0)->width();
349 return (lifesPix->at(0)->width() > levelPix->at(0)->width()) ? 349 return (lifesPix->at(0)->width() > levelPix->at(0)->width()) ?
350 lifesPix->at(0)->width() : levelPix->at(0)->width(); 350 lifesPix->at(0)->width() : levelPix->at(0)->width();
351} 351}
352 352
353void Status::setLifes(int lifes) 353void Status::setLifes(int lifes)
354{ 354{
355 actualLifes = lifes; 355 actualLifes = lifes;
356 repaint(); 356 repaint();
357} 357}
358 358
359void Status::setLevel(int Level) 359void Status::setLevel(int Level)
360{ 360{
361 level = Level; 361 level = Level;
362 362
363 initPixmaps(); 363 initPixmaps();
364 364
365 actualLevel = (level > (int) levelPix->count()) ? (int) levelPix->count() : level; 365 actualLevel = (level > (int) levelPix->count()) ? (int) levelPix->count() : level;
366 repaint(); 366 repaint();
367} 367}