summaryrefslogtreecommitdiff
authorsimon <simon>2002-04-30 14:49:30 (UTC)
committer simon <simon>2002-04-30 14:49:30 (UTC)
commitc959b0c2170d2c12f93f5fa04ff02ca4c7c0ef4a (patch) (unidiff)
treee85e8136aeb87c582e958a48f8428765ef7b99be
parenta0cdb6f85e270e20bd5383e980df9dcf862a93ce (diff)
downloadopie-c959b0c2170d2c12f93f5fa04ff02ca4c7c0ef4a.zip
opie-c959b0c2170d2c12f93f5fa04ff02ca4c7c0ef4a.tar.gz
opie-c959b0c2170d2c12f93f5fa04ff02ca4c7c0ef4a.tar.bz2
- resolved clash between const char *name and struct utsname name
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/qasteroids/toplevel.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/games/qasteroids/toplevel.cpp b/noncore/games/qasteroids/toplevel.cpp
index 090099f..71daf60 100644
--- a/noncore/games/qasteroids/toplevel.cpp
+++ b/noncore/games/qasteroids/toplevel.cpp
@@ -1,532 +1,532 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 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 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 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************//* 19**********************************************************************//*
20 * KAsteroids - Copyright (c) Martin R. Jones 1997 20 * KAsteroids - Copyright (c) Martin R. Jones 1997
21 * 21 *
22 * Part of the KDE project 22 * Part of the KDE project
23 */ 23 */
24 //--- toplevel.cpp --- 24 //--- toplevel.cpp ---
25 25
26#include "toplevel.h" 26#include "toplevel.h"
27#include "ledmeter.h" 27#include "ledmeter.h"
28 28
29#include <qpe/qpeapplication.h> 29#include <qpe/qpeapplication.h>
30#include <qpe/resource.h> 30#include <qpe/resource.h>
31 31
32#include <qaccel.h> 32#include <qaccel.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qlcdnumber.h> 35#include <qlcdnumber.h>
36#include <qpushbutton.h> 36#include <qpushbutton.h>
37 37
38#include <sys/utsname.h> 38#include <sys/utsname.h>
39 39
40 40
41 #define SB_SCORE1 41 #define SB_SCORE1
42 #define SB_LEVEL2 42 #define SB_LEVEL2
43 #define SB_SHIPS3 43 #define SB_SHIPS3
44 44
45struct SLevel 45struct SLevel
46{ 46{
47 int nrocks; 47 int nrocks;
48 double rockSpeed; 48 double rockSpeed;
49}; 49};
50 50
51 #define MAX_LEVELS16 51 #define MAX_LEVELS16
52 52
53SLevel levels[MAX_LEVELS] = 53SLevel levels[MAX_LEVELS] =
54{ 54{
55 { 1, 0.4 }, 55 { 1, 0.4 },
56 { 1, 0.6 }, 56 { 1, 0.6 },
57 { 2, 0.5 }, 57 { 2, 0.5 },
58 { 2, 0.7 }, 58 { 2, 0.7 },
59 { 2, 0.8 }, 59 { 2, 0.8 },
60 { 3, 0.6 }, 60 { 3, 0.6 },
61 { 3, 0.7 }, 61 { 3, 0.7 },
62 { 3, 0.8 }, 62 { 3, 0.8 },
63 { 4, 0.6 }, 63 { 4, 0.6 },
64 { 4, 0.7 }, 64 { 4, 0.7 },
65 { 4, 0.8 }, 65 { 4, 0.8 },
66 { 5, 0.7 }, 66 { 5, 0.7 },
67 { 5, 0.8 }, 67 { 5, 0.8 },
68 { 5, 0.9 }, 68 { 5, 0.9 },
69 { 5, 1.0 } 69 { 5, 1.0 }
70}; 70};
71 71
72const char *soundEvents[] = 72const char *soundEvents[] =
73{ 73{
74 "ShipDestroyed", 74 "ShipDestroyed",
75 "RockDestroyed", 75 "RockDestroyed",
76 0 76 0
77}; 77};
78 78
79const char *soundDefaults[] = 79const char *soundDefaults[] =
80{ 80{
81 "Explosion.wav", 81 "Explosion.wav",
82 "ploop.wav", 82 "ploop.wav",
83 0 83 0
84}; 84};
85 85
86 86
87KAstTopLevel::KAstTopLevel( QWidget *parent, const char *name ) 87KAstTopLevel::KAstTopLevel( QWidget *parent, const char *_name )
88 : QMainWindow( parent, name ) 88 : QMainWindow( parent, _name )
89{ 89{
90 setCaption( tr("Asteroids") ); 90 setCaption( tr("Asteroids") );
91 QWidget *border = new QWidget( this ); 91 QWidget *border = new QWidget( this );
92 border->setBackgroundColor( black ); 92 border->setBackgroundColor( black );
93 setCentralWidget( border ); 93 setCentralWidget( border );
94 94
95 QVBoxLayout *borderLayout = new QVBoxLayout( border ); 95 QVBoxLayout *borderLayout = new QVBoxLayout( border );
96 96
97 QWidget *mainWin = new QWidget( border ); 97 QWidget *mainWin = new QWidget( border );
98 borderLayout->addWidget( mainWin, 2, AlignHCenter ); 98 borderLayout->addWidget( mainWin, 2, AlignHCenter );
99 99
100 view = new KAsteroidsView( mainWin ); 100 view = new KAsteroidsView( mainWin );
101 connect( view, SIGNAL( shipKilled() ), SLOT( slotShipKilled() ) ); 101 connect( view, SIGNAL( shipKilled() ), SLOT( slotShipKilled() ) );
102 connect( view, SIGNAL( rockHit(int) ), SLOT( slotRockHit(int) ) ); 102 connect( view, SIGNAL( rockHit(int) ), SLOT( slotRockHit(int) ) );
103 connect( view, SIGNAL( rocksRemoved() ), SLOT( slotRocksRemoved() ) ); 103 connect( view, SIGNAL( rocksRemoved() ), SLOT( slotRocksRemoved() ) );
104 connect( view, SIGNAL( updateVitals() ), SLOT( slotUpdateVitals() ) ); 104 connect( view, SIGNAL( updateVitals() ), SLOT( slotUpdateVitals() ) );
105 105
106 QVBoxLayout *vb = new QVBoxLayout( mainWin ); 106 QVBoxLayout *vb = new QVBoxLayout( mainWin );
107 QHBoxLayout *hb = new QHBoxLayout; 107 QHBoxLayout *hb = new QHBoxLayout;
108 QHBoxLayout *hbd = new QHBoxLayout; 108 QHBoxLayout *hbd = new QHBoxLayout;
109 vb->addLayout( hb ); 109 vb->addLayout( hb );
110 110
111 QFont labelFont( "helvetica", 12 ); 111 QFont labelFont( "helvetica", 12 );
112 QColorGroup grp( darkGreen, black, QColor( 128, 128, 128 ), 112 QColorGroup grp( darkGreen, black, QColor( 128, 128, 128 ),
113 QColor( 64, 64, 64 ), black, darkGreen, black ); 113 QColor( 64, 64, 64 ), black, darkGreen, black );
114 QPalette pal( grp, grp, grp ); 114 QPalette pal( grp, grp, grp );
115 115
116 mainWin->setPalette( pal ); 116 mainWin->setPalette( pal );
117 117
118 QLabel *label; 118 QLabel *label;
119 label = new QLabel( tr("Score"), mainWin ); 119 label = new QLabel( tr("Score"), mainWin );
120 label->setFont( labelFont ); 120 label->setFont( labelFont );
121 label->setPalette( pal ); 121 label->setPalette( pal );
122// label->setFixedWidth( label->sizeHint().width() ); 122// label->setFixedWidth( label->sizeHint().width() );
123 hb->addWidget( label ); 123 hb->addWidget( label );
124 124
125 scoreLCD = new QLCDNumber( 5, mainWin ); 125 scoreLCD = new QLCDNumber( 5, mainWin );
126 scoreLCD->setFrameStyle( QFrame::NoFrame ); 126 scoreLCD->setFrameStyle( QFrame::NoFrame );
127 scoreLCD->setSegmentStyle( QLCDNumber::Flat ); 127 scoreLCD->setSegmentStyle( QLCDNumber::Flat );
128 scoreLCD->setFixedHeight( 16 ); 128 scoreLCD->setFixedHeight( 16 );
129 scoreLCD->setPalette( pal ); 129 scoreLCD->setPalette( pal );
130 hb->addWidget( scoreLCD ); 130 hb->addWidget( scoreLCD );
131 hb->addStretch( 1 ); 131 hb->addStretch( 1 );
132 132
133 label = new QLabel( tr("Level"), mainWin ); 133 label = new QLabel( tr("Level"), mainWin );
134 label->setFont( labelFont ); 134 label->setFont( labelFont );
135 label->setPalette( pal ); 135 label->setPalette( pal );
136// label->setFixedWidth( label->sizeHint().width() ); 136// label->setFixedWidth( label->sizeHint().width() );
137 hb->addWidget( label ); 137 hb->addWidget( label );
138 138
139 levelLCD = new QLCDNumber( 2, mainWin ); 139 levelLCD = new QLCDNumber( 2, mainWin );
140 levelLCD->setFrameStyle( QFrame::NoFrame ); 140 levelLCD->setFrameStyle( QFrame::NoFrame );
141 levelLCD->setSegmentStyle( QLCDNumber::Flat ); 141 levelLCD->setSegmentStyle( QLCDNumber::Flat );
142 levelLCD->setFixedHeight( 16 ); 142 levelLCD->setFixedHeight( 16 );
143 levelLCD->setPalette( pal ); 143 levelLCD->setPalette( pal );
144 hb->addWidget( levelLCD ); 144 hb->addWidget( levelLCD );
145 hb->addStretch( 1 ); 145 hb->addStretch( 1 );
146 146
147 label = new QLabel( tr("Ships"), mainWin ); 147 label = new QLabel( tr("Ships"), mainWin );
148 label->setFont( labelFont ); 148 label->setFont( labelFont );
149// label->setFixedWidth( label->sizeHint().width() ); 149// label->setFixedWidth( label->sizeHint().width() );
150 label->setPalette( pal ); 150 label->setPalette( pal );
151 hb->addWidget( label ); 151 hb->addWidget( label );
152 152
153 shipsLCD = new QLCDNumber( 1, mainWin ); 153 shipsLCD = new QLCDNumber( 1, mainWin );
154 shipsLCD->setFrameStyle( QFrame::NoFrame ); 154 shipsLCD->setFrameStyle( QFrame::NoFrame );
155 shipsLCD->setSegmentStyle( QLCDNumber::Flat ); 155 shipsLCD->setSegmentStyle( QLCDNumber::Flat );
156 shipsLCD->setFixedHeight( 16 ); 156 shipsLCD->setFixedHeight( 16 );
157 shipsLCD->setPalette( pal ); 157 shipsLCD->setPalette( pal );
158 hb->addWidget( shipsLCD ); 158 hb->addWidget( shipsLCD );
159 159
160// hb->addStrut( 14 ); 160// hb->addStrut( 14 );
161 161
162 vb->addWidget( view, 10 ); 162 vb->addWidget( view, 10 );
163 163
164// -- bottom layout: 164// -- bottom layout:
165 vb->addLayout( hbd ); 165 vb->addLayout( hbd );
166 166
167 QFont smallFont( "helvetica", 12 ); 167 QFont smallFont( "helvetica", 12 );
168 hbd->addSpacing( 5 ); 168 hbd->addSpacing( 5 );
169 169
170/* 170/*
171 label = new QLabel( tr( "T" ), mainWin ); 171 label = new QLabel( tr( "T" ), mainWin );
172 label->setFont( smallFont ); 172 label->setFont( smallFont );
173 label->setFixedWidth( label->sizeHint().width() ); 173 label->setFixedWidth( label->sizeHint().width() );
174 label->setPalette( pal ); 174 label->setPalette( pal );
175 hbd->addWidget( label ); 175 hbd->addWidget( label );
176 176
177 teleportsLCD = new QLCDNumber( 1, mainWin ); 177 teleportsLCD = new QLCDNumber( 1, mainWin );
178 teleportsLCD->setFrameStyle( QFrame::NoFrame ); 178 teleportsLCD->setFrameStyle( QFrame::NoFrame );
179 teleportsLCD->setSegmentStyle( QLCDNumber::Flat ); 179 teleportsLCD->setSegmentStyle( QLCDNumber::Flat );
180 teleportsLCD->setPalette( pal ); 180 teleportsLCD->setPalette( pal );
181 teleportsLCD->setFixedHeight( 18 ); 181 teleportsLCD->setFixedHeight( 18 );
182 hbd->addWidget( teleportsLCD ); 182 hbd->addWidget( teleportsLCD );
183 183
184 hbd->addSpacing( 10 ); 184 hbd->addSpacing( 10 );
185*/ 185*/
186 label = new QLabel( mainWin ); 186 label = new QLabel( mainWin );
187 label->setPixmap( Resource::loadPixmap("qasteroids/powerups/brake.png") ); 187 label->setPixmap( Resource::loadPixmap("qasteroids/powerups/brake.png") );
188 label->setFixedWidth( 16 ); 188 label->setFixedWidth( 16 );
189 label->setPalette( pal ); 189 label->setPalette( pal );
190 hbd->addWidget( label ); 190 hbd->addWidget( label );
191 191
192 brakesLCD = new QLCDNumber( 1, mainWin ); 192 brakesLCD = new QLCDNumber( 1, mainWin );
193 brakesLCD->setFrameStyle( QFrame::NoFrame ); 193 brakesLCD->setFrameStyle( QFrame::NoFrame );
194 brakesLCD->setSegmentStyle( QLCDNumber::Flat ); 194 brakesLCD->setSegmentStyle( QLCDNumber::Flat );
195 brakesLCD->setPalette( pal ); 195 brakesLCD->setPalette( pal );
196 brakesLCD->setFixedHeight( 16 ); 196 brakesLCD->setFixedHeight( 16 );
197 hbd->addWidget( brakesLCD ); 197 hbd->addWidget( brakesLCD );
198 198
199 hbd->addSpacing( 5 ); 199 hbd->addSpacing( 5 );
200 200
201 label = new QLabel( mainWin ); 201 label = new QLabel( mainWin );
202 label->setPixmap( Resource::loadPixmap("qasteroids/powerups/shield.png") ); 202 label->setPixmap( Resource::loadPixmap("qasteroids/powerups/shield.png") );
203 label->setFixedWidth( 16 ); 203 label->setFixedWidth( 16 );
204 label->setPalette( pal ); 204 label->setPalette( pal );
205 hbd->addWidget( label ); 205 hbd->addWidget( label );
206 206
207 shieldLCD = new QLCDNumber( 1, mainWin ); 207 shieldLCD = new QLCDNumber( 1, mainWin );
208 shieldLCD->setFrameStyle( QFrame::NoFrame ); 208 shieldLCD->setFrameStyle( QFrame::NoFrame );
209 shieldLCD->setSegmentStyle( QLCDNumber::Flat ); 209 shieldLCD->setSegmentStyle( QLCDNumber::Flat );
210 shieldLCD->setPalette( pal ); 210 shieldLCD->setPalette( pal );
211 shieldLCD->setFixedHeight( 16 ); 211 shieldLCD->setFixedHeight( 16 );
212 hbd->addWidget( shieldLCD ); 212 hbd->addWidget( shieldLCD );
213 213
214 hbd->addSpacing( 5 ); 214 hbd->addSpacing( 5 );
215 215
216 label = new QLabel( mainWin ); 216 label = new QLabel( mainWin );
217 label->setPixmap( Resource::loadPixmap("qasteroids/powerups/shoot.png") ); 217 label->setPixmap( Resource::loadPixmap("qasteroids/powerups/shoot.png") );
218 label->setFixedWidth( 16 ); 218 label->setFixedWidth( 16 );
219 label->setPalette( pal ); 219 label->setPalette( pal );
220 hbd->addWidget( label ); 220 hbd->addWidget( label );
221 221
222 shootLCD = new QLCDNumber( 1, mainWin ); 222 shootLCD = new QLCDNumber( 1, mainWin );
223 shootLCD->setFrameStyle( QFrame::NoFrame ); 223 shootLCD->setFrameStyle( QFrame::NoFrame );
224 shootLCD->setSegmentStyle( QLCDNumber::Flat ); 224 shootLCD->setSegmentStyle( QLCDNumber::Flat );
225 shootLCD->setPalette( pal ); 225 shootLCD->setPalette( pal );
226 shootLCD->setFixedHeight( 16 ); 226 shootLCD->setFixedHeight( 16 );
227 hbd->addWidget( shootLCD ); 227 hbd->addWidget( shootLCD );
228 228
229 hbd->addStretch( 1 ); 229 hbd->addStretch( 1 );
230 230
231 label = new QLabel( tr( "Fuel" ), mainWin ); 231 label = new QLabel( tr( "Fuel" ), mainWin );
232 label->setFont( smallFont ); 232 label->setFont( smallFont );
233 label->setFixedWidth( label->sizeHint().width() + 5 ); 233 label->setFixedWidth( label->sizeHint().width() + 5 );
234 label->setPalette( pal ); 234 label->setPalette( pal );
235 hbd->addWidget( label ); 235 hbd->addWidget( label );
236 236
237 powerMeter = new KALedMeter( mainWin ); 237 powerMeter = new KALedMeter( mainWin );
238 powerMeter->setFrameStyle( QFrame::Box | QFrame::Plain ); 238 powerMeter->setFrameStyle( QFrame::Box | QFrame::Plain );
239 powerMeter->setRange( MAX_POWER_LEVEL ); 239 powerMeter->setRange( MAX_POWER_LEVEL );
240 powerMeter->addColorRange( 10, darkRed ); 240 powerMeter->addColorRange( 10, darkRed );
241 powerMeter->addColorRange( 20, QColor(160, 96, 0) ); 241 powerMeter->addColorRange( 20, QColor(160, 96, 0) );
242 powerMeter->addColorRange( 70, darkGreen ); 242 powerMeter->addColorRange( 70, darkGreen );
243 powerMeter->setCount( 15 ); 243 powerMeter->setCount( 15 );
244 powerMeter->setPalette( pal ); 244 powerMeter->setPalette( pal );
245 powerMeter->setFixedSize( 60, 12 ); 245 powerMeter->setFixedSize( 60, 12 );
246 hbd->addWidget( powerMeter ); 246 hbd->addWidget( powerMeter );
247 247
248 shipsRemain = 3; 248 shipsRemain = 3;
249 showHiscores = FALSE; 249 showHiscores = FALSE;
250 250
251 actions.insert( Qt::Key_Up, Thrust ); 251 actions.insert( Qt::Key_Up, Thrust );
252 actions.insert( Qt::Key_Left, RotateLeft ); 252 actions.insert( Qt::Key_Left, RotateLeft );
253 actions.insert( Qt::Key_Right, RotateRight ); 253 actions.insert( Qt::Key_Right, RotateRight );
254 actions.insert( Qt::Key_Enter, Shoot ); 254 actions.insert( Qt::Key_Enter, Shoot );
255 actions.insert( Qt::Key_Z, Teleport ); 255 actions.insert( Qt::Key_Z, Teleport );
256 actions.insert( Qt::Key_Down, Brake ); 256 actions.insert( Qt::Key_Down, Brake );
257 actions.insert( Qt::Key_P, Pause ); 257 actions.insert( Qt::Key_P, Pause );
258 258
259 259
260 struct utsname name; /* check for embedix kernel running on the zaurus, if 260 struct utsname name; /* check for embedix kernel running on the zaurus, if
261 lineo change string, this break 261 lineo change string, this break
262 */ 262 */
263 if (uname(&name) != -1) { 263 if (uname(&name) != -1) {
264 QString release=name.release; 264 QString release=name.release;
265 if(release.find("embedix",0,TRUE) !=-1) { 265 if(release.find("embedix",0,TRUE) !=-1) {
266 actions.insert( Key_F12, Launch ); 266 actions.insert( Key_F12, Launch );
267 actions.insert( Key_F11, Shield ); 267 actions.insert( Key_F11, Shield );
268 actions.insert( Key_F9, NewGame ); 268 actions.insert( Key_F9, NewGame );
269 } else { 269 } else {
270 // ipaq 270 // ipaq
271 actions.insert( Key_F12, Shoot ); 271 actions.insert( Key_F12, Shoot );
272 actions.insert( Key_F11, Shield ); 272 actions.insert( Key_F11, Shield );
273 actions.insert( Key_F10, Launch ); 273 actions.insert( Key_F10, Launch );
274 actions.insert( Key_F9, NewGame ); 274 actions.insert( Key_F9, NewGame );
275 } 275 }
276 } 276 }
277 277
278// actions.insert( Qt::Key_S, Shield ); 278// actions.insert( Qt::Key_S, Shield );
279// actions.insert( Qt::Key_X, Brake ); 279// actions.insert( Qt::Key_X, Brake );
280// actions.insert( Qt::Key_L, Launch ); 280// actions.insert( Qt::Key_L, Launch );
281 actions.insert( Qt::Key_Space, Shoot ); 281 actions.insert( Qt::Key_Space, Shoot );
282 282
283 view->showText( tr( "Press Calendar to start playing" ), yellow ); 283 view->showText( tr( "Press Calendar to start playing" ), yellow );
284 284
285 setFocusPolicy( StrongFocus ); 285 setFocusPolicy( StrongFocus );
286 286
287 slotNewGame(); 287 slotNewGame();
288} 288}
289 289
290KAstTopLevel::~KAstTopLevel() 290KAstTopLevel::~KAstTopLevel()
291{ 291{
292} 292}
293 293
294void KAstTopLevel::playSound( const char * ) 294void KAstTopLevel::playSound( const char * )
295{ 295{
296} 296}
297 297
298void KAstTopLevel::keyPressEvent( QKeyEvent *event ) 298void KAstTopLevel::keyPressEvent( QKeyEvent *event )
299{ 299{
300 if ( event->isAutoRepeat() || !actions.contains( event->key() ) ) 300 if ( event->isAutoRepeat() || !actions.contains( event->key() ) )
301 { 301 {
302 event->ignore(); 302 event->ignore();
303 return; 303 return;
304 } 304 }
305 305
306 Action a = actions[ event->key() ]; 306 Action a = actions[ event->key() ];
307 307
308 switch ( a ) 308 switch ( a )
309 { 309 {
310 case RotateLeft: 310 case RotateLeft:
311 view->rotateLeft( TRUE ); 311 view->rotateLeft( TRUE );
312 break; 312 break;
313 313
314 case RotateRight: 314 case RotateRight:
315 view->rotateRight( TRUE ); 315 view->rotateRight( TRUE );
316 break; 316 break;
317 317
318 case Thrust: 318 case Thrust:
319 view->thrust( TRUE ); 319 view->thrust( TRUE );
320 break; 320 break;
321 321
322 case Shoot: 322 case Shoot:
323 view->shoot( TRUE ); 323 view->shoot( TRUE );
324 break; 324 break;
325 325
326 case Shield: 326 case Shield:
327 view->setShield( TRUE ); 327 view->setShield( TRUE );
328 break; 328 break;
329 329
330 case Teleport: 330 case Teleport:
331 view->teleport( TRUE ); 331 view->teleport( TRUE );
332 break; 332 break;
333 333
334 case Brake: 334 case Brake:
335 view->brake( TRUE ); 335 view->brake( TRUE );
336 break; 336 break;
337 337
338 default: 338 default:
339 event->ignore(); 339 event->ignore();
340 return; 340 return;
341 } 341 }
342 event->accept(); 342 event->accept();
343} 343}
344 344
345void KAstTopLevel::keyReleaseEvent( QKeyEvent *event ) 345void KAstTopLevel::keyReleaseEvent( QKeyEvent *event )
346{ 346{
347 if ( event->isAutoRepeat() || !actions.contains( event->key() ) ) 347 if ( event->isAutoRepeat() || !actions.contains( event->key() ) )
348 { 348 {
349 event->ignore(); 349 event->ignore();
350 return; 350 return;
351 } 351 }
352 352
353 Action a = actions[ event->key() ]; 353 Action a = actions[ event->key() ];
354 354
355 switch ( a ) 355 switch ( a )
356 { 356 {
357 case RotateLeft: 357 case RotateLeft:
358 view->rotateLeft( FALSE ); 358 view->rotateLeft( FALSE );
359 break; 359 break;
360 360
361 case RotateRight: 361 case RotateRight:
362 view->rotateRight( FALSE ); 362 view->rotateRight( FALSE );
363 break; 363 break;
364 364
365 case Thrust: 365 case Thrust:
366 view->thrust( FALSE ); 366 view->thrust( FALSE );
367 break; 367 break;
368 368
369 case Shoot: 369 case Shoot:
370 view->shoot( FALSE ); 370 view->shoot( FALSE );
371 break; 371 break;
372 372
373 case Brake: 373 case Brake:
374 view->brake( FALSE ); 374 view->brake( FALSE );
375 break; 375 break;
376 376
377 case Shield: 377 case Shield:
378 view->setShield( FALSE ); 378 view->setShield( FALSE );
379 break; 379 break;
380 380
381 case Teleport: 381 case Teleport:
382 view->teleport( FALSE ); 382 view->teleport( FALSE );
383 break; 383 break;
384 384
385 case Launch: 385 case Launch:
386 if ( waitShip ) 386 if ( waitShip )
387 { 387 {
388 view->newShip(); 388 view->newShip();
389 waitShip = FALSE; 389 waitShip = FALSE;
390 view->hideText(); 390 view->hideText();
391 } 391 }
392 else 392 else
393 { 393 {
394 event->ignore(); 394 event->ignore();
395 return; 395 return;
396 } 396 }
397 break; 397 break;
398 398
399 case NewGame: 399 case NewGame:
400 slotNewGame(); 400 slotNewGame();
401 break; 401 break;
402/* 402/*
403 case Pause: 403 case Pause:
404 { 404 {
405 view->pause( TRUE ); 405 view->pause( TRUE );
406 QMessageBox::information( this, 406 QMessageBox::information( this,
407 tr("KAsteroids is paused"), 407 tr("KAsteroids is paused"),
408 tr("Paused") ); 408 tr("Paused") );
409 view->pause( FALSE ); 409 view->pause( FALSE );
410 } 410 }
411 break; 411 break;
412*/ 412*/
413 default: 413 default:
414 event->ignore(); 414 event->ignore();
415 return; 415 return;
416 } 416 }
417 417
418 event->accept(); 418 event->accept();
419} 419}
420 420
421void KAstTopLevel::showEvent( QShowEvent *e ) 421void KAstTopLevel::showEvent( QShowEvent *e )
422{ 422{
423 QMainWindow::showEvent( e ); 423 QMainWindow::showEvent( e );
424 view->pause( FALSE ); 424 view->pause( FALSE );
425 setFocus(); 425 setFocus();
426} 426}
427 427
428void KAstTopLevel::hideEvent( QHideEvent *e ) 428void KAstTopLevel::hideEvent( QHideEvent *e )
429{ 429{
430 QMainWindow::hideEvent( e ); 430 QMainWindow::hideEvent( e );
431 view->pause( TRUE ); 431 view->pause( TRUE );
432} 432}
433 433
434void KAstTopLevel::focusInEvent( QFocusEvent * ) 434void KAstTopLevel::focusInEvent( QFocusEvent * )
435{ 435{
436 view->pause( FALSE ); 436 view->pause( FALSE );
437 setFocus(); 437 setFocus();
438} 438}
439 439
440void KAstTopLevel::focusOutEvent( QFocusEvent * ) 440void KAstTopLevel::focusOutEvent( QFocusEvent * )
441{ 441{
442 view->pause( TRUE ); 442 view->pause( TRUE );
443} 443}
444 444
445void KAstTopLevel::slotNewGame() 445void KAstTopLevel::slotNewGame()
446{ 446{
447 shipsRemain = 3; 447 shipsRemain = 3;
448 score = 0; 448 score = 0;
449 scoreLCD->display( 0 ); 449 scoreLCD->display( 0 );
450 level = 0; 450 level = 0;
451 levelLCD->display( level+1 ); 451 levelLCD->display( level+1 );
452 shipsLCD->display( shipsRemain-1 ); 452 shipsLCD->display( shipsRemain-1 );
453 view->newGame(); 453 view->newGame();
454 view->setRockSpeed( levels[0].rockSpeed ); 454 view->setRockSpeed( levels[0].rockSpeed );
455 view->addRocks( levels[0].nrocks ); 455 view->addRocks( levels[0].nrocks );
456 view->newShip(); 456 view->newShip();
457 waitShip = FALSE; 457 waitShip = FALSE;
458 view->hideText(); 458 view->hideText();
459 isPaused = FALSE; 459 isPaused = FALSE;
460} 460}
461 461
462void KAstTopLevel::slotShipKilled() 462void KAstTopLevel::slotShipKilled()
463{ 463{
464 shipsRemain--; 464 shipsRemain--;
465 shipsLCD->display( shipsRemain-1 ); 465 shipsLCD->display( shipsRemain-1 );
466 466
467 playSound( "ShipDestroyed" ); 467 playSound( "ShipDestroyed" );
468 468
469 if ( shipsRemain > 0 ) 469 if ( shipsRemain > 0 )
470 { 470 {
471 waitShip = TRUE; 471 waitShip = TRUE;
472 view->showText( tr( "Ship Destroyed.\nPress Contacts/Home key."), yellow ); 472 view->showText( tr( "Ship Destroyed.\nPress Contacts/Home key."), yellow );
473 } 473 }
474 else 474 else
475 { 475 {
476 view->endGame(); 476 view->endGame();
477 doStats(); 477 doStats();
478 } 478 }
479} 479}
480 480
481void KAstTopLevel::slotRockHit( int size ) 481void KAstTopLevel::slotRockHit( int size )
482{ 482{
483 switch ( size ) 483 switch ( size )
484 { 484 {
485 case 0: 485 case 0:
486 score += 10; 486 score += 10;
487 break; 487 break;
488 488
489 case 1: 489 case 1:
490 score += 20; 490 score += 20;
491 break; 491 break;
492 492
493 default: 493 default:
494 score += 40; 494 score += 40;
495 } 495 }
496 496
497 playSound( "RockDestroyed" ); 497 playSound( "RockDestroyed" );
498 498
499 scoreLCD->display( score ); 499 scoreLCD->display( score );
500} 500}
501 501
502void KAstTopLevel::slotRocksRemoved() 502void KAstTopLevel::slotRocksRemoved()
503{ 503{
504 level++; 504 level++;
505 505
506 if ( level >= MAX_LEVELS ) 506 if ( level >= MAX_LEVELS )
507 level = MAX_LEVELS - 1; 507 level = MAX_LEVELS - 1;
508 508
509 view->setRockSpeed( levels[level-1].rockSpeed ); 509 view->setRockSpeed( levels[level-1].rockSpeed );
510 view->addRocks( levels[level-1].nrocks ); 510 view->addRocks( levels[level-1].nrocks );
511 511
512 levelLCD->display( level+1 ); 512 levelLCD->display( level+1 );
513} 513}
514 514
515void KAstTopLevel::doStats() 515void KAstTopLevel::doStats()
516{ 516{
517 QString r( "0.00" ); 517 QString r( "0.00" );
518 if ( view->shots() ) 518 if ( view->shots() )
519 r = QString::number( (double)view->hits() / view->shots() * 100.0, 519 r = QString::number( (double)view->hits() / view->shots() * 100.0,
520 'g', 2 ); 520 'g', 2 );
521 521
522 view->showText( tr( "Game Over.\nPress Calendar for a new game." ), yellow, FALSE ); 522 view->showText( tr( "Game Over.\nPress Calendar for a new game." ), yellow, FALSE );
523} 523}
524 524
525void KAstTopLevel::slotUpdateVitals() 525void KAstTopLevel::slotUpdateVitals()
526{ 526{
527 brakesLCD->display( view->brakeCount() ); 527 brakesLCD->display( view->brakeCount() );
528 shieldLCD->display( view->shieldCount() ); 528 shieldLCD->display( view->shieldCount() );
529 shootLCD->display( view->shootCount() ); 529 shootLCD->display( view->shootCount() );
530// teleportsLCD->display( view->teleportCount() ); 530// teleportsLCD->display( view->teleportCount() );
531 powerMeter->setValue( view->power() ); 531 powerMeter->setValue( view->power() );
532} 532}