summaryrefslogtreecommitdiff
Unidiff
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,253 +1,256 @@
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();
@@ -256,109 +259,110 @@ void Kpacman::toggleHallOfFame()
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,108 +1,108 @@
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
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,106 +1,106 @@
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,
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,110 +1,110 @@
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)) {
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,108 +1,108 @@
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);
@@ -154,193 +154,193 @@ void Status::fillArray(QArray<int> &array, QString values, int max)
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())