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