summaryrefslogtreecommitdiff
authorzecke <zecke>2003-05-14 12:08:54 (UTC)
committer zecke <zecke>2003-05-14 12:08:54 (UTC)
commitc480b91a5afe1f259287c3c4173ec02f2b4854cb (patch) (unidiff)
treeffe59a2fc544f6067fd96065d94a877188f1ef88
parent415a300230e10e29660b2af26a23798fd0b12e03 (diff)
downloadopie-c480b91a5afe1f259287c3c4173ec02f2b4854cb.zip
opie-c480b91a5afe1f259287c3c4173ec02f2b4854cb.tar.gz
opie-c480b91a5afe1f259287c3c4173ec02f2b4854cb.tar.bz2
patch by Scott Bronson
kill the duplicated config.cpp and config.h file add proper default values so that kpacman actually works out of the box Config wanted to read kpacman.conf but this file did only exist globally
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/kpacman/config.cpp394
-rw-r--r--noncore/games/kpacman/config.h74
-rw-r--r--noncore/games/kpacman/keys.cpp4
-rw-r--r--noncore/games/kpacman/kpacman.cpp18
-rw-r--r--noncore/games/kpacman/kpacman.pro2
-rw-r--r--noncore/games/kpacman/kpacmanwidget.cpp2
-rw-r--r--noncore/games/kpacman/painter.cpp2
-rw-r--r--noncore/games/kpacman/referee.cpp2
-rw-r--r--noncore/games/kpacman/status.cpp4
9 files changed, 19 insertions, 483 deletions
diff --git a/noncore/games/kpacman/config.cpp b/noncore/games/kpacman/config.cpp
deleted file mode 100644
index b9e3607..0000000
--- a/noncore/games/kpacman/config.cpp
+++ b/dev/null
@@ -1,394 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19** $Id$
20**
21**********************************************************************/
22
23#include "config.h"
24
25#include <qfile.h>
26#include <qdir.h>
27#include <qfileinfo.h>
28#include <qtextstream.h>
29#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
30#include <qtextcodec.h>
31#endif
32#include <stdlib.h>
33#include <sys/stat.h>
34#include <sys/types.h>
35#include <fcntl.h>
36#include <unistd.h>
37
38/*!
39 \internal
40*/
41QString Config::configFilename(const QString& name, Domain d)
42{
43 switch (d) {
44 case File:
45 return name;
46 case User: {
47 QDir dir = (QString(getenv("HOME")) + "/Settings");
48 if ( !dir.exists() )
49 mkdir(dir.path().local8Bit(),0700);
50 return dir.path() + "/" + name + ".conf";
51 }
52 }
53 return name;
54}
55
56/*!
57 \class Config config.h
58 \brief The Config class provides for saving application cofniguration state.
59
60 You should keep a Config in existence only while you do not want others
61 to be able to change the state. There is no locking currently, but there
62 may be in the future.
63*/
64
65/*!
66 \enum Config::ConfigGroup
67 \internal
68*/
69
70/*!
71 \enum Config::Domain
72
73 \value File
74 \value User
75
76 See Config for details.
77*/
78
79/*!
80 Constructs a config that will load or create a configuration with the
81 given \a name in the given \a domain.
82
83 You must call setGroup() before doing much else with the Config.
84
85 In the default Domain, \e User,
86 the configuration is user-specific. \a name should not contain "/" in
87 this case, and in general should be the name of the C++ class that is
88 primarily responsible for maintaining the configuration.
89
90 In the File Domain, \a name is an absolute filename.
91*/
92Config::Config( const QString &name, Domain domain )
93 : filename( configFilename(name,domain) )
94{
95 git = groups.end();
96 read();
97
98 lang = getenv("LANG");
99 int i = lang.find(".");
100 if ( i > 0 )
101 lang = lang.left( i );
102 i = lang.find( "_" );
103 if ( i > 0 )
104 glang = lang.left(i);
105}
106
107/*!
108 Writes any changes to disk and destroys the in-memory object.
109*/
110Config::~Config()
111{
112 if ( changed )
113 write();
114}
115
116/*!
117 Returns whether the current group has an entry called \a key.
118*/
119bool Config::hasKey( const QString &key ) const
120{
121 if ( groups.end() == git )
122 return FALSE;
123 ConfigGroup::ConstIterator it = ( *git ).find( key );
124 return it != ( *git ).end();
125}
126
127/*!
128 Sets the current group for subsequent reading and writing of
129 entries to \a gname. Grouping allows the application to partition the namespace.
130
131 This function must be called prior to any reading or writing
132 of entries.
133
134 The \a gname must not be empty.
135*/
136void Config::setGroup( const QString &gname )
137{
138 QMap< QString, ConfigGroup>::Iterator it = groups.find( gname );
139 if ( it == groups.end() ) {
140 ConfigGroup *grp = new ConfigGroup;
141 git = groups.insert( gname, *grp );
142 changed = TRUE;
143 return;
144 }
145 git = it;
146}
147
148/*!
149 Writes a (\a key, \a value) entry to the current group.
150
151 \sa readEntry()
152*/
153void Config::writeEntry( const QString &key, const QString &value )
154{
155 if ( git == groups.end() ) {
156 qWarning( "no group set" );
157 return;
158 }
159 if ( (*git)[key] != value ) {
160 ( *git ).insert( key, value );
161 changed = TRUE;
162 }
163}
164
165/*!
166 Writes a (\a key, \a num) entry to the current group.
167
168 \sa readNumEntry()
169*/
170void Config::writeEntry( const QString &key, int num )
171{
172 QString s;
173 s.setNum( num );
174 writeEntry( key, s );
175}
176
177#ifdef Q_HAS_BOOL_TYPE
178/*!
179 Writes a (\a key, \a b) entry to the current group.
180
181 \sa readBoolEntry()
182*/
183void Config::writeEntry( const QString &key, bool b )
184{
185 QString s;
186 s.setNum( ( int )b );
187 writeEntry( key, s );
188}
189#endif
190
191/*!
192 Writes a (\a key, \a lst) entry to the current group. The list
193 is separated by \a sep, so the strings must not contain that character.
194
195 \sa readListEntry()
196*/
197void Config::writeEntry( const QString &key, const QStringList &lst, const QChar &sep )
198{
199 QString s;
200 QStringList::ConstIterator it = lst.begin();
201 for ( ; it != lst.end(); ++it )
202 s += *it + sep;
203 writeEntry( key, s );
204}
205
206
207
208/*!
209 Reads a string entry stored with \a key, defaulting to \a deflt if there is no entry.
210*/
211QString Config::readEntry( const QString &key, const QString &deflt )
212{
213 QString res = readEntryDirect( key+"["+lang+"]" );
214 if ( !res.isNull() )
215 return res;
216 if ( !glang.isEmpty() ) {
217 res = readEntryDirect( key+"["+glang+"]" );
218 if ( !res.isNull() )
219 return res;
220 }
221 return readEntryDirect( key, deflt );
222}
223
224/*!
225 \internal
226*/
227QString Config::readEntryDirect( const QString &key, const QString &deflt )
228{
229 if ( git == groups.end() ) {
230 //qWarning( "no group set" );
231 return deflt;
232 }
233 ConfigGroup::Iterator it = ( *git ).find( key );
234 if ( it != ( *git ).end() )
235 return *it;
236 else
237 return deflt;
238}
239
240/*!
241 Reads a numeric entry stored with \a key, defaulting to \a deflt if there is no entry.
242*/
243int Config::readNumEntry( const QString &key, int deflt )
244{
245 QString s = readEntry( key );
246 if ( s.isEmpty() )
247 return deflt;
248 else
249 return s.toInt();
250}
251
252/*!
253 Reads a bool entry stored with \a key, defaulting to \a deflt if there is no entry.
254*/
255bool Config::readBoolEntry( const QString &key, bool deflt )
256{
257 QString s = readEntry( key );
258 if ( s.isEmpty() )
259 return deflt;
260 else
261 return (bool)s.toInt();
262}
263
264/*!
265 Reads a string list entry stored with \a key, and with \a sep as the separator.
266*/
267QStringList Config::readListEntry( const QString &key, const QChar &sep )
268{
269 QString s = readEntry( key );
270 if ( s.isEmpty() )
271 return QStringList();
272 else
273 return QStringList::split( sep, s );
274}
275
276/*!
277 Removes all entries from the current group.
278*/
279void Config::clearGroup()
280{
281 if ( git == groups.end() ) {
282 qWarning( "no group set" );
283 return;
284 }
285 if ( !(*git).isEmpty() ) {
286 ( *git ).clear();
287 changed = TRUE;
288 }
289}
290
291/*!
292 \internal
293*/
294void Config::write( const QString &fn )
295{
296 if ( !fn.isEmpty() )
297 filename = fn;
298
299 QFile f( filename );
300 if ( !f.open( IO_WriteOnly ) ) {
301 qWarning( "could not open for writing `%s'", filename.latin1() );
302 git = groups.end();
303 return;
304 }
305
306 QTextStream s( &f );
307#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
308 // The below should work, but doesn't in Qt 2.3.0
309 s.setCodec( QTextCodec::codecForMib( 106 ) );
310#else
311 s.setEncoding( QTextStream::UnicodeUTF8 );
312#endif
313 QMap< QString, ConfigGroup >::Iterator g_it = groups.begin();
314 for ( ; g_it != groups.end(); ++g_it ) {
315 s << "[" << g_it.key() << "]" << "\n";
316 ConfigGroup::Iterator e_it = ( *g_it ).begin();
317 for ( ; e_it != ( *g_it ).end(); ++e_it )
318 s << e_it.key() << " = " << *e_it << "\n";
319 }
320
321 f.close();
322}
323
324/*!
325 Returns whether the Config is in a valid state.
326*/
327bool Config::isValid() const
328{
329 return groups.end() != git;
330}
331
332/*!
333 \internal
334*/
335void Config::read()
336{
337 changed = FALSE;
338
339 if ( !QFileInfo( filename ).exists() ) {
340 git = groups.end();
341 return;
342 }
343
344 QFile f( filename );
345 if ( !f.open( IO_ReadOnly ) ) {
346 git = groups.end();
347 return;
348 }
349
350 QTextStream s( &f );
351#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
352 // The below should work, but doesn't in Qt 2.3.0
353 s.setCodec( QTextCodec::codecForMib( 106 ) );
354#else
355 s.setEncoding( QTextStream::UnicodeUTF8 );
356#endif
357
358 QString line;
359 while ( !s.atEnd() ) {
360 line = s.readLine();
361 if ( !parse( line ) ) {
362 git = groups.end();
363 return;
364 }
365 }
366
367 f.close();
368}
369
370/*!
371 \internal
372*/
373bool Config::parse( const QString &l )
374{
375 QString line = l.stripWhiteSpace();
376 if ( line[ 0 ] == QChar( '[' ) ) {
377 QString gname = line;
378 gname = gname.remove( 0, 1 );
379 if ( gname[ (int)gname.length() - 1 ] == QChar( ']' ) )
380 gname = gname.remove( gname.length() - 1, 1 );
381 ConfigGroup *grp = new ConfigGroup;
382 git = groups.insert( gname, *grp );
383 } else if ( !line.isEmpty() ) {
384 if ( git == groups.end() )
385 return FALSE;
386 int eq = line.find( '=' );
387 if ( eq == -1 )
388 return FALSE;
389 QString key = line.left(eq).stripWhiteSpace();
390 QString value = line.mid(eq+1).stripWhiteSpace();
391 ( *git ).insert( key, value );
392 }
393 return TRUE;
394}
diff --git a/noncore/games/kpacman/config.h b/noncore/games/kpacman/config.h
deleted file mode 100644
index 3c26b5d..0000000
--- a/noncore/games/kpacman/config.h
+++ b/dev/null
@@ -1,74 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Designer.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#ifndef CONFIG_H
22#define CONFIG_H
23
24// ##### could use QSettings with Qt 3.0
25
26#include <qmap.h>
27#include <qstringlist.h>
28
29class ConfigPrivate;
30class Config
31{
32public:
33 typedef QMap< QString, QString > ConfigGroup;
34
35 enum Domain { File, User };
36 Config( const QString &name, Domain domain=User );
37 ~Config();
38
39 bool isValid() const;
40 bool hasKey( const QString &key ) const;
41
42 void setGroup( const QString &gname );
43 void writeEntry( const QString &key, const QString &value );
44 void writeEntry( const QString &key, int num );
45#ifdef Q_HAS_BOOL_TYPE
46 void writeEntry( const QString &key, bool b );
47#endif
48 void writeEntry( const QString &key, const QStringList &lst, const QChar &sep );
49
50 QString readEntry( const QString &key, const QString &deflt = QString::null );
51 QString readEntryDirect( const QString &key, const QString &deflt = QString::null );
52 int readNumEntry( const QString &key, int deflt = -1 );
53 bool readBoolEntry( const QString &key, bool deflt = FALSE );
54 QStringList readListEntry( const QString &key, const QChar &sep );
55
56 void clearGroup();
57
58 void write( const QString &fn = QString::null );
59
60protected:
61 void read();
62 bool parse( const QString &line );
63
64 QMap< QString, ConfigGroup > groups;
65 QMap< QString, ConfigGroup >::Iterator git;
66 QString filename;
67 QString lang;
68 QString glang;
69 bool changed;
70 ConfigPrivate *d;
71 static QString configFilename(const QString& name, Domain);
72};
73
74#endif
diff --git a/noncore/games/kpacman/keys.cpp b/noncore/games/kpacman/keys.cpp
index 8b17785..07ce135 100644
--- a/noncore/games/kpacman/keys.cpp
+++ b/noncore/games/kpacman/keys.cpp
@@ -1,203 +1,205 @@
1 1
2#include "portable.h" 2#include "portable.h"
3 3
4#if defined( KDE2_PORT ) 4#if defined( KDE2_PORT )
5#include <kapp.h> 5#include <kapp.h>
6#include <kconfig.h> 6#include <kconfig.h>
7#include <klocale.h> 7#include <klocale.h>
8#include <kstddirs.h> 8#include <kstddirs.h>
9#include <kaccel.h> 9#include <kaccel.h>
10 10
11#include <keys.h> 11#include <keys.h>
12#include <keys.moc> 12#include <keys.moc>
13#elif defined( QPE_PORT ) 13#elif defined( QPE_PORT )
14#include <qaccel.h> 14#include <qaccel.h>
15#include <qpe/qpeapplication.h> 15#include <qpe/qpeapplication.h>
16#include "config.h" 16#include <qpe/config.h>
17#include "keys.h" 17#include "keys.h"
18#endif 18#endif
19 19
20#include <qpushbt.h> 20#include <qpushbt.h>
21#include <qlabel.h> 21#include <qlabel.h>
22#include <qframe.h> 22#include <qframe.h>
23#include <qkeycode.h> 23#include <qkeycode.h>
24#include <qpixmap.h> 24#include <qpixmap.h>
25#include <qstring.h> 25#include <qstring.h>
26 26
27Keys::Keys( QWidget *parent, const char *name) 27Keys::Keys( QWidget *parent, const char *name)
28 : QDialog( parent, name, TRUE ) 28 : QDialog( parent, name, TRUE )
29{ 29{
30 //KStandardDirs *dirs = KGlobal::dirs(); 30 //KStandardDirs *dirs = KGlobal::dirs();
31 31
32 QPushButton *okButton = new QPushButton(this); 32 QPushButton *okButton = new QPushButton(this);
33 okButton->setText(tr("Ok")); 33 okButton->setText(tr("Ok"));
34 okButton->setFixedSize(okButton->size()); 34 okButton->setFixedSize(okButton->size());
35 connect( okButton, SIGNAL(clicked()),this, SLOT(ok()) ); 35 connect( okButton, SIGNAL(clicked()),this, SLOT(ok()) );
36 okButton->move(20,210); 36 okButton->move(20,210);
37 37
38 QPushButton *defaultButton = new QPushButton(this); 38 QPushButton *defaultButton = new QPushButton(this);
39 defaultButton->setText(tr("Defaults")); 39 defaultButton->setText(tr("Defaults"));
40 defaultButton->setFixedSize(defaultButton->size()); 40 defaultButton->setFixedSize(defaultButton->size());
41 connect( defaultButton, SIGNAL(clicked()),this, SLOT(defaults()) ); 41 connect( defaultButton, SIGNAL(clicked()),this, SLOT(defaults()) );
42 defaultButton->move(140,210); 42 defaultButton->move(140,210);
43 43
44 QPushButton *cancelButton = new QPushButton(this); 44 QPushButton *cancelButton = new QPushButton(this);
45 cancelButton->setText(tr("Cancel")); 45 cancelButton->setText(tr("Cancel"));
46 cancelButton->setFixedSize(cancelButton->size()); 46 cancelButton->setFixedSize(cancelButton->size());
47 connect( cancelButton, SIGNAL(clicked()),this, SLOT(reject()) ); 47 connect( cancelButton, SIGNAL(clicked()),this, SLOT(reject()) );
48 cancelButton->move(260,210); 48 cancelButton->move(260,210);
49 49
50 QFrame *separator = new QFrame(this); 50 QFrame *separator = new QFrame(this);
51 separator->setFrameStyle( QFrame::HLine | QFrame::Sunken ); 51 separator->setFrameStyle( QFrame::HLine | QFrame::Sunken );
52 separator->setGeometry( 20, 190, 340, 4 ); 52 separator->setGeometry( 20, 190, 340, 4 );
53 53
54 for ( int x = 0; x < 4; x++) { 54 for ( int x = 0; x < 4; x++) {
55 QLabel *l = new QLabel(this); 55 QLabel *l = new QLabel(this);
56 l->setAlignment(AlignCenter); 56 l->setAlignment(AlignCenter);
57 labels[x] = l; 57 labels[x] = l;
58 } 58 }
59 59
60 labels[0]->setGeometry(120, 20, 140, 20 ); 60 labels[0]->setGeometry(120, 20, 140, 20 );
61 labels[1]->setGeometry(120,160, 140, 20 ); 61 labels[1]->setGeometry(120,160, 140, 20 );
62 labels[2]->setGeometry( 20, 92, 100, 20 ); 62 labels[2]->setGeometry( 20, 92, 100, 20 );
63 labels[3]->setGeometry(265, 92, 100, 20 ); 63 labels[3]->setGeometry(265, 92, 100, 20 );
64 64
65 QString pixPath; 65 QString pixPath;
66 66
67 QPushButton *up = new QPushButton(this); 67 QPushButton *up = new QPushButton(this);
68 pixPath = FIND_APP_DATA( "pics/up.xpm" ); 68 pixPath = FIND_APP_DATA( "pics/up.xpm" );
69 up->setPixmap( QPixmap(pixPath)); 69 up->setPixmap( QPixmap(pixPath));
70 up->setFixedSize(up->pixmap()->size()); 70 up->setFixedSize(up->pixmap()->size());
71 connect( up, SIGNAL(clicked()),this, SLOT(butUp()) ); 71 connect( up, SIGNAL(clicked()),this, SLOT(butUp()) );
72 up->move(180, 50); 72 up->move(180, 50);
73 73
74 QPushButton *down = new QPushButton(this); 74 QPushButton *down = new QPushButton(this);
75 pixPath = FIND_APP_DATA( "pics/down.xpm"); 75 pixPath = FIND_APP_DATA( "pics/down.xpm");
76 down->setPixmap( QPixmap(pixPath)); 76 down->setPixmap( QPixmap(pixPath));
77 down->setFixedSize(down->pixmap()->size()); 77 down->setFixedSize(down->pixmap()->size());
78 connect( down, SIGNAL(clicked()),this, SLOT(butDown()) ); 78 connect( down, SIGNAL(clicked()),this, SLOT(butDown()) );
79 down->move(180, 130); 79 down->move(180, 130);
80 80
81 QPushButton *left = new QPushButton(this); 81 QPushButton *left = new QPushButton(this);
82 pixPath = FIND_APP_DATA( "pics/left.xpm"); 82 pixPath = FIND_APP_DATA( "pics/left.xpm");
83 left->setPixmap( QPixmap(pixPath)); 83 left->setPixmap( QPixmap(pixPath));
84 left->setFixedSize(left->pixmap()->size()); 84 left->setFixedSize(left->pixmap()->size());
85 connect( left, SIGNAL(clicked()),this, SLOT(butLeft()) ); 85 connect( left, SIGNAL(clicked()),this, SLOT(butLeft()) );
86 left->move(140, 90); 86 left->move(140, 90);
87 87
88 QPushButton *right = new QPushButton(this); 88 QPushButton *right = new QPushButton(this);
89 pixPath = FIND_APP_DATA( "pics/right.xpm"); 89 pixPath = FIND_APP_DATA( "pics/right.xpm");
90 right->setPixmap( QPixmap(pixPath)); 90 right->setPixmap( QPixmap(pixPath));
91 right->setFixedSize(right->pixmap()->size()); 91 right->setFixedSize(right->pixmap()->size());
92 connect( right, SIGNAL(clicked()),this, SLOT(butRight()) ); 92 connect( right, SIGNAL(clicked()),this, SLOT(butRight()) );
93 right->move(220, 90); 93 right->move(220, 90);
94 94
95 95
96 setCaption(tr("Change Direction Keys")); 96 setCaption(tr("Change Direction Keys"));
97 setFixedSize(380, 260); 97 setFixedSize(380, 260);
98 lab = 0; 98 lab = 0;
99 init(); 99 init();
100} 100}
101 101
102void Keys::keyPressEvent( QKeyEvent *e ) 102void Keys::keyPressEvent( QKeyEvent *e )
103{ 103{
104 uint kCode = e->key() & ~(SHIFT | CTRL | ALT); 104 uint kCode = e->key() & ~(SHIFT | CTRL | ALT);
105 QString string = KAccel::keyToString(kCode); 105 QString string = KAccel::keyToString(kCode);
106 106
107 if (lab != 0) { 107 if (lab != 0) {
108 if ( string.isNull() ) 108 if ( string.isNull() )
109 lab->setText(tr("Undefined key")); 109 lab->setText(tr("Undefined key"));
110 else 110 else
111 lab->setText(string); 111 lab->setText(string);
112 } 112 }
113 else if ( lab == 0 && e->key() == Key_Escape) 113 else if ( lab == 0 && e->key() == Key_Escape)
114 reject(); 114 reject();
115} 115}
116 116
117void Keys::butUp() 117void Keys::butUp()
118{ 118{
119 getKey(0); 119 getKey(0);
120} 120}
121 121
122void Keys::butDown() 122void Keys::butDown()
123{ 123{
124 getKey(1); 124 getKey(1);
125} 125}
126 126
127void Keys::butLeft() 127void Keys::butLeft()
128{ 128{
129 getKey(2); 129 getKey(2);
130} 130}
131 131
132void Keys::butRight() 132void Keys::butRight()
133{ 133{
134 getKey(3); 134 getKey(3);
135} 135}
136 136
137void Keys::getKey(int i) 137void Keys::getKey(int i)
138{ 138{
139 if ( lab != 0) 139 if ( lab != 0)
140 focusOut(lab); 140 focusOut(lab);
141 141
142 focusIn(labels[i]); 142 focusIn(labels[i]);
143} 143}
144 144
145void Keys::focusOut(QLabel *l) 145void Keys::focusOut(QLabel *l)
146{ 146{
147 l->setFrameStyle( QFrame::NoFrame ); 147 l->setFrameStyle( QFrame::NoFrame );
148 l->setBackgroundColor(backgroundColor()); 148 l->setBackgroundColor(backgroundColor());
149 l->repaint(); 149 l->repaint();
150} 150}
151 151
152void Keys::focusIn(QLabel *l) 152void Keys::focusIn(QLabel *l)
153{ 153{
154 lab = l; 154 lab = l;
155 lab->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 155 lab->setFrameStyle( QFrame::Panel | QFrame::Sunken );
156 lab->setBackgroundColor(white); 156 lab->setBackgroundColor(white);
157 lab->repaint(); 157 lab->repaint();
158} 158}
159 159
160void Keys::defaults() 160void Keys::defaults()
161{ 161{
162 if ( lab != 0) 162 if ( lab != 0)
163 focusOut(lab); 163 focusOut(lab);
164 164
165 lab = 0; 165 lab = 0;
166 166
167 labels[0]->setText("Up"); 167 labels[0]->setText("Up");
168 labels[1]->setText("Down"); 168 labels[1]->setText("Down");
169 labels[2]->setText("Left"); 169 labels[2]->setText("Left");
170 labels[3]->setText("Right"); 170 labels[3]->setText("Right");
171} 171}
172 172
173void Keys::init() 173void Keys::init()
174{ 174{
175 APP_CONFIG_BEGIN( cfg ); 175 APP_CONFIG_BEGIN( cfg );
176 QString up("Up"); 176 QString up("Up");
177 up = cfg->readEntry("upKey", (const char*) up); 177 up = cfg->readEntry("upKey", (const char*) up);
178 labels[0]->setText(up); 178 labels[0]->setText(up);
179 179
180 QString down("Down"); 180 QString down("Down");
181 down = cfg->readEntry("downKey", (const char*) down); 181 down = cfg->readEntry("downKey", (const char*) down);
182 labels[1]->setText(down); 182 labels[1]->setText(down);
183 183
184 QString left("Left"); 184 QString left("Left");
185 left = cfg->readEntry("leftKey", (const char*) left); 185 left = cfg->readEntry("leftKey", (const char*) left);
186 labels[2]->setText(left); 186 labels[2]->setText(left);
187 187
188 QString right("Right"); 188 QString right("Right");
189 right = cfg->readEntry("rightKey", (const char*) right); 189 right = cfg->readEntry("rightKey", (const char*) right);
190 labels[3]->setText(right); 190 labels[3]->setText(right);
191 APP_CONFIG_END( cfg ); 191 APP_CONFIG_END( cfg );
192} 192}
193 193
194void Keys::ok() 194void Keys::ok()
195{ 195{
196 /*
196 APP_CONFIG_BEGIN( cfg ); 197 APP_CONFIG_BEGIN( cfg );
197 cfg->writeEntry("upKey", (const char*) labels[0]->text() ); 198 cfg->writeEntry("upKey", (const char*) labels[0]->text() );
198 cfg->writeEntry("downKey", (const char*) labels[1]->text() ); 199 cfg->writeEntry("downKey", (const char*) labels[1]->text() );
199 cfg->writeEntry("leftKey", (const char*) labels[2]->text() ); 200 cfg->writeEntry("leftKey", (const char*) labels[2]->text() );
200 cfg->writeEntry("rightKey",(const char*) labels[3]->text() ); 201 cfg->writeEntry("rightKey",(const char*) labels[3]->text() );
201 APP_CONFIG_END( cfg ); 202 APP_CONFIG_END( cfg );
203 */
202 accept(); 204 accept();
203} 205}
diff --git a/noncore/games/kpacman/kpacman.cpp b/noncore/games/kpacman/kpacman.cpp
index aee8eea..812e9ea 100644
--- a/noncore/games/kpacman/kpacman.cpp
+++ b/noncore/games/kpacman/kpacman.cpp
@@ -1,364 +1,368 @@
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 <qpe/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 m_view = new QWidget( this, "m_view" ); 29 m_view = new QWidget( this, "m_view" );
30 m_view->setBackgroundColor( black ); 30 m_view->setBackgroundColor( black );
31 m_layout = new QGridLayout( m_view ); 31 m_layout = new QGridLayout( m_view );
32 m_layout->setMargin( 7 ); 32 m_layout->setMargin( 7 );
33 33
34 view = new KpacmanWidget( this, QString(name)+"widget"); 34 view = new KpacmanWidget( this, QString(name)+"widget");
35 m_layout->addWidget( view, 0, 0 ); 35 m_layout->addWidget( view, 0, 0 );
36 36
37 setCaption( "KPacman" ); 37 setCaption( "KPacman" );
38 38
39 view->referee->setFocus(); 39 view->referee->setFocus();
40 40
41 connect(view->referee, SIGNAL(setScore(int, int)), 41 connect(view->referee, SIGNAL(setScore(int, int)),
42 view->score, SLOT(setScore(int, int))); 42 view->score, SLOT(setScore(int, int)));
43 connect(view->referee, SIGNAL(setPoints(int)), 43 connect(view->referee, SIGNAL(setPoints(int)),
44 view->score, SLOT(set(int))); 44 view->score, SLOT(set(int)));
45 connect(view->referee, SIGNAL(setLifes(int)), 45 connect(view->referee, SIGNAL(setLifes(int)),
46 view->status, SLOT(setLifes(int))); 46 view->status, SLOT(setLifes(int)));
47 connect(view->referee, SIGNAL(setLevel(int)), 47 connect(view->referee, SIGNAL(setLevel(int)),
48 view->status, SLOT(setLevel(int))); 48 view->status, SLOT(setLevel(int)));
49 connect(view->referee, SIGNAL(forcedHallOfFame(bool)), 49 connect(view->referee, SIGNAL(forcedHallOfFame(bool)),
50 this, SLOT(forcedHallOfFame(bool))); 50 this, SLOT(forcedHallOfFame(bool)));
51 connect(view->referee, SIGNAL(togglePaused()), this, SLOT(togglePaused())); 51 connect(view->referee, SIGNAL(togglePaused()), this, SLOT(togglePaused()));
52 connect(view->referee, SIGNAL(toggleNew()), this, SLOT(toggleNew())); 52 connect(view->referee, SIGNAL(toggleNew()), this, SLOT(toggleNew()));
53 53
54 connect(view->score, SIGNAL(toggleNew()), this, SLOT(toggleNew())); 54 connect(view->score, SIGNAL(toggleNew()), this, SLOT(toggleNew()));
55 connect(view->score, SIGNAL(forcedHallOfFame(bool)), 55 connect(view->score, SIGNAL(forcedHallOfFame(bool)),
56 this, SLOT(forcedHallOfFame(bool))); 56 this, SLOT(forcedHallOfFame(bool)));
57 57
58 APP_CONFIG_BEGIN( cfg ); 58 APP_CONFIG_BEGIN( cfg );
59 focusOutPause = !cfg->readBoolEntry("FocusOutPause", TRUE); 59 focusOutPause = !cfg->readBoolEntry("FocusOutPause", TRUE);
60 focusInContinue = !cfg->readBoolEntry("FocusInContinue", TRUE); 60 focusInContinue = !cfg->readBoolEntry("FocusInContinue", TRUE);
61 hideMouseCursor = !cfg->readBoolEntry("HideMouseCursor", TRUE); 61 hideMouseCursor = !cfg->readBoolEntry("HideMouseCursor", TRUE);
62 APP_CONFIG_END( cfg ); 62 APP_CONFIG_END( cfg );
63 63
64 toggleFocusOutPause(); 64 toggleFocusOutPause();
65 toggleFocusInContinue(); 65 toggleFocusInContinue();
66 toggleHideMouseCursor(); 66 toggleHideMouseCursor();
67 67
68 setCentralWidget( m_view ); 68 setCentralWidget( m_view );
69} 69}
70 70
71Kpacman::~Kpacman() 71Kpacman::~Kpacman()
72{ 72{
73 APP_CONFIG_BEGIN( cfg ); 73 /* APP_CONFIG_BEGIN( cfg );
74 cfg->writeEntry("FocusOutPause", focusOutPause); 74 cfg->writeEntry("FocusOutPause", focusOutPause);
75 cfg->writeEntry("FocusInContinue", focusInContinue); 75 cfg->writeEntry("FocusInContinue", focusInContinue);
76 cfg->writeEntry("HideMouseCursor", hideMouseCursor); 76 cfg->writeEntry("HideMouseCursor", hideMouseCursor);
77 APP_CONFIG_END( cfg ); 77 APP_CONFIG_END( cfg );
78 */
78 delete _menuBar; 79 delete _menuBar;
79} 80}
80 81
81void Kpacman::menu() 82void Kpacman::menu()
82{ 83{
83 gamePopup = new QPopupMenu(); 84 gamePopup = new QPopupMenu();
84 CHECK_PTR( gamePopup ); 85 CHECK_PTR( gamePopup );
85 newID = gamePopup->insertItem(tr("&New"), this, SLOT(newKpacman()),Key_F2); 86 newID = gamePopup->insertItem(tr("&New"), this, SLOT(newKpacman()),Key_F2);
86 pauseID = gamePopup->insertItem(tr("&Pause"), 87 pauseID = gamePopup->insertItem(tr("&Pause"),
87 this, SLOT(pauseKpacman()), Key_F3); 88 this, SLOT(pauseKpacman()), Key_F3);
88 hofID = gamePopup->insertItem(tr("&Hall of fame"), 89 hofID = gamePopup->insertItem(tr("&Hall of fame"),
89 this, SLOT(toggleHallOfFame()), Key_F4); 90 this, SLOT(toggleHallOfFame()), Key_F4);
90 gamePopup->insertSeparator(); 91 gamePopup->insertSeparator();
91 gamePopup->insertItem(tr("&Quit"), this, SLOT(quitKpacman()), CTRL+Key_Q); 92 gamePopup->insertItem(tr("&Quit"), this, SLOT(quitKpacman()), CTRL+Key_Q);
92 gamePopup->setCheckable(TRUE); 93 gamePopup->setCheckable(TRUE);
93 94
94 optionsPopup = new QPopupMenu(); 95 optionsPopup = new QPopupMenu();
95 CHECK_PTR(optionsPopup); 96 CHECK_PTR(optionsPopup);
96 97
97 modesPopup = new QPopupMenu(); 98 modesPopup = new QPopupMenu();
98 CHECK_PTR(modesPopup); 99 CHECK_PTR(modesPopup);
99 100
100 hideMouseCursorID = optionsPopup->insertItem(tr("&Hide Mousecursor"), 101 hideMouseCursorID = optionsPopup->insertItem(tr("&Hide Mousecursor"),
101 this, SLOT(toggleHideMouseCursor()), 102 this, SLOT(toggleHideMouseCursor()),
102 CTRL+Key_H); 103 CTRL+Key_H);
103 optionsPopup->insertSeparator(); 104 optionsPopup->insertSeparator();
104 105
105 if (lookupSchemes() > 0) { 106 if (lookupSchemes() > 0) {
106 optionsPopup->insertItem(tr("&Select graphic scheme"), modesPopup); 107 optionsPopup->insertItem(tr("&Select graphic scheme"), modesPopup);
107 optionsPopup->insertSeparator(); 108 optionsPopup->insertSeparator();
108 } 109 }
109 110
110 focusOutPauseID = optionsPopup->insertItem(tr("&Pause in Background"), 111 focusOutPauseID = optionsPopup->insertItem(tr("&Pause in Background"),
111 this, SLOT(toggleFocusOutPause())); 112 this, SLOT(toggleFocusOutPause()));
112 focusInContinueID = optionsPopup->insertItem(tr("&Continue in Foreground"), 113 focusInContinueID = optionsPopup->insertItem(tr("&Continue in Foreground"),
113 this, SLOT(toggleFocusInContinue())); 114 this, SLOT(toggleFocusInContinue()));
114 optionsPopup->insertSeparator(); 115 optionsPopup->insertSeparator();
115 116
116 optionsPopup->insertItem(tr("Change &keys..."), this, SLOT(confKeys())); 117 optionsPopup->insertItem(tr("Change &keys..."), this, SLOT(confKeys()));
117 118
118#ifndef QPE_PORT 119#ifndef QPE_PORT
119 QString aboutText = tr("@PACKAGE@ - @VERSION@\n\n" 120 QString aboutText = tr("@PACKAGE@ - @VERSION@\n\n"
120 "Joerg Thoennissen (joe@dsite.de)\n\n" 121 "Joerg Thoennissen (joe@dsite.de)\n\n"
121 "A pacman game for the KDE Desktop\n\n" 122 "A pacman game for the KDE Desktop\n\n"
122 "The program based on the source of ksnake\n" 123 "The program based on the source of ksnake\n"
123 "by Michel Filippi (mfilippi@sade.rhein-main.de).\n" 124 "by Michel Filippi (mfilippi@sade.rhein-main.de).\n"
124 "The design was strongly influenced by the pacman\n" 125 "The design was strongly influenced by the pacman\n"
125 "(c) 1980 MIDWAY MFG.CO.\n\n" 126 "(c) 1980 MIDWAY MFG.CO.\n\n"
126 "I like to thank my girlfriend Elke Krueers for\n" 127 "I like to thank my girlfriend Elke Krueers for\n"
127 "the last 10 years of her friendship.\n"); 128 "the last 10 years of her friendship.\n");
128 aboutText.replace(QRegExp("@PACKAGE@"), PACKAGE); 129 aboutText.replace(QRegExp("@PACKAGE@"), PACKAGE);
129 aboutText.replace(QRegExp("@VERSION@"), VERSION); 130 aboutText.replace(QRegExp("@VERSION@"), VERSION);
130 QPopupMenu *helpPopup = helpMenu(aboutText, FALSE); 131 QPopupMenu *helpPopup = helpMenu(aboutText, FALSE);
131#endif 132#endif
132 133
133 //_menuBar = new KMenuBar(this); 134 //_menuBar = new KMenuBar(this);
134 //CHECK_PTR( _menuBar ); 135 //CHECK_PTR( _menuBar );
135 //_menuBar->insertItem(tr("&Game"), gamePopup); 136 //_menuBar->insertItem(tr("&Game"), gamePopup);
136 //_menuBar->insertItem(tr("&Options"), optionsPopup); 137 //_menuBar->insertItem(tr("&Options"), optionsPopup);
137 //_menuBar->insertSeparator(); 138 //_menuBar->insertSeparator();
138#ifndef QPE_PORT 139#ifndef QPE_PORT
139 _menuBar->insertItem(tr("&Help"), helpPopup); 140 _menuBar->insertItem(tr("&Help"), helpPopup);
140#endif 141#endif
141} 142}
142 143
143int Kpacman::lookupSchemes() 144int Kpacman::lookupSchemes()
144{ 145{
145 APP_CONFIG_BEGIN( cfg ); 146 APP_CONFIG_BEGIN( cfg );
146 int ModeCount = cfg->readNumEntry("ModeCount", -1); 147 int ModeCount = cfg->readNumEntry("ModeCount", 0);
147 int Mode = cfg->readNumEntry("Mode", -1); 148 int Mode = cfg->readNumEntry("Mode", 0);
148 int SchemeCount = cfg->readNumEntry("SchemeCount"); 149 int SchemeCount = cfg->readNumEntry("SchemeCount", 0);
149 int Scheme = cfg->readNumEntry("Scheme", -1); 150 int Scheme = cfg->readNumEntry("Scheme", 0);
150 151
152 /*
151 if (SchemeCount == 0 || Scheme == -1) { 153 if (SchemeCount == 0 || Scheme == -1) {
152 QMessageBox::warning(this, tr("Configuration Error"), 154 QMessageBox::warning(this, tr("Configuration Error"),
153 tr("There are no schemes defined,\n" 155 tr("There are no schemes defined,\n"
154 "or no scheme is selected.")); 156 "or no scheme is selected."));
155 APP_CONFIG_END( cfg ); 157 APP_CONFIG_END( cfg );
156 return 0; 158 return 0;
157 } 159 }
160 */
158 161
159 connect(modesPopup, SIGNAL(activated(int)), this, SLOT(schemeChecked(int))); 162 connect(modesPopup, SIGNAL(activated(int)), this, SLOT(schemeChecked(int)));
160 modeID.resize(ModeCount > 0 ? ModeCount : 0); 163 modeID.resize(ModeCount > 0 ? ModeCount : 0);
161 164
162 if (!schemesPopup->isEmpty()) 165 if (!schemesPopup->isEmpty())
163 schemesPopup->clear(); 166 schemesPopup->clear();
164 167
165 SAVE_CONFIG_GROUP( cfg, oldgroup ); 168 SAVE_CONFIG_GROUP( cfg, oldgroup );
166 169
167 QString ModeGroup; 170 QString ModeGroup;
168 QString ModeName; 171 QString ModeName;
169 172
170 for (int m = 0; m < ModeCount; m++) { 173 for (int m = 0; m < ModeCount; m++) {
171 ModeGroup.sprintf("Mode %d", m); 174 ModeGroup.sprintf("Mode %d", m);
172 cfg->setGroup(ModeGroup); 175 cfg->setGroup(ModeGroup);
173 176
174 ModeName = cfg->readEntry("Description", ModeGroup); 177 ModeName = cfg->readEntry("Description", ModeGroup);
175 178
176 QPopupMenu *p = new QPopupMenu; 179 QPopupMenu *p = new QPopupMenu;
177 p->setCheckable(TRUE); 180 p->setCheckable(TRUE);
178 connect(p, SIGNAL(activated(int)), this, SLOT(schemeChecked(int))); 181 connect(p, SIGNAL(activated(int)), this, SLOT(schemeChecked(int)));
179 schemesPopup->append(p); 182 schemesPopup->append(p);
180 183
181 modeID[m] = modesPopup->insertItem(ModeName, schemesPopup->at(m)); 184 modeID[m] = modesPopup->insertItem(ModeName, schemesPopup->at(m));
182 modesPopup->setItemEnabled(modeID[m], FALSE); 185 modesPopup->setItemEnabled(modeID[m], FALSE);
183 modesPopup->setItemChecked(modeID[m], m == Mode); 186 modesPopup->setItemChecked(modeID[m], m == Mode);
184 } 187 }
185 188
186 schemeID.resize(SchemeCount); 189 schemeID.resize(SchemeCount);
187 schemeMode.resize(SchemeCount); 190 schemeMode.resize(SchemeCount);
188 191
189 QString SchemeGroup; 192 QString SchemeGroup;
190 QString SchemeName; 193 QString SchemeName;
191 int SchemeMode; 194 int SchemeMode;
192 195
193 for (int i = 0; i < SchemeCount; i++) { 196 for (int i = 0; i < SchemeCount; i++) {
194 SchemeGroup.sprintf("Scheme %d", i); 197 SchemeGroup.sprintf("Scheme %d", i);
195 cfg->setGroup(SchemeGroup); 198 cfg->setGroup(SchemeGroup);
196 199
197 SchemeName = cfg->readEntry("Description", SchemeGroup); 200 SchemeName = cfg->readEntry("Description", SchemeGroup);
198 SchemeMode = cfg->readNumEntry("Mode", -1); 201 SchemeMode = cfg->readNumEntry("Mode", -1);
199 202
200 schemeMode[i] = SchemeMode; 203 schemeMode[i] = SchemeMode;
201 if (SchemeMode == -1) { 204 if (SchemeMode == -1) {
202 schemeID[i] = modesPopup->insertItem(SchemeName); 205 schemeID[i] = modesPopup->insertItem(SchemeName);
203 modesPopup->setItemChecked(schemeID[i], i == Scheme); 206 modesPopup->setItemChecked(schemeID[i], i == Scheme);
204 } else { 207 } else {
205 schemeID[i] = schemesPopup->at(SchemeMode)->insertItem(SchemeName); 208 schemeID[i] = schemesPopup->at(SchemeMode)->insertItem(SchemeName);
206 schemesPopup->at(SchemeMode)-> 209 schemesPopup->at(SchemeMode)->
207 setItemChecked(schemeID[i], i == Scheme); 210 setItemChecked(schemeID[i], i == Scheme);
208 modesPopup->setItemEnabled(modeID[SchemeMode], TRUE); 211 modesPopup->setItemEnabled(modeID[SchemeMode], TRUE);
209 } 212 }
210 } 213 }
211 214
212 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 215 RESTORE_CONFIG_GROUP( cfg, oldgroup );
213 216
214 APP_CONFIG_END( cfg ); 217 APP_CONFIG_END( cfg );
215 return SchemeCount; 218 return SchemeCount;
216} 219}
217 220
218void Kpacman::quitKpacman() 221void Kpacman::quitKpacman()
219{ 222{
220 APP_QUIT(); 223 APP_QUIT();
221} 224}
222 225
223void Kpacman::newKpacman() 226void Kpacman::newKpacman()
224{ 227{
225 if (!gamePopup->isItemEnabled(hofID)) 228 if (!gamePopup->isItemEnabled(hofID))
226 gamePopup->setItemEnabled(hofID, TRUE); 229 gamePopup->setItemEnabled(hofID, TRUE);
227 230
228 if (gamePopup->isItemChecked(hofID)) 231 if (gamePopup->isItemChecked(hofID))
229 toggleHallOfFame(); 232 toggleHallOfFame();
230 233
231 if (gamePopup->isItemChecked(pauseID)) 234 if (gamePopup->isItemChecked(pauseID))
232 pauseKpacman(); 235 pauseKpacman();
233 236
234 view->referee->play(); 237 view->referee->play();
235} 238}
236 239
237void Kpacman::pauseKpacman() 240void Kpacman::pauseKpacman()
238{ 241{
239 view->referee->pause(); 242 view->referee->pause();
240 view->score->setPause(gamePopup->isItemChecked(pauseID)); 243 view->score->setPause(gamePopup->isItemChecked(pauseID));
241} 244}
242 245
243void Kpacman::toggleHallOfFame() 246void Kpacman::toggleHallOfFame()
244{ 247{
245 gamePopup->setItemChecked(hofID, !gamePopup->isItemChecked(hofID)); 248 gamePopup->setItemChecked(hofID, !gamePopup->isItemChecked(hofID));
246 view->referee->toggleHallOfFame(); 249 view->referee->toggleHallOfFame();
247 250
248 if (gamePopup->isItemChecked(hofID)) { 251 if (gamePopup->isItemChecked(hofID)) {
249 view->referee->lower(); 252 view->referee->lower();
250 view->status->lower(); 253 view->status->lower();
251 } else { 254 } else {
252 view->status->raise(); 255 view->status->raise();
253 view->referee->raise(); 256 view->referee->raise();
254 view->referee->setFocus(); 257 view->referee->setFocus();
255 } 258 }
256} 259}
257 260
258/* 261/*
259 * Disable or enable the "Hall of fame"-menuitem if the referee says so. 262 * Disable or enable the "Hall of fame"-menuitem if the referee says so.
260 * This is done, to disable turning off the "hall of fame"-display, in the automated 263 * This is done, to disable turning off the "hall of fame"-display, in the automated
261 * sequence of displaying the introduction, the demonstration (or playing) and the 264 * sequence of displaying the introduction, the demonstration (or playing) and the
262 * hall of fame. 265 * hall of fame.
263 * If on == TRUE then also lower the referee and the status widgets. 266 * If on == TRUE then also lower the referee and the status widgets.
264 */ 267 */
265void Kpacman::forcedHallOfFame(bool on) 268void Kpacman::forcedHallOfFame(bool on)
266{ 269{
267 if (!on && !gamePopup->isItemChecked(hofID)) 270 if (!on && !gamePopup->isItemChecked(hofID))
268 return; 271 return;
269 272
270 gamePopup->setItemEnabled(hofID, !on); 273 gamePopup->setItemEnabled(hofID, !on);
271 gamePopup->setItemChecked(hofID, on); 274 gamePopup->setItemChecked(hofID, on);
272 275
273 view->referee->toggleHallOfFame(); 276 view->referee->toggleHallOfFame();
274 if (on) { 277 if (on) {
275 view->referee->lower(); 278 view->referee->lower();
276 view->status->lower(); 279 view->status->lower();
277 } else { 280 } else {
278 view->status->raise(); 281 view->status->raise();
279 view->referee->raise(); 282 view->referee->raise();
280 view->referee->setFocus(); 283 view->referee->setFocus();
281 view->referee->intro(); 284 view->referee->intro();
282 } 285 }
283} 286}
284 287
285void Kpacman::togglePaused() 288void Kpacman::togglePaused()
286{ 289{
287 static bool checked = FALSE; 290 static bool checked = FALSE;
288 checked = !checked; 291 checked = !checked;
289 gamePopup->setItemChecked( pauseID, checked ); 292 gamePopup->setItemChecked( pauseID, checked );
290 view->score->setPause(gamePopup->isItemChecked(pauseID)); 293 view->score->setPause(gamePopup->isItemChecked(pauseID));
291} 294}
292 295
293/* 296/*
294 * This disables the "New Game" menuitem to prevent interruptions of the current 297 * This disables the "New Game" menuitem to prevent interruptions of the current
295 * play. 298 * play.
296 */ 299 */
297void Kpacman::toggleNew() 300void Kpacman::toggleNew()
298{ 301{
299 gamePopup->setItemEnabled(newID, !gamePopup->isItemEnabled(newID)); 302 gamePopup->setItemEnabled(newID, !gamePopup->isItemEnabled(newID));
300} 303}
301 304
302void Kpacman::toggleHideMouseCursor() 305void Kpacman::toggleHideMouseCursor()
303{ 306{
304 hideMouseCursor = !hideMouseCursor; 307 hideMouseCursor = !hideMouseCursor;
305 optionsPopup->setItemChecked(hideMouseCursorID, hideMouseCursor); 308 optionsPopup->setItemChecked(hideMouseCursorID, hideMouseCursor);
306 if (hideMouseCursor) 309 if (hideMouseCursor)
307 view->setCursor(blankCursor); 310 view->setCursor(blankCursor);
308 else 311 else
309 view->setCursor(arrowCursor); 312 view->setCursor(arrowCursor);
310} 313}
311 314
312void Kpacman::toggleFocusOutPause() 315void Kpacman::toggleFocusOutPause()
313{ 316{
314 focusOutPause = !focusOutPause; 317 focusOutPause = !focusOutPause;
315 optionsPopup->setItemChecked(focusOutPauseID, focusOutPause); 318 optionsPopup->setItemChecked(focusOutPauseID, focusOutPause);
316 view->referee->setFocusOutPause(focusOutPause); 319 view->referee->setFocusOutPause(focusOutPause);
317} 320}
318 321
319void Kpacman::toggleFocusInContinue() 322void Kpacman::toggleFocusInContinue()
320{ 323{
321 focusInContinue = !focusInContinue; 324 focusInContinue = !focusInContinue;
322 optionsPopup->setItemChecked(focusInContinueID, focusInContinue); 325 optionsPopup->setItemChecked(focusInContinueID, focusInContinue);
323 view->referee->setFocusInContinue(focusInContinue); 326 view->referee->setFocusInContinue(focusInContinue);
324} 327}
325 328
326void Kpacman::confKeys() 329void Kpacman::confKeys()
327{ 330{
328 Keys *keys = new Keys(); 331 Keys *keys = new Keys();
329 if (keys->exec() == QDialog::Accepted) { 332 if (keys->exec() == QDialog::Accepted) {
330 view->referee->initKeys(); 333 view->referee->initKeys();
331 view->score->initKeys(); 334 view->score->initKeys();
332 } 335 }
333 delete keys; 336 delete keys;
334} 337}
335 338
336void Kpacman::schemeChecked(int id) 339void Kpacman::schemeChecked(int id)
337{ 340{
338 int mode = 0, scheme = -1; 341 int mode = 0, scheme = -1;
339 342
340 for (uint s = 0; s < schemeID.size(); s++) { 343 for (uint s = 0; s < schemeID.size(); s++) {
341 if (schemeID[s] == id) { 344 if (schemeID[s] == id) {
342 scheme = s; 345 scheme = s;
343 mode = schemeMode[s]; 346 mode = schemeMode[s];
344 } 347 }
345 if (schemeMode[s] == -1) { 348 if (schemeMode[s] == -1) {
346 modesPopup->setItemChecked(schemeID[s], schemeID[s] == id); 349 modesPopup->setItemChecked(schemeID[s], schemeID[s] == id);
347 } else { 350 } else {
348 modesPopup->setItemChecked(modeID[schemeMode[s]], schemeMode[s] == mode); 351 modesPopup->setItemChecked(modeID[schemeMode[s]], schemeMode[s] == mode);
349 schemesPopup->at(schemeMode[s])->setItemChecked(schemeID[s], schemeID[s] == id); 352 schemesPopup->at(schemeMode[s])->setItemChecked(schemeID[s], schemeID[s] == id);
350 } 353 }
351 } 354 }
352 355 /*
353 APP_CONFIG_BEGIN( cfg ); 356 APP_CONFIG_BEGIN( cfg );
354 cfg->writeEntry("Scheme", scheme); 357 cfg->writeEntry("Scheme", scheme);
355 cfg->writeEntry("Mode", mode); 358 cfg->writeEntry("Mode", mode);
356 APP_CONFIG_END( cfg ); 359 APP_CONFIG_END( cfg );
360 */
357 361
358 view->setScheme(scheme, mode); 362 view->setScheme(scheme, mode);
359 view->updateGeometry(); 363 view->updateGeometry();
360 updateGeometry(); 364 updateGeometry();
361 update(); 365 update();
362 repaint(TRUE); 366 repaint(TRUE);
363 show(); 367 show();
364} 368}
diff --git a/noncore/games/kpacman/kpacman.pro b/noncore/games/kpacman/kpacman.pro
index e193ebc..81d369a 100644
--- a/noncore/games/kpacman/kpacman.pro
+++ b/noncore/games/kpacman/kpacman.pro
@@ -1,63 +1,61 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 #CONFIG = qt warn_on debug 2 #CONFIG = qt warn_on debug
3 CONFIG = qt warn_on release 3 CONFIG = qt warn_on release
4 #TMAKE_CXXFLAGS+= 4 #TMAKE_CXXFLAGS+=
5 HEADERS = kpacmanwidget.h \ 5 HEADERS = kpacmanwidget.h \
6 referee.h \ 6 referee.h \
7 status.h \ 7 status.h \
8 painter.h \ 8 painter.h \
9 score.h \ 9 score.h \
10 pacman.h \ 10 pacman.h \
11 monster.h \ 11 monster.h \
12 keys.h \ 12 keys.h \
13 fruit.h \ 13 fruit.h \
14 energizer.h \ 14 energizer.h \
15 board.h \ 15 board.h \
16 bitfont.h \ 16 bitfont.h \
17 kpacman.h \ 17 kpacman.h \
18 bitmaps.h \ 18 bitmaps.h \
19 colors.h \ 19 colors.h \
20 config.h \
21 portable.h 20 portable.h
22 SOURCES = kpacmanwidget.cpp \ 21 SOURCES = kpacmanwidget.cpp \
23 referee.cpp \ 22 referee.cpp \
24 status.cpp \ 23 status.cpp \
25 painter.cpp \ 24 painter.cpp \
26 score.cpp \ 25 score.cpp \
27 pacman.cpp \ 26 pacman.cpp \
28 monster.cpp \ 27 monster.cpp \
29 keys.cpp \ 28 keys.cpp \
30 fruit.cpp \ 29 fruit.cpp \
31 energizer.cpp \ 30 energizer.cpp \
32 board.cpp \ 31 board.cpp \
33 bitfont.cpp \ 32 bitfont.cpp \
34 kpacman.cpp \ 33 kpacman.cpp \
35 config.cpp \
36 main.cpp 34 main.cpp
37 INCLUDEPATH+= $(OPIEDIR)/include 35 INCLUDEPATH+= $(OPIEDIR)/include
38 DEPENDPATH+= $(OPIEDIR)/include 36 DEPENDPATH+= $(OPIEDIR)/include
39LIBS += -lqpe 37LIBS += -lqpe
40DESTDIR = $(OPIEDIR)/bin 38DESTDIR = $(OPIEDIR)/bin
41 TARGET = kpacman 39 TARGET = kpacman
42 40
43TRANSLATIONS = ../../../i18n/de/kpacman.ts \ 41TRANSLATIONS = ../../../i18n/de/kpacman.ts \
44 ../../../i18n/nl/kpacman.ts \ 42 ../../../i18n/nl/kpacman.ts \
45 ../../../i18n/da/kpacman.ts \ 43 ../../../i18n/da/kpacman.ts \
46 ../../../i18n/xx/kpacman.ts \ 44 ../../../i18n/xx/kpacman.ts \
47 ../../../i18n/en/kpacman.ts \ 45 ../../../i18n/en/kpacman.ts \
48 ../../../i18n/es/kpacman.ts \ 46 ../../../i18n/es/kpacman.ts \
49 ../../../i18n/fr/kpacman.ts \ 47 ../../../i18n/fr/kpacman.ts \
50 ../../../i18n/hu/kpacman.ts \ 48 ../../../i18n/hu/kpacman.ts \
51 ../../../i18n/ja/kpacman.ts \ 49 ../../../i18n/ja/kpacman.ts \
52 ../../../i18n/ko/kpacman.ts \ 50 ../../../i18n/ko/kpacman.ts \
53 ../../../i18n/no/kpacman.ts \ 51 ../../../i18n/no/kpacman.ts \
54 ../../../i18n/pl/kpacman.ts \ 52 ../../../i18n/pl/kpacman.ts \
55 ../../../i18n/pt/kpacman.ts \ 53 ../../../i18n/pt/kpacman.ts \
56 ../../../i18n/pt_BR/kpacman.ts \ 54 ../../../i18n/pt_BR/kpacman.ts \
57 ../../../i18n/sl/kpacman.ts \ 55 ../../../i18n/sl/kpacman.ts \
58 ../../../i18n/zh_CN/kpacman.ts \ 56 ../../../i18n/zh_CN/kpacman.ts \
59 ../../../i18n/zh_TW/kpacman.ts 57 ../../../i18n/zh_TW/kpacman.ts
60 58
61 59
62 60
63include ( $(OPIEDIR)/include.pro ) 61include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/games/kpacman/kpacmanwidget.cpp b/noncore/games/kpacman/kpacmanwidget.cpp
index cf2aed9..823d2bf 100644
--- a/noncore/games/kpacman/kpacmanwidget.cpp
+++ b/noncore/games/kpacman/kpacmanwidget.cpp
@@ -1,158 +1,158 @@
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 <qpe/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 score = 0l; 26 score = 0l;
27 referee = 0l; 27 referee = 0l;
28 status = 0l; 28 status = 0l;
29 bitfont = NULL; 29 bitfont = NULL;
30 fontName = ""; 30 fontName = "";
31 31
32 scheme = mode = -1; 32 scheme = mode = -1;
33 confScheme(); 33 confScheme();
34 34
35 score = new Score(this, name, scheme, mode, bitfont); 35 score = new Score(this, name, scheme, mode, bitfont);
36 referee = new Referee( this, name, scheme, mode, bitfont); 36 referee = new Referee( this, name, scheme, mode, bitfont);
37 status = new Status(this, name, scheme, mode); 37 status = new Status(this, name, scheme, mode);
38 38
39 setBackgroundColor( black ); 39 setBackgroundColor( black );
40} 40}
41 41
42KpacmanWidget::~KpacmanWidget() 42KpacmanWidget::~KpacmanWidget()
43{ 43{
44} 44}
45 45
46void KpacmanWidget::confMisc(bool defGroup) 46void KpacmanWidget::confMisc(bool defGroup)
47{ 47{
48 APP_CONFIG_BEGIN( cfg ); 48 APP_CONFIG_BEGIN( cfg );
49 //KStandardDirs *dirs = KGlobal::dirs(); 49 //KStandardDirs *dirs = KGlobal::dirs();
50 QString findPath; 50 QString findPath;
51 51
52 if (defGroup || cfg->hasKey("Font")) { 52 if (defGroup || cfg->hasKey("Font")) {
53 fontName = cfg->readEntry("Font"); 53 fontName = cfg->readEntry("Font");
54 54
55 if (fontName.left(1) != "/" && fontName.left(1) != "~") 55 if (fontName.left(1) != "/" && fontName.left(1) != "~")
56 fontName.insert(0, "fonts/"); 56 fontName.insert(0, "fonts/");
57 if (fontName.right(1) == "/") 57 if (fontName.right(1) == "/")
58 fontName.append("font.xbm"); 58 fontName.append("font.xbm");
59 59
60 //findPath = dirs->findResource("appdata", fontName); 60 //findPath = dirs->findResource("appdata", fontName);
61 findPath = FIND_APP_DATA( fontName ); 61 findPath = FIND_APP_DATA( fontName );
62 if (!findPath.isEmpty()) 62 if (!findPath.isEmpty())
63 fontName = findPath; 63 fontName = findPath;
64 64
65 bitfontFirstChar = cfg->readNumEntry("FontFirstChar", 0x0e); 65 bitfontFirstChar = cfg->readNumEntry("FontFirstChar", 0x0e);
66 bitfontLastChar = cfg->readNumEntry("FontLastChar", 0x5f); 66 bitfontLastChar = cfg->readNumEntry("FontLastChar", 0x5f);
67 } 67 }
68 APP_CONFIG_END( cfg ); 68 APP_CONFIG_END( cfg );
69} 69}
70 70
71void KpacmanWidget::confScheme() 71void KpacmanWidget::confScheme()
72{ 72{
73 APP_CONFIG_BEGIN( cfg ); 73 APP_CONFIG_BEGIN( cfg );
74 QString lastFontName = fontName; 74 QString lastFontName = fontName;
75 SAVE_CONFIG_GROUP( cfg, oldgroup ); 75 SAVE_CONFIG_GROUP( cfg, oldgroup );
76 QString newgroup; 76 QString newgroup;
77 77
78 // if not set, read mode and scheme from the configfile 78 // if not set, read mode and scheme from the configfile
79 if (mode == -1 && scheme == -1) { 79 if (mode == -1 && scheme == -1) {
80 scheme = cfg->readNumEntry("Scheme", -1); 80 scheme = cfg->readNumEntry("Scheme", -1);
81 mode = cfg->readNumEntry("Mode", -1); 81 mode = cfg->readNumEntry("Mode", -1);
82 82
83 // if mode is not set in the defGroup-group, lookup the scheme group 83 // if mode is not set in the defGroup-group, lookup the scheme group
84 if (scheme != -1 || mode == -1) { 84 if (scheme != -1 || mode == -1) {
85 newgroup.sprintf("Scheme %d", scheme); 85 newgroup.sprintf("Scheme %d", scheme);
86 cfg->setGroup(newgroup); 86 cfg->setGroup(newgroup);
87 87
88 mode = cfg->readNumEntry("Mode", -1); 88 mode = cfg->readNumEntry("Mode", -1);
89 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 89 RESTORE_CONFIG_GROUP( cfg, oldgroup );
90 } 90 }
91 } 91 }
92 92
93 confMisc(); 93 confMisc();
94 94
95 if (mode != -1) { 95 if (mode != -1) {
96 newgroup.sprintf("Mode %d", mode); 96 newgroup.sprintf("Mode %d", mode);
97 cfg->setGroup(newgroup); 97 cfg->setGroup(newgroup);
98 98
99 confMisc(FALSE); 99 confMisc(FALSE);
100 } 100 }
101 101
102 if (scheme != -1) { 102 if (scheme != -1) {
103 newgroup.sprintf("Scheme %d", scheme); 103 newgroup.sprintf("Scheme %d", scheme);
104 cfg->setGroup(newgroup); 104 cfg->setGroup(newgroup);
105 105
106 confMisc(FALSE); 106 confMisc(FALSE);
107 } 107 }
108 108
109 if (lastFontName != fontName) { 109 if (lastFontName != fontName) {
110 110
111 if (bitfont != 0) 111 if (bitfont != 0)
112 delete bitfont; 112 delete bitfont;
113 113
114 bitfont = new Bitfont(fontName, bitfontFirstChar, bitfontLastChar); 114 bitfont = new Bitfont(fontName, bitfontFirstChar, bitfontLastChar);
115 if (bitfont->width() == 0 || bitfont->height() == 0) { 115 if (bitfont->width() == 0 || bitfont->height() == 0) {
116 QString msg = tr("The bitfont could not be contructed.\n\n" 116 QString msg = tr("The bitfont could not be contructed.\n\n"
117 "The file '@FONTNAME@' does not exist,\n" 117 "The file '@FONTNAME@' does not exist,\n"
118 "or is of an unknown format."); 118 "or is of an unknown format.");
119 msg.replace(QRegExp("@FONTNAME@"), fontName); 119 msg.replace(QRegExp("@FONTNAME@"), fontName);
120 // QMessageBox::critical(this, tr("Initialization Error"), msg); 120 // QMessageBox::critical(this, tr("Initialization Error"), msg);
121 printf("%s\n", msg.data()); 121 printf("%s\n", msg.data());
122 } 122 }
123 } 123 }
124 124
125 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 125 RESTORE_CONFIG_GROUP( cfg, oldgroup );
126 APP_CONFIG_END( cfg ); 126 APP_CONFIG_END( cfg );
127} 127}
128 128
129void KpacmanWidget::setScheme(int Scheme, int Mode) 129void KpacmanWidget::setScheme(int Scheme, int Mode)
130{ 130{
131 mode = Mode; 131 mode = Mode;
132 scheme = Scheme; 132 scheme = Scheme;
133 133
134 confScheme(); 134 confScheme();
135 135
136 score->setScheme(Scheme, Mode, bitfont); 136 score->setScheme(Scheme, Mode, bitfont);
137 referee->setScheme(Scheme, Mode, bitfont); 137 referee->setScheme(Scheme, Mode, bitfont);
138 status->setScheme(Scheme, Mode); 138 status->setScheme(Scheme, Mode);
139 139
140 score->repaint(FALSE); 140 score->repaint(FALSE);
141 referee->repaint(FALSE); 141 referee->repaint(FALSE);
142 status->repaint(FALSE); 142 status->repaint(FALSE);
143} 143}
144 144
145void KpacmanWidget::resizeEvent( QResizeEvent * ) 145void KpacmanWidget::resizeEvent( QResizeEvent * )
146{ 146{
147 qWarning("Resize"); 147 qWarning("Resize");
148 referee->setGeometry(0, bitfont->height()*3, referee->width(), referee->height()); 148 referee->setGeometry(0, bitfont->height()*3, referee->width(), referee->height());
149 referee->setBackgroundColor(BLACK); 149 referee->setBackgroundColor(BLACK);
150 150
151 if(!status ) return; 151 if(!status ) return;
152 status->setGeometry(0, bitfont->height()*3+referee->height(), referee->width(), 152 status->setGeometry(0, bitfont->height()*3+referee->height(), referee->width(),
153 status->height()); 153 status->height());
154 status->setBackgroundColor(BLACK); 154 status->setBackgroundColor(BLACK);
155 155
156 score->setGeometry(0, 0, referee->width(), bitfont->height()*3+referee->height()+status->height()); 156 score->setGeometry(0, 0, referee->width(), bitfont->height()*3+referee->height()+status->height());
157 score->setBackgroundColor(BLACK); 157 score->setBackgroundColor(BLACK);
158} 158}
diff --git a/noncore/games/kpacman/painter.cpp b/noncore/games/kpacman/painter.cpp
index 80aeab0..d8c7460 100644
--- a/noncore/games/kpacman/painter.cpp
+++ b/noncore/games/kpacman/painter.cpp
@@ -1,972 +1,972 @@
1 1
2#include "portable.h" 2#include "portable.h"
3 3
4#if defined( KDE2_PORT ) 4#if defined( KDE2_PORT )
5#include <kapp.h> 5#include <kapp.h>
6#include <kconfig.h> 6#include <kconfig.h>
7#include <kstddirs.h> 7#include <kstddirs.h>
8#elif defined( QPE_PORT ) 8#elif defined( QPE_PORT )
9#include <qpe/qpeapplication.h> 9#include <qpe/qpeapplication.h>
10#include "config.h" 10#include <qpe/config.h>
11#endif 11#endif
12 12
13#include <qcolor.h> 13#include <qcolor.h>
14#include <qpainter.h> 14#include <qpainter.h>
15#include <qpixmap.h> 15#include <qpixmap.h>
16#include <qbitmap.h> 16#include <qbitmap.h>
17#include <qrect.h> 17#include <qrect.h>
18#include <qstring.h> 18#include <qstring.h>
19 19
20#include <qmessagebox.h> 20#include <qmessagebox.h>
21#include <qfileinfo.h> 21#include <qfileinfo.h>
22 22
23#include "painter.h" 23#include "painter.h"
24#include "board.h" 24#include "board.h"
25 25
26Painter::Painter( Board *b, QWidget *parent, int Scheme, int Mode, Bitfont *font) 26Painter::Painter( Board *b, QWidget *parent, int Scheme, int Mode, Bitfont *font)
27{ 27{
28 w = parent; 28 w = parent;
29 board = b; 29 board = b;
30 30
31 pointPix = NULL; 31 pointPix = NULL;
32 wallPix = NULL; 32 wallPix = NULL;
33 prisonPix = NULL; 33 prisonPix = NULL;
34 energizerPix = NULL; 34 energizerPix = NULL;
35 fruitPix = NULL; 35 fruitPix = NULL;
36 pacmanPix = NULL; 36 pacmanPix = NULL;
37 dyingPix = NULL; 37 dyingPix = NULL;
38 eyesPix = NULL; 38 eyesPix = NULL;
39 monsterPix = NULL; 39 monsterPix = NULL;
40 fruitScorePix = NULL; 40 fruitScorePix = NULL;
41 monsterScorePix = NULL; 41 monsterScorePix = NULL;
42 42
43 lastPointPixmapName = ""; 43 lastPointPixmapName = "";
44 lastWallPixmapName = ""; 44 lastWallPixmapName = "";
45 lastPrisonPixmapName = ""; 45 lastPrisonPixmapName = "";
46 lastEnergizerPixmapName = ""; 46 lastEnergizerPixmapName = "";
47 lastFruitPixmapName = ""; 47 lastFruitPixmapName = "";
48 lastPacmanPixmapName = ""; 48 lastPacmanPixmapName = "";
49 lastDyingPixmapName = ""; 49 lastDyingPixmapName = "";
50 lastEyesPixmapName = ""; 50 lastEyesPixmapName = "";
51 lastMonsterPixmapName = ""; 51 lastMonsterPixmapName = "";
52 lastFruitScorePixmapName = ""; 52 lastFruitScorePixmapName = "";
53 lastMonsterScorePixmapName = ""; 53 lastMonsterScorePixmapName = "";
54 54
55 bitfont = font; 55 bitfont = font;
56 56
57 scheme = Scheme; 57 scheme = Scheme;
58 mode = Mode; 58 mode = Mode;
59 level = 0; 59 level = 0;
60 60
61 confScheme(); 61 confScheme();
62} 62}
63 63
64QList<QPixmap> *Painter::loadPixmap(QWidget*, QString pixmapName, 64QList<QPixmap> *Painter::loadPixmap(QWidget*, QString pixmapName,
65 QList<QPixmap> *pixmaps) 65 QList<QPixmap> *pixmaps)
66{ 66{
67 if (pixmaps == NULL) { 67 if (pixmaps == NULL) {
68 pixmaps = new QList<QPixmap>; 68 pixmaps = new QList<QPixmap>;
69 pixmaps->setAutoDelete(TRUE); 69 pixmaps->setAutoDelete(TRUE);
70 } 70 }
71 71
72 if (!pixmaps->isEmpty()) 72 if (!pixmaps->isEmpty())
73 pixmaps->clear(); 73 pixmaps->clear();
74 74
75 QPixmap PIXMAP(pixmapName); 75 QPixmap PIXMAP(pixmapName);
76 if (PIXMAP.isNull() || PIXMAP.mask() == NULL) { 76 if (PIXMAP.isNull() || PIXMAP.mask() == NULL) {
77 QString msg = "The pixmap could not be contructed.\n\n" 77 QString msg = "The pixmap could not be contructed.\n\n"
78 "The file '@PIXMAPNAME@' does not exist,\n" 78 "The file '@PIXMAPNAME@' does not exist,\n"
79 "or is of an unknown format."; 79 "or is of an unknown format.";
80 msg.replace(QRegExp("@PIXMAPNAME@"), pixmapName); 80 msg.replace(QRegExp("@PIXMAPNAME@"), pixmapName);
81 // QMessageBox::critical(parent, tr("Initialization Error"), msg); 81 // QMessageBox::critical(parent, tr("Initialization Error"), msg);
82 printf("%s\n", msg.data()); 82 printf("%s\n", msg.data());
83 return 0; 83 return 0;
84 } 84 }
85 85
86 int height = PIXMAP.height(); 86 int height = PIXMAP.height();
87 int width = (height == 0) ? 0 : PIXMAP.width()/(PIXMAP.width()/height); 87 int width = (height == 0) ? 0 : PIXMAP.width()/(PIXMAP.width()/height);
88 88
89 QBitmap BITMAP; 89 QBitmap BITMAP;
90 QBitmap MASK; 90 QBitmap MASK;
91 91
92 BITMAP = *PIXMAP.mask(); 92 BITMAP = *PIXMAP.mask();
93 MASK.resize(width, height); 93 MASK.resize(width, height);
94 94
95 for (int x = 0; x < PIXMAP.width()/width; x++) { 95 for (int x = 0; x < PIXMAP.width()/width; x++) {
96 QPixmap *pixmap = new QPixmap(width, height); 96 QPixmap *pixmap = new QPixmap(width, height);
97 pixmaps->append(pixmap); 97 pixmaps->append(pixmap);
98 bitBlt(pixmap, 0, 0, &PIXMAP, x*width, 0, width, height, QPixmap::CopyROP, TRUE); 98 bitBlt(pixmap, 0, 0, &PIXMAP, x*width, 0, width, height, QPixmap::CopyROP, TRUE);
99 bitBlt(&MASK, 0, 0, &BITMAP, x*width, 0, width, height, QPixmap::CopyROP, TRUE); 99 bitBlt(&MASK, 0, 0, &BITMAP, x*width, 0, width, height, QPixmap::CopyROP, TRUE);
100 pixmap->setMask(MASK); 100 pixmap->setMask(MASK);
101 } 101 }
102 102
103 return pixmaps; 103 return pixmaps;
104} 104}
105 105
106QList<QPixmap> *Painter::textPixmap(QStrList &str, QList<QPixmap> *pixmaps, 106QList<QPixmap> *Painter::textPixmap(QStrList &str, QList<QPixmap> *pixmaps,
107 QColor fg, QColor bg) 107 QColor fg, QColor bg)
108{ 108{
109 if (pixmaps == NULL) { 109 if (pixmaps == NULL) {
110 pixmaps = new QList<QPixmap>; 110 pixmaps = new QList<QPixmap>;
111 pixmaps->setAutoDelete(TRUE); 111 pixmaps->setAutoDelete(TRUE);
112 } 112 }
113 113
114 if (!pixmaps->isEmpty()) 114 if (!pixmaps->isEmpty())
115 pixmaps->clear(); 115 pixmaps->clear();
116 116
117 for (uint s = 0; s < str.count(); s++) { 117 for (uint s = 0; s < str.count(); s++) {
118 QPixmap *pixmap = new QPixmap(bitfont->text(str.at(s), fg, bg)); 118 QPixmap *pixmap = new QPixmap(bitfont->text(str.at(s), fg, bg));
119 pixmaps->append(pixmap); 119 pixmaps->append(pixmap);
120 } 120 }
121 121
122 return pixmaps; 122 return pixmaps;
123} 123}
124 124
125QList<QPixmap> *Painter::textPixmap(QString str, QList<QPixmap> *pixmaps, 125QList<QPixmap> *Painter::textPixmap(QString str, QList<QPixmap> *pixmaps,
126 QColor fg, QColor bg) 126 QColor fg, QColor bg)
127{ 127{
128 if (pixmaps == NULL) { 128 if (pixmaps == NULL) {
129 pixmaps = new QList<QPixmap>; 129 pixmaps = new QList<QPixmap>;
130 pixmaps->setAutoDelete(TRUE); 130 pixmaps->setAutoDelete(TRUE);
131 } 131 }
132 132
133 if (!pixmaps->isEmpty()) 133 if (!pixmaps->isEmpty())
134 pixmaps->clear(); 134 pixmaps->clear();
135 135
136 QPixmap *pixmap = new QPixmap(bitfont->text(str, fg, bg)); 136 QPixmap *pixmap = new QPixmap(bitfont->text(str, fg, bg));
137 pixmaps->append(pixmap); 137 pixmaps->append(pixmap);
138 138
139 return pixmaps; 139 return pixmaps;
140} 140}
141 141
142/* Return the point of the upperleft pixel of the block representing that position 142/* Return the point of the upperleft pixel of the block representing that position
143 * on the board. 143 * on the board.
144 */ 144 */
145QPoint Painter::point(int pos) 145QPoint Painter::point(int pos)
146{ 146{
147 return QPoint((board->x(pos)-1)*BlockWidth, (board->y(pos)-1)*BlockHeight); 147 return QPoint((board->x(pos)-1)*BlockWidth, (board->y(pos)-1)*BlockHeight);
148} 148}
149 149
150 150
151QRect Painter::rect(int pos, PixMap pix, uint i) 151QRect Painter::rect(int pos, PixMap pix, uint i)
152{ 152{
153 if (pos == OUT) 153 if (pos == OUT)
154 return QRect(); 154 return QRect();
155 155
156 QPixmap *PIXMAP = NULL; 156 QPixmap *PIXMAP = NULL;
157 switch (pix) { 157 switch (pix) {
158 case PacmanPix : PIXMAP = pacmanPix-> 158 case PacmanPix : PIXMAP = pacmanPix->
159 at(checkRange(i, pacmanPix->count()-1)); 159 at(checkRange(i, pacmanPix->count()-1));
160 break; 160 break;
161 case DyingPix : PIXMAP = dyingPix-> 161 case DyingPix : PIXMAP = dyingPix->
162 at(checkRange(i, dyingPix->count()-1)); 162 at(checkRange(i, dyingPix->count()-1));
163 break; 163 break;
164 case MonsterPix : PIXMAP = monsterPix-> 164 case MonsterPix : PIXMAP = monsterPix->
165 at(checkRange(i, monsterPix->count()-1)); 165 at(checkRange(i, monsterPix->count()-1));
166 break; 166 break;
167 case EyesPix : PIXMAP = eyesPix-> 167 case EyesPix : PIXMAP = eyesPix->
168 at(checkRange(i, eyesPix->count()-1)); 168 at(checkRange(i, eyesPix->count()-1));
169 break; 169 break;
170 case FruitPix : PIXMAP = fruitPix-> 170 case FruitPix : PIXMAP = fruitPix->
171 at(checkRange(i, fruitPix->count()-1)); 171 at(checkRange(i, fruitPix->count()-1));
172 break; 172 break;
173 case PointPix : PIXMAP = pointPix-> 173 case PointPix : PIXMAP = pointPix->
174 at(checkRange(i, pointPix->count()-1)); 174 at(checkRange(i, pointPix->count()-1));
175 break; 175 break;
176 case EnergizerPix : PIXMAP = energizerPix-> 176 case EnergizerPix : PIXMAP = energizerPix->
177 at(checkRange(i, energizerPix->count()-1)); 177 at(checkRange(i, energizerPix->count()-1));
178 break; 178 break;
179 case FruitScorePix : PIXMAP = fruitScorePix-> 179 case FruitScorePix : PIXMAP = fruitScorePix->
180 at(checkRange(i, fruitScorePix->count()-1)); 180 at(checkRange(i, fruitScorePix->count()-1));
181 break; 181 break;
182 case MonsterScorePix : PIXMAP = monsterScorePix-> 182 case MonsterScorePix : PIXMAP = monsterScorePix->
183 at(checkRange(i,monsterScorePix->count()-1)); 183 at(checkRange(i,monsterScorePix->count()-1));
184 break; 184 break;
185 default : PIXMAP = wallPix-> 185 default : PIXMAP = wallPix->
186 at(checkRange(i, wallPix->count()-1)); 186 at(checkRange(i, wallPix->count()-1));
187 } 187 }
188 if (PIXMAP == NULL) 188 if (PIXMAP == NULL)
189 return QRect(); 189 return QRect();
190 190
191 QRect rect = PIXMAP->rect(); 191 QRect rect = PIXMAP->rect();
192 QPoint point = this->point(pos); 192 QPoint point = this->point(pos);
193 rect.moveCenter(QPoint(point.x()-1, point.y()-1)); 193 rect.moveCenter(QPoint(point.x()-1, point.y()-1));
194 194
195 return rect; 195 return rect;
196} 196}
197 197
198QRect Painter::rect(int pos, QString str, int align) 198QRect Painter::rect(int pos, QString str, int align)
199{ 199{
200 if (pos == OUT) // return an empty rect if the position 200 if (pos == OUT) // return an empty rect if the position
201 return QRect(); // is invalid 201 return QRect(); // is invalid
202 QPoint point = this->point(pos); 202 QPoint point = this->point(pos);
203 QRect rect = bitfont->rect(str); 203 QRect rect = bitfont->rect(str);
204 204
205 rect.moveCenter(QPoint(point.x()-1, point.y()-1)); 205 rect.moveCenter(QPoint(point.x()-1, point.y()-1));
206 206
207 int dx = 0; 207 int dx = 0;
208 int dy = 0; 208 int dy = 0;
209 209
210 if (align & QLabel::AlignLeft || align & QLabel::AlignRight) { 210 if (align & QLabel::AlignLeft || align & QLabel::AlignRight) {
211 dx = (str.length()-1) * (bitfont->width()/2); 211 dx = (str.length()-1) * (bitfont->width()/2);
212 if (align & QLabel::AlignRight) 212 if (align & QLabel::AlignRight)
213 dx *= -1; 213 dx *= -1;
214 } 214 }
215 215
216 if (align & QLabel::AlignTop || align & QLabel::AlignBottom) { 216 if (align & QLabel::AlignTop || align & QLabel::AlignBottom) {
217 dy = bitfont->height()/2; 217 dy = bitfont->height()/2;
218 if (align & QLabel::AlignBottom) 218 if (align & QLabel::AlignBottom)
219 dy *= -1; 219 dy *= -1;
220 } 220 }
221 221
222 if (dx != 0 || dy != 0) 222 if (dx != 0 || dy != 0)
223 rect.moveBy(dx, dy); 223 rect.moveBy(dx, dy);
224 224
225 return rect; 225 return rect;
226} 226}
227 227
228QRect Painter::rect(QRect r1, QRect r2) 228QRect Painter::rect(QRect r1, QRect r2)
229{ 229{
230 QRect rect; 230 QRect rect;
231 rect.setLeft(r1.left() < r2.left() ? r1.left() : r2.left()); 231 rect.setLeft(r1.left() < r2.left() ? r1.left() : r2.left());
232 rect.setTop(r1.top() < r2.top() ? r1.top() : r2.top()); 232 rect.setTop(r1.top() < r2.top() ? r1.top() : r2.top());
233 rect.setRight(r1.right() > r2.right() ? r1.right() : r2.right()); 233 rect.setRight(r1.right() > r2.right() ? r1.right() : r2.right());
234 rect.setBottom(r1.bottom() > r2.bottom() ? r1.bottom() : r2.bottom()); 234 rect.setBottom(r1.bottom() > r2.bottom() ? r1.bottom() : r2.bottom());
235 235
236 return rect; 236 return rect;
237} 237}
238 238
239void Painter::erase(int pos, PixMap pix, uint i) 239void Painter::erase(int pos, PixMap pix, uint i)
240{ 240{
241 if (pos == OUT) 241 if (pos == OUT)
242 return; 242 return;
243 QRect rect = this->rect(pos, pix, i); 243 QRect rect = this->rect(pos, pix, i);
244 bitBlt(&roomPix, rect.x(), rect.y(), &backPix, 244 bitBlt(&roomPix, rect.x(), rect.y(), &backPix,
245 rect.x(), rect.y(), rect.width(), rect.height()); 245 rect.x(), rect.y(), rect.width(), rect.height());
246} 246}
247 247
248int Painter::maxPixmaps(PixMap pix) 248int Painter::maxPixmaps(PixMap pix)
249{ 249{
250 switch (pix) { 250 switch (pix) {
251 case WallPix : return (int) wallPix->count(); 251 case WallPix : return (int) wallPix->count();
252 case PrisonPix : return (int) prisonPix->count(); 252 case PrisonPix : return (int) prisonPix->count();
253 case PointPix : return (int) pointPix->count(); 253 case PointPix : return (int) pointPix->count();
254 case EnergizerPix : return (int) energizerPix->count(); 254 case EnergizerPix : return (int) energizerPix->count();
255 case FruitPix : return (int) fruitPix->count(); 255 case FruitPix : return (int) fruitPix->count();
256 case PacmanPix : return (int) pacmanPix->count(); 256 case PacmanPix : return (int) pacmanPix->count();
257 case DyingPix : return (int) dyingPix->count(); 257 case DyingPix : return (int) dyingPix->count();
258 case EyesPix : return (int) eyesPix->count(); 258 case EyesPix : return (int) eyesPix->count();
259 case MonsterPix : return (int) monsterPix->count(); 259 case MonsterPix : return (int) monsterPix->count();
260 case FruitScorePix : return (int) fruitScorePix->count(); 260 case FruitScorePix : return (int) fruitScorePix->count();
261 case MonsterScorePix : return (int) monsterScorePix->count(); 261 case MonsterScorePix : return (int) monsterScorePix->count();
262 default : return 0; 262 default : return 0;
263 } 263 }
264} 264}
265 265
266void Painter::draw(QPoint point, DrawWidget where, QPixmap pix) 266void Painter::draw(QPoint point, DrawWidget where, QPixmap pix)
267{ 267{
268 switch (where) { 268 switch (where) {
269 case Widget : bitBlt(w, point.x(), point.y(), &pix); 269 case Widget : bitBlt(w, point.x(), point.y(), &pix);
270 break; 270 break;
271 case RoomPix : bitBlt(&roomPix, point.x(), point.y(), &pix); 271 case RoomPix : bitBlt(&roomPix, point.x(), point.y(), &pix);
272 break; 272 break;
273 case BackPix : bitBlt(&backPix, point.x(), point.y(), &pix); 273 case BackPix : bitBlt(&backPix, point.x(), point.y(), &pix);
274 break; 274 break;
275 } 275 }
276} 276}
277 277
278void Painter::draw(QRect rect, DrawWidget where, QPixmap pix) 278void Painter::draw(QRect rect, DrawWidget where, QPixmap pix)
279{ 279{
280 draw(QPoint(rect.x(), rect.y()), where, pix); 280 draw(QPoint(rect.x(), rect.y()), where, pix);
281} 281}
282 282
283void Painter::draw(int pos, DrawWidget where, PixMap pix, uint i) 283void Painter::draw(int pos, DrawWidget where, PixMap pix, uint i)
284{ 284{
285 QPixmap *PIXMAP = NULL; 285 QPixmap *PIXMAP = NULL;
286 switch (pix) { 286 switch (pix) {
287 case PacmanPix : PIXMAP = pacmanPix-> 287 case PacmanPix : PIXMAP = pacmanPix->
288 at(checkRange(i, pacmanPix->count()-1)); 288 at(checkRange(i, pacmanPix->count()-1));
289 break; 289 break;
290 case DyingPix : PIXMAP = dyingPix-> 290 case DyingPix : PIXMAP = dyingPix->
291 at(checkRange(i, dyingPix->count()-1)); 291 at(checkRange(i, dyingPix->count()-1));
292 break; 292 break;
293 case MonsterPix : PIXMAP = monsterPix-> 293 case MonsterPix : PIXMAP = monsterPix->
294 at(checkRange(i, monsterPix->count()-1)); 294 at(checkRange(i, monsterPix->count()-1));
295 break; 295 break;
296 case EyesPix : PIXMAP = eyesPix-> 296 case EyesPix : PIXMAP = eyesPix->
297 at(checkRange(i, eyesPix->count()-1)); 297 at(checkRange(i, eyesPix->count()-1));
298 break; 298 break;
299 case FruitPix : PIXMAP = fruitPix-> 299 case FruitPix : PIXMAP = fruitPix->
300 at(checkRange(i, fruitPix->count()-1)); 300 at(checkRange(i, fruitPix->count()-1));
301 break; 301 break;
302 case EnergizerPix : PIXMAP = energizerPix-> 302 case EnergizerPix : PIXMAP = energizerPix->
303 at(checkRange(i, energizerPix->count()-1)); 303 at(checkRange(i, energizerPix->count()-1));
304 break; 304 break;
305 case FruitScorePix : PIXMAP = fruitScorePix-> 305 case FruitScorePix : PIXMAP = fruitScorePix->
306 at(checkRange(i, fruitScorePix->count()-1)); 306 at(checkRange(i, fruitScorePix->count()-1));
307 break; 307 break;
308 case MonsterScorePix : PIXMAP = monsterScorePix-> 308 case MonsterScorePix : PIXMAP = monsterScorePix->
309 at(checkRange(i,monsterScorePix->count()-1)); 309 at(checkRange(i,monsterScorePix->count()-1));
310 break; 310 break;
311 default : ; 311 default : ;
312 } 312 }
313 313
314 if (PIXMAP == NULL) 314 if (PIXMAP == NULL)
315 return; 315 return;
316 316
317 QRect rect = PIXMAP->rect(); 317 QRect rect = PIXMAP->rect();
318 QPoint point = this->point(pos); 318 QPoint point = this->point(pos);
319 rect.moveCenter(QPoint(point.x()-1, point.y()-1)); 319 rect.moveCenter(QPoint(point.x()-1, point.y()-1));
320 320
321 switch (where) { 321 switch (where) {
322 case Widget : bitBlt(w, rect.x(), rect.y(), PIXMAP); 322 case Widget : bitBlt(w, rect.x(), rect.y(), PIXMAP);
323 break; 323 break;
324 case RoomPix : bitBlt(&roomPix, rect.x(), rect.y(), PIXMAP); 324 case RoomPix : bitBlt(&roomPix, rect.x(), rect.y(), PIXMAP);
325 break; 325 break;
326 case BackPix : bitBlt(&backPix, rect.x(), rect.y(), PIXMAP); 326 case BackPix : bitBlt(&backPix, rect.x(), rect.y(), PIXMAP);
327 break; 327 break;
328 } 328 }
329} 329}
330 330
331QPixmap Painter::draw(int pos, DrawWidget where, 331QPixmap Painter::draw(int pos, DrawWidget where,
332 QString str, QColor fg, QColor bg, int align) 332 QString str, QColor fg, QColor bg, int align)
333{ 333{
334 QPixmap TEXT = bitfont->text(str, fg, bg); 334 QPixmap TEXT = bitfont->text(str, fg, bg);
335 335
336 QRect rect = this->rect(pos, str, align); 336 QRect rect = this->rect(pos, str, align);
337 QPixmap SAVE = QPixmap(rect.width(), rect.height()); 337 QPixmap SAVE = QPixmap(rect.width(), rect.height());
338 338
339 switch (where) { 339 switch (where) {
340 case Widget : bitBlt(&SAVE, 0, 0, w, rect.x(), rect.y()); 340 case Widget : bitBlt(&SAVE, 0, 0, w, rect.x(), rect.y());
341 bitBlt(w, rect.x(), rect.y(), &TEXT); 341 bitBlt(w, rect.x(), rect.y(), &TEXT);
342 break; 342 break;
343 case RoomPix : bitBlt(&SAVE, 0, 0, &roomPix, rect.x(), rect.y()); 343 case RoomPix : bitBlt(&SAVE, 0, 0, &roomPix, rect.x(), rect.y());
344 bitBlt(&roomPix, rect.x(), rect.y(), &TEXT); 344 bitBlt(&roomPix, rect.x(), rect.y(), &TEXT);
345 break; 345 break;
346 case BackPix : bitBlt(&SAVE, 0, 0, &backPix, rect.x(), rect.y()); 346 case BackPix : bitBlt(&SAVE, 0, 0, &backPix, rect.x(), rect.y());
347 bitBlt(&backPix, rect.x(), rect.y(), &TEXT); 347 bitBlt(&backPix, rect.x(), rect.y(), &TEXT);
348 break; 348 break;
349 } 349 }
350 350
351 return SAVE; 351 return SAVE;
352} 352}
353 353
354QRect Painter::draw(int col, int row, DrawWidget where, 354QRect Painter::draw(int col, int row, DrawWidget where,
355 QString str, QColor fg, QColor bg, int align) 355 QString str, QColor fg, QColor bg, int align)
356{ 356{
357 QPixmap TEXT = bitfont->text(str, fg, bg); 357 QPixmap TEXT = bitfont->text(str, fg, bg);
358 358
359 QRect rect = this->rect(row*BoardWidth+col, str, align); 359 QRect rect = this->rect(row*BoardWidth+col, str, align);
360 draw(rect, where, TEXT); 360 draw(rect, where, TEXT);
361 361
362 return rect; 362 return rect;
363} 363}
364 364
365void Painter::initPixmaps() 365void Painter::initPixmaps()
366{ 366{
367 if (lastPointPixmapName != pointPixmapName.at(level)) { 367 if (lastPointPixmapName != pointPixmapName.at(level)) {
368 pointPix = loadPixmap(w, pointPixmapName.at(level), pointPix); 368 pointPix = loadPixmap(w, pointPixmapName.at(level), pointPix);
369 lastPointPixmapName = pointPixmapName.at(level); 369 lastPointPixmapName = pointPixmapName.at(level);
370 } 370 }
371 if (lastPrisonPixmapName != prisonPixmapName.at(level)) { 371 if (lastPrisonPixmapName != prisonPixmapName.at(level)) {
372 prisonPix = loadPixmap(w, prisonPixmapName.at(level), prisonPix); 372 prisonPix = loadPixmap(w, prisonPixmapName.at(level), prisonPix);
373 lastPrisonPixmapName = prisonPixmapName.at(level); 373 lastPrisonPixmapName = prisonPixmapName.at(level);
374 } 374 }
375 if (lastEnergizerPixmapName != energizerPixmapName.at(level)) { 375 if (lastEnergizerPixmapName != energizerPixmapName.at(level)) {
376 energizerPix = loadPixmap(w, energizerPixmapName.at(level), energizerPix); 376 energizerPix = loadPixmap(w, energizerPixmapName.at(level), energizerPix);
377 lastEnergizerPixmapName = energizerPixmapName.at(level); 377 lastEnergizerPixmapName = energizerPixmapName.at(level);
378 } 378 }
379 if (lastFruitPixmapName != fruitPixmapName.at(level)) { 379 if (lastFruitPixmapName != fruitPixmapName.at(level)) {
380 fruitPix = loadPixmap(w, fruitPixmapName.at(level), fruitPix); 380 fruitPix = loadPixmap(w, fruitPixmapName.at(level), fruitPix);
381 lastFruitPixmapName = fruitPixmapName.at(level); 381 lastFruitPixmapName = fruitPixmapName.at(level);
382 } 382 }
383 if (lastPacmanPixmapName != pacmanPixmapName.at(level)) { 383 if (lastPacmanPixmapName != pacmanPixmapName.at(level)) {
384 pacmanPix = loadPixmap(w, pacmanPixmapName.at(level), pacmanPix); 384 pacmanPix = loadPixmap(w, pacmanPixmapName.at(level), pacmanPix);
385 lastPacmanPixmapName = pacmanPixmapName.at(level); 385 lastPacmanPixmapName = pacmanPixmapName.at(level);
386 } 386 }
387 if (lastDyingPixmapName != dyingPixmapName.at(level)) { 387 if (lastDyingPixmapName != dyingPixmapName.at(level)) {
388 dyingPix = loadPixmap(w, dyingPixmapName.at(level), dyingPix); 388 dyingPix = loadPixmap(w, dyingPixmapName.at(level), dyingPix);
389 lastDyingPixmapName = dyingPixmapName.at(level); 389 lastDyingPixmapName = dyingPixmapName.at(level);
390 } 390 }
391 if (lastEyesPixmapName != eyesPixmapName.at(level)) { 391 if (lastEyesPixmapName != eyesPixmapName.at(level)) {
392 eyesPix = loadPixmap(w, eyesPixmapName.at(level), eyesPix); 392 eyesPix = loadPixmap(w, eyesPixmapName.at(level), eyesPix);
393 lastEyesPixmapName = eyesPixmapName.at(level); 393 lastEyesPixmapName = eyesPixmapName.at(level);
394 } 394 }
395 if (lastMonsterPixmapName != monsterPixmapName.at(level)) { 395 if (lastMonsterPixmapName != monsterPixmapName.at(level)) {
396 monsterPix = loadPixmap(w, monsterPixmapName.at(level), monsterPix); 396 monsterPix = loadPixmap(w, monsterPixmapName.at(level), monsterPix);
397 lastMonsterPixmapName = monsterPixmapName.at(level); 397 lastMonsterPixmapName = monsterPixmapName.at(level);
398 } 398 }
399 399
400 if (lastFruitScorePixmapName != fruitScorePixmapName.at(level) || 400 if (lastFruitScorePixmapName != fruitScorePixmapName.at(level) ||
401 (const char *) *fruitScorePixmapName.at(level) == '\0') { 401 (const char *) *fruitScorePixmapName.at(level) == '\0') {
402 if ((const char *) *fruitScorePixmapName.at(level) == '\0') { 402 if ((const char *) *fruitScorePixmapName.at(level) == '\0') {
403 fruitScorePix = textPixmap(fruitScoreString, fruitScorePix, PINK); 403 fruitScorePix = textPixmap(fruitScoreString, fruitScorePix, PINK);
404 } else { 404 } else {
405 fruitScorePix = loadPixmap(w, fruitScorePixmapName.at(level), 405 fruitScorePix = loadPixmap(w, fruitScorePixmapName.at(level),
406 fruitScorePix); 406 fruitScorePix);
407 lastFruitScorePixmapName = fruitScorePixmapName.at(level); 407 lastFruitScorePixmapName = fruitScorePixmapName.at(level);
408 } 408 }
409 } 409 }
410 410
411 if (lastMonsterScorePixmapName != monsterScorePixmapName.at(level) || 411 if (lastMonsterScorePixmapName != monsterScorePixmapName.at(level) ||
412 (const char *) *monsterScorePixmapName.at(level) == '\0') { 412 (const char *) *monsterScorePixmapName.at(level) == '\0') {
413 if ((const char *) *monsterScorePixmapName.at(level) == '\0') { 413 if ((const char *) *monsterScorePixmapName.at(level) == '\0') {
414 monsterScorePix = textPixmap(monsterScoreString, monsterScorePix, CYAN); 414 monsterScorePix = textPixmap(monsterScoreString, monsterScorePix, CYAN);
415 } else { 415 } else {
416 monsterScorePix = loadPixmap(w, monsterScorePixmapName.at(level), 416 monsterScorePix = loadPixmap(w, monsterScorePixmapName.at(level),
417 monsterScorePix); 417 monsterScorePix);
418 lastMonsterScorePixmapName = monsterScorePixmapName.at(level); 418 lastMonsterScorePixmapName = monsterScorePixmapName.at(level);
419 } 419 }
420 } 420 }
421 421
422 if (lastWallPixmapName != wallPixmapName.at(level)) { 422 if (lastWallPixmapName != wallPixmapName.at(level)) {
423 wallPix = loadPixmap(w, wallPixmapName.at(level), wallPix); 423 wallPix = loadPixmap(w, wallPixmapName.at(level), wallPix);
424 if (wallPix->isEmpty()) { 424 if (wallPix->isEmpty()) {
425 BlockWidth = 0; 425 BlockWidth = 0;
426 BlockHeight = 0; 426 BlockHeight = 0;
427 } else { 427 } else {
428 BlockWidth = wallPix->at(0)->width(); 428 BlockWidth = wallPix->at(0)->width();
429 BlockHeight = wallPix->at(0)->height(); 429 BlockHeight = wallPix->at(0)->height();
430 } 430 }
431 lastWallPixmapName = wallPixmapName.at(level); 431 lastWallPixmapName = wallPixmapName.at(level);
432 } 432 }
433} 433}
434 434
435void Painter::initbackPixmaps() 435void Painter::initbackPixmaps()
436{ 436{
437 backgroundColor = BLACK; 437 backgroundColor = BLACK;
438 438
439 backPix.resize((BoardWidth-3)*BlockWidth, (BoardHeight-3)*BlockHeight ); 439 backPix.resize((BoardWidth-3)*BlockWidth, (BoardHeight-3)*BlockHeight );
440 backPix.fill(backgroundColor); 440 backPix.fill(backgroundColor);
441} 441}
442 442
443void Painter::initRoomPixmap() 443void Painter::initRoomPixmap()
444{ 444{
445 roomPix.resize((BoardWidth-3)*BlockWidth, (BoardHeight-3)*BlockHeight ); 445 roomPix.resize((BoardWidth-3)*BlockWidth, (BoardHeight-3)*BlockHeight );
446 bitBlt(&roomPix,0,0, &backPix); 446 bitBlt(&roomPix,0,0, &backPix);
447 447
448 for (unsigned int x = 0; x < board->size(); x++) { 448 for (unsigned int x = 0; x < board->size(); x++) {
449 if (board->isBrick(x)) 449 if (board->isBrick(x))
450 drawBrick(x); 450 drawBrick(x);
451 if (board->isPrison(x) || board->isGate(x)) 451 if (board->isPrison(x) || board->isGate(x))
452 drawPrison(x); 452 drawPrison(x);
453 if (board->isPoint(x)) 453 if (board->isPoint(x))
454 drawPoint(x); 454 drawPoint(x);
455 } 455 }
456} 456}
457 457
458void Painter::drawBrick(int pos) 458void Painter::drawBrick(int pos)
459{ 459{
460 int border = 0; 460 int border = 0;
461 if (board->isBrick(board->move(pos, N ))) border |= (1 << 0); 461 if (board->isBrick(board->move(pos, N ))) border |= (1 << 0);
462 if (board->isBrick(board->move(pos, NE))) border |= (1 << 1); 462 if (board->isBrick(board->move(pos, NE))) border |= (1 << 1);
463 if (board->isBrick(board->move(pos, E ))) border |= (1 << 2); 463 if (board->isBrick(board->move(pos, E ))) border |= (1 << 2);
464 if (board->isBrick(board->move(pos, SE))) border |= (1 << 3); 464 if (board->isBrick(board->move(pos, SE))) border |= (1 << 3);
465 if (board->isBrick(board->move(pos, S ))) border |= (1 << 4); 465 if (board->isBrick(board->move(pos, S ))) border |= (1 << 4);
466 if (board->isBrick(board->move(pos, SW))) border |= (1 << 5); 466 if (board->isBrick(board->move(pos, SW))) border |= (1 << 5);
467 if (board->isBrick(board->move(pos, W ))) border |= (1 << 6); 467 if (board->isBrick(board->move(pos, W ))) border |= (1 << 6);
468 if (board->isBrick(board->move(pos, NW))) border |= (1 << 7); 468 if (board->isBrick(board->move(pos, NW))) border |= (1 << 7);
469 469
470 if (board->isOut(board->move(pos, N ))) border |= (1 << 8); 470 if (board->isOut(board->move(pos, N ))) border |= (1 << 8);
471 if (board->isOut(board->move(pos, NE))) border |= (1 << 9); 471 if (board->isOut(board->move(pos, NE))) border |= (1 << 9);
472 if (board->isOut(board->move(pos, E ))) border |= (1 << 10); 472 if (board->isOut(board->move(pos, E ))) border |= (1 << 10);
473 if (board->isOut(board->move(pos, SE))) border |= (1 << 11); 473 if (board->isOut(board->move(pos, SE))) border |= (1 << 11);
474 if (board->isOut(board->move(pos, S ))) border |= (1 << 12); 474 if (board->isOut(board->move(pos, S ))) border |= (1 << 12);
475 if (board->isOut(board->move(pos, SW))) border |= (1 << 13); 475 if (board->isOut(board->move(pos, SW))) border |= (1 << 13);
476 if (board->isOut(board->move(pos, W ))) border |= (1 << 14); 476 if (board->isOut(board->move(pos, W ))) border |= (1 << 14);
477 if (board->isOut(board->move(pos, NW))) border |= (1 << 15); 477 if (board->isOut(board->move(pos, NW))) border |= (1 << 15);
478 478
479 switch (border & 0xFF) { 479 switch (border & 0xFF) {
480 case 31 : border = 0; break; 480 case 31 : border = 0; break;
481 case 159 : border = 0; break; 481 case 159 : border = 0; break;
482 case 63 : border = 0; break; 482 case 63 : border = 0; break;
483 case 191 : border = 0; break; 483 case 191 : border = 0; break;
484 case 241 : border = 1; break; 484 case 241 : border = 1; break;
485 case 249 : border = 1; break; 485 case 249 : border = 1; break;
486 case 243 : border = 1; break; 486 case 243 : border = 1; break;
487 case 251 : border = 1; break; 487 case 251 : border = 1; break;
488 case 124 : border = 2; break; 488 case 124 : border = 2; break;
489 case 252 : border = 2; break; 489 case 252 : border = 2; break;
490 case 126 : border = 2; break; 490 case 126 : border = 2; break;
491 case 199 : border = 3; break; 491 case 199 : border = 3; break;
492 case 231 : border = 3; break; 492 case 231 : border = 3; break;
493 case 207 : border = 3; break; 493 case 207 : border = 3; break;
494 case 28 : if ((border >> 8) > 0) 494 case 28 : if ((border >> 8) > 0)
495 border = 24; 495 border = 24;
496 else 496 else
497 border = 4; 497 border = 4;
498 break; 498 break;
499 case 112 : if ((border >> 8) > 0) 499 case 112 : if ((border >> 8) > 0)
500 border = 27; 500 border = 27;
501 else 501 else
502 border = 5; 502 border = 5;
503 break; 503 break;
504 case 7 : if ((border >> 8) > 0) 504 case 7 : if ((border >> 8) > 0)
505 border = 25; 505 border = 25;
506 else 506 else
507 border = 6; 507 border = 6;
508 break; 508 break;
509 case 193 : if ((border >> 8) > 0) 509 case 193 : if ((border >> 8) > 0)
510 border = 26; 510 border = 26;
511 else 511 else
512 border = 7; 512 border = 7;
513 break; 513 break;
514 case 247 : if ((border & (1 << 11)) > 0) 514 case 247 : if ((border & (1 << 11)) > 0)
515 border = 23; 515 border = 23;
516 else 516 else
517 border = 8; 517 border = 8;
518 break; 518 break;
519 case 119 : if ((border & (1 << 15)) > 0) 519 case 119 : if ((border & (1 << 15)) > 0)
520 border = 8; 520 border = 8;
521 if ((border & (1 << 11)) > 0) 521 if ((border & (1 << 11)) > 0)
522 border = 11; 522 border = 11;
523 break; 523 break;
524 case 223 : if ((border & (1 << 13)) > 0) 524 case 223 : if ((border & (1 << 13)) > 0)
525 border = 20; 525 border = 20;
526 else 526 else
527 border = 9; 527 border = 9;
528 break; 528 break;
529 case 221 : if ((border & (1 << 13)) > 0) 529 case 221 : if ((border & (1 << 13)) > 0)
530 border = 10; 530 border = 10;
531 if ((border & (1 << 9)) > 0) 531 if ((border & (1 << 9)) > 0)
532 border = 9; 532 border = 9;
533 break; 533 break;
534 case 253 : if ((border & (1 << 9)) > 0) 534 case 253 : if ((border & (1 << 9)) > 0)
535 border = 21; 535 border = 21;
536 else 536 else
537 border = 10; 537 border = 10;
538 break; 538 break;
539 case 127 : if ((border & (1 << 15)) > 0) 539 case 127 : if ((border & (1 << 15)) > 0)
540 border = 22; 540 border = 22;
541 else 541 else
542 border = 11; 542 border = 11;
543 break; 543 break;
544 case 30 : border = 12; break; 544 case 30 : border = 12; break;
545 case 240 : border = 13; break; 545 case 240 : border = 13; break;
546 case 15 : border = 14; break; 546 case 15 : border = 14; break;
547 case 225 : border = 15; break; 547 case 225 : border = 15; break;
548 case 135 : border = 16; break; 548 case 135 : border = 16; break;
549 case 195 : border = 17; break; 549 case 195 : border = 17; break;
550 case 60 : border = 18; break; 550 case 60 : border = 18; break;
551 case 120 : border = 19; break; 551 case 120 : border = 19; break;
552 case 255 : border = 28; break; 552 case 255 : border = 28; break;
553 default : border = -1; 553 default : border = -1;
554 } 554 }
555 if (border != -1 && border < (int) wallPix->count()) { 555 if (border != -1 && border < (int) wallPix->count()) {
556 QRect rect = this->rect(pos, WallPix); 556 QRect rect = this->rect(pos, WallPix);
557 bitBlt(&roomPix, rect.x(), rect.y(), wallPix->at((uint) border)); 557 bitBlt(&roomPix, rect.x(), rect.y(), wallPix->at((uint) border));
558 } 558 }
559} 559}
560 560
561void Painter::drawPrison(int pos) 561void Painter::drawPrison(int pos)
562{ 562{
563 int border = 0; 563 int border = 0;
564 if (board->isPrison(board->move(pos, N ))) border |= (1 << 0); 564 if (board->isPrison(board->move(pos, N ))) border |= (1 << 0);
565 if (board->isPrison(board->move(pos, NE))) border |= (1 << 1); 565 if (board->isPrison(board->move(pos, NE))) border |= (1 << 1);
566 if (board->isPrison(board->move(pos, E ))) border |= (1 << 2); 566 if (board->isPrison(board->move(pos, E ))) border |= (1 << 2);
567 if (board->isPrison(board->move(pos, SE))) border |= (1 << 3); 567 if (board->isPrison(board->move(pos, SE))) border |= (1 << 3);
568 if (board->isPrison(board->move(pos, S ))) border |= (1 << 4); 568 if (board->isPrison(board->move(pos, S ))) border |= (1 << 4);
569 if (board->isPrison(board->move(pos, SW))) border |= (1 << 5); 569 if (board->isPrison(board->move(pos, SW))) border |= (1 << 5);
570 if (board->isPrison(board->move(pos, W ))) border |= (1 << 6); 570 if (board->isPrison(board->move(pos, W ))) border |= (1 << 6);
571 if (board->isPrison(board->move(pos, NW))) border |= (1 << 7); 571 if (board->isPrison(board->move(pos, NW))) border |= (1 << 7);
572 572
573 if (board->isGate(board->move(pos, N ))) border |= (1 << 8); 573 if (board->isGate(board->move(pos, N ))) border |= (1 << 8);
574 if (board->isGate(board->move(pos, NE))) border |= (1 << 9); 574 if (board->isGate(board->move(pos, NE))) border |= (1 << 9);
575 if (board->isGate(board->move(pos, E ))) border |= (1 << 10); 575 if (board->isGate(board->move(pos, E ))) border |= (1 << 10);
576 if (board->isGate(board->move(pos, SE))) border |= (1 << 11); 576 if (board->isGate(board->move(pos, SE))) border |= (1 << 11);
577 if (board->isGate(board->move(pos, S ))) border |= (1 << 12); 577 if (board->isGate(board->move(pos, S ))) border |= (1 << 12);
578 if (board->isGate(board->move(pos, SW))) border |= (1 << 13); 578 if (board->isGate(board->move(pos, SW))) border |= (1 << 13);
579 if (board->isGate(board->move(pos, W ))) border |= (1 << 14); 579 if (board->isGate(board->move(pos, W ))) border |= (1 << 14);
580 if (board->isGate(board->move(pos, NW))) border |= (1 << 15); 580 if (board->isGate(board->move(pos, NW))) border |= (1 << 15);
581 581
582 switch (border & 0xFF) { 582 switch (border & 0xFF) {
583 case 31 : border = 0; break; 583 case 31 : border = 0; break;
584 case 159 : border = 0; break; 584 case 159 : border = 0; break;
585 case 63 : border = 0; break; 585 case 63 : border = 0; break;
586 case 241 : border = 1; break; 586 case 241 : border = 1; break;
587 case 249 : border = 1; break; 587 case 249 : border = 1; break;
588 case 243 : border = 1; break; 588 case 243 : border = 1; break;
589 case 124 : border = 2; break; 589 case 124 : border = 2; break;
590 case 252 : border = 2; break; 590 case 252 : border = 2; break;
591 case 126 : border = 2; break; 591 case 126 : border = 2; break;
592 case 199 : border = 3; break; 592 case 199 : border = 3; break;
593 case 231 : border = 3; break; 593 case 231 : border = 3; break;
594 case 207 : border = 3; break; 594 case 207 : border = 3; break;
595 case 28 : if ((border >> 8) != 0) 595 case 28 : if ((border >> 8) != 0)
596 border = 12; 596 border = 12;
597 else 597 else
598 border = 4; 598 border = 4;
599 break; 599 break;
600 case 112 : if ((border >> 8) != 0) 600 case 112 : if ((border >> 8) != 0)
601 border = 13; 601 border = 13;
602 else 602 else
603 border = 5; 603 border = 5;
604 break; 604 break;
605 case 7 : if ((border >> 8) != 0) 605 case 7 : if ((border >> 8) != 0)
606 border = 14; 606 border = 14;
607 else 607 else
608 border = 6; 608 border = 6;
609 break; 609 break;
610 case 193 : if ((border >> 8) != 0) 610 case 193 : if ((border >> 8) != 0)
611 border = 15; 611 border = 15;
612 else 612 else
613 border = 7; 613 border = 7;
614 break; 614 break;
615 case 247 : border = 8; break; 615 case 247 : border = 8; break;
616 case 223 : border = 9; break; 616 case 223 : border = 9; break;
617 case 253 : border = 10; break; 617 case 253 : border = 10; break;
618 case 127 : border = 11; break; 618 case 127 : border = 11; break;
619 default : border = -1; 619 default : border = -1;
620 } 620 }
621 if (board->isGate(pos)) { 621 if (board->isGate(pos)) {
622 if (board->isGate(board->move(pos, N))) 622 if (board->isGate(board->move(pos, N)))
623 border = 17; 623 border = 17;
624 else 624 else
625 border = 16; 625 border = 16;
626 } 626 }
627 627
628 if (border != -1 && border < (int) prisonPix->count()) { 628 if (border != -1 && border < (int) prisonPix->count()) {
629 QRect rect = this->rect(pos, PrisonPix); 629 QRect rect = this->rect(pos, PrisonPix);
630 bitBlt(&roomPix, rect.x(), rect.y(), prisonPix->at((uint) border)); 630 bitBlt(&roomPix, rect.x(), rect.y(), prisonPix->at((uint) border));
631 } 631 }
632} 632}
633 633
634void Painter::drawPoint(int pos) 634void Painter::drawPoint(int pos)
635{ 635{
636 if (!pointPix->isEmpty()) { 636 if (!pointPix->isEmpty()) {
637 QRect rect = this->rect(pos, PointPix); 637 QRect rect = this->rect(pos, PointPix);
638 bitBlt(&roomPix, rect.x(), rect.y(), pointPix->at(0)); 638 bitBlt(&roomPix, rect.x(), rect.y(), pointPix->at(0));
639 } 639 }
640} 640}
641 641
642QString Painter::decodeHexOctString(QString s) 642QString Painter::decodeHexOctString(QString s)
643{ 643{
644 QString value; 644 QString value;
645 QString valids; 645 QString valids;
646 int pos, xpos = 0, opos = 0; 646 int pos, xpos = 0, opos = 0;
647 int v, len, leadin; 647 int v, len, leadin;
648 const char *ptr; 648 const char *ptr;
649 uchar c; 649 uchar c;
650 650
651 while (((xpos = s.find(QRegExp("\\\\x[0-9a-fA-F]+"), xpos)) != -1) || 651 while (((xpos = s.find(QRegExp("\\\\x[0-9a-fA-F]+"), xpos)) != -1) ||
652 ((opos = s.find(QRegExp("\\\\[0-7]+"), opos)) != -1)) { 652 ((opos = s.find(QRegExp("\\\\[0-7]+"), opos)) != -1)) {
653 if (xpos != -1) { 653 if (xpos != -1) {
654 valids = "0123456789abcdef"; 654 valids = "0123456789abcdef";
655 leadin = 2; 655 leadin = 2;
656 pos = xpos; 656 pos = xpos;
657 } else { 657 } else {
658 valids = "01234567"; 658 valids = "01234567";
659 leadin = 1; 659 leadin = 1;
660 pos = opos; 660 pos = opos;
661 } 661 }
662 662
663 c = '\0'; 663 c = '\0';
664 len = 0; 664 len = 0;
665 value = s.mid(pos+leadin, 3); 665 value = s.mid(pos+leadin, 3);
666 ptr = (const char *) value; 666 ptr = (const char *) value;
667 667
668 while (*ptr != '\0' && (v = valids.find(*ptr++, 0, FALSE)) != -1) { 668 while (*ptr != '\0' && (v = valids.find(*ptr++, 0, FALSE)) != -1) {
669 c = (c * valids.length()) + v; 669 c = (c * valids.length()) + v;
670 len++; 670 len++;
671 } 671 }
672 672
673 value.fill(c, 1); 673 value.fill(c, 1);
674 s.replace(pos, len+leadin, value); 674 s.replace(pos, len+leadin, value);
675 } 675 }
676 676
677 return s; 677 return s;
678} 678}
679 679
680void Painter::fillScoreString(QStrList &list, QArray<int> &values) 680void Painter::fillScoreString(QStrList &list, QArray<int> &values)
681{ 681{
682 if( !list.isEmpty()) 682 if( !list.isEmpty())
683 list.clear(); 683 list.clear();
684 684
685 QString s; 685 QString s;
686 686
687 for (uint i = 0; i < values.size(); i++) { 687 for (uint i = 0; i < values.size(); i++) {
688 688
689 if (values[i] < 10 || values[i] > 10000) 689 if (values[i] < 10 || values[i] > 10000)
690 s = "?"; 690 s = "?";
691 else if (values[i] == 1600) 691 else if (values[i] == 1600)
692 s = "\x1a\x1b"; 692 s = "\x1a\x1b";
693 else if (values[i] < 100) { 693 else if (values[i] < 100) {
694 s = "\x0e"; 694 s = "\x0e";
695 s.insert(0, char (values[i] / 10 + 0x10)); 695 s.insert(0, char (values[i] / 10 + 0x10));
696 } else if (values[i] < 1000) { 696 } else if (values[i] < 1000) {
697 s = "\x0f"; 697 s = "\x0f";
698 s.insert(0, char (values[i] / 100 + 0x10)); 698 s.insert(0, char (values[i] / 100 + 0x10));
699 } else { 699 } else {
700 s = "\x0f\x10"; 700 s = "\x0f\x10";
701 s.insert(0, char (values[i] / 1000 + 0x10)); 701 s.insert(0, char (values[i] / 1000 + 0x10));
702 } 702 }
703 703
704 list.append(s.data()); 704 list.append(s.data());
705 } 705 }
706} 706}
707 707
708void Painter::fillArray(QArray<int> &array, QString values, int max) 708void Painter::fillArray(QArray<int> &array, QString values, int max)
709{ 709{
710 array.resize(max); 710 array.resize(max);
711 int last = 0; 711 int last = 0;
712 bool ok; 712 bool ok;
713 QString value; 713 QString value;
714 714
715 for (uint i = 0; i < array.size(); i++) { 715 for (uint i = 0; i < array.size(); i++) {
716 if (values.find(',') < 0 && values.length() > 0) { 716 if (values.find(',') < 0 && values.length() > 0) {
717 value = values; 717 value = values;
718 values = ""; 718 values = "";
719 } 719 }
720 if (values.find(',') >= 0) { 720 if (values.find(',') >= 0) {
721 value = values.left(values.find(',')); 721 value = values.left(values.find(','));
722 values.remove(0,values.find(',')+1); 722 values.remove(0,values.find(',')+1);
723 } 723 }
724 array[i] = value.toInt(&ok); 724 array[i] = value.toInt(&ok);
725 if (ok) 725 if (ok)
726 last = array[i]; 726 last = array[i];
727 else 727 else
728 array[i] = last; 728 array[i] = last;
729 } 729 }
730} 730}
731 731
732void Painter::fillStrList(QStrList &list, QString values, int max) 732void Painter::fillStrList(QStrList &list, QString values, int max)
733{ 733{
734 if (!list.isEmpty()) 734 if (!list.isEmpty())
735 list.clear(); 735 list.clear();
736 736
737 QString last = ""; 737 QString last = "";
738 QString value; 738 QString value;
739 739
740 for (uint i = 0; i < (uint) max; i++) { 740 for (uint i = 0; i < (uint) max; i++) {
741 if (values.find(',') < 0 && values.length() > 0) { 741 if (values.find(',') < 0 && values.length() > 0) {
742 value = values; 742 value = values;
743 values = ""; 743 values = "";
744 } 744 }
745 if (values.find(',') >= 0) { 745 if (values.find(',') >= 0) {
746 value = values.left(values.find(',')); 746 value = values.left(values.find(','));
747 values.remove(0,values.find(',')+1); 747 values.remove(0,values.find(',')+1);
748 } 748 }
749 if (!value.isEmpty()) 749 if (!value.isEmpty())
750 last = decodeHexOctString(value); 750 last = decodeHexOctString(value);
751 list.append(last); 751 list.append(last);
752 } 752 }
753} 753}
754 754
755void Painter::fillPixmapName(QStrList &pixmapName) 755void Painter::fillPixmapName(QStrList &pixmapName)
756{ 756{
757 QStrList list = pixmapName; 757 QStrList list = pixmapName;
758 758
759 if (!pixmapName.isEmpty()) 759 if (!pixmapName.isEmpty())
760 pixmapName.clear(); 760 pixmapName.clear();
761 761
762 QString pixmap; 762 QString pixmap;
763 763
764 QFileInfo fileInfo; 764 QFileInfo fileInfo;
765 765
766 for (uint i = 0; i < list.count(); i++) { 766 for (uint i = 0; i < list.count(); i++) {
767 pixmap = list.at(i); 767 pixmap = list.at(i);
768 768
769 if (pixmap.left(1) != "/" && pixmap.left(1) != "~") 769 if (pixmap.left(1) != "/" && pixmap.left(1) != "~")
770 pixmap = FIND_APP_DATA( pixmapDirectory+pixmap ); 770 pixmap = FIND_APP_DATA( pixmapDirectory+pixmap );
771 771
772 fileInfo.setFile(pixmap); 772 fileInfo.setFile(pixmap);
773 if (!fileInfo.isReadable() || !fileInfo.isFile()) 773 if (!fileInfo.isReadable() || !fileInfo.isFile())
774 pixmap = ""; 774 pixmap = "";
775 775
776 pixmapName.append(pixmap); 776 pixmapName.append(pixmap);
777 } 777 }
778} 778}
779 779
780void Painter::confLevels(bool defGroup) 780void Painter::confLevels(bool defGroup)
781{ 781{
782 APP_CONFIG_BEGIN( cfg ); 782 APP_CONFIG_BEGIN( cfg );
783 if (defGroup || cfg->hasKey("Levels")) 783 if (defGroup || cfg->hasKey("Levels"))
784 maxLevel = cfg->readNumEntry("Levels", 13); 784 maxLevel = cfg->readNumEntry("Levels", 13);
785 APP_CONFIG_END( cfg ); 785 APP_CONFIG_END( cfg );
786} 786}
787 787
788void Painter::confMisc(bool defGroup) 788void Painter::confMisc(bool defGroup)
789{ 789{
790 APP_CONFIG_BEGIN( cfg ); 790 APP_CONFIG_BEGIN( cfg );
791 if (defGroup || cfg->hasKey("PixmapDirectory")) { 791 if (defGroup || cfg->hasKey("PixmapDirectory")) {
792 pixmapDirectory = cfg->readEntry("PixmapDirectory"); 792 pixmapDirectory = cfg->readEntry("PixmapDirectory");
793 793
794 if (pixmapDirectory.left(1) != "/" && pixmapDirectory.left(1) != "~") 794 if (pixmapDirectory.left(1) != "/" && pixmapDirectory.left(1) != "~")
795 pixmapDirectory.insert(0, "pics/"); 795 pixmapDirectory.insert(0, "pics/");
796 if (pixmapDirectory.right(1) != "/") 796 if (pixmapDirectory.right(1) != "/")
797 pixmapDirectory.append("/"); 797 pixmapDirectory.append("/");
798 } 798 }
799 799
800 if (defGroup || cfg->hasKey("PointPixmapName")) 800 if (defGroup || cfg->hasKey("PointPixmapName"))
801 fillStrList(pointPixmapName, 801 fillStrList(pointPixmapName,
802 cfg->readEntry("PointPixmapName", "point.xpm"), maxLevel+1); 802 cfg->readEntry("PointPixmapName", "point.xpm"), maxLevel+1);
803 if (defGroup || cfg->hasKey("WallPixmapName")) 803 if (defGroup || cfg->hasKey("WallPixmapName"))
804 fillStrList(wallPixmapName, 804 fillStrList(wallPixmapName,
805 cfg->readEntry("WallPixmapName", "wall.xpm"), maxLevel+1); 805 cfg->readEntry("WallPixmapName", "wall.xpm"), maxLevel+1);
806 if (defGroup || cfg->hasKey("PrisonPixmapName")) 806 if (defGroup || cfg->hasKey("PrisonPixmapName"))
807 fillStrList(prisonPixmapName, 807 fillStrList(prisonPixmapName,
808 cfg->readEntry("PrisonPixmapName", "prison.xpm"), maxLevel+1); 808 cfg->readEntry("PrisonPixmapName", "prison.xpm"), maxLevel+1);
809 if (defGroup || cfg->hasKey("EnergizerPixmapName")) 809 if (defGroup || cfg->hasKey("EnergizerPixmapName"))
810 fillStrList(energizerPixmapName, 810 fillStrList(energizerPixmapName,
811 cfg->readEntry("EnergizerPixmapName", "switch.xpm"),maxLevel+1); 811 cfg->readEntry("EnergizerPixmapName", "switch.xpm"),maxLevel+1);
812 if (defGroup || cfg->hasKey("FruitPixmapName")) 812 if (defGroup || cfg->hasKey("FruitPixmapName"))
813 fillStrList(fruitPixmapName, 813 fillStrList(fruitPixmapName,
814 cfg->readEntry("FruitPixmapName", "fruit.xpm"), maxLevel+1); 814 cfg->readEntry("FruitPixmapName", "fruit.xpm"), maxLevel+1);
815 if (defGroup || cfg->hasKey("PacmanPixmapName")) 815 if (defGroup || cfg->hasKey("PacmanPixmapName"))
816 fillStrList(pacmanPixmapName, 816 fillStrList(pacmanPixmapName,
817 cfg->readEntry("PacmanPixmapName", "pacman.xpm"), maxLevel+1); 817 cfg->readEntry("PacmanPixmapName", "pacman.xpm"), maxLevel+1);
818 if (defGroup || cfg->hasKey("DyingPixmapName")) 818 if (defGroup || cfg->hasKey("DyingPixmapName"))
819 fillStrList(dyingPixmapName, 819 fillStrList(dyingPixmapName,
820 cfg->readEntry("DyingPixmapName", "dying.xpm"), maxLevel+1); 820 cfg->readEntry("DyingPixmapName", "dying.xpm"), maxLevel+1);
821 if (defGroup || cfg->hasKey("EyesPixmapName")) 821 if (defGroup || cfg->hasKey("EyesPixmapName"))
822 fillStrList(eyesPixmapName, 822 fillStrList(eyesPixmapName,
823 cfg->readEntry("EyesPixmapName", "eyes.xpm"), maxLevel+1); 823 cfg->readEntry("EyesPixmapName", "eyes.xpm"), maxLevel+1);
824 if (defGroup || cfg->hasKey("MonsterPixmapName")) 824 if (defGroup || cfg->hasKey("MonsterPixmapName"))
825 fillStrList(monsterPixmapName, 825 fillStrList(monsterPixmapName,
826 cfg->readEntry("MonsterPixmapName", "monster.xpm"), maxLevel+1); 826 cfg->readEntry("MonsterPixmapName", "monster.xpm"), maxLevel+1);
827 827
828 if (defGroup || cfg->hasKey("FruitScorePixmapName")) 828 if (defGroup || cfg->hasKey("FruitScorePixmapName"))
829 fillStrList(fruitScorePixmapName, 829 fillStrList(fruitScorePixmapName,
830 cfg->readEntry("FruitScorePixmapName"), maxLevel+1); 830 cfg->readEntry("FruitScorePixmapName"), maxLevel+1);
831 if (defGroup || cfg->hasKey("MonsterScorePixmapName")) 831 if (defGroup || cfg->hasKey("MonsterScorePixmapName"))
832 fillStrList(monsterScorePixmapName, 832 fillStrList(monsterScorePixmapName,
833 cfg->readEntry("MonsterScorePixmapName"), maxLevel+1); 833 cfg->readEntry("MonsterScorePixmapName"), maxLevel+1);
834 APP_CONFIG_END( cfg ); 834 APP_CONFIG_END( cfg );
835} 835}
836 836
837void Painter::confScoring(bool defGroup) 837void Painter::confScoring(bool defGroup)
838{ 838{
839 APP_CONFIG_BEGIN( cfg ); 839 APP_CONFIG_BEGIN( cfg );
840 if (defGroup || cfg->hasKey("FruitScore")) 840 if (defGroup || cfg->hasKey("FruitScore"))
841 fillArray(fruitScore, 841 fillArray(fruitScore,
842 cfg->readEntry("FruitScore", 842 cfg->readEntry("FruitScore",
843 "100,300,500,,700,,1000,,2000,,3000,,5000"), 843 "100,300,500,,700,,1000,,2000,,3000,,5000"),
844 maxLevel+1); 844 maxLevel+1);
845 if (defGroup || cfg->hasKey("MonsterScore")) 845 if (defGroup || cfg->hasKey("MonsterScore"))
846 fillArray(monsterScore, 846 fillArray(monsterScore,
847 cfg->readEntry("MonsterScore", "200,400,800,1600"), 4); 847 cfg->readEntry("MonsterScore", "200,400,800,1600"), 4);
848 848
849 if (defGroup || cfg->hasKey("FruitScoreString")) 849 if (defGroup || cfg->hasKey("FruitScoreString"))
850 fillStrList(fruitScoreString, 850 fillStrList(fruitScoreString,
851 cfg->readEntry("FruitScoreString"), maxLevel+1); 851 cfg->readEntry("FruitScoreString"), maxLevel+1);
852 if (defGroup || cfg->hasKey("MonsterScoreString")) 852 if (defGroup || cfg->hasKey("MonsterScoreString"))
853 fillStrList(monsterScoreString, 853 fillStrList(monsterScoreString,
854 cfg->readEntry("MonsterScoreString"), 4); 854 cfg->readEntry("MonsterScoreString"), 4);
855 APP_CONFIG_END( cfg ); 855 APP_CONFIG_END( cfg );
856} 856}
857 857
858void Painter::confScheme() 858void Painter::confScheme()
859{ 859{
860 APP_CONFIG_BEGIN( cfg ); 860 APP_CONFIG_BEGIN( cfg );
861 SAVE_CONFIG_GROUP( cfg, oldgroup ); 861 SAVE_CONFIG_GROUP( cfg, oldgroup );
862 QString newgroup; 862 QString newgroup;
863 863
864 // if not set, read mode and scheme from the configfile 864 // if not set, read mode and scheme from the configfile
865 if (mode == -1 && scheme == -1) { 865 if (mode == -1 && scheme == -1) {
866 scheme = cfg->readNumEntry("Scheme", -1); 866 scheme = cfg->readNumEntry("Scheme", -1);
867 mode = cfg->readNumEntry("Mode", -1); 867 mode = cfg->readNumEntry("Mode", -1);
868 868
869 // if mode is not set in the defGroup-group, lookup the scheme group 869 // if mode is not set in the defGroup-group, lookup the scheme group
870 if (scheme != -1 || mode == -1) { 870 if (scheme != -1 || mode == -1) {
871 newgroup.sprintf("Scheme %d", scheme); 871 newgroup.sprintf("Scheme %d", scheme);
872 cfg->setGroup(newgroup); 872 cfg->setGroup(newgroup);
873 873
874 mode = cfg->readNumEntry("Mode", -1); 874 mode = cfg->readNumEntry("Mode", -1);
875 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 875 RESTORE_CONFIG_GROUP( cfg, oldgroup );
876 } 876 }
877 } 877 }
878 878
879 confLevels(); 879 confLevels();
880 880
881 if (mode != -1) { 881 if (mode != -1) {
882 newgroup.sprintf("Mode %d", mode); 882 newgroup.sprintf("Mode %d", mode);
883 cfg->setGroup(newgroup); 883 cfg->setGroup(newgroup);
884 884
885 confLevels(FALSE); 885 confLevels(FALSE);
886 } 886 }
887 887
888 if (scheme != -1) { 888 if (scheme != -1) {
889 newgroup.sprintf("Scheme %d", scheme); 889 newgroup.sprintf("Scheme %d", scheme);
890 cfg->setGroup(newgroup); 890 cfg->setGroup(newgroup);
891 891
892 confLevels(FALSE); 892 confLevels(FALSE);
893 } 893 }
894 894
895 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 895 RESTORE_CONFIG_GROUP( cfg, oldgroup );
896 896
897 confMisc(); 897 confMisc();
898 confScoring(); 898 confScoring();
899 899
900 if (mode != -1) { 900 if (mode != -1) {
901 newgroup.sprintf("Mode %d", mode); 901 newgroup.sprintf("Mode %d", mode);
902 cfg->setGroup(newgroup); 902 cfg->setGroup(newgroup);
903 903
904 confMisc(FALSE); 904 confMisc(FALSE);
905 confScoring(FALSE); 905 confScoring(FALSE);
906 } 906 }
907 907
908 if (scheme != -1) { 908 if (scheme != -1) {
909 newgroup.sprintf("Scheme %d", scheme); 909 newgroup.sprintf("Scheme %d", scheme);
910 cfg->setGroup(newgroup); 910 cfg->setGroup(newgroup);
911 911
912 confMisc(FALSE); 912 confMisc(FALSE);
913 confScoring(FALSE); 913 confScoring(FALSE);
914 } 914 }
915 915
916 if ((const char *) *fruitScoreString.at(0) == '\0') 916 if ((const char *) *fruitScoreString.at(0) == '\0')
917 fillScoreString(fruitScoreString, fruitScore); 917 fillScoreString(fruitScoreString, fruitScore);
918 if ((const char *) *monsterScoreString.at(0) == '\0') 918 if ((const char *) *monsterScoreString.at(0) == '\0')
919 fillScoreString(monsterScoreString, monsterScore); 919 fillScoreString(monsterScoreString, monsterScore);
920 920
921 fillPixmapName(pointPixmapName); 921 fillPixmapName(pointPixmapName);
922 fillPixmapName(wallPixmapName); 922 fillPixmapName(wallPixmapName);
923 fillPixmapName(prisonPixmapName); 923 fillPixmapName(prisonPixmapName);
924 fillPixmapName(energizerPixmapName); 924 fillPixmapName(energizerPixmapName);
925 fillPixmapName(fruitPixmapName); 925 fillPixmapName(fruitPixmapName);
926 fillPixmapName(pacmanPixmapName); 926 fillPixmapName(pacmanPixmapName);
927 fillPixmapName(dyingPixmapName); 927 fillPixmapName(dyingPixmapName);
928 fillPixmapName(eyesPixmapName); 928 fillPixmapName(eyesPixmapName);
929 fillPixmapName(monsterPixmapName); 929 fillPixmapName(monsterPixmapName);
930 fillPixmapName(fruitScorePixmapName); 930 fillPixmapName(fruitScorePixmapName);
931 fillPixmapName(monsterScorePixmapName); 931 fillPixmapName(monsterScorePixmapName);
932 932
933 initPixmaps(); 933 initPixmaps();
934 initbackPixmaps(); 934 initbackPixmaps();
935 initRoomPixmap(); 935 initRoomPixmap();
936 936
937 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 937 RESTORE_CONFIG_GROUP( cfg, oldgroup );
938 APP_CONFIG_END( cfg ); 938 APP_CONFIG_END( cfg );
939} 939}
940 940
941void Painter::setScheme(int Scheme, int Mode, Bitfont *font) 941void Painter::setScheme(int Scheme, int Mode, Bitfont *font)
942{ 942{
943 bitfont = font; 943 bitfont = font;
944 944
945 mode = Mode; 945 mode = Mode;
946 scheme = Scheme; 946 scheme = Scheme;
947 947
948 confScheme(); 948 confScheme();
949} 949}
950 950
951void Painter::setLevel(int Level) 951void Painter::setLevel(int Level)
952{ 952{
953 level = Level; 953 level = Level;
954 954
955 initPixmaps(); 955 initPixmaps();
956 initbackPixmaps(); 956 initbackPixmaps();
957 initRoomPixmap(); 957 initRoomPixmap();
958} 958}
959 959
960int Painter::checkRange(int value, int max, int min) 960int Painter::checkRange(int value, int max, int min)
961{ 961{
962 if (value < min) { 962 if (value < min) {
963 printf("Painter::checkRange (value = %d, max = %d, min = %d)\n", 963 printf("Painter::checkRange (value = %d, max = %d, min = %d)\n",
964 value, max, min); 964 value, max, min);
965 return min; 965 return min;
966 } else if (value > max) { 966 } else if (value > max) {
967 printf("Painter::checkRange (value = %d, max = %d, min = %d)\n", 967 printf("Painter::checkRange (value = %d, max = %d, min = %d)\n",
968 value, max, min); 968 value, max, min);
969 return max; 969 return max;
970 } else 970 } else
971 return value; 971 return value;
972} 972}
diff --git a/noncore/games/kpacman/referee.cpp b/noncore/games/kpacman/referee.cpp
index 6d8f3fb..1b810d8 100644
--- a/noncore/games/kpacman/referee.cpp
+++ b/noncore/games/kpacman/referee.cpp
@@ -1,1417 +1,1417 @@
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 <qpe/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 729
730 if ( !gameState.testBit(Playing) && ( key == Key_Up || key == Key_Down || key == Key_Left || key == Key_Right ) ) 730 if ( !gameState.testBit(Playing) && ( key == Key_Up || key == Key_Down || key == Key_Left || key == Key_Right ) )
731 play(); 731 play();
732 732
733 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame) || 733 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame) ||
734 gameState.testBit(Demonstration) || gameState.testBit(Dying) || 734 gameState.testBit(Demonstration) || gameState.testBit(Dying) ||
735 gameState.testBit(Ready) || gameState.testBit(LevelDone) || 735 gameState.testBit(Ready) || gameState.testBit(LevelDone) ||
736 !gameState.testBit(Playing)) 736 !gameState.testBit(Playing))
737 return; 737 return;
738 738
739 if (key == UpKey) 739 if (key == UpKey)
740 pacman->setDirection(N); 740 pacman->setDirection(N);
741 else if (key == DownKey) 741 else if (key == DownKey)
742 pacman->setDirection(S); 742 pacman->setDirection(S);
743 else if (key == RightKey) 743 else if (key == RightKey)
744 pacman->setDirection(E); 744 pacman->setDirection(E);
745 else if (key == LeftKey) 745 else if (key == LeftKey)
746 pacman->setDirection(W); 746 pacman->setDirection(W);
747 747
748#ifdef CHEATS 748#ifdef CHEATS
749 else if (key == Key_L) { printf("levelUp()\n"); levelUp(); } 749 else if (key == Key_L) { printf("levelUp()\n"); levelUp(); }
750 else if (key == Key_F) { printf("fruit->move(TRUE)\n"); fruit->move(TRUE); repaint(FALSE); } 750 else if (key == Key_F) { printf("fruit->move(TRUE)\n"); fruit->move(TRUE); repaint(FALSE); }
751 else if (key == Key_E) { printf("setLifes(++lifes)\n"); emit setLifes(++lifes); } 751 else if (key == Key_E) { printf("setLifes(++lifes)\n"); emit setLifes(++lifes); }
752#endif 752#endif
753 753
754 else { 754 else {
755 k->ignore(); 755 k->ignore();
756 return; 756 return;
757 } 757 }
758 k->accept(); 758 k->accept();
759} 759}
760 760
761void Referee::score(int p) 761void Referee::score(int p)
762{ 762{
763 if (!gameState.testBit(Playing)) 763 if (!gameState.testBit(Playing))
764 return; 764 return;
765 765
766 if ((points += p) < 0) 766 if ((points += p) < 0)
767 points = 0; 767 points = 0;
768 768
769 emit setPoints(points); 769 emit setPoints(points);
770 770
771 if (points >= nextExtraLifeScore) { 771 if (points >= nextExtraLifeScore) {
772 emit setLifes(++lifes); 772 emit setLifes(++lifes);
773 if (extraLifeScoreIndex < (int) extraLifeScore.size()-1) 773 if (extraLifeScoreIndex < (int) extraLifeScore.size()-1)
774 extraLifeScoreIndex++; 774 extraLifeScoreIndex++;
775 if (extraLifeScore[extraLifeScoreIndex] < 0) 775 if (extraLifeScore[extraLifeScoreIndex] < 0)
776 nextExtraLifeScore = extraLifeScore[extraLifeScoreIndex] * -1; 776 nextExtraLifeScore = extraLifeScore[extraLifeScoreIndex] * -1;
777 else 777 else
778 nextExtraLifeScore += extraLifeScore[extraLifeScoreIndex]; 778 nextExtraLifeScore += extraLifeScore[extraLifeScoreIndex];
779 } 779 }
780} 780}
781 781
782void Referee::eaten() 782void Referee::eaten()
783{ 783{
784 if (gameState.testBit(Ready)) 784 if (gameState.testBit(Ready))
785 return; 785 return;
786 786
787 stop(); 787 stop();
788 788
789 if (monstersEaten < 4) 789 if (monstersEaten < 4)
790 monstersEaten++; 790 monstersEaten++;
791 791
792 gameState.setBit(Scoring); 792 gameState.setBit(Scoring);
793 score(monsterScore[monstersEaten-1]); 793 score(monsterScore[monstersEaten-1]);
794 794
795 repaint(pix->rect(pix->rect(pacman->position(), MonsterPix), 795 repaint(pix->rect(pix->rect(pacman->position(), MonsterPix),
796 pix->rect(pacman->position(), MonsterScorePix, monstersEaten-1))); 796 pix->rect(pacman->position(), MonsterScorePix, monstersEaten-1)));
797 797
798 if (--timerCount > 0) 798 if (--timerCount > 0)
799 QTimer::singleShot( monsterScoreDurMS, this, SLOT(eaten())); 799 QTimer::singleShot( monsterScoreDurMS, this, SLOT(eaten()));
800 else { 800 else {
801 for (Monster *m = monsters->first(); m != 0; m = monsters->next()) 801 for (Monster *m = monsters->first(); m != 0; m = monsters->next())
802 if (m && m->direction() == X && !gameState.testBit(Introducing)) 802 if (m && m->direction() == X && !gameState.testBit(Introducing))
803 m->setDirection(N); 803 m->setDirection(N);
804 if (monstersEaten != 4 || !gameState.testBit(Introducing)) 804 if (monstersEaten != 4 || !gameState.testBit(Introducing))
805 QTimer::singleShot( monsterScoreDurMS, this, SLOT(start())); 805 QTimer::singleShot( monsterScoreDurMS, this, SLOT(start()));
806 } 806 }
807} 807}
808 808
809void Referee::toggleHallOfFame() 809void Referee::toggleHallOfFame()
810{ 810{
811 gameState.toggleBit(HallOfFame); 811 gameState.toggleBit(HallOfFame);
812} 812}
813 813
814void Referee::hallOfFame() 814void Referee::hallOfFame()
815{ 815{
816 if (gameState.testBit(HallOfFame)) // If the HallOfFame is switched on manually, toggle the 816 if (gameState.testBit(HallOfFame)) // If the HallOfFame is switched on manually, toggle the
817 toggleHallOfFame(); // bit twice. 817 toggleHallOfFame(); // bit twice.
818 818
819 emit setLevel(0); // Clear status display for hall of fame 819 emit setLevel(0); // Clear status display for hall of fame
820 emit setScore(level, 0); 820 emit setScore(level, 0);
821 emit forcedHallOfFame(TRUE); 821 emit forcedHallOfFame(TRUE);
822} 822}
823 823
824void Referee::pause() 824void Referee::pause()
825{ 825{
826 static int pausedTimer = 0; 826 static int pausedTimer = 0;
827 827
828 if (!gameState.testBit(Paused)) { 828 if (!gameState.testBit(Paused)) {
829 pausedTimer = gameTimer; 829 pausedTimer = gameTimer;
830 stop(); 830 stop();
831 stopEnergizer(); 831 stopEnergizer();
832 gameState.setBit(Paused); 832 gameState.setBit(Paused);
833 repaint(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, tr("PAUSED")), FALSE); 833 repaint(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, tr("PAUSED")), FALSE);
834 } else { 834 } else {
835 gameState.clearBit(Paused); 835 gameState.clearBit(Paused);
836 repaint(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, tr("PAUSED")), FALSE); 836 repaint(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, tr("PAUSED")), FALSE);
837 if (pausedTimer) { 837 if (pausedTimer) {
838 pausedTimer = 0; 838 pausedTimer = 0;
839 start(); 839 start();
840 } 840 }
841 } 841 }
842 emit togglePaused(); 842 emit togglePaused();
843} 843}
844 844
845void Referee::intro() 845void Referee::intro()
846{ 846{
847 stop(); 847 stop();
848 stopEnergizer(); 848 stopEnergizer();
849 bool paused = gameState.testBit(Paused); 849 bool paused = gameState.testBit(Paused);
850 850
851 gameState.fill(FALSE); 851 gameState.fill(FALSE);
852 gameState.setBit(Introducing); 852 gameState.setBit(Introducing);
853 gameState.setBit(Init); 853 gameState.setBit(Init);
854 854
855 if (paused) 855 if (paused)
856 gameState.setBit(Paused); 856 gameState.setBit(Paused);
857 857
858 level = 0; 858 level = 0;
859 emit setLevel(level); 859 emit setLevel(level);
860 860
861 board->init(Intro); 861 board->init(Intro);
862 pix->setLevel(level); 862 pix->setLevel(level);
863 863
864 initPacman(); 864 initPacman();
865 initFruit(); 865 initFruit();
866 initMonsters(); 866 initMonsters();
867 initEnergizers(); 867 initEnergizers();
868 868
869 repaint(); 869 repaint();
870 870
871 monstersEaten = 0; 871 monstersEaten = 0;
872 timerCount = 0; 872 timerCount = 0;
873 introPlay(); 873 introPlay();
874} 874}
875 875
876void Referee::introMonster(int id) 876void Referee::introMonster(int id)
877{ 877{
878 Monster *m = new Monster(board, id); 878 Monster *m = new Monster(board, id);
879 879
880 m->setPosition((10+id*6)*BoardWidth+10); 880 m->setPosition((10+id*6)*BoardWidth+10);
881 m->setDirection(E); 881 m->setDirection(E);
882 m->setDangerous(dangerousTicks[level], monsterIQ[level]); 882 m->setDangerous(dangerousTicks[level], monsterIQ[level]);
883 m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix)); 883 m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix));
884 884
885 if (m->body() != -1) 885 if (m->body() != -1)
886 pix->draw(m->position(), RoomPix, MonsterPix, m->body()); 886 pix->draw(m->position(), RoomPix, MonsterPix, m->body());
887 if (m->eyes() != -1) 887 if (m->eyes() != -1)
888 pix->draw(m->position(), RoomPix, EyesPix, m->eyes()); 888 pix->draw(m->position(), RoomPix, EyesPix, m->eyes());
889 889
890 repaint(pix->rect(m->position(), MonsterPix), FALSE); 890 repaint(pix->rect(m->position(), MonsterPix), FALSE);
891 m->setPosition(OUT); 891 m->setPosition(OUT);
892} 892}
893 893
894void Referee::introPaint(int t) 894void Referee::introPaint(int t)
895{ 895{
896 QString pts; 896 QString pts;
897 897
898 switch (t) { 898 switch (t) {
899 case 0 : repaint(pix->draw(16, 6, RoomPix, tr("CHARACTER"), WHITE, QColor(), AlignLeft), FALSE); 899 case 0 : repaint(pix->draw(16, 6, RoomPix, tr("CHARACTER"), WHITE, QColor(), AlignLeft), FALSE);
900 repaint(pix->draw(36, 6, RoomPix, tr("/"), WHITE, QColor(), AlignLeft), FALSE); 900 repaint(pix->draw(36, 6, RoomPix, tr("/"), WHITE, QColor(), AlignLeft), FALSE);
901 repaint(pix->draw(40, 6, RoomPix, tr("NICKNAME"), WHITE, QColor(), AlignLeft), FALSE); 901 repaint(pix->draw(40, 6, RoomPix, tr("NICKNAME"), WHITE, QColor(), AlignLeft), FALSE);
902 break; 902 break;
903 case 1 : introMonster(0); 903 case 1 : introMonster(0);
904 break; 904 break;
905 case 2 : repaint(pix->draw(16, 10, RoomPix, tr("-SHADOW"), RED, QColor(), AlignLeft), FALSE); 905 case 2 : repaint(pix->draw(16, 10, RoomPix, tr("-SHADOW"), RED, QColor(), AlignLeft), FALSE);
906 break; 906 break;
907 case 3 : repaint(pix->draw(38, 10, RoomPix, tr("\"BLINKY\""), RED, QColor(), AlignLeft), FALSE); 907 case 3 : repaint(pix->draw(38, 10, RoomPix, tr("\"BLINKY\""), RED, QColor(), AlignLeft), FALSE);
908 break; 908 break;
909 case 4 : introMonster(1); 909 case 4 : introMonster(1);
910 break; 910 break;
911 case 5 : repaint(pix->draw(16, 16, RoomPix, tr("-SPEEDY"), PINK, QColor(), AlignLeft), FALSE); 911 case 5 : repaint(pix->draw(16, 16, RoomPix, tr("-SPEEDY"), PINK, QColor(), AlignLeft), FALSE);
912 break; 912 break;
913 case 6 : repaint(pix->draw(38, 16, RoomPix, tr("\"PINKY\""), PINK, QColor(), AlignLeft), FALSE); 913 case 6 : repaint(pix->draw(38, 16, RoomPix, tr("\"PINKY\""), PINK, QColor(), AlignLeft), FALSE);
914 break; 914 break;
915 case 7 : introMonster(2); 915 case 7 : introMonster(2);
916 break; 916 break;
917 case 8 : repaint(pix->draw(16, 22, RoomPix, tr("-BASHFUL"), CYAN, QColor(), AlignLeft), FALSE); 917 case 8 : repaint(pix->draw(16, 22, RoomPix, tr("-BASHFUL"), CYAN, QColor(), AlignLeft), FALSE);
918 break; 918 break;
919 case 9 : repaint(pix->draw(38, 22, RoomPix, tr("\"INKY\""), CYAN, QColor(), AlignLeft), FALSE); 919 case 9 : repaint(pix->draw(38, 22, RoomPix, tr("\"INKY\""), CYAN, QColor(), AlignLeft), FALSE);
920 break; 920 break;
921 case 10 : introMonster(3); 921 case 10 : introMonster(3);
922 break; 922 break;
923 case 11 : repaint(pix->draw(16, 28, RoomPix, tr("-POKEY"), ORANGE, QColor(), AlignLeft), FALSE); 923 case 11 : repaint(pix->draw(16, 28, RoomPix, tr("-POKEY"), ORANGE, QColor(), AlignLeft), FALSE);
924 break; 924 break;
925 case 12 : repaint(pix->draw(38, 28, RoomPix, tr("\"CLYDE\""), ORANGE, QColor(), AlignLeft), FALSE); 925 case 12 : repaint(pix->draw(38, 28, RoomPix, tr("\"CLYDE\""), ORANGE, QColor(), AlignLeft), FALSE);
926 break; 926 break;
927 case 13 : pts.sprintf("%d", pointScore); 927 case 13 : pts.sprintf("%d", pointScore);
928 repaint(pix->draw(28, 44, RoomPix, pts.data(), WHITE, QColor(), AlignRight), FALSE); 928 repaint(pix->draw(28, 44, RoomPix, pts.data(), WHITE, QColor(), AlignRight), FALSE);
929 repaint(pix->draw(31, 44, RoomPix, "\x1C\x1D\x1E", WHITE, QColor(), AlignLeft), FALSE); 929 repaint(pix->draw(31, 44, RoomPix, "\x1C\x1D\x1E", WHITE, QColor(), AlignLeft), FALSE);
930 pts.sprintf("%d", energizerScore); 930 pts.sprintf("%d", energizerScore);
931 repaint(pix->draw(28, 48, RoomPix, pts.data(), WHITE, QColor(), AlignRight), FALSE); 931 repaint(pix->draw(28, 48, RoomPix, pts.data(), WHITE, QColor(), AlignRight), FALSE);
932 repaint(pix->draw(31, 48, RoomPix, "\x1C\x1D\x1E", WHITE, QColor(), AlignLeft), FALSE); 932 repaint(pix->draw(31, 48, RoomPix, "\x1C\x1D\x1E", WHITE, QColor(), AlignLeft), FALSE);
933 break; 933 break;
934 case 14 : // "@ 1980 MIDWAY MFG.CO." 934 case 14 : // "@ 1980 MIDWAY MFG.CO."
935#if defined( KDE2_PORT ) 935#if defined( KDE2_PORT )
936 repaint(pix->draw(30, 58, RoomPix, "© 1998-2002 J.THÖNNISSEN", PINK), FALSE); 936 repaint(pix->draw(30, 58, RoomPix, "© 1998-2002 J.THÖNNISSEN", PINK), FALSE);
937#elif defined( QPE_PORT ) 937#elif defined( QPE_PORT )
938 repaint(pix->draw(30, 55, RoomPix, "© 1998-2002 J.THÖNNISSEN", PINK), FALSE); 938 repaint(pix->draw(30, 55, RoomPix, "© 1998-2002 J.THÖNNISSEN", PINK), FALSE);
939 repaint(pix->draw(29, 58, RoomPix, tr("QTOPIA PORT: CATALIN CLIMOV"), GREEN), FALSE); 939 repaint(pix->draw(29, 58, RoomPix, tr("QTOPIA PORT: CATALIN CLIMOV"), GREEN), FALSE);
940 repaint(pix->draw(29, 61, RoomPix, tr("PRESS CURSOR TO START"), GREEN), FALSE); 940 repaint(pix->draw(29, 61, RoomPix, tr("PRESS CURSOR TO START"), GREEN), FALSE);
941#endif 941#endif
942 break; 942 break;
943 } 943 }
944} 944}
945 945
946void Referee::introPlay() 946void Referee::introPlay()
947{ 947{
948 if (!gameState.testBit(Introducing) || gameState.testBit(Ready)) 948 if (!gameState.testBit(Introducing) || gameState.testBit(Ready))
949 return; 949 return;
950 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { 950 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) {
951 QTimer::singleShot(afterPauseMS, this, SLOT(introPlay())); 951 QTimer::singleShot(afterPauseMS, this, SLOT(introPlay()));
952 return; 952 return;
953 } 953 }
954 954
955 if (!gameState.testBit(Init)) { 955 if (!gameState.testBit(Init)) {
956 if (monstersEaten == 4) { 956 if (monstersEaten == 4) {
957 stop(); 957 stop();
958 QTimer::singleShot(introPostAnimationMS, this, SLOT(demo())); 958 QTimer::singleShot(introPostAnimationMS, this, SLOT(demo()));
959 } 959 }
960 if (pacman->direction() == W) { 960 if (pacman->direction() == W) {
961 int id = -1; 961 int id = -1;
962 if (pacman->position() == 37*BoardWidth-6) 962 if (pacman->position() == 37*BoardWidth-6)
963 id = 0; 963 id = 0;
964 else 964 else
965 if (board->isMonster(37*BoardWidth-6)) 965 if (board->isMonster(37*BoardWidth-6))
966 for (Monster *m = monsters->first(); m != 0; m = monsters->next()) 966 for (Monster *m = monsters->first(); m != 0; m = monsters->next())
967 if (m && m->position() == 37*BoardWidth-6) { 967 if (m && m->position() == 37*BoardWidth-6) {
968 id = m->id(); 968 id = m->id();
969 id++; 969 id++;
970 break; 970 break;
971 } 971 }
972 972
973 if (id >= 0 && id <= 4) 973 if (id >= 0 && id <= 4)
974 for (Monster *m = monsters->first(); m != 0; m = monsters->next()) 974 for (Monster *m = monsters->first(); m != 0; m = monsters->next())
975 if (m && m->id() == id && m->position() == OUT) { 975 if (m && m->id() == id && m->position() == OUT) {
976 m->setPosition(37*BoardWidth-1); 976 m->setPosition(37*BoardWidth-1);
977 m->setDirection(W); 977 m->setDirection(W);
978 m->setDangerous(dangerousTicks[level], monsterIQ[level]); 978 m->setDangerous(dangerousTicks[level], monsterIQ[level]);
979 board->set(37*BoardWidth-1, monsterhome, id); 979 board->set(37*BoardWidth-1, monsterhome, id);
980 repaint(pix->rect(m->position(), MonsterPix)); 980 repaint(pix->rect(m->position(), MonsterPix));
981 break; 981 break;
982 } 982 }
983 } 983 }
984 return; 984 return;
985 } 985 }
986 986
987 if (timerCount < 15) 987 if (timerCount < 15)
988 introPaint(timerCount); 988 introPaint(timerCount);
989 989
990 switch (timerCount) { 990 switch (timerCount) {
991 case 13 : board->set(44*BoardWidth+22, Point); 991 case 13 : board->set(44*BoardWidth+22, Point);
992 pix->drawPoint(44*BoardWidth+22); 992 pix->drawPoint(44*BoardWidth+22);
993 repaint(pix->rect(44*BoardWidth+22, PointPix), FALSE); 993 repaint(pix->rect(44*BoardWidth+22, PointPix), FALSE);
994 energizers->at(0)->setPosition(48*BoardWidth+22); 994 energizers->at(0)->setPosition(48*BoardWidth+22);
995 energizers->at(0)->setOn(); 995 energizers->at(0)->setOn();
996 repaint(pix->rect(48*BoardWidth+22, EnergizerPix), FALSE); 996 repaint(pix->rect(48*BoardWidth+22, EnergizerPix), FALSE);
997 break; 997 break;
998 case 14 : energizers->at(1)->setPosition(36*BoardWidth+10); 998 case 14 : energizers->at(1)->setPosition(36*BoardWidth+10);
999 energizers->at(1)->setOn(); 999 energizers->at(1)->setOn();
1000 repaint(pix->rect(36*BoardWidth+10, EnergizerPix), FALSE); 1000 repaint(pix->rect(36*BoardWidth+10, EnergizerPix), FALSE);
1001 for (int pos = 8; pos < BoardWidth; pos++) { 1001 for (int pos = 8; pos < BoardWidth; pos++) {
1002 board->set(34*BoardWidth+pos, out); 1002 board->set(34*BoardWidth+pos, out);
1003 board->set(38*BoardWidth+pos, out); 1003 board->set(38*BoardWidth+pos, out);
1004 } 1004 }
1005 board->set(36*BoardWidth+8, out); 1005 board->set(36*BoardWidth+8, out);
1006 break; 1006 break;
1007 case 15 : gameState.clearBit(Init); 1007 case 15 : gameState.clearBit(Init);
1008 initPacman(); 1008 initPacman();
1009 pacman->setDemo(TRUE); 1009 pacman->setDemo(TRUE);
1010 pacman->setPosition(37*BoardWidth-1); 1010 pacman->setPosition(37*BoardWidth-1);
1011 repaintFigures(); 1011 repaintFigures();
1012 start(); 1012 start();
1013 return; 1013 return;
1014 } 1014 }
1015 1015
1016 if (timerCount++ < 15) 1016 if (timerCount++ < 15)
1017 QTimer::singleShot(introAnimationMS, this, SLOT(introPlay())); 1017 QTimer::singleShot(introAnimationMS, this, SLOT(introPlay()));
1018} 1018}
1019 1019
1020void Referee::demo() 1020void Referee::demo()
1021{ 1021{
1022 if (gameState.testBit(Ready)) 1022 if (gameState.testBit(Ready))
1023 return; 1023 return;
1024 1024
1025 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { 1025 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) {
1026 QTimer::singleShot(afterPauseMS, this, SLOT(demo())); 1026 QTimer::singleShot(afterPauseMS, this, SLOT(demo()));
1027 return; 1027 return;
1028 } 1028 }
1029 1029
1030 stop(); 1030 stop();
1031 stopEnergizer(); 1031 stopEnergizer();
1032 1032
1033 gameState.fill(FALSE); 1033 gameState.fill(FALSE);
1034 gameState.setBit(Init); 1034 gameState.setBit(Init);
1035 gameState.setBit(Demonstration); 1035 gameState.setBit(Demonstration);
1036 1036
1037 level = 0; 1037 level = 0;
1038 emit setLevel(level); 1038 emit setLevel(level);
1039 1039
1040 board->init(Demo, mapName.at(0)); 1040 board->init(Demo, mapName.at(0));
1041 pix->setLevel(level); 1041 pix->setLevel(level);
1042 1042
1043 initPacman(); 1043 initPacman();
1044 initFruit(); 1044 initFruit();
1045 initMonsters(); 1045 initMonsters();
1046 initEnergizers(); 1046 initEnergizers();
1047 1047
1048 gameState.clearBit(Init); 1048 gameState.clearBit(Init);
1049 1049
1050 repaint(); 1050 repaint();
1051 1051
1052 timerCount = 0; 1052 timerCount = 0;
1053 QTimer::singleShot(playerDurMS, this, SLOT(start())); 1053 QTimer::singleShot(playerDurMS, this, SLOT(start()));
1054} 1054}
1055 1055
1056void Referee::play() 1056void Referee::play()
1057{ 1057{
1058 stop(); 1058 stop();
1059 stopEnergizer(); 1059 stopEnergizer();
1060 1060
1061 gameState.fill(FALSE); 1061 gameState.fill(FALSE);
1062 gameState.setBit(Init); 1062 gameState.setBit(Init);
1063 gameState.setBit(Playing); 1063 gameState.setBit(Playing);
1064 gameState.setBit(Player); 1064 gameState.setBit(Player);
1065 gameState.setBit(Ready); 1065 gameState.setBit(Ready);
1066 1066
1067 lifes = 3; 1067 lifes = 3;
1068 level = 1; 1068 level = 1;
1069 points = 0; 1069 points = 0;
1070 1070
1071 extraLifeScoreIndex = 0; 1071 extraLifeScoreIndex = 0;
1072 nextExtraLifeScore = extraLifeScore[extraLifeScoreIndex]; 1072 nextExtraLifeScore = extraLifeScore[extraLifeScoreIndex];
1073 if (nextExtraLifeScore < 0) 1073 if (nextExtraLifeScore < 0)
1074 nextExtraLifeScore *= -1; 1074 nextExtraLifeScore *= -1;
1075 1075
1076 board->init(Level, mapName.at(level)); 1076 board->init(Level, mapName.at(level));
1077 pix->setLevel(level); 1077 pix->setLevel(level);
1078 1078
1079 initPacman(); 1079 initPacman();
1080 initFruit(); 1080 initFruit();
1081 initMonsters(); 1081 initMonsters();
1082 initEnergizers(); 1082 initEnergizers();
1083 1083
1084 repaint(); 1084 repaint();
1085 emit toggleNew(); 1085 emit toggleNew();
1086 emit setLifes(lifes); 1086 emit setLifes(lifes);
1087 emit setLevel(level); 1087 emit setLevel(level);
1088 emit setPoints(points); 1088 emit setPoints(points);
1089 1089
1090 repaint(pix->rect(board->position(monsterhome, 0), tr("PLAYER ONE")), FALSE); 1090 repaint(pix->rect(board->position(monsterhome, 0), tr("PLAYER ONE")), FALSE);
1091 repaint(pix->rect(board->position(fruithome), tr("READY!")), FALSE); 1091 repaint(pix->rect(board->position(fruithome), tr("READY!")), FALSE);
1092 1092
1093 timerCount = 0; 1093 timerCount = 0;
1094 QTimer::singleShot(playerDurMS, this, SLOT(ready())); 1094 QTimer::singleShot(playerDurMS, this, SLOT(ready()));
1095} 1095}
1096 1096
1097void Referee::ready() 1097void Referee::ready()
1098{ 1098{
1099 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { 1099 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) {
1100 QTimer::singleShot(afterPauseMS, this, SLOT(ready())); 1100 QTimer::singleShot(afterPauseMS, this, SLOT(ready()));
1101 return; 1101 return;
1102 } 1102 }
1103 1103
1104 if (gameState.testBit(Player)) { 1104 if (gameState.testBit(Player)) {
1105 emit setLifes(--lifes); 1105 emit setLifes(--lifes);
1106 gameState.clearBit(Player); 1106 gameState.clearBit(Player);
1107 gameState.clearBit(Init); 1107 gameState.clearBit(Init);
1108 repaint(pix->rect(board->position(monsterhome, 0), tr("PLAYER ONE")), FALSE); 1108 repaint(pix->rect(board->position(monsterhome, 0), tr("PLAYER ONE")), FALSE);
1109 repaintFigures(); 1109 repaintFigures();
1110 QTimer::singleShot(playerDurMS, this, SLOT(ready())); 1110 QTimer::singleShot(playerDurMS, this, SLOT(ready()));
1111 return; 1111 return;
1112 } 1112 }
1113 1113
1114 if (gameState.testBit(Ready)) { 1114 if (gameState.testBit(Ready)) {
1115 gameState.clearBit(Ready); 1115 gameState.clearBit(Ready);
1116 repaint(pix->rect(board->position(fruithome), tr("READY!")), FALSE); 1116 repaint(pix->rect(board->position(fruithome), tr("READY!")), FALSE);
1117 start(); 1117 start();
1118 } else { 1118 } else {
1119 gameState.setBit(Ready); 1119 gameState.setBit(Ready);
1120 gameState.clearBit(Init); 1120 gameState.clearBit(Init);
1121 repaint(pix->rect(board->position(fruithome), tr("READY!")), FALSE); 1121 repaint(pix->rect(board->position(fruithome), tr("READY!")), FALSE);
1122 QTimer::singleShot(readyDurMS, this, SLOT(ready())); 1122 QTimer::singleShot(readyDurMS, this, SLOT(ready()));
1123 } 1123 }
1124} 1124}
1125 1125
1126 1126
1127void Referee::levelUp() 1127void Referee::levelUp()
1128{ 1128{
1129 stop(); 1129 stop();
1130 stopEnergizer(); 1130 stopEnergizer();
1131 1131
1132 gameState.setBit(LevelDone); 1132 gameState.setBit(LevelDone);
1133 pacman->setPosition(pacman->position()); // set mouthPosition to "0" 1133 pacman->setPosition(pacman->position()); // set mouthPosition to "0"
1134 repaint(pix->rect(pacman->position(), PacmanPix)); 1134 repaint(pix->rect(pacman->position(), PacmanPix));
1135 1135
1136 timerCount = 0; 1136 timerCount = 0;
1137 QTimer::singleShot(levelUpPreAnimationMS, this, SLOT(levelUpPlay())); 1137 QTimer::singleShot(levelUpPreAnimationMS, this, SLOT(levelUpPlay()));
1138} 1138}
1139 1139
1140void Referee::levelUpPlay() 1140void Referee::levelUpPlay()
1141{ 1141{
1142 if (gameState.testBit(Ready)) 1142 if (gameState.testBit(Ready))
1143 return; 1143 return;
1144 1144
1145 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { 1145 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) {
1146 QTimer::singleShot(afterPauseMS, this, SLOT(levelUpPlay())); 1146 QTimer::singleShot(afterPauseMS, this, SLOT(levelUpPlay()));
1147 return; 1147 return;
1148 } 1148 }
1149 1149
1150 switch (timerCount) { 1150 switch (timerCount) {
1151 case 0 : gameState.setBit(Init); 1151 case 0 : gameState.setBit(Init);
1152 setOnEnergizers(); 1152 setOnEnergizers();
1153 repaintFigures(); 1153 repaintFigures();
1154 break; 1154 break;
1155 case 1 : gameState.clearBit(LevelDone); 1155 case 1 : gameState.clearBit(LevelDone);
1156 repaint(pix->rect(pacman->position(), PacmanPix)); 1156 repaint(pix->rect(pacman->position(), PacmanPix));
1157 break; 1157 break;
1158 } 1158 }
1159 1159
1160 if (timerCount++ < 2) { 1160 if (timerCount++ < 2) {
1161 QTimer::singleShot(levelUpAnimationMS, this, SLOT(levelUpPlay())); 1161 QTimer::singleShot(levelUpAnimationMS, this, SLOT(levelUpPlay()));
1162 return; 1162 return;
1163 } 1163 }
1164 1164
1165 gameState.clearBit(Init); 1165 gameState.clearBit(Init);
1166 1166
1167 if (gameState.testBit(Demonstration)) { 1167 if (gameState.testBit(Demonstration)) {
1168 hallOfFame(); 1168 hallOfFame();
1169 return; 1169 return;
1170 } 1170 }
1171 1171
1172 if (level < maxLevel) 1172 if (level < maxLevel)
1173 level++; 1173 level++;
1174 1174
1175 board->init(Level, mapName.at(level)); 1175 board->init(Level, mapName.at(level));
1176 pix->setLevel(level); 1176 pix->setLevel(level);
1177 1177
1178 initPacman(); 1178 initPacman();
1179 initFruit(); 1179 initFruit();
1180 initMonsters(); 1180 initMonsters();
1181 initEnergizers(); 1181 initEnergizers();
1182 1182
1183 repaint(); 1183 repaint();
1184 emit setLevel(level); 1184 emit setLevel(level);
1185 1185
1186 ready(); 1186 ready();
1187} 1187}
1188 1188
1189void Referee::start() 1189void Referee::start()
1190{ 1190{
1191 if (gameState.testBit(Ready)) 1191 if (gameState.testBit(Ready))
1192 return; 1192 return;
1193 1193
1194 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { 1194 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) {
1195 QTimer::singleShot(afterPauseMS, this, SLOT(start())); 1195 QTimer::singleShot(afterPauseMS, this, SLOT(start()));
1196 return; 1196 return;
1197 } 1197 }
1198 1198
1199 if (gameState.testBit(Scoring)) { 1199 if (gameState.testBit(Scoring)) {
1200 gameState.clearBit(Scoring); 1200 gameState.clearBit(Scoring);
1201 repaint(pix->rect(pix->rect(pacman->position(), MonsterPix), 1201 repaint(pix->rect(pix->rect(pacman->position(), MonsterPix),
1202 pix->rect(pacman->position(), MonsterScorePix, monstersEaten-1))); 1202 pix->rect(pacman->position(), MonsterScorePix, monstersEaten-1)));
1203 } 1203 }
1204 1204
1205 if (!gameTimer) 1205 if (!gameTimer)
1206 gameTimer = startTimer( speed [level] ); 1206 gameTimer = startTimer( speed [level] );
1207 1207
1208 if (!energizerTimer) 1208 if (!energizerTimer)
1209 energizerTimer = startTimer( energizerAnimationMS ); 1209 energizerTimer = startTimer( energizerAnimationMS );
1210} 1210}
1211 1211
1212void Referee::start(int t) 1212void Referee::start(int t)
1213{ 1213{
1214 gameTimer = startTimer(t); 1214 gameTimer = startTimer(t);
1215} 1215}
1216 1216
1217void Referee::stop() 1217void Referee::stop()
1218{ 1218{
1219 if (gameTimer) { 1219 if (gameTimer) {
1220 killTimer (gameTimer); 1220 killTimer (gameTimer);
1221 gameTimer = 0; 1221 gameTimer = 0;
1222 } 1222 }
1223} 1223}
1224 1224
1225void Referee::stopEnergizer() 1225void Referee::stopEnergizer()
1226{ 1226{
1227 if (energizerTimer) { 1227 if (energizerTimer) {
1228 killTimer (energizerTimer); 1228 killTimer (energizerTimer);
1229 energizerTimer = 0; 1229 energizerTimer = 0;
1230 } 1230 }
1231} 1231}
1232 1232
1233void Referee::killed() 1233void Referee::killed()
1234{ 1234{
1235 if (gameState.testBit(Ready)) 1235 if (gameState.testBit(Ready))
1236 return; 1236 return;
1237 1237
1238 if (!gameState.testBit(Dying)) { 1238 if (!gameState.testBit(Dying)) {
1239 gameState.setBit(Dying); 1239 gameState.setBit(Dying);
1240 1240
1241 pacman->setDirection(X, TRUE); 1241 pacman->setDirection(X, TRUE);
1242 for (Monster *m = monsters->first(); m != 0; m = monsters->next()) 1242 for (Monster *m = monsters->first(); m != 0; m = monsters->next())
1243 if (m) 1243 if (m)
1244 m->setDirection(X); 1244 m->setDirection(X);
1245 QTimer::singleShot(dyingPreAnimationMS, this, SLOT(killed())); 1245 QTimer::singleShot(dyingPreAnimationMS, this, SLOT(killed()));
1246 } else { 1246 } else {
1247 stop(); 1247 stop();
1248 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { 1248 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) {
1249 QTimer::singleShot(afterPauseMS, this, SLOT(killed())); 1249 QTimer::singleShot(afterPauseMS, this, SLOT(killed()));
1250 return; 1250 return;
1251 } 1251 }
1252 1252
1253 gameState.setBit(Init); 1253 gameState.setBit(Init);
1254 1254
1255 repaintFigures(); 1255 repaintFigures();
1256 1256
1257 timerCount = 0; 1257 timerCount = 0;
1258 killedPlay(); 1258 killedPlay();
1259 } 1259 }
1260} 1260}
1261 1261
1262void Referee::killedPlay() 1262void Referee::killedPlay()
1263{ 1263{
1264 if (!gameState.testBit(Dying) || gameState.testBit(Ready)) 1264 if (!gameState.testBit(Dying) || gameState.testBit(Ready))
1265 return; 1265 return;
1266 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { 1266 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) {
1267 QTimer::singleShot(afterPauseMS, this, SLOT(killedPlay())); 1267 QTimer::singleShot(afterPauseMS, this, SLOT(killedPlay()));
1268 return; 1268 return;
1269 } 1269 }
1270 1270
1271 if (timerCount <= pix->maxPixmaps(DyingPix)) { 1271 if (timerCount <= pix->maxPixmaps(DyingPix)) {
1272 repaint(pix->rect(pacman->position(), PacmanPix), FALSE); 1272 repaint(pix->rect(pacman->position(), PacmanPix), FALSE);
1273 if (timerCount >= pix->maxPixmaps(DyingPix)-1 || timerCount == 0) 1273 if (timerCount >= pix->maxPixmaps(DyingPix)-1 || timerCount == 0)
1274 QTimer::singleShot(dyingPostAnimationMS, this, SLOT(killedPlay())); 1274 QTimer::singleShot(dyingPostAnimationMS, this, SLOT(killedPlay()));
1275 else 1275 else
1276 QTimer::singleShot(dyingAnimationMS, this, SLOT(killedPlay())); 1276 QTimer::singleShot(dyingAnimationMS, this, SLOT(killedPlay()));
1277 timerCount++; 1277 timerCount++;
1278 } else { 1278 } else {
1279 gameState.clearBit(Dying); 1279 gameState.clearBit(Dying);
1280 stopEnergizer(); 1280 stopEnergizer();
1281 if (lifes == 0) { 1281 if (lifes == 0) {
1282 gameState.setBit(GameOver); 1282 gameState.setBit(GameOver);
1283 gameState.clearBit(Playing); 1283 gameState.clearBit(Playing);
1284 for (int e = 0; e < board->energizers(); e++) { 1284 for (int e = 0; e < board->energizers(); e++) {
1285 energizers->at(e)->setOff(); 1285 energizers->at(e)->setOff();
1286 repaint(pix->rect(board->position(energizer, e), EnergizerPix), FALSE); 1286 repaint(pix->rect(board->position(energizer, e), EnergizerPix), FALSE);
1287 } 1287 }
1288 repaint(pix->rect(board->position(fruithome), tr("GAME OVER")), FALSE); 1288 repaint(pix->rect(board->position(fruithome), tr("GAME OVER")), FALSE);
1289 QTimer::singleShot(gameOverDurMS, this, SLOT(hallOfFame())); 1289 QTimer::singleShot(gameOverDurMS, this, SLOT(hallOfFame()));
1290 } else { 1290 } else {
1291 gameState.clearBit(Init); 1291 gameState.clearBit(Init);
1292 initPacman(); 1292 initPacman();
1293 initFruit(); 1293 initFruit();
1294 initMonsters(); 1294 initMonsters();
1295 initEnergizers(); 1295 initEnergizers();
1296 emit setLifes(--lifes); 1296 emit setLifes(--lifes);
1297 repaintFigures(); 1297 repaintFigures();
1298 ready(); 1298 ready();
1299 } 1299 }
1300 } 1300 }
1301} 1301}
1302 1302
1303void Referee::initPacman() 1303void Referee::initPacman()
1304{ 1304{
1305 pacman->setMaxPixmaps(pix->maxPixmaps(PacmanPix)); 1305 pacman->setMaxPixmaps(pix->maxPixmaps(PacmanPix));
1306 pacman->setDemo(gameState.testBit(Demonstration)); 1306 pacman->setDemo(gameState.testBit(Demonstration));
1307 pacman->setPosition(board->position(pacmanhome)); 1307 pacman->setPosition(board->position(pacmanhome));
1308 pacman->setDirection(W, TRUE); 1308 pacman->setDirection(W, TRUE);
1309 pacman->setAlive(pacmanTicks[level]); 1309 pacman->setAlive(pacmanTicks[level]);
1310} 1310}
1311 1311
1312void Referee::initFruit(bool fullInitialization) 1312void Referee::initFruit(bool fullInitialization)
1313{ 1313{
1314 if (fullInitialization) { 1314 if (fullInitialization) {
1315 fruit->setMaxPixmaps(pix->maxPixmaps(FruitPix)); 1315 fruit->setMaxPixmaps(pix->maxPixmaps(FruitPix));
1316 if (fruitIndex[level] == 0) 1316 if (fruitIndex[level] == 0)
1317 fruit->setLevel(level, fruitAppearsTicks[level], 1317 fruit->setLevel(level, fruitAppearsTicks[level],
1318 fruitDurTicks[level], fruitTicks[level]); 1318 fruitDurTicks[level], fruitTicks[level]);
1319 else if (fruitIndex[level] < 0) 1319 else if (fruitIndex[level] < 0)
1320 fruit->setLevel(pix->maxPixmaps(FruitPix)+1, 1320 fruit->setLevel(pix->maxPixmaps(FruitPix)+1,
1321 fruitAppearsTicks[level], 1321 fruitAppearsTicks[level],
1322 fruitDurTicks[level], fruitTicks[level]); 1322 fruitDurTicks[level], fruitTicks[level]);
1323 else 1323 else
1324 fruit->setLevel(fruitIndex[level], fruitAppearsTicks[level], 1324 fruit->setLevel(fruitIndex[level], fruitAppearsTicks[level],
1325 fruitDurTicks[level], fruitTicks[level]); 1325 fruitDurTicks[level], fruitTicks[level]);
1326 } 1326 }
1327 1327
1328 if (board->tunnels() > 0) 1328 if (board->tunnels() > 0)
1329 fruit->setMovement(board->position(tunnel, rand() % board->tunnels()), 1329 fruit->setMovement(board->position(tunnel, rand() % board->tunnels()),
1330 board->position(tunnel, rand() % board->tunnels()), 1330 board->position(tunnel, rand() % board->tunnels()),
1331 fruitIQ[level]); 1331 fruitIQ[level]);
1332} 1332}
1333 1333
1334void Referee::initMonsters() 1334void Referee::initMonsters()
1335{ 1335{
1336 if( !monsters->isEmpty()) 1336 if( !monsters->isEmpty())
1337 monsters->clear(); 1337 monsters->clear();
1338 if( !monsterRect->isEmpty()) 1338 if( !monsterRect->isEmpty())
1339 monsterRect->clear(); 1339 monsterRect->clear();
1340 1340
1341 for (int id = 0; id < (gameState.testBit(Introducing) ? 4 : board->monsters()); id++) { 1341 for (int id = 0; id < (gameState.testBit(Introducing) ? 4 : board->monsters()); id++) {
1342 Monster *m = new Monster(board, id); 1342 Monster *m = new Monster(board, id);
1343 monsters->append(m); 1343 monsters->append(m);
1344 QRect *r = new QRect(); 1344 QRect *r = new QRect();
1345 monsterRect->append(r); 1345 monsterRect->append(r);
1346 if (!gameState.testBit(Introducing)) { 1346 if (!gameState.testBit(Introducing)) {
1347 m->setFreedom(board->position(prisonexit)); 1347 m->setFreedom(board->position(prisonexit));
1348 m->setDangerous(dangerousTicks[level], monsterIQ[level]); 1348 m->setDangerous(dangerousTicks[level], monsterIQ[level]);
1349 if (id == 0) 1349 if (id == 0)
1350 m->setPrison(board->position(prisonentry)); 1350 m->setPrison(board->position(prisonentry));
1351 else { 1351 else {
1352 m->setPrison(board->position(monsterhome, id)); 1352 m->setPrison(board->position(monsterhome, id));
1353 m->setArrested(arrestTicks[level], arrestDurTicks[level]*id); 1353 m->setArrested(arrestTicks[level], arrestDurTicks[level]*id);
1354 } 1354 }
1355 m->setPosition(board->position(monsterhome, id)); 1355 m->setPosition(board->position(monsterhome, id));
1356 switch(id) { 1356 switch(id) {
1357 case 0 : m->setDirection(W); break; 1357 case 0 : m->setDirection(W); break;
1358 case 1 : m->setDirection(N); break; 1358 case 1 : m->setDirection(N); break;
1359 default : m->setDirection(S); 1359 default : m->setDirection(S);
1360 } 1360 }
1361 } 1361 }
1362 m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix)); 1362 m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix));
1363 } 1363 }
1364} 1364}
1365 1365
1366void Referee::initEnergizers() 1366void Referee::initEnergizers()
1367{ 1367{
1368 if( !energizers->isEmpty()) 1368 if( !energizers->isEmpty())
1369 energizers->clear(); 1369 energizers->clear();
1370 if( !energizerRect->isEmpty()) 1370 if( !energizerRect->isEmpty())
1371 energizerRect->clear(); 1371 energizerRect->clear();
1372 1372
1373 for (int id = 0; id < (gameState.testBit(Introducing) ? 2 : board->energizers()); id++) { 1373 for (int id = 0; id < (gameState.testBit(Introducing) ? 2 : board->energizers()); id++) {
1374 Energizer *e = new Energizer(board); 1374 Energizer *e = new Energizer(board);
1375 energizers->append(e); 1375 energizers->append(e);
1376 QRect *r = new QRect(); 1376 QRect *r = new QRect();
1377 energizerRect->append(r); 1377 energizerRect->append(r);
1378 if (!gameState.testBit(Introducing)) { 1378 if (!gameState.testBit(Introducing)) {
1379 e->setPosition(board->position(energizer, id)); 1379 e->setPosition(board->position(energizer, id));
1380 e->setOn(); 1380 e->setOn();
1381 } 1381 }
1382 e->setMaxPixmaps(pix->maxPixmaps(EnergizerPix)); 1382 e->setMaxPixmaps(pix->maxPixmaps(EnergizerPix));
1383 } 1383 }
1384} 1384}
1385 1385
1386void Referee::setOnEnergizers() 1386void Referee::setOnEnergizers()
1387{ 1387{
1388 for (int e = 0; e < board->energizers(); e++) { 1388 for (int e = 0; e < board->energizers(); e++) {
1389 energizers->at(e)->setOn(); 1389 energizers->at(e)->setOn();
1390 } 1390 }
1391} 1391}
1392 1392
1393void Referee::setFocusOutPause(bool FocusOutPause) 1393void Referee::setFocusOutPause(bool FocusOutPause)
1394{ 1394{
1395 focusOutPause = FocusOutPause; 1395 focusOutPause = FocusOutPause;
1396} 1396}
1397 1397
1398void Referee::setFocusInContinue(bool FocusInContinue) 1398void Referee::setFocusInContinue(bool FocusInContinue)
1399{ 1399{
1400 focusInContinue = FocusInContinue; 1400 focusInContinue = FocusInContinue;
1401} 1401}
1402 1402
1403void Referee::focusInEvent(QFocusEvent *) 1403void Referee::focusInEvent(QFocusEvent *)
1404{ 1404{
1405 if (focusInContinue && focusedPause && 1405 if (focusInContinue && focusedPause &&
1406 gameState.testBit(Paused) && gameState.testBit(Playing)) { 1406 gameState.testBit(Paused) && gameState.testBit(Playing)) {
1407 pause(); 1407 pause();
1408 } 1408 }
1409} 1409}
1410 1410
1411void Referee::focusOutEvent(QFocusEvent *) 1411void Referee::focusOutEvent(QFocusEvent *)
1412{ 1412{
1413 if (focusOutPause && !gameState.testBit(Paused) && gameState.testBit(Playing)) { 1413 if (focusOutPause && !gameState.testBit(Paused) && gameState.testBit(Playing)) {
1414 focusedPause = TRUE; 1414 focusedPause = TRUE;
1415 pause(); 1415 pause();
1416 } 1416 }
1417} 1417}
diff --git a/noncore/games/kpacman/status.cpp b/noncore/games/kpacman/status.cpp
index 1ef910d..2a17c21 100644
--- a/noncore/games/kpacman/status.cpp
+++ b/noncore/games/kpacman/status.cpp
@@ -1,368 +1,368 @@
1 1
2#include "portable.h" 2#include "portable.h"
3 3
4#if defined( KDE2_PORT ) 4#if defined( KDE2_PORT )
5#include <kapp.h> 5#include <kapp.h>
6#include <klocale.h> 6#include <klocale.h>
7#include <kstddirs.h> 7#include <kstddirs.h>
8#include <status.h> 8#include <status.h>
9#include <status.moc> 9#include <status.moc>
10#elif defined( QPE_PORT ) 10#elif defined( QPE_PORT )
11#include <qpe/qpeapplication.h> 11#include <qpe/qpeapplication.h>
12#include "config.h" 12#include <qpe/config.h>
13#include "status.h" 13#include "status.h"
14#endif 14#endif
15 15
16#include <qpixmap.h> 16#include <qpixmap.h>
17#include <qbitmap.h> 17#include <qbitmap.h>
18#include <qstring.h> 18#include <qstring.h>
19#include <qmsgbox.h> 19#include <qmsgbox.h>
20#include <qfileinfo.h> 20#include <qfileinfo.h>
21 21
22Status::Status( QWidget *parent, const char *name, int Scheme, int Mode ) : 22Status::Status( QWidget *parent, const char *name, int Scheme, int Mode ) :
23 QWidget( parent, name ) 23 QWidget( parent, name )
24{ 24{
25 qWarning("Status::Status"); 25 qWarning("Status::Status");
26 actualLifes = 0; 26 actualLifes = 0;
27 actualLevel = 0; 27 actualLevel = 0;
28 28
29 lifesPix = NULL; 29 lifesPix = NULL;
30 levelPix = NULL; 30 levelPix = NULL;
31 31
32 scheme = Scheme; 32 scheme = Scheme;
33 mode = Mode; 33 mode = Mode;
34 level = 0; 34 level = 0;
35 35
36 confScheme(); 36 confScheme();
37} 37}
38 38
39QList<QPixmap> *Status::loadPixmap(QWidget *parent, QString pixmapName, 39QList<QPixmap> *Status::loadPixmap(QWidget *parent, QString pixmapName,
40 QList<QPixmap> *pixmaps) 40 QList<QPixmap> *pixmaps)
41{ 41{
42 if (pixmaps == NULL) { 42 if (pixmaps == NULL) {
43 pixmaps = new QList<QPixmap>; 43 pixmaps = new QList<QPixmap>;
44 pixmaps->setAutoDelete(TRUE); 44 pixmaps->setAutoDelete(TRUE);
45 } 45 }
46 46
47 if (!pixmaps->isEmpty()) 47 if (!pixmaps->isEmpty())
48 pixmaps->clear(); 48 pixmaps->clear();
49 49
50 QPixmap PIXMAP(pixmapName); 50 QPixmap PIXMAP(pixmapName);
51 if (PIXMAP.isNull() || PIXMAP.mask() == NULL) { 51 if (PIXMAP.isNull() || PIXMAP.mask() == NULL) {
52 QString msg = tr("The pixmap could not be contructed.\n\n" 52 QString msg = tr("The pixmap could not be contructed.\n\n"
53 "The file '@PIXMAPNAME@' does not exist,\n" 53 "The file '@PIXMAPNAME@' does not exist,\n"
54 "or is of an unknown format."); 54 "or is of an unknown format.");
55 msg.replace(QRegExp("@PIXMAPNAME@"), pixmapName); 55 msg.replace(QRegExp("@PIXMAPNAME@"), pixmapName);
56 QMessageBox::information(parent, tr("Initialization Error"), 56 QMessageBox::information(parent, tr("Initialization Error"),
57 (const char *) msg); 57 (const char *) msg);
58 return 0; 58 return 0;
59 } 59 }
60 60
61 int height = PIXMAP.height(); 61 int height = PIXMAP.height();
62 int width = (height == 0) ? 0 : PIXMAP.width()/(PIXMAP.width()/height); 62 int width = (height == 0) ? 0 : PIXMAP.width()/(PIXMAP.width()/height);
63 63
64 QBitmap BITMAP; 64 QBitmap BITMAP;
65 QBitmap MASK; 65 QBitmap MASK;
66 66
67 BITMAP = *PIXMAP.mask(); 67 BITMAP = *PIXMAP.mask();
68 MASK.resize(width, height); 68 MASK.resize(width, height);
69 69
70 for (int x = 0; x < PIXMAP.width()/width; x++) { 70 for (int x = 0; x < PIXMAP.width()/width; x++) {
71 QPixmap *pixmap = new QPixmap(width, height); 71 QPixmap *pixmap = new QPixmap(width, height);
72 pixmaps->append(pixmap); 72 pixmaps->append(pixmap);
73 bitBlt(pixmap, 0, 0, &PIXMAP, x*width, 0, width, height, CopyROP, TRUE); 73 bitBlt(pixmap, 0, 0, &PIXMAP, x*width, 0, width, height, CopyROP, TRUE);
74 bitBlt(&MASK, 0, 0, &BITMAP, x*width, 0, width, height, CopyROP, TRUE); 74 bitBlt(&MASK, 0, 0, &BITMAP, x*width, 0, width, height, CopyROP, TRUE);
75 pixmap->setMask(MASK); 75 pixmap->setMask(MASK);
76 } 76 }
77 77
78 return pixmaps; 78 return pixmaps;
79} 79}
80 80
81void Status::paintEvent( QPaintEvent *) 81void Status::paintEvent( QPaintEvent *)
82{ 82{
83 for (int x = 0; x < actualLifes && !lifesPix->isEmpty(); x++) 83 for (int x = 0; x < actualLifes && !lifesPix->isEmpty(); x++)
84 bitBlt(this, lifesPix->at(0)->width()+(lifesPix->at(0)->width()*x), 84 bitBlt(this, lifesPix->at(0)->width()+(lifesPix->at(0)->width()*x),
85 (height()-lifesPix->at(0)->height())/2, 85 (height()-lifesPix->at(0)->height())/2,
86 lifesPix->at(0), 0, 0, 86 lifesPix->at(0), 0, 0,
87 lifesPix->at(0)->width(), lifesPix->at(0)->height()); 87 lifesPix->at(0)->width(), lifesPix->at(0)->height());
88 88
89 for (int x = 0; x < actualLevel && !levelPix->isEmpty(); x++) { 89 for (int x = 0; x < actualLevel && !levelPix->isEmpty(); x++) {
90 erase((width()-levelPix->at(x)->width()*2)-(levelPix->at(x)->width()*levelPos[x]), 90 erase((width()-levelPix->at(x)->width()*2)-(levelPix->at(x)->width()*levelPos[x]),
91 (height()-levelPix->at(x)->height())/2, 91 (height()-levelPix->at(x)->height())/2,
92 levelPix->at(x)->width(), levelPix->at(x)->height()); 92 levelPix->at(x)->width(), levelPix->at(x)->height());
93 bitBlt(this, (width()-levelPix->at(x)->width()*2)-(levelPix->at(x)->width()*levelPos[x]), 93 bitBlt(this, (width()-levelPix->at(x)->width()*2)-(levelPix->at(x)->width()*levelPos[x]),
94 (height()-levelPix->at(x)->height())/2, 94 (height()-levelPix->at(x)->height())/2,
95 levelPix->at(x), 0, 0, 95 levelPix->at(x), 0, 0,
96 levelPix->at(x)->width(), levelPix->at(x)->height()); 96 levelPix->at(x)->width(), levelPix->at(x)->height());
97 } 97 }
98} 98}
99 99
100void Status::initPixmaps() 100void Status::initPixmaps()
101{ 101{
102 if (lastLifesPixmapName != lifesPixmapName.at(level)) { 102 if (lastLifesPixmapName != lifesPixmapName.at(level)) {
103 lifesPix = loadPixmap(this, lifesPixmapName.at(level), lifesPix); 103 lifesPix = loadPixmap(this, lifesPixmapName.at(level), lifesPix);
104 lastLifesPixmapName = lifesPixmapName.at(level); 104 lastLifesPixmapName = lifesPixmapName.at(level);
105 } 105 }
106 if (lastLevelPixmapName != levelPixmapName.at(level)) { 106 if (lastLevelPixmapName != levelPixmapName.at(level)) {
107 levelPix = loadPixmap(this, levelPixmapName.at(level), levelPix); 107 levelPix = loadPixmap(this, levelPixmapName.at(level), levelPix);
108 lastLevelPixmapName = levelPixmapName.at(level); 108 lastLevelPixmapName = levelPixmapName.at(level);
109 } 109 }
110} 110}
111 111
112QString Status::decodeHexOctString(QString s) 112QString Status::decodeHexOctString(QString s)
113{ 113{
114 QString value; 114 QString value;
115 QString valids; 115 QString valids;
116 int pos, xpos = 0, opos = 0; 116 int pos, xpos = 0, opos = 0;
117 int v, len, leadin; 117 int v, len, leadin;
118 const char *ptr; 118 const char *ptr;
119 uchar c; 119 uchar c;
120 120
121 while (((xpos = s.find(QRegExp("\\\\x[0-9a-fA-F]+"), xpos)) != -1) || 121 while (((xpos = s.find(QRegExp("\\\\x[0-9a-fA-F]+"), xpos)) != -1) ||
122 ((opos = s.find(QRegExp("\\\\[0-7]+"), opos)) != -1)) { 122 ((opos = s.find(QRegExp("\\\\[0-7]+"), opos)) != -1)) {
123 if (xpos != -1) { 123 if (xpos != -1) {
124 valids = "0123456789abcdef"; 124 valids = "0123456789abcdef";
125 leadin = 2; 125 leadin = 2;
126 pos = xpos; 126 pos = xpos;
127 } else { 127 } else {
128 valids = "01234567"; 128 valids = "01234567";
129 leadin = 1; 129 leadin = 1;
130 pos = opos; 130 pos = opos;
131 } 131 }
132 132
133 c = '\0'; 133 c = '\0';
134 len = 0; 134 len = 0;
135 value = s.mid(pos+leadin, 3); 135 value = s.mid(pos+leadin, 3);
136 ptr = (const char *) value; 136 ptr = (const char *) value;
137 137
138 while (*ptr != '\0' && (v = valids.find(*ptr++, 0, FALSE)) != -1) { 138 while (*ptr != '\0' && (v = valids.find(*ptr++, 0, FALSE)) != -1) {
139 c = (c * valids.length()) + v; 139 c = (c * valids.length()) + v;
140 len++; 140 len++;
141 } 141 }
142 142
143 value.fill(c, 1); 143 value.fill(c, 1);
144 s.replace(pos, len+leadin, value); 144 s.replace(pos, len+leadin, value);
145 } 145 }
146 146
147 return s; 147 return s;
148} 148}
149 149
150void Status::fillArray(QArray<int> &array, QString values, int max) 150void Status::fillArray(QArray<int> &array, QString values, int max)
151{ 151{
152 array.resize(max); 152 array.resize(max);
153 int last = 0; 153 int last = 0;
154 bool ok; 154 bool ok;
155 QString value; 155 QString value;
156 156
157 for (uint i = 0; i < array.size(); i++) { 157 for (uint i = 0; i < array.size(); i++) {
158 if (values.find(',') < 0 && values.length() > 0) { 158 if (values.find(',') < 0 && values.length() > 0) {
159 value = values; 159 value = values;
160 values = ""; 160 values = "";
161 } 161 }
162 if (values.find(',') >= 0) { 162 if (values.find(',') >= 0) {
163 value = values.left(values.find(',')); 163 value = values.left(values.find(','));
164 values.remove(0,values.find(',')+1); 164 values.remove(0,values.find(',')+1);
165 } 165 }
166 array[i] = value.toInt(&ok); 166 array[i] = value.toInt(&ok);
167 if (ok) 167 if (ok)
168 last = array[i]; 168 last = array[i];
169 else 169 else
170 array[i] = last; 170 array[i] = last;
171 } 171 }
172} 172}
173 173
174void Status::fillStrList(QStrList &list, QString values, int max) 174void Status::fillStrList(QStrList &list, QString values, int max)
175{ 175{
176 if (!list.isEmpty()) 176 if (!list.isEmpty())
177 list.clear(); 177 list.clear();
178 178
179 QString last = ""; 179 QString last = "";
180 QString value; 180 QString value;
181 181
182 for (uint i = 0; i < (uint) max; i++) { 182 for (uint i = 0; i < (uint) max; i++) {
183 if (values.find(',') < 0 && values.length() > 0) { 183 if (values.find(',') < 0 && values.length() > 0) {
184 value = values; 184 value = values;
185 values = ""; 185 values = "";
186 } 186 }
187 if (values.find(',') >= 0) { 187 if (values.find(',') >= 0) {
188 value = values.left(values.find(',')); 188 value = values.left(values.find(','));
189 values.remove(0,values.find(',')+1); 189 values.remove(0,values.find(',')+1);
190 } 190 }
191 if (!value.isEmpty()) 191 if (!value.isEmpty())
192 last = decodeHexOctString(value); 192 last = decodeHexOctString(value);
193 list.append(last); 193 list.append(last);
194 } 194 }
195} 195}
196 196
197void Status::fillPixmapName(QStrList &pixmapName) 197void Status::fillPixmapName(QStrList &pixmapName)
198{ 198{
199 QStrList list = pixmapName; 199 QStrList list = pixmapName;
200 200
201 if (!pixmapName.isEmpty()) 201 if (!pixmapName.isEmpty())
202 pixmapName.clear(); 202 pixmapName.clear();
203 203
204 QString pixmap; 204 QString pixmap;
205 205
206 QFileInfo fileInfo; 206 QFileInfo fileInfo;
207 207
208 for (uint i = 0; i < list.count(); i++) { 208 for (uint i = 0; i < list.count(); i++) {
209 pixmap = list.at(i); 209 pixmap = list.at(i);
210 210
211 if (pixmap.left(1) != "/" && pixmap.left(1) != "~") 211 if (pixmap.left(1) != "/" && pixmap.left(1) != "~")
212 pixmap = FIND_APP_DATA( pixmapDirectory+pixmap ); 212 pixmap = FIND_APP_DATA( pixmapDirectory+pixmap );
213 213
214 fileInfo.setFile(pixmap); 214 fileInfo.setFile(pixmap);
215 if (!fileInfo.isReadable() || !fileInfo.isFile()) 215 if (!fileInfo.isReadable() || !fileInfo.isFile())
216 pixmap = ""; 216 pixmap = "";
217 217
218 pixmapName.append(pixmap); 218 pixmapName.append(pixmap);
219 } 219 }
220} 220}
221 221
222void Status::confLevels(bool defGroup) 222void Status::confLevels(bool defGroup)
223{ 223{
224 APP_CONFIG_BEGIN( cfg ); 224 APP_CONFIG_BEGIN( cfg );
225 if (defGroup || cfg->hasKey("Levels")) 225 if (defGroup || cfg->hasKey("Levels"))
226 maxLevel = cfg->readNumEntry("Levels", 13); 226 maxLevel = cfg->readNumEntry("Levels", 13);
227 APP_CONFIG_END( cfg ); 227 APP_CONFIG_END( cfg );
228} 228}
229 229
230void Status::confMisc(bool defGroup) 230void Status::confMisc(bool defGroup)
231{ 231{
232 APP_CONFIG_BEGIN( cfg ); 232 APP_CONFIG_BEGIN( cfg );
233 if (defGroup || cfg->hasKey("LevelPosition")) 233 if (defGroup || cfg->hasKey("LevelPosition"))
234 fillArray(levelPos, cfg->readEntry("LevelPosition", "0,1,2,3,,4,,5,,6,,7"), maxLevel); 234 fillArray(levelPos, cfg->readEntry("LevelPosition", "0,1,2,3,,4,,5,,6,,7"), maxLevel);
235 235
236 if (defGroup || cfg->hasKey("PixmapDirectory")) { 236 if (defGroup || cfg->hasKey("PixmapDirectory")) {
237 pixmapDirectory = cfg->readEntry("PixmapDirectory"); 237 pixmapDirectory = cfg->readEntry("PixmapDirectory");
238 238
239 if (pixmapDirectory.left(1) != "/" && pixmapDirectory.left(1) != "~") 239 if (pixmapDirectory.left(1) != "/" && pixmapDirectory.left(1) != "~")
240 pixmapDirectory.insert(0, "pics/"); 240 pixmapDirectory.insert(0, "pics/");
241 if (pixmapDirectory.right(1) != "/") 241 if (pixmapDirectory.right(1) != "/")
242 pixmapDirectory.append("/"); 242 pixmapDirectory.append("/");
243 } 243 }
244 244
245 if (defGroup || cfg->hasKey("LifesPixmapName")) 245 if (defGroup || cfg->hasKey("LifesPixmapName"))
246 fillStrList(lifesPixmapName, 246 fillStrList(lifesPixmapName,
247 cfg->readEntry("LifesPixmapName", "lifes.xpm"), maxLevel+1); 247 cfg->readEntry("LifesPixmapName", "lifes.xpm"), maxLevel+1);
248 if (defGroup || cfg->hasKey("LevelPixmapName")) 248 if (defGroup || cfg->hasKey("LevelPixmapName"))
249 fillStrList(levelPixmapName, 249 fillStrList(levelPixmapName,
250 cfg->readEntry("LevelPixmapName", "level.xpm"), maxLevel+1); 250 cfg->readEntry("LevelPixmapName", "fruit.xpm"), maxLevel+1);
251 APP_CONFIG_END( cfg ); 251 APP_CONFIG_END( cfg );
252} 252}
253 253
254void Status::confScheme() 254void Status::confScheme()
255{ 255{
256 APP_CONFIG_BEGIN( cfg ); 256 APP_CONFIG_BEGIN( cfg );
257 SAVE_CONFIG_GROUP( cfg, oldgroup ); 257 SAVE_CONFIG_GROUP( cfg, oldgroup );
258 QString newgroup; 258 QString newgroup;
259 259
260 // if not set, read mode and scheme from the configfile 260 // if not set, read mode and scheme from the configfile
261 if (mode == -1 && scheme == -1) { 261 if (mode == -1 && scheme == -1) {
262 scheme = cfg->readNumEntry("Scheme", -1); 262 scheme = cfg->readNumEntry("Scheme", -1);
263 mode = cfg->readNumEntry("Mode", -1); 263 mode = cfg->readNumEntry("Mode", -1);
264 264
265 // if mode is not set in the defGroup-group, lookup the scheme group 265 // if mode is not set in the defGroup-group, lookup the scheme group
266 if (scheme != -1 || mode == -1) { 266 if (scheme != -1 || mode == -1) {
267 newgroup.sprintf("Scheme %d", scheme); 267 newgroup.sprintf("Scheme %d", scheme);
268 cfg->setGroup(newgroup); 268 cfg->setGroup(newgroup);
269 269
270 mode = cfg->readNumEntry("Mode", -1); 270 mode = cfg->readNumEntry("Mode", -1);
271 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 271 RESTORE_CONFIG_GROUP( cfg, oldgroup );
272 } 272 }
273 } 273 }
274 274
275 confLevels(); 275 confLevels();
276 276
277 if (mode != -1) { 277 if (mode != -1) {
278 newgroup.sprintf("Mode %d", mode); 278 newgroup.sprintf("Mode %d", mode);
279 cfg->setGroup(newgroup); 279 cfg->setGroup(newgroup);
280 280
281 confLevels(FALSE); 281 confLevels(FALSE);
282 } 282 }
283 283
284 if (scheme != -1) { 284 if (scheme != -1) {
285 newgroup.sprintf("Scheme %d", scheme); 285 newgroup.sprintf("Scheme %d", scheme);
286 cfg->setGroup(newgroup); 286 cfg->setGroup(newgroup);
287 287
288 confLevels(FALSE); 288 confLevels(FALSE);
289 } 289 }
290 290
291 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 291 RESTORE_CONFIG_GROUP( cfg, oldgroup );
292 292
293 confMisc(); 293 confMisc();
294 294
295 if (mode != -1) { 295 if (mode != -1) {
296 newgroup.sprintf("Mode %d", mode); 296 newgroup.sprintf("Mode %d", mode);
297 cfg->setGroup(newgroup); 297 cfg->setGroup(newgroup);
298 298
299 confMisc(FALSE); 299 confMisc(FALSE);
300 } 300 }
301 301
302 if (scheme != -1) { 302 if (scheme != -1) {
303 newgroup.sprintf("Scheme %d", scheme); 303 newgroup.sprintf("Scheme %d", scheme);
304 cfg->setGroup(newgroup); 304 cfg->setGroup(newgroup);
305 305
306 confMisc(FALSE); 306 confMisc(FALSE);
307 } 307 }
308 308
309 fillPixmapName(lifesPixmapName); 309 fillPixmapName(lifesPixmapName);
310 fillPixmapName(levelPixmapName); 310 fillPixmapName(levelPixmapName);
311 311
312 initPixmaps(); 312 initPixmaps();
313 313
314 setFixedHeight(minHeight()); 314 setFixedHeight(minHeight());
315 315
316 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 316 RESTORE_CONFIG_GROUP( cfg, oldgroup );
317 APP_CONFIG_END( cfg ); 317 APP_CONFIG_END( cfg );
318} 318}
319 319
320void Status::setScheme(int Scheme, int Mode) 320void Status::setScheme(int Scheme, int Mode)
321{ 321{
322 mode = Mode; 322 mode = Mode;
323 scheme = Scheme; 323 scheme = Scheme;
324 324
325 confScheme(); 325 confScheme();
326 326
327 repaint(); 327 repaint();
328} 328}
329 329
330int Status::minHeight() 330int Status::minHeight()
331{ 331{
332 if (lifesPix->isEmpty() && levelPix->isEmpty()) 332 if (lifesPix->isEmpty() && levelPix->isEmpty())
333 return 0; 333 return 0;
334 if (levelPix->isEmpty()) 334 if (levelPix->isEmpty())
335 return lifesPix->at(0)->height(); 335 return lifesPix->at(0)->height();
336 if (lifesPix->isEmpty()) 336 if (lifesPix->isEmpty())
337 return levelPix->at(0)->height(); 337 return levelPix->at(0)->height();
338 return (lifesPix->at(0)->height() > levelPix->at(0)->height()) ? 338 return (lifesPix->at(0)->height() > levelPix->at(0)->height()) ?
339 lifesPix->at(0)->height() : levelPix->at(0)->height(); 339 lifesPix->at(0)->height() : levelPix->at(0)->height();
340} 340}
341 341
342int Status::minWidth() 342int Status::minWidth()
343{ 343{
344 if (lifesPix->isEmpty() && levelPix->isEmpty()) 344 if (lifesPix->isEmpty() && levelPix->isEmpty())
345 return 0; 345 return 0;
346 if (levelPix->isEmpty()) 346 if (levelPix->isEmpty())
347 return lifesPix->at(0)->width(); 347 return lifesPix->at(0)->width();
348 if (lifesPix->isEmpty()) 348 if (lifesPix->isEmpty())
349 return levelPix->at(0)->width(); 349 return levelPix->at(0)->width();
350 return (lifesPix->at(0)->width() > levelPix->at(0)->width()) ? 350 return (lifesPix->at(0)->width() > levelPix->at(0)->width()) ?
351 lifesPix->at(0)->width() : levelPix->at(0)->width(); 351 lifesPix->at(0)->width() : levelPix->at(0)->width();
352} 352}
353 353
354void Status::setLifes(int lifes) 354void Status::setLifes(int lifes)
355{ 355{
356 actualLifes = lifes; 356 actualLifes = lifes;
357 repaint(); 357 repaint();
358} 358}
359 359
360void Status::setLevel(int Level) 360void Status::setLevel(int Level)
361{ 361{
362 level = Level; 362 level = Level;
363 363
364 initPixmaps(); 364 initPixmaps();
365 365
366 actualLevel = (level > (int) levelPix->count()) ? (int) levelPix->count() : level; 366 actualLevel = (level > (int) levelPix->count()) ? (int) levelPix->count() : level;
367 repaint(); 367 repaint();
368} 368}