summaryrefslogtreecommitdiff
Side-by-side diff
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,85 +1,87 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************//*
* KAsteroids - Copyright (c) Martin R. Jones 1997
*
* Part of the KDE project
*/
// --- toplevel.cpp ---
#include "toplevel.h"
#include "ledmeter.h"
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include <qaccel.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlcdnumber.h>
#include <qpushbutton.h>
+#include <sys/utsname.h>
+
#define SB_SCORE 1
#define SB_LEVEL 2
#define SB_SHIPS 3
struct SLevel
{
int nrocks;
double rockSpeed;
};
#define MAX_LEVELS 16
SLevel levels[MAX_LEVELS] =
{
{ 1, 0.4 },
{ 1, 0.6 },
{ 2, 0.5 },
{ 2, 0.7 },
{ 2, 0.8 },
{ 3, 0.6 },
{ 3, 0.7 },
{ 3, 0.8 },
{ 4, 0.6 },
{ 4, 0.7 },
{ 4, 0.8 },
{ 5, 0.7 },
{ 5, 0.8 },
{ 5, 0.9 },
{ 5, 1.0 }
};
const char *soundEvents[] =
{
"ShipDestroyed",
"RockDestroyed",
0
};
const char *soundDefaults[] =
{
"Explosion.wav",
"ploop.wav",
0
};
KAstTopLevel::KAstTopLevel( QWidget *parent, const char *name )
@@ -208,99 +210,115 @@ KAstTopLevel::KAstTopLevel( QWidget *parent, const char *name )
shieldLCD->setPalette( pal );
shieldLCD->setFixedHeight( 16 );
hbd->addWidget( shieldLCD );
hbd->addSpacing( 5 );
label = new QLabel( mainWin );
label->setPixmap( Resource::loadPixmap("qasteroids/powerups/shoot.png") );
label->setFixedWidth( 16 );
label->setPalette( pal );
hbd->addWidget( label );
shootLCD = new QLCDNumber( 1, mainWin );
shootLCD->setFrameStyle( QFrame::NoFrame );
shootLCD->setSegmentStyle( QLCDNumber::Flat );
shootLCD->setPalette( pal );
shootLCD->setFixedHeight( 16 );
hbd->addWidget( shootLCD );
hbd->addStretch( 1 );
label = new QLabel( tr( "Fuel" ), mainWin );
label->setFont( smallFont );
label->setFixedWidth( label->sizeHint().width() + 5 );
label->setPalette( pal );
hbd->addWidget( label );
powerMeter = new KALedMeter( mainWin );
powerMeter->setFrameStyle( QFrame::Box | QFrame::Plain );
powerMeter->setRange( MAX_POWER_LEVEL );
powerMeter->addColorRange( 10, darkRed );
powerMeter->addColorRange( 20, QColor(160, 96, 0) );
powerMeter->addColorRange( 70, darkGreen );
powerMeter->setCount( 15 );
powerMeter->setPalette( pal );
powerMeter->setFixedSize( 60, 12 );
hbd->addWidget( powerMeter );
shipsRemain = 3;
showHiscores = FALSE;
actions.insert( Qt::Key_Up, Thrust );
actions.insert( Qt::Key_Left, RotateLeft );
actions.insert( Qt::Key_Right, RotateRight );
actions.insert( Qt::Key_Enter, Shoot );
actions.insert( Qt::Key_Z, Teleport );
actions.insert( Qt::Key_Down, Brake );
actions.insert( Qt::Key_P, Pause );
- actions.insert( Key_F12, Launch );
- actions.insert( Key_F11, Shield );
- actions.insert( Key_F9, NewGame );
+
+
+ struct utsname name; /* check for embedix kernel running on the zaurus, if
+ lineo change string, this break
+ */
+ if (uname(&name) != -1) {
+ QString release=name.release;
+ if(release.find("embedix",0,TRUE) !=-1) {
+ actions.insert( Key_F12, Launch );
+ actions.insert( Key_F11, Shield );
+ actions.insert( Key_F9, NewGame );
+ } else {
+ // ipaq
+ actions.insert( Key_F12, Shoot );
+ actions.insert( Key_F11, Shield );
+ actions.insert( Key_F10, Launch );
+ actions.insert( Key_F9, NewGame );
+ }
+ }
// actions.insert( Qt::Key_S, Shield );
// actions.insert( Qt::Key_X, Brake );
// actions.insert( Qt::Key_L, Launch );
actions.insert( Qt::Key_Space, Shoot );
view->showText( tr( "Press Calendar to start playing" ), yellow );
setFocusPolicy( StrongFocus );
slotNewGame();
}
KAstTopLevel::~KAstTopLevel()
{
}
void KAstTopLevel::playSound( const char * )
{
}
void KAstTopLevel::keyPressEvent( QKeyEvent *event )
{
if ( event->isAutoRepeat() || !actions.contains( event->key() ) )
{
event->ignore();
return;
}
Action a = actions[ event->key() ];
switch ( a )
{
case RotateLeft:
view->rotateLeft( TRUE );
break;
case RotateRight:
view->rotateRight( TRUE );
break;
case Thrust:
view->thrust( TRUE );
break;
case Shoot:
view->shoot( TRUE );
break;
@@ -406,97 +424,97 @@ void KAstTopLevel::showEvent( QShowEvent *e )
view->pause( FALSE );
setFocus();
}
void KAstTopLevel::hideEvent( QHideEvent *e )
{
QMainWindow::hideEvent( e );
view->pause( TRUE );
}
void KAstTopLevel::focusInEvent( QFocusEvent * )
{
view->pause( FALSE );
setFocus();
}
void KAstTopLevel::focusOutEvent( QFocusEvent * )
{
view->pause( TRUE );
}
void KAstTopLevel::slotNewGame()
{
shipsRemain = 3;
score = 0;
scoreLCD->display( 0 );
level = 0;
levelLCD->display( level+1 );
shipsLCD->display( shipsRemain-1 );
view->newGame();
view->setRockSpeed( levels[0].rockSpeed );
view->addRocks( levels[0].nrocks );
view->newShip();
waitShip = FALSE;
view->hideText();
isPaused = FALSE;
}
void KAstTopLevel::slotShipKilled()
{
shipsRemain--;
shipsLCD->display( shipsRemain-1 );
playSound( "ShipDestroyed" );
if ( shipsRemain > 0 )
{
waitShip = TRUE;
- view->showText( tr( "Ship Destroyed.\nPress Launch/Home key."), yellow );
+ view->showText( tr( "Ship Destroyed.\nPress Contacts/Home key."), yellow );
}
else
{
view->endGame();
doStats();
}
}
void KAstTopLevel::slotRockHit( int size )
{
switch ( size )
{
case 0:
score += 10;
break;
case 1:
score += 20;
break;
default:
score += 40;
}
playSound( "RockDestroyed" );
scoreLCD->display( score );
}
void KAstTopLevel::slotRocksRemoved()
{
level++;
if ( level >= MAX_LEVELS )
level = MAX_LEVELS - 1;
view->setRockSpeed( levels[level-1].rockSpeed );
view->addRocks( levels[level-1].nrocks );
levelLCD->display( level+1 );
}
void KAstTopLevel::doStats()
{
QString r( "0.00" );
if ( view->shots() )
r = QString::number( (double)view->hits() / view->shots() * 100.0,
'g', 2 );