summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/kpacman/kpacman.cpp23
-rw-r--r--noncore/games/kpacman/kpacman.h18
-rw-r--r--noncore/games/kpacman/kpacmanwidget.cpp9
-rw-r--r--noncore/games/kpacman/referee.cpp4
-rw-r--r--noncore/games/kpacman/score.cpp61
5 files changed, 14 insertions, 101 deletions
diff --git a/noncore/games/kpacman/kpacman.cpp b/noncore/games/kpacman/kpacman.cpp
index 7df6ef0..d9d2d69 100644
--- a/noncore/games/kpacman/kpacman.cpp
+++ b/noncore/games/kpacman/kpacman.cpp
@@ -1,369 +1,364 @@
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 m_view = new QWidget( this, "m_view" );
30 m_view->setBackgroundColor( black );
31 m_layout = new QGridLayout( m_view );
32 m_layout->setMargin( 7 );
30 33
31#ifndef QWS 34 view = new KpacmanWidget( this, QString(name)+"widget");
32 setFixedSize(view->width(), view->height()); 35 m_layout->addWidget( view, 0, 0 );
33#else 36
34 setCaption( "Kpacman" ); 37 setCaption( "KPacman" );
35#endif
36 38
37 view->referee->setFocus(); 39 view->referee->setFocus();
38 40
39 connect(view->referee, SIGNAL(setScore(int, int)), 41 connect(view->referee, SIGNAL(setScore(int, int)),
40 view->score, SLOT(setScore(int, int))); 42 view->score, SLOT(setScore(int, int)));
41 connect(view->referee, SIGNAL(setPoints(int)), 43 connect(view->referee, SIGNAL(setPoints(int)),
42 view->score, SLOT(set(int))); 44 view->score, SLOT(set(int)));
43 connect(view->referee, SIGNAL(setLifes(int)), 45 connect(view->referee, SIGNAL(setLifes(int)),
44 view->status, SLOT(setLifes(int))); 46 view->status, SLOT(setLifes(int)));
45 connect(view->referee, SIGNAL(setLevel(int)), 47 connect(view->referee, SIGNAL(setLevel(int)),
46 view->status, SLOT(setLevel(int))); 48 view->status, SLOT(setLevel(int)));
47 connect(view->referee, SIGNAL(forcedHallOfFame(bool)), 49 connect(view->referee, SIGNAL(forcedHallOfFame(bool)),
48 this, SLOT(forcedHallOfFame(bool))); 50 this, SLOT(forcedHallOfFame(bool)));
49 connect(view->referee, SIGNAL(togglePaused()), this, SLOT(togglePaused())); 51 connect(view->referee, SIGNAL(togglePaused()), this, SLOT(togglePaused()));
50 connect(view->referee, SIGNAL(toggleNew()), this, SLOT(toggleNew())); 52 connect(view->referee, SIGNAL(toggleNew()), this, SLOT(toggleNew()));
51 53
52 connect(view->score, SIGNAL(toggleNew()), this, SLOT(toggleNew())); 54 connect(view->score, SIGNAL(toggleNew()), this, SLOT(toggleNew()));
53 connect(view->score, SIGNAL(forcedHallOfFame(bool)), 55 connect(view->score, SIGNAL(forcedHallOfFame(bool)),
54 this, SLOT(forcedHallOfFame(bool))); 56 this, SLOT(forcedHallOfFame(bool)));
55 57
56 APP_CONFIG_BEGIN( cfg ); 58 APP_CONFIG_BEGIN( cfg );
57 focusOutPause = !cfg->readBoolEntry("FocusOutPause", TRUE); 59 focusOutPause = !cfg->readBoolEntry("FocusOutPause", TRUE);
58 focusInContinue = !cfg->readBoolEntry("FocusInContinue", TRUE); 60 focusInContinue = !cfg->readBoolEntry("FocusInContinue", TRUE);
59 hideMouseCursor = !cfg->readBoolEntry("HideMouseCursor", TRUE); 61 hideMouseCursor = !cfg->readBoolEntry("HideMouseCursor", TRUE);
60 APP_CONFIG_END( cfg ); 62 APP_CONFIG_END( cfg );
61 63
62 toggleFocusOutPause(); 64 toggleFocusOutPause();
63 toggleFocusInContinue(); 65 toggleFocusInContinue();
64 toggleHideMouseCursor(); 66 toggleHideMouseCursor();
65 67
66#ifndef QWS 68 setCentralWidget( m_view );
67 menuBar->show();
68 view->show();
69 setMenu(menuBar);
70 setView(view);
71#else
72 setCentralWidget( view );
73#endif
74} 69}
75 70
76Kpacman::~Kpacman() 71Kpacman::~Kpacman()
77{ 72{
78 APP_CONFIG_BEGIN( cfg ); 73 APP_CONFIG_BEGIN( cfg );
79 cfg->writeEntry("FocusOutPause", focusOutPause); 74 cfg->writeEntry("FocusOutPause", focusOutPause);
80 cfg->writeEntry("FocusInContinue", focusInContinue); 75 cfg->writeEntry("FocusInContinue", focusInContinue);
81 cfg->writeEntry("HideMouseCursor", hideMouseCursor); 76 cfg->writeEntry("HideMouseCursor", hideMouseCursor);
82 APP_CONFIG_END( cfg ); 77 APP_CONFIG_END( cfg );
83 delete _menuBar; 78 delete _menuBar;
84} 79}
85 80
86void Kpacman::menu() 81void Kpacman::menu()
87{ 82{
88 gamePopup = new QPopupMenu(); 83 gamePopup = new QPopupMenu();
89 CHECK_PTR( gamePopup ); 84 CHECK_PTR( gamePopup );
90 newID = gamePopup->insertItem(tr("&New"), this, SLOT(newKpacman()),Key_F2); 85 newID = gamePopup->insertItem(tr("&New"), this, SLOT(newKpacman()),Key_F2);
91 pauseID = gamePopup->insertItem(tr("&Pause"), 86 pauseID = gamePopup->insertItem(tr("&Pause"),
92 this, SLOT(pauseKpacman()), Key_F3); 87 this, SLOT(pauseKpacman()), Key_F3);
93 hofID = gamePopup->insertItem(tr("&Hall of fame"), 88 hofID = gamePopup->insertItem(tr("&Hall of fame"),
94 this, SLOT(toggleHallOfFame()), Key_F4); 89 this, SLOT(toggleHallOfFame()), Key_F4);
95 gamePopup->insertSeparator(); 90 gamePopup->insertSeparator();
96 gamePopup->insertItem(tr("&Quit"), this, SLOT(quitKpacman()), CTRL+Key_Q); 91 gamePopup->insertItem(tr("&Quit"), this, SLOT(quitKpacman()), CTRL+Key_Q);
97 gamePopup->setCheckable(TRUE); 92 gamePopup->setCheckable(TRUE);
98 93
99 optionsPopup = new QPopupMenu(); 94 optionsPopup = new QPopupMenu();
100 CHECK_PTR(optionsPopup); 95 CHECK_PTR(optionsPopup);
101 96
102 modesPopup = new QPopupMenu(); 97 modesPopup = new QPopupMenu();
103 CHECK_PTR(modesPopup); 98 CHECK_PTR(modesPopup);
104 99
105 hideMouseCursorID = optionsPopup->insertItem(tr("&Hide Mousecursor"), 100 hideMouseCursorID = optionsPopup->insertItem(tr("&Hide Mousecursor"),
106 this, SLOT(toggleHideMouseCursor()), 101 this, SLOT(toggleHideMouseCursor()),
107 CTRL+Key_H); 102 CTRL+Key_H);
108 optionsPopup->insertSeparator(); 103 optionsPopup->insertSeparator();
109 104
110 if (lookupSchemes() > 0) { 105 if (lookupSchemes() > 0) {
111 optionsPopup->insertItem(tr("&Select graphic scheme"), modesPopup); 106 optionsPopup->insertItem(tr("&Select graphic scheme"), modesPopup);
112 optionsPopup->insertSeparator(); 107 optionsPopup->insertSeparator();
113 } 108 }
114 109
115 focusOutPauseID = optionsPopup->insertItem(tr("&Pause in Background"), 110 focusOutPauseID = optionsPopup->insertItem(tr("&Pause in Background"),
116 this, SLOT(toggleFocusOutPause())); 111 this, SLOT(toggleFocusOutPause()));
117 focusInContinueID = optionsPopup->insertItem(tr("&Continue in Foreground"), 112 focusInContinueID = optionsPopup->insertItem(tr("&Continue in Foreground"),
118 this, SLOT(toggleFocusInContinue())); 113 this, SLOT(toggleFocusInContinue()));
119 optionsPopup->insertSeparator(); 114 optionsPopup->insertSeparator();
120 115
121 optionsPopup->insertItem(tr("Change &keys..."), this, SLOT(confKeys())); 116 optionsPopup->insertItem(tr("Change &keys..."), this, SLOT(confKeys()));
122 117
123#ifndef QWS 118#ifndef QWS
124 QString aboutText = tr("@PACKAGE@ - @VERSION@\n\n" 119 QString aboutText = tr("@PACKAGE@ - @VERSION@\n\n"
125 "Joerg Thoennissen (joe@dsite.de)\n\n" 120 "Joerg Thoennissen (joe@dsite.de)\n\n"
126 "A pacman game for the KDE Desktop\n\n" 121 "A pacman game for the KDE Desktop\n\n"
127 "The program based on the source of ksnake\n" 122 "The program based on the source of ksnake\n"
128 "by Michel Filippi (mfilippi@sade.rhein-main.de).\n" 123 "by Michel Filippi (mfilippi@sade.rhein-main.de).\n"
129 "The design was strongly influenced by the pacman\n" 124 "The design was strongly influenced by the pacman\n"
130 "(c) 1980 MIDWAY MFG.CO.\n\n" 125 "(c) 1980 MIDWAY MFG.CO.\n\n"
131 "I like to thank my girlfriend Elke Krueers for\n" 126 "I like to thank my girlfriend Elke Krueers for\n"
132 "the last 10 years of her friendship.\n"); 127 "the last 10 years of her friendship.\n");
133 aboutText.replace(QRegExp("@PACKAGE@"), PACKAGE); 128 aboutText.replace(QRegExp("@PACKAGE@"), PACKAGE);
134 aboutText.replace(QRegExp("@VERSION@"), VERSION); 129 aboutText.replace(QRegExp("@VERSION@"), VERSION);
135 QPopupMenu *helpPopup = helpMenu(aboutText, FALSE); 130 QPopupMenu *helpPopup = helpMenu(aboutText, FALSE);
136#endif 131#endif
137 132
138 //_menuBar = new KMenuBar(this); 133 //_menuBar = new KMenuBar(this);
139 //CHECK_PTR( _menuBar ); 134 //CHECK_PTR( _menuBar );
140 //_menuBar->insertItem(tr("&Game"), gamePopup); 135 //_menuBar->insertItem(tr("&Game"), gamePopup);
141 //_menuBar->insertItem(tr("&Options"), optionsPopup); 136 //_menuBar->insertItem(tr("&Options"), optionsPopup);
142 //_menuBar->insertSeparator(); 137 //_menuBar->insertSeparator();
143#ifndef QWS 138#ifndef QWS
144 _menuBar->insertItem(tr("&Help"), helpPopup); 139 _menuBar->insertItem(tr("&Help"), helpPopup);
145#endif 140#endif
146} 141}
147 142
148int Kpacman::lookupSchemes() 143int Kpacman::lookupSchemes()
149{ 144{
150 APP_CONFIG_BEGIN( cfg ); 145 APP_CONFIG_BEGIN( cfg );
151 int ModeCount = cfg->readNumEntry("ModeCount", -1); 146 int ModeCount = cfg->readNumEntry("ModeCount", -1);
152 int Mode = cfg->readNumEntry("Mode", -1); 147 int Mode = cfg->readNumEntry("Mode", -1);
153 int SchemeCount = cfg->readNumEntry("SchemeCount"); 148 int SchemeCount = cfg->readNumEntry("SchemeCount");
154 int Scheme = cfg->readNumEntry("Scheme", -1); 149 int Scheme = cfg->readNumEntry("Scheme", -1);
155 150
156 if (SchemeCount == 0 || Scheme == -1) { 151 if (SchemeCount == 0 || Scheme == -1) {
157 QMessageBox::warning(this, tr("Configuration Error"), 152 QMessageBox::warning(this, tr("Configuration Error"),
158 tr("There are no schemes defined,\n" 153 tr("There are no schemes defined,\n"
159 "or no scheme is selected.")); 154 "or no scheme is selected."));
160 APP_CONFIG_END( cfg ); 155 APP_CONFIG_END( cfg );
161 return 0; 156 return 0;
162 } 157 }
163 158
164 connect(modesPopup, SIGNAL(activated(int)), this, SLOT(schemeChecked(int))); 159 connect(modesPopup, SIGNAL(activated(int)), this, SLOT(schemeChecked(int)));
165 modeID.resize(ModeCount > 0 ? ModeCount : 0); 160 modeID.resize(ModeCount > 0 ? ModeCount : 0);
166 161
167 if (!schemesPopup->isEmpty()) 162 if (!schemesPopup->isEmpty())
168 schemesPopup->clear(); 163 schemesPopup->clear();
169 164
170 SAVE_CONFIG_GROUP( cfg, oldgroup ); 165 SAVE_CONFIG_GROUP( cfg, oldgroup );
171 166
172 QString ModeGroup; 167 QString ModeGroup;
173 QString ModeName; 168 QString ModeName;
174 169
175 for (int m = 0; m < ModeCount; m++) { 170 for (int m = 0; m < ModeCount; m++) {
176 ModeGroup.sprintf("Mode %d", m); 171 ModeGroup.sprintf("Mode %d", m);
177 cfg->setGroup(ModeGroup); 172 cfg->setGroup(ModeGroup);
178 173
179 ModeName = cfg->readEntry("Description", ModeGroup); 174 ModeName = cfg->readEntry("Description", ModeGroup);
180 175
181 QPopupMenu *p = new QPopupMenu; 176 QPopupMenu *p = new QPopupMenu;
182 p->setCheckable(TRUE); 177 p->setCheckable(TRUE);
183 connect(p, SIGNAL(activated(int)), this, SLOT(schemeChecked(int))); 178 connect(p, SIGNAL(activated(int)), this, SLOT(schemeChecked(int)));
184 schemesPopup->append(p); 179 schemesPopup->append(p);
185 180
186 modeID[m] = modesPopup->insertItem(ModeName, schemesPopup->at(m)); 181 modeID[m] = modesPopup->insertItem(ModeName, schemesPopup->at(m));
187 modesPopup->setItemEnabled(modeID[m], FALSE); 182 modesPopup->setItemEnabled(modeID[m], FALSE);
188 modesPopup->setItemChecked(modeID[m], m == Mode); 183 modesPopup->setItemChecked(modeID[m], m == Mode);
189 } 184 }
190 185
191 schemeID.resize(SchemeCount); 186 schemeID.resize(SchemeCount);
192 schemeMode.resize(SchemeCount); 187 schemeMode.resize(SchemeCount);
193 188
194 QString SchemeGroup; 189 QString SchemeGroup;
195 QString SchemeName; 190 QString SchemeName;
196 int SchemeMode; 191 int SchemeMode;
197 192
198 for (int i = 0; i < SchemeCount; i++) { 193 for (int i = 0; i < SchemeCount; i++) {
199 SchemeGroup.sprintf("Scheme %d", i); 194 SchemeGroup.sprintf("Scheme %d", i);
200 cfg->setGroup(SchemeGroup); 195 cfg->setGroup(SchemeGroup);
201 196
202 SchemeName = cfg->readEntry("Description", SchemeGroup); 197 SchemeName = cfg->readEntry("Description", SchemeGroup);
203 SchemeMode = cfg->readNumEntry("Mode", -1); 198 SchemeMode = cfg->readNumEntry("Mode", -1);
204 199
205 schemeMode[i] = SchemeMode; 200 schemeMode[i] = SchemeMode;
206 if (SchemeMode == -1) { 201 if (SchemeMode == -1) {
207 schemeID[i] = modesPopup->insertItem(SchemeName); 202 schemeID[i] = modesPopup->insertItem(SchemeName);
208 modesPopup->setItemChecked(schemeID[i], i == Scheme); 203 modesPopup->setItemChecked(schemeID[i], i == Scheme);
209 } else { 204 } else {
210 schemeID[i] = schemesPopup->at(SchemeMode)->insertItem(SchemeName); 205 schemeID[i] = schemesPopup->at(SchemeMode)->insertItem(SchemeName);
211 schemesPopup->at(SchemeMode)-> 206 schemesPopup->at(SchemeMode)->
212 setItemChecked(schemeID[i], i == Scheme); 207 setItemChecked(schemeID[i], i == Scheme);
213 modesPopup->setItemEnabled(modeID[SchemeMode], TRUE); 208 modesPopup->setItemEnabled(modeID[SchemeMode], TRUE);
214 } 209 }
215 } 210 }
216 211
217 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 212 RESTORE_CONFIG_GROUP( cfg, oldgroup );
218 213
219 APP_CONFIG_END( cfg ); 214 APP_CONFIG_END( cfg );
220 return SchemeCount; 215 return SchemeCount;
221} 216}
222 217
223void Kpacman::quitKpacman() 218void Kpacman::quitKpacman()
224{ 219{
225 APP_QUIT(); 220 APP_QUIT();
226} 221}
227 222
228void Kpacman::newKpacman() 223void Kpacman::newKpacman()
229{ 224{
230 if (!gamePopup->isItemEnabled(hofID)) 225 if (!gamePopup->isItemEnabled(hofID))
231 gamePopup->setItemEnabled(hofID, TRUE); 226 gamePopup->setItemEnabled(hofID, TRUE);
232 227
233 if (gamePopup->isItemChecked(hofID)) 228 if (gamePopup->isItemChecked(hofID))
234 toggleHallOfFame(); 229 toggleHallOfFame();
235 230
236 if (gamePopup->isItemChecked(pauseID)) 231 if (gamePopup->isItemChecked(pauseID))
237 pauseKpacman(); 232 pauseKpacman();
238 233
239 view->referee->play(); 234 view->referee->play();
240} 235}
241 236
242void Kpacman::pauseKpacman() 237void Kpacman::pauseKpacman()
243{ 238{
244 view->referee->pause(); 239 view->referee->pause();
245 view->score->setPause(gamePopup->isItemChecked(pauseID)); 240 view->score->setPause(gamePopup->isItemChecked(pauseID));
246} 241}
247 242
248void Kpacman::toggleHallOfFame() 243void Kpacman::toggleHallOfFame()
249{ 244{
250 gamePopup->setItemChecked(hofID, !gamePopup->isItemChecked(hofID)); 245 gamePopup->setItemChecked(hofID, !gamePopup->isItemChecked(hofID));
251 view->referee->toggleHallOfFame(); 246 view->referee->toggleHallOfFame();
252 247
253 if (gamePopup->isItemChecked(hofID)) { 248 if (gamePopup->isItemChecked(hofID)) {
254 view->referee->lower(); 249 view->referee->lower();
255 view->status->lower(); 250 view->status->lower();
256 } else { 251 } else {
257 view->status->raise(); 252 view->status->raise();
258 view->referee->raise(); 253 view->referee->raise();
259 view->referee->setFocus(); 254 view->referee->setFocus();
260 } 255 }
261} 256}
262 257
263/* 258/*
264 * Disable or enable the "Hall of fame"-menuitem if the referee says so. 259 * 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 260 * 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 261 * sequence of displaying the introduction, the demonstration (or playing) and the
267 * hall of fame. 262 * hall of fame.
268 * If on == TRUE then also lower the referee and the status widgets. 263 * If on == TRUE then also lower the referee and the status widgets.
269 */ 264 */
270void Kpacman::forcedHallOfFame(bool on) 265void Kpacman::forcedHallOfFame(bool on)
271{ 266{
272 if (!on && !gamePopup->isItemChecked(hofID)) 267 if (!on && !gamePopup->isItemChecked(hofID))
273 return; 268 return;
274 269
275 gamePopup->setItemEnabled(hofID, !on); 270 gamePopup->setItemEnabled(hofID, !on);
276 gamePopup->setItemChecked(hofID, on); 271 gamePopup->setItemChecked(hofID, on);
277 272
278 view->referee->toggleHallOfFame(); 273 view->referee->toggleHallOfFame();
279 if (on) { 274 if (on) {
280 view->referee->lower(); 275 view->referee->lower();
281 view->status->lower(); 276 view->status->lower();
282 } else { 277 } else {
283 view->status->raise(); 278 view->status->raise();
284 view->referee->raise(); 279 view->referee->raise();
285 view->referee->setFocus(); 280 view->referee->setFocus();
286 view->referee->intro(); 281 view->referee->intro();
287 } 282 }
288} 283}
289 284
290void Kpacman::togglePaused() 285void Kpacman::togglePaused()
291{ 286{
292 static bool checked = FALSE; 287 static bool checked = FALSE;
293 checked = !checked; 288 checked = !checked;
294 gamePopup->setItemChecked( pauseID, checked ); 289 gamePopup->setItemChecked( pauseID, checked );
295 view->score->setPause(gamePopup->isItemChecked(pauseID)); 290 view->score->setPause(gamePopup->isItemChecked(pauseID));
296} 291}
297 292
298/* 293/*
299 * This disables the "New Game" menuitem to prevent interruptions of the current 294 * This disables the "New Game" menuitem to prevent interruptions of the current
300 * play. 295 * play.
301 */ 296 */
302void Kpacman::toggleNew() 297void Kpacman::toggleNew()
303{ 298{
304 gamePopup->setItemEnabled(newID, !gamePopup->isItemEnabled(newID)); 299 gamePopup->setItemEnabled(newID, !gamePopup->isItemEnabled(newID));
305} 300}
306 301
307void Kpacman::toggleHideMouseCursor() 302void Kpacman::toggleHideMouseCursor()
308{ 303{
309 hideMouseCursor = !hideMouseCursor; 304 hideMouseCursor = !hideMouseCursor;
310 optionsPopup->setItemChecked(hideMouseCursorID, hideMouseCursor); 305 optionsPopup->setItemChecked(hideMouseCursorID, hideMouseCursor);
311 if (hideMouseCursor) 306 if (hideMouseCursor)
312 view->setCursor(blankCursor); 307 view->setCursor(blankCursor);
313 else 308 else
314 view->setCursor(arrowCursor); 309 view->setCursor(arrowCursor);
315} 310}
316 311
317void Kpacman::toggleFocusOutPause() 312void Kpacman::toggleFocusOutPause()
318{ 313{
319 focusOutPause = !focusOutPause; 314 focusOutPause = !focusOutPause;
320 optionsPopup->setItemChecked(focusOutPauseID, focusOutPause); 315 optionsPopup->setItemChecked(focusOutPauseID, focusOutPause);
321 view->referee->setFocusOutPause(focusOutPause); 316 view->referee->setFocusOutPause(focusOutPause);
322} 317}
323 318
324void Kpacman::toggleFocusInContinue() 319void Kpacman::toggleFocusInContinue()
325{ 320{
326 focusInContinue = !focusInContinue; 321 focusInContinue = !focusInContinue;
327 optionsPopup->setItemChecked(focusInContinueID, focusInContinue); 322 optionsPopup->setItemChecked(focusInContinueID, focusInContinue);
328 view->referee->setFocusInContinue(focusInContinue); 323 view->referee->setFocusInContinue(focusInContinue);
329} 324}
330 325
331void Kpacman::confKeys() 326void Kpacman::confKeys()
332{ 327{
333 Keys *keys = new Keys(); 328 Keys *keys = new Keys();
334 if (keys->exec() == QDialog::Accepted) { 329 if (keys->exec() == QDialog::Accepted) {
335 view->referee->initKeys(); 330 view->referee->initKeys();
336 view->score->initKeys(); 331 view->score->initKeys();
337 } 332 }
338 delete keys; 333 delete keys;
339} 334}
340 335
341void Kpacman::schemeChecked(int id) 336void Kpacman::schemeChecked(int id)
342{ 337{
343 int mode = 0, scheme = -1; 338 int mode = 0, scheme = -1;
344 339
345 for (uint s = 0; s < schemeID.size(); s++) { 340 for (uint s = 0; s < schemeID.size(); s++) {
346 if (schemeID[s] == id) { 341 if (schemeID[s] == id) {
347 scheme = s; 342 scheme = s;
348 mode = schemeMode[s]; 343 mode = schemeMode[s];
349 } 344 }
350 if (schemeMode[s] == -1) { 345 if (schemeMode[s] == -1) {
351 modesPopup->setItemChecked(schemeID[s], schemeID[s] == id); 346 modesPopup->setItemChecked(schemeID[s], schemeID[s] == id);
352 } else { 347 } else {
353 modesPopup->setItemChecked(modeID[schemeMode[s]], schemeMode[s] == mode); 348 modesPopup->setItemChecked(modeID[schemeMode[s]], schemeMode[s] == mode);
354 schemesPopup->at(schemeMode[s])->setItemChecked(schemeID[s], schemeID[s] == id); 349 schemesPopup->at(schemeMode[s])->setItemChecked(schemeID[s], schemeID[s] == id);
355 } 350 }
356 } 351 }
357 352
358 APP_CONFIG_BEGIN( cfg ); 353 APP_CONFIG_BEGIN( cfg );
359 cfg->writeEntry("Scheme", scheme); 354 cfg->writeEntry("Scheme", scheme);
360 cfg->writeEntry("Mode", mode); 355 cfg->writeEntry("Mode", mode);
361 APP_CONFIG_END( cfg ); 356 APP_CONFIG_END( cfg );
362 357
363 view->setScheme(scheme, mode); 358 view->setScheme(scheme, mode);
364 view->updateGeometry(); 359 view->updateGeometry();
365 updateGeometry(); 360 updateGeometry();
366 update(); 361 update();
367 repaint(TRUE); 362 repaint(TRUE);
368 show(); 363 show();
369} 364}
diff --git a/noncore/games/kpacman/kpacman.h b/noncore/games/kpacman/kpacman.h
index d7de9de..2c1de70 100644
--- a/noncore/games/kpacman/kpacman.h
+++ b/noncore/games/kpacman/kpacman.h
@@ -1,95 +1,83 @@
1#ifndef KPACMAN_H 1#ifndef KPACMAN_H
2#define KPACMAN_H 2#define KPACMAN_H
3 3
4#ifdef HAVE_CONFIG_H 4#ifdef HAVE_CONFIG_H
5#include <config.h> 5#include <config.h>
6#endif 6#endif
7 7
8#include "portable.h" 8#include "portable.h"
9 9
10#if defined( KDE2_PORT )
11#include <kapp.h>
12#include <klocale.h>
13#include <ktmainwindow.h>
14#include <kmenubar.h>
15#elif defined( QPE_PORT )
16#include <qmainwindow.h> 10#include <qmainwindow.h>
17class QMenuBar; 11class QMenuBar;
18#endif
19
20#include <qregexp.h> 12#include <qregexp.h>
21 13
22#include "kpacmanwidget.h" 14#include "kpacmanwidget.h"
23 15
24#include <qpopmenu.h> 16#include <qpopmenu.h>
25 17
26#include <qlist.h> 18#include <qlist.h>
27#include <qfileinf.h> 19#include <qfileinf.h>
20#include <qlayout.h>
28 21
29#if defined( KDE2_PORT )
30#include <referee.h>
31#include <status.h>
32#include <score.h>
33#include <keys.h>
34#elif defined( QPE_PORT )
35#include "referee.h" 22#include "referee.h"
36#include "status.h" 23#include "status.h"
37#include "score.h" 24#include "score.h"
38#include "keys.h" 25#include "keys.h"
39#endif
40 26
41class Kpacman : public KTMainWindow 27class Kpacman : public KTMainWindow
42{ 28{
43 Q_OBJECT 29 Q_OBJECT
44public: 30public:
45 Kpacman(QWidget *parent = 0, const char *name = 0); 31 Kpacman(QWidget *parent = 0, const char *name = 0);
46 virtual ~Kpacman(); 32 virtual ~Kpacman();
47 33
48public slots: 34public slots:
49 void forcedHallOfFame(bool); 35 void forcedHallOfFame(bool);
50 36
51private slots: 37private slots:
52 void newKpacman(); 38 void newKpacman();
53 void pauseKpacman(); 39 void pauseKpacman();
54 void toggleHallOfFame(); 40 void toggleHallOfFame();
55 void toggleNew(); 41 void toggleNew();
56 void togglePaused(); 42 void togglePaused();
57 void quitKpacman(); 43 void quitKpacman();
58 44
59 void schemeChecked(int); 45 void schemeChecked(int);
60 void toggleFocusOutPause(); 46 void toggleFocusOutPause();
61 void toggleFocusInContinue(); 47 void toggleFocusInContinue();
62 void toggleHideMouseCursor(); 48 void toggleHideMouseCursor();
63 void confKeys(); 49 void confKeys();
64 50
65protected: 51protected:
66 52
67private: 53private:
68 KpacmanWidget *view; 54 KpacmanWidget *view;
69 55
70 void menu(); 56 void menu();
71 57
72 int lookupSchemes(); 58 int lookupSchemes();
73 59
60 QGridLayout *m_layout;
61 QWidget *m_view;
74 KMenuBar *_menuBar; 62 KMenuBar *_menuBar;
75 QPopupMenu *gamePopup; 63 QPopupMenu *gamePopup;
76 QPopupMenu *optionsPopup; 64 QPopupMenu *optionsPopup;
77 QPopupMenu *modesPopup; 65 QPopupMenu *modesPopup;
78 QList<QPopupMenu> *schemesPopup; 66 QList<QPopupMenu> *schemesPopup;
79 67
80 int newID; 68 int newID;
81 int pauseID; 69 int pauseID;
82 int hofID; 70 int hofID;
83 QArray<int> modeID; 71 QArray<int> modeID;
84 QArray<int> schemeID; 72 QArray<int> schemeID;
85 QArray<int> schemeMode; 73 QArray<int> schemeMode;
86 int focusOutPauseID; 74 int focusOutPauseID;
87 int focusInContinueID; 75 int focusInContinueID;
88 int hideMouseCursorID; 76 int hideMouseCursorID;
89 77
90 bool focusOutPause; 78 bool focusOutPause;
91 bool focusInContinue; 79 bool focusInContinue;
92 bool hideMouseCursor; 80 bool hideMouseCursor;
93}; 81};
94 82
95#endif // KPACMAN_H 83#endif // KPACMAN_H
diff --git a/noncore/games/kpacman/kpacmanwidget.cpp b/noncore/games/kpacman/kpacmanwidget.cpp
index 215dcda..feb782c 100644
--- a/noncore/games/kpacman/kpacmanwidget.cpp
+++ b/noncore/games/kpacman/kpacmanwidget.cpp
@@ -1,162 +1,153 @@
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
37 setFixedSize(referee->width(), bitfont->height()*3 + referee->height() + status->height());
38#else
39 setBackgroundColor( black ); 36 setBackgroundColor( black );
40#endif
41} 37}
42 38
43KpacmanWidget::~KpacmanWidget() 39KpacmanWidget::~KpacmanWidget()
44{ 40{
45} 41}
46 42
47void KpacmanWidget::confMisc(bool defGroup) 43void KpacmanWidget::confMisc(bool defGroup)
48{ 44{
49 APP_CONFIG_BEGIN( cfg ); 45 APP_CONFIG_BEGIN( cfg );
50 //KStandardDirs *dirs = KGlobal::dirs(); 46 //KStandardDirs *dirs = KGlobal::dirs();
51 QString findPath; 47 QString findPath;
52 48
53 if (defGroup || cfg->hasKey("Font")) { 49 if (defGroup || cfg->hasKey("Font")) {
54 fontName = cfg->readEntry("Font"); 50 fontName = cfg->readEntry("Font");
55 51
56 if (fontName.left(1) != "/" && fontName.left(1) != "~") 52 if (fontName.left(1) != "/" && fontName.left(1) != "~")
57 fontName.insert(0, "fonts/"); 53 fontName.insert(0, "fonts/");
58 if (fontName.right(1) == "/") 54 if (fontName.right(1) == "/")
59 fontName.append("font.xbm"); 55 fontName.append("font.xbm");
60 56
61 //findPath = dirs->findResource("appdata", fontName); 57 //findPath = dirs->findResource("appdata", fontName);
62 findPath = FIND_APP_DATA( fontName ); 58 findPath = FIND_APP_DATA( fontName );
63 if (!findPath.isEmpty()) 59 if (!findPath.isEmpty())
64 fontName = findPath; 60 fontName = findPath;
65 61
66 bitfontFirstChar = cfg->readNumEntry("FontFirstChar", 0x0e); 62 bitfontFirstChar = cfg->readNumEntry("FontFirstChar", 0x0e);
67 bitfontLastChar = cfg->readNumEntry("FontLastChar", 0x5f); 63 bitfontLastChar = cfg->readNumEntry("FontLastChar", 0x5f);
68 } 64 }
69 APP_CONFIG_END( cfg ); 65 APP_CONFIG_END( cfg );
70} 66}
71 67
72void KpacmanWidget::confScheme() 68void KpacmanWidget::confScheme()
73{ 69{
74 APP_CONFIG_BEGIN( cfg ); 70 APP_CONFIG_BEGIN( cfg );
75 QString lastFontName = fontName; 71 QString lastFontName = fontName;
76 SAVE_CONFIG_GROUP( cfg, oldgroup ); 72 SAVE_CONFIG_GROUP( cfg, oldgroup );
77 QString newgroup; 73 QString newgroup;
78 74
79 // if not set, read mode and scheme from the configfile 75 // if not set, read mode and scheme from the configfile
80 if (mode == -1 && scheme == -1) { 76 if (mode == -1 && scheme == -1) {
81 scheme = cfg->readNumEntry("Scheme", -1); 77 scheme = cfg->readNumEntry("Scheme", -1);
82 mode = cfg->readNumEntry("Mode", -1); 78 mode = cfg->readNumEntry("Mode", -1);
83 79
84 // if mode is not set in the defGroup-group, lookup the scheme group 80 // if mode is not set in the defGroup-group, lookup the scheme group
85 if (scheme != -1 || mode == -1) { 81 if (scheme != -1 || mode == -1) {
86 newgroup.sprintf("Scheme %d", scheme); 82 newgroup.sprintf("Scheme %d", scheme);
87 cfg->setGroup(newgroup); 83 cfg->setGroup(newgroup);
88 84
89 mode = cfg->readNumEntry("Mode", -1); 85 mode = cfg->readNumEntry("Mode", -1);
90 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 86 RESTORE_CONFIG_GROUP( cfg, oldgroup );
91 } 87 }
92 } 88 }
93 89
94 confMisc(); 90 confMisc();
95 91
96 if (mode != -1) { 92 if (mode != -1) {
97 newgroup.sprintf("Mode %d", mode); 93 newgroup.sprintf("Mode %d", mode);
98 cfg->setGroup(newgroup); 94 cfg->setGroup(newgroup);
99 95
100 confMisc(FALSE); 96 confMisc(FALSE);
101 } 97 }
102 98
103 if (scheme != -1) { 99 if (scheme != -1) {
104 newgroup.sprintf("Scheme %d", scheme); 100 newgroup.sprintf("Scheme %d", scheme);
105 cfg->setGroup(newgroup); 101 cfg->setGroup(newgroup);
106 102
107 confMisc(FALSE); 103 confMisc(FALSE);
108 } 104 }
109 105
110 if (lastFontName != fontName) { 106 if (lastFontName != fontName) {
111 107
112 if (bitfont != 0) 108 if (bitfont != 0)
113 delete bitfont; 109 delete bitfont;
114 110
115 bitfont = new Bitfont(fontName, bitfontFirstChar, bitfontLastChar); 111 bitfont = new Bitfont(fontName, bitfontFirstChar, bitfontLastChar);
116 if (bitfont->width() == 0 || bitfont->height() == 0) { 112 if (bitfont->width() == 0 || bitfont->height() == 0) {
117 QString msg = tr("The bitfont could not be contructed.\n\n" 113 QString msg = tr("The bitfont could not be contructed.\n\n"
118 "The file '@FONTNAME@' does not exist,\n" 114 "The file '@FONTNAME@' does not exist,\n"
119 "or is of an unknown format."); 115 "or is of an unknown format.");
120 msg.replace(QRegExp("@FONTNAME@"), fontName); 116 msg.replace(QRegExp("@FONTNAME@"), fontName);
121 // QMessageBox::critical(this, tr("Initialization Error"), msg); 117 // QMessageBox::critical(this, tr("Initialization Error"), msg);
122 printf("%s\n", msg.data()); 118 printf("%s\n", msg.data());
123 } 119 }
124 } 120 }
125 121
126 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 122 RESTORE_CONFIG_GROUP( cfg, oldgroup );
127 APP_CONFIG_END( cfg ); 123 APP_CONFIG_END( cfg );
128} 124}
129 125
130void KpacmanWidget::setScheme(int Scheme, int Mode) 126void KpacmanWidget::setScheme(int Scheme, int Mode)
131{ 127{
132 mode = Mode; 128 mode = Mode;
133 scheme = Scheme; 129 scheme = Scheme;
134 130
135 confScheme(); 131 confScheme();
136 132
137 score->setScheme(Scheme, Mode, bitfont); 133 score->setScheme(Scheme, Mode, bitfont);
138 referee->setScheme(Scheme, Mode, bitfont); 134 referee->setScheme(Scheme, Mode, bitfont);
139 status->setScheme(Scheme, Mode); 135 status->setScheme(Scheme, Mode);
140 136
141#ifndef QWS
142 setFixedSize(referee->width(),
143 bitfont->height()*3 + referee->height() + status->height());
144#endif
145
146 score->repaint(FALSE); 137 score->repaint(FALSE);
147 referee->repaint(FALSE); 138 referee->repaint(FALSE);
148 status->repaint(FALSE); 139 status->repaint(FALSE);
149} 140}
150 141
151void KpacmanWidget::resizeEvent( QResizeEvent * ) 142void KpacmanWidget::resizeEvent( QResizeEvent * )
152{ 143{
153 referee->setGeometry(0, bitfont->height()*3, referee->width(), referee->height()); 144 referee->setGeometry(0, bitfont->height()*3, referee->width(), referee->height());
154 referee->setBackgroundColor(BLACK); 145 referee->setBackgroundColor(BLACK);
155 146
156 status->setGeometry(0, bitfont->height()*3+referee->height(), referee->width(), 147 status->setGeometry(0, bitfont->height()*3+referee->height(), referee->width(),
157 status->height()); 148 status->height());
158 status->setBackgroundColor(BLACK); 149 status->setBackgroundColor(BLACK);
159 150
160 score->setGeometry(0, 0, referee->width(), bitfont->height()*3+referee->height()+status->height()); 151 score->setGeometry(0, 0, referee->width(), bitfont->height()*3+referee->height()+status->height());
161 score->setBackgroundColor(BLACK); 152 score->setBackgroundColor(BLACK);
162} 153}
diff --git a/noncore/games/kpacman/referee.cpp b/noncore/games/kpacman/referee.cpp
index 70916f0..81f331b 100644
--- a/noncore/games/kpacman/referee.cpp
+++ b/noncore/games/kpacman/referee.cpp
@@ -1,1431 +1,1431 @@
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), tr("GAME OVER")))) 98 rect.intersects(pix->rect(board->position(fruithome), tr("GAME OVER"))))
99 pix->draw(board->position(fruithome), Widget, tr("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), tr("PLAYER ONE")))) 160 rect.intersects(pix->rect(board->position(monsterhome, 0), tr("PLAYER ONE"))))
161 pix->draw(board->position(monsterhome, 0), Widget, tr("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), tr("READY!")))) 164 rect.intersects(pix->rect(board->position(fruithome), tr("READY!"))))
165 pix->draw(board->position(fruithome), Widget, tr("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, tr("PAUSED")))) 168 rect.intersects(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, tr("PAUSED"))))
169 pix->draw((BoardWidth*BoardHeight)/2-BoardWidth, Widget, tr("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) && 733 else if ( !gameState.testBit(Playing) &&
734 key == Key_Up || 734 ( key == Key_Up ||
735 key == Key_Down || 735 key == Key_Down ||
736 key == Key_Right || 736 key == Key_Right ||
737 key == Key_Left ) 737 key == Key_Left ))
738 play(); 738 play();
739 // "Space" => pause 739 // "Space" => pause
740 //else if ( key == Key_Space || key == Key_F3 ) 740 //else if ( key == Key_Space || key == Key_F3 )
741 // pause(); 741 // pause();
742 // "Menu" => hall of fame 742 // "Menu" => hall of fame
743 //else if ( key == Key_F11 || key == Key_F4 ) 743 //else if ( key == Key_F11 || key == Key_F4 )
744 // toggleHallOfFame(); 744 // toggleHallOfFame();
745#endif 745#endif
746 746
747 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame) || 747 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame) ||
748 gameState.testBit(Demonstration) || gameState.testBit(Dying) || 748 gameState.testBit(Demonstration) || gameState.testBit(Dying) ||
749 gameState.testBit(Ready) || gameState.testBit(LevelDone) || 749 gameState.testBit(Ready) || gameState.testBit(LevelDone) ||
750 !gameState.testBit(Playing)) 750 !gameState.testBit(Playing))
751 return; 751 return;
752 752
753 if (key == UpKey) 753 if (key == UpKey)
754 pacman->setDirection(N); 754 pacman->setDirection(N);
755 else if (key == DownKey) 755 else if (key == DownKey)
756 pacman->setDirection(S); 756 pacman->setDirection(S);
757 else if (key == RightKey) 757 else if (key == RightKey)
758 pacman->setDirection(E); 758 pacman->setDirection(E);
759 else if (key == LeftKey) 759 else if (key == LeftKey)
760 pacman->setDirection(W); 760 pacman->setDirection(W);
761 761
762#ifdef CHEATS 762#ifdef CHEATS
763 else if (key == Key_L) { printf("levelUp()\n"); levelUp(); } 763 else if (key == Key_L) { printf("levelUp()\n"); levelUp(); }
764 else if (key == Key_F) { printf("fruit->move(TRUE)\n"); fruit->move(TRUE); repaint(FALSE); } 764 else if (key == Key_F) { printf("fruit->move(TRUE)\n"); fruit->move(TRUE); repaint(FALSE); }
765 else if (key == Key_E) { printf("setLifes(++lifes)\n"); emit setLifes(++lifes); } 765 else if (key == Key_E) { printf("setLifes(++lifes)\n"); emit setLifes(++lifes); }
766#endif 766#endif
767 767
768 else { 768 else {
769 k->ignore(); 769 k->ignore();
770 return; 770 return;
771 } 771 }
772 k->accept(); 772 k->accept();
773} 773}
774 774
775void Referee::score(int p) 775void Referee::score(int p)
776{ 776{
777 if (!gameState.testBit(Playing)) 777 if (!gameState.testBit(Playing))
778 return; 778 return;
779 779
780 if ((points += p) < 0) 780 if ((points += p) < 0)
781 points = 0; 781 points = 0;
782 782
783 emit setPoints(points); 783 emit setPoints(points);
784 784
785 if (points >= nextExtraLifeScore) { 785 if (points >= nextExtraLifeScore) {
786 emit setLifes(++lifes); 786 emit setLifes(++lifes);
787 if (extraLifeScoreIndex < (int) extraLifeScore.size()-1) 787 if (extraLifeScoreIndex < (int) extraLifeScore.size()-1)
788 extraLifeScoreIndex++; 788 extraLifeScoreIndex++;
789 if (extraLifeScore[extraLifeScoreIndex] < 0) 789 if (extraLifeScore[extraLifeScoreIndex] < 0)
790 nextExtraLifeScore = extraLifeScore[extraLifeScoreIndex] * -1; 790 nextExtraLifeScore = extraLifeScore[extraLifeScoreIndex] * -1;
791 else 791 else
792 nextExtraLifeScore += extraLifeScore[extraLifeScoreIndex]; 792 nextExtraLifeScore += extraLifeScore[extraLifeScoreIndex];
793 } 793 }
794} 794}
795 795
796void Referee::eaten() 796void Referee::eaten()
797{ 797{
798 if (gameState.testBit(Ready)) 798 if (gameState.testBit(Ready))
799 return; 799 return;
800 800
801 stop(); 801 stop();
802 802
803 if (monstersEaten < 4) 803 if (monstersEaten < 4)
804 monstersEaten++; 804 monstersEaten++;
805 805
806 gameState.setBit(Scoring); 806 gameState.setBit(Scoring);
807 score(monsterScore[monstersEaten-1]); 807 score(monsterScore[monstersEaten-1]);
808 808
809 repaint(pix->rect(pix->rect(pacman->position(), MonsterPix), 809 repaint(pix->rect(pix->rect(pacman->position(), MonsterPix),
810 pix->rect(pacman->position(), MonsterScorePix, monstersEaten-1))); 810 pix->rect(pacman->position(), MonsterScorePix, monstersEaten-1)));
811 811
812 if (--timerCount > 0) 812 if (--timerCount > 0)
813 QTimer::singleShot( monsterScoreDurMS, this, SLOT(eaten())); 813 QTimer::singleShot( monsterScoreDurMS, this, SLOT(eaten()));
814 else { 814 else {
815 for (Monster *m = monsters->first(); m != 0; m = monsters->next()) 815 for (Monster *m = monsters->first(); m != 0; m = monsters->next())
816 if (m && m->direction() == X && !gameState.testBit(Introducing)) 816 if (m && m->direction() == X && !gameState.testBit(Introducing))
817 m->setDirection(N); 817 m->setDirection(N);
818 if (monstersEaten != 4 || !gameState.testBit(Introducing)) 818 if (monstersEaten != 4 || !gameState.testBit(Introducing))
819 QTimer::singleShot( monsterScoreDurMS, this, SLOT(start())); 819 QTimer::singleShot( monsterScoreDurMS, this, SLOT(start()));
820 } 820 }
821} 821}
822 822
823void Referee::toggleHallOfFame() 823void Referee::toggleHallOfFame()
824{ 824{
825 gameState.toggleBit(HallOfFame); 825 gameState.toggleBit(HallOfFame);
826} 826}
827 827
828void Referee::hallOfFame() 828void Referee::hallOfFame()
829{ 829{
830 if (gameState.testBit(HallOfFame)) // If the HallOfFame is switched on manually, toggle the 830 if (gameState.testBit(HallOfFame)) // If the HallOfFame is switched on manually, toggle the
831 toggleHallOfFame(); // bit twice. 831 toggleHallOfFame(); // bit twice.
832 832
833 emit setLevel(0); // Clear status display for hall of fame 833 emit setLevel(0); // Clear status display for hall of fame
834 emit setScore(level, 0); 834 emit setScore(level, 0);
835 emit forcedHallOfFame(TRUE); 835 emit forcedHallOfFame(TRUE);
836} 836}
837 837
838void Referee::pause() 838void Referee::pause()
839{ 839{
840 static int pausedTimer = 0; 840 static int pausedTimer = 0;
841 841
842 if (!gameState.testBit(Paused)) { 842 if (!gameState.testBit(Paused)) {
843 pausedTimer = gameTimer; 843 pausedTimer = gameTimer;
844 stop(); 844 stop();
845 stopEnergizer(); 845 stopEnergizer();
846 gameState.setBit(Paused); 846 gameState.setBit(Paused);
847 repaint(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, tr("PAUSED")), FALSE); 847 repaint(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, tr("PAUSED")), FALSE);
848 } else { 848 } else {
849 gameState.clearBit(Paused); 849 gameState.clearBit(Paused);
850 repaint(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, tr("PAUSED")), FALSE); 850 repaint(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, tr("PAUSED")), FALSE);
851 if (pausedTimer) { 851 if (pausedTimer) {
852 pausedTimer = 0; 852 pausedTimer = 0;
853 start(); 853 start();
854 } 854 }
855 } 855 }
856 emit togglePaused(); 856 emit togglePaused();
857} 857}
858 858
859void Referee::intro() 859void Referee::intro()
860{ 860{
861 stop(); 861 stop();
862 stopEnergizer(); 862 stopEnergizer();
863 bool paused = gameState.testBit(Paused); 863 bool paused = gameState.testBit(Paused);
864 864
865 gameState.fill(FALSE); 865 gameState.fill(FALSE);
866 gameState.setBit(Introducing); 866 gameState.setBit(Introducing);
867 gameState.setBit(Init); 867 gameState.setBit(Init);
868 868
869 if (paused) 869 if (paused)
870 gameState.setBit(Paused); 870 gameState.setBit(Paused);
871 871
872 level = 0; 872 level = 0;
873 emit setLevel(level); 873 emit setLevel(level);
874 874
875 board->init(Intro); 875 board->init(Intro);
876 pix->setLevel(level); 876 pix->setLevel(level);
877 877
878 initPacman(); 878 initPacman();
879 initFruit(); 879 initFruit();
880 initMonsters(); 880 initMonsters();
881 initEnergizers(); 881 initEnergizers();
882 882
883 repaint(); 883 repaint();
884 884
885 monstersEaten = 0; 885 monstersEaten = 0;
886 timerCount = 0; 886 timerCount = 0;
887 introPlay(); 887 introPlay();
888} 888}
889 889
890void Referee::introMonster(int id) 890void Referee::introMonster(int id)
891{ 891{
892 Monster *m = new Monster(board, id); 892 Monster *m = new Monster(board, id);
893 893
894 m->setPosition((10+id*6)*BoardWidth+10); 894 m->setPosition((10+id*6)*BoardWidth+10);
895 m->setDirection(E); 895 m->setDirection(E);
896 m->setDangerous(dangerousTicks[level], monsterIQ[level]); 896 m->setDangerous(dangerousTicks[level], monsterIQ[level]);
897 m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix)); 897 m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix));
898 898
899 if (m->body() != -1) 899 if (m->body() != -1)
900 pix->draw(m->position(), RoomPix, MonsterPix, m->body()); 900 pix->draw(m->position(), RoomPix, MonsterPix, m->body());
901 if (m->eyes() != -1) 901 if (m->eyes() != -1)
902 pix->draw(m->position(), RoomPix, EyesPix, m->eyes()); 902 pix->draw(m->position(), RoomPix, EyesPix, m->eyes());
903 903
904 repaint(pix->rect(m->position(), MonsterPix), FALSE); 904 repaint(pix->rect(m->position(), MonsterPix), FALSE);
905 m->setPosition(OUT); 905 m->setPosition(OUT);
906} 906}
907 907
908void Referee::introPaint(int t) 908void Referee::introPaint(int t)
909{ 909{
910 QString pts; 910 QString pts;
911 911
912 switch (t) { 912 switch (t) {
913 case 0 : repaint(pix->draw(16, 6, RoomPix, tr("CHARACTER"), WHITE, QColor(), AlignLeft), FALSE); 913 case 0 : repaint(pix->draw(16, 6, RoomPix, tr("CHARACTER"), WHITE, QColor(), AlignLeft), FALSE);
914 repaint(pix->draw(36, 6, RoomPix, tr("/"), WHITE, QColor(), AlignLeft), FALSE); 914 repaint(pix->draw(36, 6, RoomPix, tr("/"), WHITE, QColor(), AlignLeft), FALSE);
915 repaint(pix->draw(40, 6, RoomPix, tr("NICKNAME"), WHITE, QColor(), AlignLeft), FALSE); 915 repaint(pix->draw(40, 6, RoomPix, tr("NICKNAME"), WHITE, QColor(), AlignLeft), FALSE);
916 break; 916 break;
917 case 1 : introMonster(0); 917 case 1 : introMonster(0);
918 break; 918 break;
919 case 2 : repaint(pix->draw(16, 10, RoomPix, tr("-SHADOW"), RED, QColor(), AlignLeft), FALSE); 919 case 2 : repaint(pix->draw(16, 10, RoomPix, tr("-SHADOW"), RED, QColor(), AlignLeft), FALSE);
920 break; 920 break;
921 case 3 : repaint(pix->draw(38, 10, RoomPix, tr("\"BLINKY\""), RED, QColor(), AlignLeft), FALSE); 921 case 3 : repaint(pix->draw(38, 10, RoomPix, tr("\"BLINKY\""), RED, QColor(), AlignLeft), FALSE);
922 break; 922 break;
923 case 4 : introMonster(1); 923 case 4 : introMonster(1);
924 break; 924 break;
925 case 5 : repaint(pix->draw(16, 16, RoomPix, tr("-SPEEDY"), PINK, QColor(), AlignLeft), FALSE); 925 case 5 : repaint(pix->draw(16, 16, RoomPix, tr("-SPEEDY"), PINK, QColor(), AlignLeft), FALSE);
926 break; 926 break;
927 case 6 : repaint(pix->draw(38, 16, RoomPix, tr("\"PINKY\""), PINK, QColor(), AlignLeft), FALSE); 927 case 6 : repaint(pix->draw(38, 16, RoomPix, tr("\"PINKY\""), PINK, QColor(), AlignLeft), FALSE);
928 break; 928 break;
929 case 7 : introMonster(2); 929 case 7 : introMonster(2);
930 break; 930 break;
931 case 8 : repaint(pix->draw(16, 22, RoomPix, tr("-BASHFUL"), CYAN, QColor(), AlignLeft), FALSE); 931 case 8 : repaint(pix->draw(16, 22, RoomPix, tr("-BASHFUL"), CYAN, QColor(), AlignLeft), FALSE);
932 break; 932 break;
933 case 9 : repaint(pix->draw(38, 22, RoomPix, tr("\"INKY\""), CYAN, QColor(), AlignLeft), FALSE); 933 case 9 : repaint(pix->draw(38, 22, RoomPix, tr("\"INKY\""), CYAN, QColor(), AlignLeft), FALSE);
934 break; 934 break;
935 case 10 : introMonster(3); 935 case 10 : introMonster(3);
936 break; 936 break;
937 case 11 : repaint(pix->draw(16, 28, RoomPix, tr("-POKEY"), ORANGE, QColor(), AlignLeft), FALSE); 937 case 11 : repaint(pix->draw(16, 28, RoomPix, tr("-POKEY"), ORANGE, QColor(), AlignLeft), FALSE);
938 break; 938 break;
939 case 12 : repaint(pix->draw(38, 28, RoomPix, tr("\"CLYDE\""), ORANGE, QColor(), AlignLeft), FALSE); 939 case 12 : repaint(pix->draw(38, 28, RoomPix, tr("\"CLYDE\""), ORANGE, QColor(), AlignLeft), FALSE);
940 break; 940 break;
941 case 13 : pts.sprintf("%d", pointScore); 941 case 13 : pts.sprintf("%d", pointScore);
942 repaint(pix->draw(28, 44, RoomPix, pts.data(), WHITE, QColor(), AlignRight), FALSE); 942 repaint(pix->draw(28, 44, RoomPix, pts.data(), WHITE, QColor(), AlignRight), FALSE);
943 repaint(pix->draw(31, 44, RoomPix, "\x1C\x1D\x1E", WHITE, QColor(), AlignLeft), FALSE); 943 repaint(pix->draw(31, 44, RoomPix, "\x1C\x1D\x1E", WHITE, QColor(), AlignLeft), FALSE);
944 pts.sprintf("%d", energizerScore); 944 pts.sprintf("%d", energizerScore);
945 repaint(pix->draw(28, 48, RoomPix, pts.data(), WHITE, QColor(), AlignRight), FALSE); 945 repaint(pix->draw(28, 48, RoomPix, pts.data(), WHITE, QColor(), AlignRight), FALSE);
946 repaint(pix->draw(31, 48, RoomPix, "\x1C\x1D\x1E", WHITE, QColor(), AlignLeft), FALSE); 946 repaint(pix->draw(31, 48, RoomPix, "\x1C\x1D\x1E", WHITE, QColor(), AlignLeft), FALSE);
947 break; 947 break;
948 case 14 : // "@ 1980 MIDWAY MFG.CO." 948 case 14 : // "@ 1980 MIDWAY MFG.CO."
949#if defined( KDE2_PORT ) 949#if defined( KDE2_PORT )
950 repaint(pix->draw(30, 58, RoomPix, "© 1998-2002 J.THÖNNISSEN", PINK), FALSE); 950 repaint(pix->draw(30, 58, RoomPix, "© 1998-2002 J.THÖNNISSEN", PINK), FALSE);
951#elif defined( QPE_PORT ) 951#elif defined( QPE_PORT )
952 repaint(pix->draw(30, 55, RoomPix, "© 1998-2002 J.THÖNNISSEN", PINK), FALSE); 952 repaint(pix->draw(30, 55, RoomPix, "© 1998-2002 J.THÖNNISSEN", PINK), FALSE);
953 repaint(pix->draw(29, 58, RoomPix, tr("QTOPIA PORT: CATALIN CLIMOV"), GREEN), FALSE); 953 repaint(pix->draw(29, 58, RoomPix, tr("QTOPIA PORT: CATALIN CLIMOV"), GREEN), FALSE);
954 repaint(pix->draw(29, 61, RoomPix, tr("PRESS CURSOR TO START"), GREEN), FALSE); 954 repaint(pix->draw(29, 61, RoomPix, tr("PRESS CURSOR TO START"), GREEN), FALSE);
955#endif 955#endif
956 break; 956 break;
957 } 957 }
958} 958}
959 959
960void Referee::introPlay() 960void Referee::introPlay()
961{ 961{
962 if (!gameState.testBit(Introducing) || gameState.testBit(Ready)) 962 if (!gameState.testBit(Introducing) || gameState.testBit(Ready))
963 return; 963 return;
964 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { 964 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) {
965 QTimer::singleShot(afterPauseMS, this, SLOT(introPlay())); 965 QTimer::singleShot(afterPauseMS, this, SLOT(introPlay()));
966 return; 966 return;
967 } 967 }
968 968
969 if (!gameState.testBit(Init)) { 969 if (!gameState.testBit(Init)) {
970 if (monstersEaten == 4) { 970 if (monstersEaten == 4) {
971 stop(); 971 stop();
972 QTimer::singleShot(introPostAnimationMS, this, SLOT(demo())); 972 QTimer::singleShot(introPostAnimationMS, this, SLOT(demo()));
973 } 973 }
974 if (pacman->direction() == W) { 974 if (pacman->direction() == W) {
975 int id = -1; 975 int id = -1;
976 if (pacman->position() == 37*BoardWidth-6) 976 if (pacman->position() == 37*BoardWidth-6)
977 id = 0; 977 id = 0;
978 else 978 else
979 if (board->isMonster(37*BoardWidth-6)) 979 if (board->isMonster(37*BoardWidth-6))
980 for (Monster *m = monsters->first(); m != 0; m = monsters->next()) 980 for (Monster *m = monsters->first(); m != 0; m = monsters->next())
981 if (m && m->position() == 37*BoardWidth-6) { 981 if (m && m->position() == 37*BoardWidth-6) {
982 id = m->id(); 982 id = m->id();
983 id++; 983 id++;
984 break; 984 break;
985 } 985 }
986 986
987 if (id >= 0 && id <= 4) 987 if (id >= 0 && id <= 4)
988 for (Monster *m = monsters->first(); m != 0; m = monsters->next()) 988 for (Monster *m = monsters->first(); m != 0; m = monsters->next())
989 if (m && m->id() == id && m->position() == OUT) { 989 if (m && m->id() == id && m->position() == OUT) {
990 m->setPosition(37*BoardWidth-1); 990 m->setPosition(37*BoardWidth-1);
991 m->setDirection(W); 991 m->setDirection(W);
992 m->setDangerous(dangerousTicks[level], monsterIQ[level]); 992 m->setDangerous(dangerousTicks[level], monsterIQ[level]);
993 board->set(37*BoardWidth-1, monsterhome, id); 993 board->set(37*BoardWidth-1, monsterhome, id);
994 repaint(pix->rect(m->position(), MonsterPix)); 994 repaint(pix->rect(m->position(), MonsterPix));
995 break; 995 break;
996 } 996 }
997 } 997 }
998 return; 998 return;
999 } 999 }
1000 1000
1001 if (timerCount < 15) 1001 if (timerCount < 15)
1002 introPaint(timerCount); 1002 introPaint(timerCount);
1003 1003
1004 switch (timerCount) { 1004 switch (timerCount) {
1005 case 13 : board->set(44*BoardWidth+22, Point); 1005 case 13 : board->set(44*BoardWidth+22, Point);
1006 pix->drawPoint(44*BoardWidth+22); 1006 pix->drawPoint(44*BoardWidth+22);
1007 repaint(pix->rect(44*BoardWidth+22, PointPix), FALSE); 1007 repaint(pix->rect(44*BoardWidth+22, PointPix), FALSE);
1008 energizers->at(0)->setPosition(48*BoardWidth+22); 1008 energizers->at(0)->setPosition(48*BoardWidth+22);
1009 energizers->at(0)->setOn(); 1009 energizers->at(0)->setOn();
1010 repaint(pix->rect(48*BoardWidth+22, EnergizerPix), FALSE); 1010 repaint(pix->rect(48*BoardWidth+22, EnergizerPix), FALSE);
1011 break; 1011 break;
1012 case 14 : energizers->at(1)->setPosition(36*BoardWidth+10); 1012 case 14 : energizers->at(1)->setPosition(36*BoardWidth+10);
1013 energizers->at(1)->setOn(); 1013 energizers->at(1)->setOn();
1014 repaint(pix->rect(36*BoardWidth+10, EnergizerPix), FALSE); 1014 repaint(pix->rect(36*BoardWidth+10, EnergizerPix), FALSE);
1015 for (int pos = 8; pos < BoardWidth; pos++) { 1015 for (int pos = 8; pos < BoardWidth; pos++) {
1016 board->set(34*BoardWidth+pos, out); 1016 board->set(34*BoardWidth+pos, out);
1017 board->set(38*BoardWidth+pos, out); 1017 board->set(38*BoardWidth+pos, out);
1018 } 1018 }
1019 board->set(36*BoardWidth+8, out); 1019 board->set(36*BoardWidth+8, out);
1020 break; 1020 break;
1021 case 15 : gameState.clearBit(Init); 1021 case 15 : gameState.clearBit(Init);
1022 initPacman(); 1022 initPacman();
1023 pacman->setDemo(TRUE); 1023 pacman->setDemo(TRUE);
1024 pacman->setPosition(37*BoardWidth-1); 1024 pacman->setPosition(37*BoardWidth-1);
1025 repaintFigures(); 1025 repaintFigures();
1026 start(); 1026 start();
1027 return; 1027 return;
1028 } 1028 }
1029 1029
1030 if (timerCount++ < 15) 1030 if (timerCount++ < 15)
1031 QTimer::singleShot(introAnimationMS, this, SLOT(introPlay())); 1031 QTimer::singleShot(introAnimationMS, this, SLOT(introPlay()));
1032} 1032}
1033 1033
1034void Referee::demo() 1034void Referee::demo()
1035{ 1035{
1036 if (gameState.testBit(Ready)) 1036 if (gameState.testBit(Ready))
1037 return; 1037 return;
1038 1038
1039 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { 1039 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) {
1040 QTimer::singleShot(afterPauseMS, this, SLOT(demo())); 1040 QTimer::singleShot(afterPauseMS, this, SLOT(demo()));
1041 return; 1041 return;
1042 } 1042 }
1043 1043
1044 stop(); 1044 stop();
1045 stopEnergizer(); 1045 stopEnergizer();
1046 1046
1047 gameState.fill(FALSE); 1047 gameState.fill(FALSE);
1048 gameState.setBit(Init); 1048 gameState.setBit(Init);
1049 gameState.setBit(Demonstration); 1049 gameState.setBit(Demonstration);
1050 1050
1051 level = 0; 1051 level = 0;
1052 emit setLevel(level); 1052 emit setLevel(level);
1053 1053
1054 board->init(Demo, mapName.at(0)); 1054 board->init(Demo, mapName.at(0));
1055 pix->setLevel(level); 1055 pix->setLevel(level);
1056 1056
1057 initPacman(); 1057 initPacman();
1058 initFruit(); 1058 initFruit();
1059 initMonsters(); 1059 initMonsters();
1060 initEnergizers(); 1060 initEnergizers();
1061 1061
1062 gameState.clearBit(Init); 1062 gameState.clearBit(Init);
1063 1063
1064 repaint(); 1064 repaint();
1065 1065
1066 timerCount = 0; 1066 timerCount = 0;
1067 QTimer::singleShot(playerDurMS, this, SLOT(start())); 1067 QTimer::singleShot(playerDurMS, this, SLOT(start()));
1068} 1068}
1069 1069
1070void Referee::play() 1070void Referee::play()
1071{ 1071{
1072 stop(); 1072 stop();
1073 stopEnergizer(); 1073 stopEnergizer();
1074 1074
1075 gameState.fill(FALSE); 1075 gameState.fill(FALSE);
1076 gameState.setBit(Init); 1076 gameState.setBit(Init);
1077 gameState.setBit(Playing); 1077 gameState.setBit(Playing);
1078 gameState.setBit(Player); 1078 gameState.setBit(Player);
1079 gameState.setBit(Ready); 1079 gameState.setBit(Ready);
1080 1080
1081 lifes = 3; 1081 lifes = 3;
1082 level = 1; 1082 level = 1;
1083 points = 0; 1083 points = 0;
1084 1084
1085 extraLifeScoreIndex = 0; 1085 extraLifeScoreIndex = 0;
1086 nextExtraLifeScore = extraLifeScore[extraLifeScoreIndex]; 1086 nextExtraLifeScore = extraLifeScore[extraLifeScoreIndex];
1087 if (nextExtraLifeScore < 0) 1087 if (nextExtraLifeScore < 0)
1088 nextExtraLifeScore *= -1; 1088 nextExtraLifeScore *= -1;
1089 1089
1090 board->init(Level, mapName.at(level)); 1090 board->init(Level, mapName.at(level));
1091 pix->setLevel(level); 1091 pix->setLevel(level);
1092 1092
1093 initPacman(); 1093 initPacman();
1094 initFruit(); 1094 initFruit();
1095 initMonsters(); 1095 initMonsters();
1096 initEnergizers(); 1096 initEnergizers();
1097 1097
1098 repaint(); 1098 repaint();
1099 emit toggleNew(); 1099 emit toggleNew();
1100 emit setLifes(lifes); 1100 emit setLifes(lifes);
1101 emit setLevel(level); 1101 emit setLevel(level);
1102 emit setPoints(points); 1102 emit setPoints(points);
1103 1103
1104 repaint(pix->rect(board->position(monsterhome, 0), tr("PLAYER ONE")), FALSE); 1104 repaint(pix->rect(board->position(monsterhome, 0), tr("PLAYER ONE")), FALSE);
1105 repaint(pix->rect(board->position(fruithome), tr("READY!")), FALSE); 1105 repaint(pix->rect(board->position(fruithome), tr("READY!")), FALSE);
1106 1106
1107 timerCount = 0; 1107 timerCount = 0;
1108 QTimer::singleShot(playerDurMS, this, SLOT(ready())); 1108 QTimer::singleShot(playerDurMS, this, SLOT(ready()));
1109} 1109}
1110 1110
1111void Referee::ready() 1111void Referee::ready()
1112{ 1112{
1113 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { 1113 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) {
1114 QTimer::singleShot(afterPauseMS, this, SLOT(ready())); 1114 QTimer::singleShot(afterPauseMS, this, SLOT(ready()));
1115 return; 1115 return;
1116 } 1116 }
1117 1117
1118 if (gameState.testBit(Player)) { 1118 if (gameState.testBit(Player)) {
1119 emit setLifes(--lifes); 1119 emit setLifes(--lifes);
1120 gameState.clearBit(Player); 1120 gameState.clearBit(Player);
1121 gameState.clearBit(Init); 1121 gameState.clearBit(Init);
1122 repaint(pix->rect(board->position(monsterhome, 0), tr("PLAYER ONE")), FALSE); 1122 repaint(pix->rect(board->position(monsterhome, 0), tr("PLAYER ONE")), FALSE);
1123 repaintFigures(); 1123 repaintFigures();
1124 QTimer::singleShot(playerDurMS, this, SLOT(ready())); 1124 QTimer::singleShot(playerDurMS, this, SLOT(ready()));
1125 return; 1125 return;
1126 } 1126 }
1127 1127
1128 if (gameState.testBit(Ready)) { 1128 if (gameState.testBit(Ready)) {
1129 gameState.clearBit(Ready); 1129 gameState.clearBit(Ready);
1130 repaint(pix->rect(board->position(fruithome), tr("READY!")), FALSE); 1130 repaint(pix->rect(board->position(fruithome), tr("READY!")), FALSE);
1131 start(); 1131 start();
1132 } else { 1132 } else {
1133 gameState.setBit(Ready); 1133 gameState.setBit(Ready);
1134 gameState.clearBit(Init); 1134 gameState.clearBit(Init);
1135 repaint(pix->rect(board->position(fruithome), tr("READY!")), FALSE); 1135 repaint(pix->rect(board->position(fruithome), tr("READY!")), FALSE);
1136 QTimer::singleShot(readyDurMS, this, SLOT(ready())); 1136 QTimer::singleShot(readyDurMS, this, SLOT(ready()));
1137 } 1137 }
1138} 1138}
1139 1139
1140 1140
1141void Referee::levelUp() 1141void Referee::levelUp()
1142{ 1142{
1143 stop(); 1143 stop();
1144 stopEnergizer(); 1144 stopEnergizer();
1145 1145
1146 gameState.setBit(LevelDone); 1146 gameState.setBit(LevelDone);
1147 pacman->setPosition(pacman->position()); // set mouthPosition to "0" 1147 pacman->setPosition(pacman->position()); // set mouthPosition to "0"
1148 repaint(pix->rect(pacman->position(), PacmanPix)); 1148 repaint(pix->rect(pacman->position(), PacmanPix));
1149 1149
1150 timerCount = 0; 1150 timerCount = 0;
1151 QTimer::singleShot(levelUpPreAnimationMS, this, SLOT(levelUpPlay())); 1151 QTimer::singleShot(levelUpPreAnimationMS, this, SLOT(levelUpPlay()));
1152} 1152}
1153 1153
1154void Referee::levelUpPlay() 1154void Referee::levelUpPlay()
1155{ 1155{
1156 if (gameState.testBit(Ready)) 1156 if (gameState.testBit(Ready))
1157 return; 1157 return;
1158 1158
1159 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { 1159 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) {
1160 QTimer::singleShot(afterPauseMS, this, SLOT(levelUpPlay())); 1160 QTimer::singleShot(afterPauseMS, this, SLOT(levelUpPlay()));
1161 return; 1161 return;
1162 } 1162 }
1163 1163
1164 switch (timerCount) { 1164 switch (timerCount) {
1165 case 0 : gameState.setBit(Init); 1165 case 0 : gameState.setBit(Init);
1166 setOnEnergizers(); 1166 setOnEnergizers();
1167 repaintFigures(); 1167 repaintFigures();
1168 break; 1168 break;
1169 case 1 : gameState.clearBit(LevelDone); 1169 case 1 : gameState.clearBit(LevelDone);
1170 repaint(pix->rect(pacman->position(), PacmanPix)); 1170 repaint(pix->rect(pacman->position(), PacmanPix));
1171 break; 1171 break;
1172 } 1172 }
1173 1173
1174 if (timerCount++ < 2) { 1174 if (timerCount++ < 2) {
1175 QTimer::singleShot(levelUpAnimationMS, this, SLOT(levelUpPlay())); 1175 QTimer::singleShot(levelUpAnimationMS, this, SLOT(levelUpPlay()));
1176 return; 1176 return;
1177 } 1177 }
1178 1178
1179 gameState.clearBit(Init); 1179 gameState.clearBit(Init);
1180 1180
1181 if (gameState.testBit(Demonstration)) { 1181 if (gameState.testBit(Demonstration)) {
1182 hallOfFame(); 1182 hallOfFame();
1183 return; 1183 return;
1184 } 1184 }
1185 1185
1186 if (level < maxLevel) 1186 if (level < maxLevel)
1187 level++; 1187 level++;
1188 1188
1189 board->init(Level, mapName.at(level)); 1189 board->init(Level, mapName.at(level));
1190 pix->setLevel(level); 1190 pix->setLevel(level);
1191 1191
1192 initPacman(); 1192 initPacman();
1193 initFruit(); 1193 initFruit();
1194 initMonsters(); 1194 initMonsters();
1195 initEnergizers(); 1195 initEnergizers();
1196 1196
1197 repaint(); 1197 repaint();
1198 emit setLevel(level); 1198 emit setLevel(level);
1199 1199
1200 ready(); 1200 ready();
1201} 1201}
1202 1202
1203void Referee::start() 1203void Referee::start()
1204{ 1204{
1205 if (gameState.testBit(Ready)) 1205 if (gameState.testBit(Ready))
1206 return; 1206 return;
1207 1207
1208 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { 1208 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) {
1209 QTimer::singleShot(afterPauseMS, this, SLOT(start())); 1209 QTimer::singleShot(afterPauseMS, this, SLOT(start()));
1210 return; 1210 return;
1211 } 1211 }
1212 1212
1213 if (gameState.testBit(Scoring)) { 1213 if (gameState.testBit(Scoring)) {
1214 gameState.clearBit(Scoring); 1214 gameState.clearBit(Scoring);
1215 repaint(pix->rect(pix->rect(pacman->position(), MonsterPix), 1215 repaint(pix->rect(pix->rect(pacman->position(), MonsterPix),
1216 pix->rect(pacman->position(), MonsterScorePix, monstersEaten-1))); 1216 pix->rect(pacman->position(), MonsterScorePix, monstersEaten-1)));
1217 } 1217 }
1218 1218
1219 if (!gameTimer) 1219 if (!gameTimer)
1220 gameTimer = startTimer( speed [level] ); 1220 gameTimer = startTimer( speed [level] );
1221 1221
1222 if (!energizerTimer) 1222 if (!energizerTimer)
1223 energizerTimer = startTimer( energizerAnimationMS ); 1223 energizerTimer = startTimer( energizerAnimationMS );
1224} 1224}
1225 1225
1226void Referee::start(int t) 1226void Referee::start(int t)
1227{ 1227{
1228 gameTimer = startTimer(t); 1228 gameTimer = startTimer(t);
1229} 1229}
1230 1230
1231void Referee::stop() 1231void Referee::stop()
1232{ 1232{
1233 if (gameTimer) { 1233 if (gameTimer) {
1234 killTimer (gameTimer); 1234 killTimer (gameTimer);
1235 gameTimer = 0; 1235 gameTimer = 0;
1236 } 1236 }
1237} 1237}
1238 1238
1239void Referee::stopEnergizer() 1239void Referee::stopEnergizer()
1240{ 1240{
1241 if (energizerTimer) { 1241 if (energizerTimer) {
1242 killTimer (energizerTimer); 1242 killTimer (energizerTimer);
1243 energizerTimer = 0; 1243 energizerTimer = 0;
1244 } 1244 }
1245} 1245}
1246 1246
1247void Referee::killed() 1247void Referee::killed()
1248{ 1248{
1249 if (gameState.testBit(Ready)) 1249 if (gameState.testBit(Ready))
1250 return; 1250 return;
1251 1251
1252 if (!gameState.testBit(Dying)) { 1252 if (!gameState.testBit(Dying)) {
1253 gameState.setBit(Dying); 1253 gameState.setBit(Dying);
1254 1254
1255 pacman->setDirection(X, TRUE); 1255 pacman->setDirection(X, TRUE);
1256 for (Monster *m = monsters->first(); m != 0; m = monsters->next()) 1256 for (Monster *m = monsters->first(); m != 0; m = monsters->next())
1257 if (m) 1257 if (m)
1258 m->setDirection(X); 1258 m->setDirection(X);
1259 QTimer::singleShot(dyingPreAnimationMS, this, SLOT(killed())); 1259 QTimer::singleShot(dyingPreAnimationMS, this, SLOT(killed()));
1260 } else { 1260 } else {
1261 stop(); 1261 stop();
1262 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { 1262 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) {
1263 QTimer::singleShot(afterPauseMS, this, SLOT(killed())); 1263 QTimer::singleShot(afterPauseMS, this, SLOT(killed()));
1264 return; 1264 return;
1265 } 1265 }
1266 1266
1267 gameState.setBit(Init); 1267 gameState.setBit(Init);
1268 1268
1269 repaintFigures(); 1269 repaintFigures();
1270 1270
1271 timerCount = 0; 1271 timerCount = 0;
1272 killedPlay(); 1272 killedPlay();
1273 } 1273 }
1274} 1274}
1275 1275
1276void Referee::killedPlay() 1276void Referee::killedPlay()
1277{ 1277{
1278 if (!gameState.testBit(Dying) || gameState.testBit(Ready)) 1278 if (!gameState.testBit(Dying) || gameState.testBit(Ready))
1279 return; 1279 return;
1280 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { 1280 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) {
1281 QTimer::singleShot(afterPauseMS, this, SLOT(killedPlay())); 1281 QTimer::singleShot(afterPauseMS, this, SLOT(killedPlay()));
1282 return; 1282 return;
1283 } 1283 }
1284 1284
1285 if (timerCount <= pix->maxPixmaps(DyingPix)) { 1285 if (timerCount <= pix->maxPixmaps(DyingPix)) {
1286 repaint(pix->rect(pacman->position(), PacmanPix), FALSE); 1286 repaint(pix->rect(pacman->position(), PacmanPix), FALSE);
1287 if (timerCount >= pix->maxPixmaps(DyingPix)-1 || timerCount == 0) 1287 if (timerCount >= pix->maxPixmaps(DyingPix)-1 || timerCount == 0)
1288 QTimer::singleShot(dyingPostAnimationMS, this, SLOT(killedPlay())); 1288 QTimer::singleShot(dyingPostAnimationMS, this, SLOT(killedPlay()));
1289 else 1289 else
1290 QTimer::singleShot(dyingAnimationMS, this, SLOT(killedPlay())); 1290 QTimer::singleShot(dyingAnimationMS, this, SLOT(killedPlay()));
1291 timerCount++; 1291 timerCount++;
1292 } else { 1292 } else {
1293 gameState.clearBit(Dying); 1293 gameState.clearBit(Dying);
1294 stopEnergizer(); 1294 stopEnergizer();
1295 if (lifes == 0) { 1295 if (lifes == 0) {
1296 gameState.setBit(GameOver); 1296 gameState.setBit(GameOver);
1297 gameState.clearBit(Playing); 1297 gameState.clearBit(Playing);
1298 for (int e = 0; e < board->energizers(); e++) { 1298 for (int e = 0; e < board->energizers(); e++) {
1299 energizers->at(e)->setOff(); 1299 energizers->at(e)->setOff();
1300 repaint(pix->rect(board->position(energizer, e), EnergizerPix), FALSE); 1300 repaint(pix->rect(board->position(energizer, e), EnergizerPix), FALSE);
1301 } 1301 }
1302 repaint(pix->rect(board->position(fruithome), tr("GAME OVER")), FALSE); 1302 repaint(pix->rect(board->position(fruithome), tr("GAME OVER")), FALSE);
1303 QTimer::singleShot(gameOverDurMS, this, SLOT(hallOfFame())); 1303 QTimer::singleShot(gameOverDurMS, this, SLOT(hallOfFame()));
1304 } else { 1304 } else {
1305 gameState.clearBit(Init); 1305 gameState.clearBit(Init);
1306 initPacman(); 1306 initPacman();
1307 initFruit(); 1307 initFruit();
1308 initMonsters(); 1308 initMonsters();
1309 initEnergizers(); 1309 initEnergizers();
1310 emit setLifes(--lifes); 1310 emit setLifes(--lifes);
1311 repaintFigures(); 1311 repaintFigures();
1312 ready(); 1312 ready();
1313 } 1313 }
1314 } 1314 }
1315} 1315}
1316 1316
1317void Referee::initPacman() 1317void Referee::initPacman()
1318{ 1318{
1319 pacman->setMaxPixmaps(pix->maxPixmaps(PacmanPix)); 1319 pacman->setMaxPixmaps(pix->maxPixmaps(PacmanPix));
1320 pacman->setDemo(gameState.testBit(Demonstration)); 1320 pacman->setDemo(gameState.testBit(Demonstration));
1321 pacman->setPosition(board->position(pacmanhome)); 1321 pacman->setPosition(board->position(pacmanhome));
1322 pacman->setDirection(W, TRUE); 1322 pacman->setDirection(W, TRUE);
1323 pacman->setAlive(pacmanTicks[level]); 1323 pacman->setAlive(pacmanTicks[level]);
1324} 1324}
1325 1325
1326void Referee::initFruit(bool fullInitialization) 1326void Referee::initFruit(bool fullInitialization)
1327{ 1327{
1328 if (fullInitialization) { 1328 if (fullInitialization) {
1329 fruit->setMaxPixmaps(pix->maxPixmaps(FruitPix)); 1329 fruit->setMaxPixmaps(pix->maxPixmaps(FruitPix));
1330 if (fruitIndex[level] == 0) 1330 if (fruitIndex[level] == 0)
1331 fruit->setLevel(level, fruitAppearsTicks[level], 1331 fruit->setLevel(level, fruitAppearsTicks[level],
1332 fruitDurTicks[level], fruitTicks[level]); 1332 fruitDurTicks[level], fruitTicks[level]);
1333 else if (fruitIndex[level] < 0) 1333 else if (fruitIndex[level] < 0)
1334 fruit->setLevel(pix->maxPixmaps(FruitPix)+1, 1334 fruit->setLevel(pix->maxPixmaps(FruitPix)+1,
1335 fruitAppearsTicks[level], 1335 fruitAppearsTicks[level],
1336 fruitDurTicks[level], fruitTicks[level]); 1336 fruitDurTicks[level], fruitTicks[level]);
1337 else 1337 else
1338 fruit->setLevel(fruitIndex[level], fruitAppearsTicks[level], 1338 fruit->setLevel(fruitIndex[level], fruitAppearsTicks[level],
1339 fruitDurTicks[level], fruitTicks[level]); 1339 fruitDurTicks[level], fruitTicks[level]);
1340 } 1340 }
1341 1341
1342 if (board->tunnels() > 0) 1342 if (board->tunnels() > 0)
1343 fruit->setMovement(board->position(tunnel, rand() % board->tunnels()), 1343 fruit->setMovement(board->position(tunnel, rand() % board->tunnels()),
1344 board->position(tunnel, rand() % board->tunnels()), 1344 board->position(tunnel, rand() % board->tunnels()),
1345 fruitIQ[level]); 1345 fruitIQ[level]);
1346} 1346}
1347 1347
1348void Referee::initMonsters() 1348void Referee::initMonsters()
1349{ 1349{
1350 if( !monsters->isEmpty()) 1350 if( !monsters->isEmpty())
1351 monsters->clear(); 1351 monsters->clear();
1352 if( !monsterRect->isEmpty()) 1352 if( !monsterRect->isEmpty())
1353 monsterRect->clear(); 1353 monsterRect->clear();
1354 1354
1355 for (int id = 0; id < (gameState.testBit(Introducing) ? 4 : board->monsters()); id++) { 1355 for (int id = 0; id < (gameState.testBit(Introducing) ? 4 : board->monsters()); id++) {
1356 Monster *m = new Monster(board, id); 1356 Monster *m = new Monster(board, id);
1357 monsters->append(m); 1357 monsters->append(m);
1358 QRect *r = new QRect(); 1358 QRect *r = new QRect();
1359 monsterRect->append(r); 1359 monsterRect->append(r);
1360 if (!gameState.testBit(Introducing)) { 1360 if (!gameState.testBit(Introducing)) {
1361 m->setFreedom(board->position(prisonexit)); 1361 m->setFreedom(board->position(prisonexit));
1362 m->setDangerous(dangerousTicks[level], monsterIQ[level]); 1362 m->setDangerous(dangerousTicks[level], monsterIQ[level]);
1363 if (id == 0) 1363 if (id == 0)
1364 m->setPrison(board->position(prisonentry)); 1364 m->setPrison(board->position(prisonentry));
1365 else { 1365 else {
1366 m->setPrison(board->position(monsterhome, id)); 1366 m->setPrison(board->position(monsterhome, id));
1367 m->setArrested(arrestTicks[level], arrestDurTicks[level]*id); 1367 m->setArrested(arrestTicks[level], arrestDurTicks[level]*id);
1368 } 1368 }
1369 m->setPosition(board->position(monsterhome, id)); 1369 m->setPosition(board->position(monsterhome, id));
1370 switch(id) { 1370 switch(id) {
1371 case 0 : m->setDirection(W); break; 1371 case 0 : m->setDirection(W); break;
1372 case 1 : m->setDirection(N); break; 1372 case 1 : m->setDirection(N); break;
1373 default : m->setDirection(S); 1373 default : m->setDirection(S);
1374 } 1374 }
1375 } 1375 }
1376 m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix)); 1376 m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix));
1377 } 1377 }
1378} 1378}
1379 1379
1380void Referee::initEnergizers() 1380void Referee::initEnergizers()
1381{ 1381{
1382 if( !energizers->isEmpty()) 1382 if( !energizers->isEmpty())
1383 energizers->clear(); 1383 energizers->clear();
1384 if( !energizerRect->isEmpty()) 1384 if( !energizerRect->isEmpty())
1385 energizerRect->clear(); 1385 energizerRect->clear();
1386 1386
1387 for (int id = 0; id < (gameState.testBit(Introducing) ? 2 : board->energizers()); id++) { 1387 for (int id = 0; id < (gameState.testBit(Introducing) ? 2 : board->energizers()); id++) {
1388 Energizer *e = new Energizer(board); 1388 Energizer *e = new Energizer(board);
1389 energizers->append(e); 1389 energizers->append(e);
1390 QRect *r = new QRect(); 1390 QRect *r = new QRect();
1391 energizerRect->append(r); 1391 energizerRect->append(r);
1392 if (!gameState.testBit(Introducing)) { 1392 if (!gameState.testBit(Introducing)) {
1393 e->setPosition(board->position(energizer, id)); 1393 e->setPosition(board->position(energizer, id));
1394 e->setOn(); 1394 e->setOn();
1395 } 1395 }
1396 e->setMaxPixmaps(pix->maxPixmaps(EnergizerPix)); 1396 e->setMaxPixmaps(pix->maxPixmaps(EnergizerPix));
1397 } 1397 }
1398} 1398}
1399 1399
1400void Referee::setOnEnergizers() 1400void Referee::setOnEnergizers()
1401{ 1401{
1402 for (int e = 0; e < board->energizers(); e++) { 1402 for (int e = 0; e < board->energizers(); e++) {
1403 energizers->at(e)->setOn(); 1403 energizers->at(e)->setOn();
1404 } 1404 }
1405} 1405}
1406 1406
1407void Referee::setFocusOutPause(bool FocusOutPause) 1407void Referee::setFocusOutPause(bool FocusOutPause)
1408{ 1408{
1409 focusOutPause = FocusOutPause; 1409 focusOutPause = FocusOutPause;
1410} 1410}
1411 1411
1412void Referee::setFocusInContinue(bool FocusInContinue) 1412void Referee::setFocusInContinue(bool FocusInContinue)
1413{ 1413{
1414 focusInContinue = FocusInContinue; 1414 focusInContinue = FocusInContinue;
1415} 1415}
1416 1416
1417void Referee::focusInEvent(QFocusEvent *) 1417void Referee::focusInEvent(QFocusEvent *)
1418{ 1418{
1419 if (focusInContinue && focusedPause && 1419 if (focusInContinue && focusedPause &&
1420 gameState.testBit(Paused) && gameState.testBit(Playing)) { 1420 gameState.testBit(Paused) && gameState.testBit(Playing)) {
1421 pause(); 1421 pause();
1422 } 1422 }
1423} 1423}
1424 1424
1425void Referee::focusOutEvent(QFocusEvent *) 1425void Referee::focusOutEvent(QFocusEvent *)
1426{ 1426{
1427 if (focusOutPause && !gameState.testBit(Paused) && gameState.testBit(Playing)) { 1427 if (focusOutPause && !gameState.testBit(Paused) && gameState.testBit(Playing)) {
1428 focusedPause = TRUE; 1428 focusedPause = TRUE;
1429 pause(); 1429 pause();
1430 } 1430 }
1431} 1431}
diff --git a/noncore/games/kpacman/score.cpp b/noncore/games/kpacman/score.cpp
index 17dbf0a..b3ff3d9 100644
--- a/noncore/games/kpacman/score.cpp
+++ b/noncore/games/kpacman/score.cpp
@@ -1,642 +1,581 @@
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, tr(" 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(tr(" 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, tr(" HIGH SCORE ")).intersects(e->rect())) { 87 if (rect(8, 0, tr(" HIGH SCORE ")).intersects(e->rect())) {
88 QPixmap pix = bitfont->text(tr(" 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, tr(" 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(tr(" 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, tr(" CONGRATULATIONS ")).intersects(e->rect())) { 116 if (rect(1, 4*1.25, tr(" CONGRATULATIONS ")).intersects(e->rect())) {
117 QPixmap pix = bitfont->text(tr(" 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, tr(" 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(tr(" 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, tr(" 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(tr(" 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, tr(" ")).intersects(e->rect())) { 128 if (rect(1, 8*1.25, tr(" ")).intersects(e->rect())) {
129 QPixmap pix = bitfont->text(tr(" "), 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, tr("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(tr("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(tr("PAUSED"), RED, BLACK); 158 QPixmap pix = bitfont->text(tr("PAUSED"), RED, BLACK);
159 QRect r = bitfont->rect(tr("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, tr(" 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, tr(" 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
482 if (!highscoreFile.exists() && highscoreFile.name() == systemHighscoreFileInfo.filePath())
483 KMessageBox::information(0,
484 tr("You're going to create the highscore-file\n"
485 "'%1'\n"
486 "for your maschine, that should be used systemwide.\n"
487 "\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"
490 "\n"
491 "To use a different directory or filename for the highscores,"
492 "specify them in the configfile (kpacmanrc:highscoreFilePath)."
493 ).arg(systemHighscoreFileInfo.filePath()));
494
495 if (highscoreFile.name() == privateHighscoreFileInfo.filePath())
496 KMessageBox::information(0,
497 tr("You're using a private highscore-file, that's mostly because of\n"
498 "missing write-access to the systemwide file\n"
499 "'%1' .\n"
500 "\n"
501 "Ask your systemadministrator for granting you access to that file,\n"
502 "by setting the appropriate rights (a+w) on it.\n"
503 "\n"
504 "To use a different directory or filename for the highscores,"
505 "specify them in the configfile (kpacmanrc:highscoreFilePath)."
506 ).arg(systemHighscoreFileInfo.filePath()),
507 QString::null, "PrivateHighscore");
508#endif
509 if (highscoreFile.open(IO_WriteOnly)) { 481 if (highscoreFile.open(IO_WriteOnly)) {
510 QDataStream s(&highscoreFile); 482 QDataStream s(&highscoreFile);
511 for (int i = 0; i < 10; i++) 483 for (int i = 0; i < 10; i++)
512 s << hallOfFame[i].points << hallOfFame[i].levels << hallOfFame[i].duration << 484 s << hallOfFame[i].points << hallOfFame[i].levels << hallOfFame[i].duration <<
513 hallOfFame[i].moment << hallOfFame[i].name.latin1(); 485 hallOfFame[i].moment << hallOfFame[i].name.latin1();
514 highscoreFile.close(); 486 highscoreFile.close();
515 } 487 }
516} 488}
517 489
518void Score::setPause(bool Paused) 490void Score::setPause(bool Paused)
519{ 491{
520 paused = Paused; 492 paused = Paused;
521 493
522 QRect r = bitfont->rect(tr("PAUSED")); 494 QRect r = bitfont->rect(tr("PAUSED"));
523 r.moveCenter(QPoint(this->width()/2, this->height()/2)); 495 r.moveCenter(QPoint(this->width()/2, this->height()/2));
524 repaint(r, TRUE); 496 repaint(r, TRUE);
525 497
526 // repaint 1UP or 2UP 498 // repaint 1UP or 2UP
527 repaint(FALSE); 499 repaint(FALSE);
528} 500}
529 501
530void Score::end() 502void Score::end()
531{ 503{
532 if (paused) { 504 if (paused) {
533 QTimer::singleShot(afterPauseMS, this, SLOT(end())); 505 QTimer::singleShot(afterPauseMS, this, SLOT(end()));
534 return; 506 return;
535 } 507 }
536 508
537 // repaint 1UP or 2UP 509 // repaint 1UP or 2UP
538 lastPlayer = -1; 510 lastPlayer = -1;
539 repaint(FALSE); 511 repaint(FALSE);
540 512
541 emit forcedHallOfFame(FALSE); 513 emit forcedHallOfFame(FALSE);
542} 514}
543 515
544/* 516/*
545 * Return the date in a formatted QString. The format can be changed using internationalization 517 * 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". 518 * of the string "YY/MM/DD". Invalid QDate's where returned as "00/00/00".
547 */ 519 */
548QString Score::formatDate(QDate date) 520QString Score::formatDate(QDate date)
549{ 521{
550 QString s = tr("@YY@/@MM@/@DD@"); 522 QString s = tr("@YY@/@MM@/@DD@");
551 523
552 QString dd; 524 QString dd;
553 dd.sprintf("%02d", date.isValid() ? date.year() % 100 : 0); 525 dd.sprintf("%02d", date.isValid() ? date.year() % 100 : 0);
554 s.replace(QRegExp("@YY@"), dd); 526 s.replace(QRegExp("@YY@"), dd);
555 dd.sprintf("%02d", date.isValid() ? date.month() : 0); 527 dd.sprintf("%02d", date.isValid() ? date.month() : 0);
556 s.replace(QRegExp("@MM@"), dd); 528 s.replace(QRegExp("@MM@"), dd);
557 dd.sprintf("%02d", date.isValid() ? date.day() : 0); 529 dd.sprintf("%02d", date.isValid() ? date.day() : 0);
558 s.replace(QRegExp("@DD@"), dd); 530 s.replace(QRegExp("@DD@"), dd);
559 531
560 return s; 532 return s;
561} 533}
562 534
563QRect Score::rect(int col, float row, QString str, int align) 535QRect Score::rect(int col, float row, QString str, int align)
564{ 536{
565 QRect r = bitfont->rect(str); 537 QRect r = bitfont->rect(str);
566 r.moveBy(x(col), y(row)); 538 r.moveBy(x(col), y(row));
567 539
568 int dx = 0; 540 int dx = 0;
569 int dy = 0; 541 int dy = 0;
570 542
571 if (align & AlignLeft || align & AlignRight) { 543 if (align & AlignLeft || align & AlignRight) {
572 dx = (str.length()-1) * (bitfont->width()/2); 544 dx = (str.length()-1) * (bitfont->width()/2);
573 if (align & AlignRight) 545 if (align & AlignRight)
574 dx *= -1; 546 dx *= -1;
575 } 547 }
576 548
577 if (align & AlignTop || align & AlignBottom) { 549 if (align & AlignTop || align & AlignBottom) {
578 dy = bitfont->height()/2; 550 dy = bitfont->height()/2;
579 if (align & AlignBottom) 551 if (align & AlignBottom)
580 dy *= -1; 552 dy *= -1;
581 } 553 }
582 554
583 if (dx != 0 || dy != 0) 555 if (dx != 0 || dy != 0)
584 r.moveBy(dx, dy); 556 r.moveBy(dx, dy);
585 557
586 return r; 558 return r;
587} 559}
588 560
589int Score::x(int col) 561int Score::x(int col)
590{ 562{
591 return col*bitfont->width(); 563 return col*bitfont->width();
592} 564}
593 565
594int Score::y(float row) 566int Score::y(float row)
595{ 567{
596 return (int) (row*(bitfont->height()+bitfont->height()/4)); 568 return (int) (row*(bitfont->height()+bitfont->height()/4));
597} 569}
598 570
599/** 571/**
600 * Ermittelt die zu benutzende "highscore"-Datei, in die auch geschrieben werden kann. 572 * Ermittelt die zu benutzende "highscore"-Datei, in die auch geschrieben werden kann.
601 * Über den "highscoreFilePath"-KConfig-Eintrag, kann abweichend von der Standardlokation 573 * Über den "highscoreFilePath"-KConfig-Eintrag, kann abweichend von der Standardlokation
602 * der Standort der "highscore"-Datei spezifiziert werden. 574 * der Standort der "highscore"-Datei spezifiziert werden.
603 * Wenn die systemweite "highscore"-Datei nicht beschrieben werden kann, wird mit einer 575 * Wenn die systemweite "highscore"-Datei nicht beschrieben werden kann, wird mit einer
604 * privaten Datei gearbeitet. 576 * privaten Datei gearbeitet.
605 */ 577 */
606QFileInfo Score::locateHighscoreFilePath() 578QFileInfo Score::locateHighscoreFilePath()
607{ 579{
608#ifndef QWS
609 QFileInfo systemHighscoreDirPath;
610 QStringList systemHighscoreDirs;
611
612 // Schreibfähige "private" highscore-Datei ermitteln für den fallback.
613 privateHighscoreFileInfo.setFile(KGlobal::dirs()->saveLocation("appdata")+highscoreName);
614
615 // FilePath aus der Konfigurationsdatei benutzen
616 systemHighscoreFileInfo.setFile(cfg->readEntry("HighscoreFilePath"));
617
618 // Kein Wert aus der Konfiguration erhalten, dann die "system"-Datei suchen.
619 if (systemHighscoreFileInfo.filePath().isEmpty())
620 systemHighscoreDirs = KGlobal::dirs()->resourceDirs("appdata");
621 else
622 systemHighscoreDirs = QStringList(systemHighscoreFileInfo.filePath());
623
624 for (QStringList::Iterator i = systemHighscoreDirs.begin(); i != systemHighscoreDirs.end(); ++i) {
625
626 systemHighscoreFileInfo.setFile(*i);
627 if (systemHighscoreFileInfo.fileName().isEmpty())
628 systemHighscoreFileInfo.setFile(systemHighscoreFileInfo.dirPath()+"/"+highscoreName);
629
630 // privateHighscoreFileInfo für die "system" Suche ignorieren
631 if (systemHighscoreFileInfo.filePath() != privateHighscoreFileInfo.filePath())
632 if (!systemHighscoreFileInfo.exists()) {
633 systemHighscoreDirPath.setFile(systemHighscoreFileInfo.dirPath());
634 if (systemHighscoreDirPath.exists() && systemHighscoreDirPath.isWritable())
635 return systemHighscoreFileInfo;
636 } else
637 if (systemHighscoreFileInfo.isWritable())
638 return systemHighscoreFileInfo;
639 }
640#endif
641 return privateHighscoreFileInfo; 580 return privateHighscoreFileInfo;
642} 581}