summaryrefslogtreecommitdiff
Unidiff
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,280 +1,280 @@
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 );