author | zecke <zecke> | 2004-09-10 11:14:02 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-10 11:14:02 (UTC) |
commit | b8baf551919868737c6f56a05e6efa1bad4d97ac (patch) (unidiff) | |
tree | 402c587e55356aff7f13990e1efcf57775bb9670 | |
parent | 046bff8abb6727f5522748a2dc8a259d27b5979b (diff) | |
download | opie-b8baf551919868737c6f56a05e6efa1bad4d97ac.zip opie-b8baf551919868737c6f56a05e6efa1bad4d97ac.tar.gz opie-b8baf551919868737c6f56a05e6efa1bad4d97ac.tar.bz2 |
Remove unused parameter
-rw-r--r-- | noncore/decorations/flat/flat.cpp | 4 | ||||
-rw-r--r-- | noncore/games/bounce/game.cpp | 17 | ||||
-rw-r--r-- | noncore/games/kbill/Game.cc | 14 | ||||
-rw-r--r-- | noncore/games/kbill/Game.h | 2 | ||||
-rw-r--r-- | noncore/games/kbill/field.cpp | 2 | ||||
-rw-r--r-- | noncore/games/kbill/inputbox.cpp | 10 | ||||
-rw-r--r-- | noncore/games/kbill/kbill.h | 42 | ||||
-rw-r--r-- | noncore/games/zsame/ZSameWidget.cpp | 12 |
8 files changed, 53 insertions, 50 deletions
diff --git a/noncore/decorations/flat/flat.cpp b/noncore/decorations/flat/flat.cpp index a2f12be..9a670cc 100644 --- a/noncore/decorations/flat/flat.cpp +++ b/noncore/decorations/flat/flat.cpp | |||
@@ -241,122 +241,122 @@ int FlatDecoration::metric( Metric m, const WindowData *wd ) const | |||
241 | 241 | ||
242 | void FlatDecoration::drawArea( Area a, QPainter *p, const WindowData *wd ) const | 242 | void FlatDecoration::drawArea( Area a, QPainter *p, const WindowData *wd ) const |
243 | { | 243 | { |
244 | int th = metric( TitleHeight, wd ); | 244 | int th = metric( TitleHeight, wd ); |
245 | QRect r = wd->rect; | 245 | QRect r = wd->rect; |
246 | 246 | ||
247 | switch ( a ) { | 247 | switch ( a ) { |
248 | case Border: | 248 | case Border: |
249 | { | 249 | { |
250 | const QColorGroup &cg = wd->palette.active(); | 250 | const QColorGroup &cg = wd->palette.active(); |
251 | if ( wd->flags & WindowData::Active ) { | 251 | if ( wd->flags & WindowData::Active ) { |
252 | p->setBrush( cg.color(QColorGroup::Highlight) ); | 252 | p->setBrush( cg.color(QColorGroup::Highlight) ); |
253 | } else { | 253 | } else { |
254 | p->setBrush( cg.color(QColorGroup::Background) ); | 254 | p->setBrush( cg.color(QColorGroup::Background) ); |
255 | } | 255 | } |
256 | p->setPen( cg.foreground() ); | 256 | p->setPen( cg.foreground() ); |
257 | int lb = metric(LeftBorder,wd); | 257 | int lb = metric(LeftBorder,wd); |
258 | int rb = metric(RightBorder,wd); | 258 | int rb = metric(RightBorder,wd); |
259 | int tb = metric(TopBorder,wd); | 259 | int tb = metric(TopBorder,wd); |
260 | int bb = metric(BottomBorder,wd); | 260 | int bb = metric(BottomBorder,wd); |
261 | p->drawRect( r.x()-lb, r.y()-tb-th, r.width()+lb+rb, | 261 | p->drawRect( r.x()-lb, r.y()-tb-th, r.width()+lb+rb, |
262 | r.height()+th+tb+bb ); | 262 | r.height()+th+tb+bb ); |
263 | } | 263 | } |
264 | break; | 264 | break; |
265 | case Title: | 265 | case Title: |
266 | if ( r.height() < 2 ) { | 266 | if ( r.height() < 2 ) { |
267 | WindowDecorationInterface::drawArea( a, p, wd ); | 267 | WindowDecorationInterface::drawArea( a, p, wd ); |
268 | } else { | 268 | } else { |
269 | const QColorGroup &cg = wd->palette.active(); | 269 | const QColorGroup &cg = wd->palette.active(); |
270 | QColor c; | 270 | QColor c; |
271 | if ( wd->flags & WindowData::Active ) | 271 | if ( wd->flags & WindowData::Active ) |
272 | c = cg.color(QColorGroup::Highlight); | 272 | c = cg.color(QColorGroup::Highlight); |
273 | else | 273 | else |
274 | c = cg.color(QColorGroup::Background); | 274 | c = cg.color(QColorGroup::Background); |
275 | p->fillRect( QRect(r.x(),r.y()-th,r.width(),th), c ); | 275 | p->fillRect( QRect(r.x(),r.y()-th,r.width(),th), c ); |
276 | } | 276 | } |
277 | break; | 277 | break; |
278 | case TitleText: | 278 | case TitleText: |
279 | p->drawText( r.left()+3+metric(HelpWidth,wd), r.top()-th, | 279 | p->drawText( r.left()+3+metric(HelpWidth,wd), r.top()-th, |
280 | r.width()-metric(HelpWidth,wd)-metric(CloseWidth,wd), th, | 280 | r.width()-metric(HelpWidth,wd)-metric(CloseWidth,wd), th, |
281 | Qt::AlignVCenter, wd->caption ); | 281 | Qt::AlignVCenter, wd->caption ); |
282 | break; | 282 | break; |
283 | default: | 283 | default: |
284 | FlatDecoration::drawArea( a, p, wd ); | 284 | FlatDecoration::drawArea( a, p, wd ); |
285 | break; | 285 | break; |
286 | } | 286 | } |
287 | } | 287 | } |
288 | 288 | ||
289 | void FlatDecoration::drawButton( Button b, QPainter *p, const WindowData *wd, int x, int y, int w, int h, QWSButton::State state ) const | 289 | void FlatDecoration::drawButton( Button b, QPainter *p, const WindowData *wd, int x, int y, int, int, QWSButton::State state ) const |
290 | { | 290 | { |
291 | QColor c; | 291 | QColor c; |
292 | const QColorGroup &cg = wd->palette.active(); | 292 | const QColorGroup &cg = wd->palette.active(); |
293 | if ( wd->flags & WindowDecorationInterface::WindowData::Active ) | 293 | if ( wd->flags & WindowDecorationInterface::WindowData::Active ) |
294 | c = cg.color(QColorGroup::HighlightedText); | 294 | c = cg.color(QColorGroup::HighlightedText); |
295 | else | 295 | else |
296 | c = cg.color(QColorGroup::Foreground); | 296 | c = cg.color(QColorGroup::Foreground); |
297 | bool r = (state & QWSButton::MouseOver) && (state & QWSButton::Clicked); | 297 | bool r = (state & QWSButton::MouseOver) && (state & QWSButton::Clicked); |
298 | int th = metric(TitleHeight, wd); | 298 | int th = metric(TitleHeight, wd); |
299 | 299 | ||
300 | QString key( "%1-%2-%3-%4" ); | 300 | QString key( "%1-%2-%3-%4" ); |
301 | key = key.arg(b).arg(th).arg(c.name()).arg(r ? "1" : "0"); | 301 | key = key.arg(b).arg(th).arg(c.name()).arg(r ? "1" : "0"); |
302 | QImage *img = buttonCache.find( key ); | 302 | QImage *img = buttonCache.find( key ); |
303 | if ( !img ) { | 303 | if ( !img ) { |
304 | QImage tmp; | 304 | QImage tmp; |
305 | switch ( b ) { | 305 | switch ( b ) { |
306 | case OK: | 306 | case OK: |
307 | tmp = QImage( ok_xpm ); | 307 | tmp = QImage( ok_xpm ); |
308 | break; | 308 | break; |
309 | case Close: | 309 | case Close: |
310 | tmp = QImage( close_xpm ); | 310 | tmp = QImage( close_xpm ); |
311 | break; | 311 | break; |
312 | case Help: | 312 | case Help: |
313 | tmp = QImage( help_xpm ); | 313 | tmp = QImage( help_xpm ); |
314 | break; | 314 | break; |
315 | case Maximize: | 315 | case Maximize: |
316 | tmp = QImage( maximize_xpm ); | 316 | tmp = QImage( maximize_xpm ); |
317 | break; | 317 | break; |
318 | } | 318 | } |
319 | colorize( tmp, c, r ); | 319 | colorize( tmp, c, r ); |
320 | img = new QImage( scaleButton(tmp,th) ); | 320 | img = new QImage( scaleButton(tmp,th) ); |
321 | FlatDecoration *that = (FlatDecoration *)this; | 321 | FlatDecoration *that = (FlatDecoration *)this; |
322 | that->buttonCache.insert( key, img, 1 ); | 322 | that->buttonCache.insert( key, img, 1 ); |
323 | } | 323 | } |
324 | 324 | ||
325 | p->drawImage( x, y, *img ); | 325 | p->drawImage( x, y, *img ); |
326 | } | 326 | } |
327 | 327 | ||
328 | QRegion FlatDecoration::mask( const WindowData *wd ) const | 328 | QRegion FlatDecoration::mask( const WindowData *wd ) const |
329 | { | 329 | { |
330 | return WindowDecorationInterface::mask( wd ); | 330 | return WindowDecorationInterface::mask( wd ); |
331 | } | 331 | } |
332 | 332 | ||
333 | QString FlatDecoration::name() const | 333 | QString FlatDecoration::name() const |
334 | { | 334 | { |
335 | return qApp->translate( "Decoration", "Flat" ); | 335 | return qApp->translate( "Decoration", "Flat" ); |
336 | } | 336 | } |
337 | 337 | ||
338 | QPixmap FlatDecoration::icon() const | 338 | QPixmap FlatDecoration::icon() const |
339 | { | 339 | { |
340 | return QPixmap(); | 340 | return QPixmap(); |
341 | } | 341 | } |
342 | 342 | ||
343 | QRESULT FlatDecoration::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 343 | QRESULT FlatDecoration::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
344 | { | 344 | { |
345 | *iface = 0; | 345 | *iface = 0; |
346 | if ( uuid == IID_QUnknown ) | 346 | if ( uuid == IID_QUnknown ) |
347 | *iface = this; | 347 | *iface = this; |
348 | else if ( uuid == IID_WindowDecoration ) | 348 | else if ( uuid == IID_WindowDecoration ) |
349 | *iface = this; | 349 | *iface = this; |
350 | else | 350 | else |
351 | return QS_FALSE; | 351 | return QS_FALSE; |
352 | 352 | ||
353 | if ( *iface ) | 353 | if ( *iface ) |
354 | (*iface)->addRef(); | 354 | (*iface)->addRef(); |
355 | return QS_OK; | 355 | return QS_OK; |
356 | } | 356 | } |
357 | 357 | ||
358 | Q_EXPORT_INTERFACE() | 358 | Q_EXPORT_INTERFACE() |
359 | { | 359 | { |
360 | Q_CREATE_INSTANCE( FlatDecoration ) | 360 | Q_CREATE_INSTANCE( FlatDecoration ) |
361 | } | 361 | } |
362 | 362 | ||
diff --git a/noncore/games/bounce/game.cpp b/noncore/games/bounce/game.cpp index bbd3d0b..5ef9f15 100644 --- a/noncore/games/bounce/game.cpp +++ b/noncore/games/bounce/game.cpp | |||
@@ -1,176 +1,176 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2000 Stefan Schimanski <1Stein@gmx.de> | 2 | * Copyright (C) 2000 Stefan Schimanski <1Stein@gmx.de> |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or | 4 | * This program is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Library General Public | 5 | * modify it under the terms of the GNU Library General Public |
6 | * License as published by the Free Software Foundation; either | 6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. | 7 | * version 2 of the License, or (at your option) any later version. |
8 | * | 8 | * |
9 | * This program is distributed in the hope that it will be useful, | 9 | * This program is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Library General Public License for more details. | 12 | * Library General Public License for more details. |
13 | * | 13 | * |
14 | * You should have received a copy of the GNU Library General Public | 14 | * You should have received a copy of the GNU Library General Public |
15 | * License along with this program; if not, write to the Free | 15 | * License along with this program; if not, write to the Free |
16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 16 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | 19 | ||
20 | #include "game.h" | 20 | #include "game.h" |
21 | 21 | ||
22 | /* OPIE */ | 22 | /* OPIE */ |
23 | #include <opie2/odebug.h> | 23 | #include <opie2/odebug.h> |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | using namespace Opie::Core; | 25 | using namespace Opie::Core; |
26 | 26 | ||
27 | /* QT */ | 27 | /* QT */ |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | 29 | ||
30 | /* STD */ | 30 | /* STD */ |
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #define TILE_SIZE 9 | 33 | #define TILE_SIZE 9 |
34 | 34 | ||
35 | #define TILE_FIRST ((FIELD_WIDTH-2)*(FIELD_HEIGHT-2)) | 35 | #define TILE_FIRST ((FIELD_WIDTH-2)*(FIELD_HEIGHT-2)) |
36 | #define TILE_FREE (TILE_FIRST + 0) | 36 | #define TILE_FREE (TILE_FIRST + 0) |
37 | #define TILE_BORDER (TILE_FIRST + 1) | 37 | #define TILE_BORDER (TILE_FIRST + 1) |
38 | #define TILE_WALLEND (TILE_FIRST + 2) | 38 | #define TILE_WALLEND (TILE_FIRST + 2) |
39 | #define TILE_WALLUP (TILE_FIRST + 3) | 39 | #define TILE_WALLUP (TILE_FIRST + 3) |
40 | #define TILE_WALLDOWN (TILE_FIRST + 4) | 40 | #define TILE_WALLDOWN (TILE_FIRST + 4) |
41 | #define TILE_WALLLEFT (TILE_FIRST + 5) | 41 | #define TILE_WALLLEFT (TILE_FIRST + 5) |
42 | #define TILE_WALLRIGHT (TILE_FIRST + 6) | 42 | #define TILE_WALLRIGHT (TILE_FIRST + 6) |
43 | 43 | ||
44 | #define GAME_DELAY 15 | 44 | #define GAME_DELAY 15 |
45 | #define BALL_ANIM_DELAY 60 | 45 | #define BALL_ANIM_DELAY 60 |
46 | #define WALL_DELAY 100 | 46 | #define WALL_DELAY 100 |
47 | 47 | ||
48 | #define MS2TICKS( ms ) ((ms)/GAME_DELAY) | 48 | #define MS2TICKS( ms ) ((ms)/GAME_DELAY) |
49 | 49 | ||
50 | Arrow::Arrow(QCanvasPixmapArray* array, QCanvas* canvas) | 50 | Arrow::Arrow(QCanvasPixmapArray* array, QCanvas* canvas) |
51 | : QCanvasSprite( array, canvas ) | 51 | : QCanvasSprite( array, canvas ) |
52 | { | 52 | { |
53 | m_vertical = true; | 53 | m_vertical = true; |
54 | move(3,3); | 54 | move(3,3); |
55 | } | 55 | } |
56 | 56 | ||
57 | void Arrow::update() | 57 | void Arrow::update() |
58 | { | 58 | { |
59 | if ( m_vertical ) | 59 | if ( m_vertical ) |
60 | setFrame( 0 ); | 60 | setFrame( 0 ); |
61 | else | 61 | else |
62 | setFrame( 1 ); | 62 | setFrame( 1 ); |
63 | } | 63 | } |
64 | 64 | ||
65 | void Arrow::changeDirection() | 65 | void Arrow::changeDirection() |
66 | { | 66 | { |
67 | m_vertical = ! m_vertical; | 67 | m_vertical = ! m_vertical; |
68 | update(); | 68 | update(); |
69 | } | 69 | } |
70 | 70 | ||
71 | 71 | ||
72 | Ball::Ball(QCanvasPixmapArray* array, QCanvas* canvas) | 72 | Ball::Ball(QCanvasPixmapArray* array, QCanvas* canvas) |
73 | : QCanvasSprite( array, canvas ), m_animDelay( 0 ), m_soundDelay( MS2TICKS(BALL_ANIM_DELAY)/2 ) | 73 | : QCanvasSprite( array, canvas ), m_animDelay( 0 ), m_soundDelay( MS2TICKS(BALL_ANIM_DELAY)/2 ) |
74 | { | 74 | { |
75 | } | 75 | } |
76 | 76 | ||
77 | void Ball::update() | 77 | void Ball::update() |
78 | { | 78 | { |
79 | m_animDelay--; | 79 | m_animDelay--; |
80 | if ( m_animDelay<=0 ) | 80 | if ( m_animDelay<=0 ) |
81 | { | 81 | { |
82 | m_animDelay = MS2TICKS(BALL_ANIM_DELAY); | 82 | m_animDelay = MS2TICKS(BALL_ANIM_DELAY); |
83 | int frameNum = frame(); | 83 | int frameNum = frame(); |
84 | frameNum++; | 84 | frameNum++; |
85 | if ( frameNum>=frameCount() ) | 85 | if ( frameNum>=frameCount() ) |
86 | frameNum = 0; | 86 | frameNum = 0; |
87 | setFrame( frameNum ); | 87 | setFrame( frameNum ); |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | void Ball::advance(int stage) | 91 | void Ball::advance(int stage) |
92 | { | 92 | { |
93 | bool reflectX = false; | 93 | bool reflectX = false; |
94 | bool reflectY = false; | 94 | bool reflectY = false; |
95 | 95 | ||
96 | // check for collisions | 96 | // check for collisions |
97 | if ( collide(xVelocity(), 0) ) reflectX = true; | 97 | if ( collide(xVelocity(), 0) ) reflectX = true; |
98 | if ( collide(0, yVelocity()) ) reflectY = true; | 98 | if ( collide(0, yVelocity()) ) reflectY = true; |
99 | if ( !reflectX && !reflectY && collide(xVelocity(), yVelocity()) ) reflectX = reflectY = true; | 99 | if ( !reflectX && !reflectY && collide(xVelocity(), yVelocity()) ) reflectX = reflectY = true; |
100 | 100 | ||
101 | // emit collision | 101 | // emit collision |
102 | QRect r = boundingRect(); | 102 | QRect r = boundingRect(); |
103 | r.moveBy( xVelocity(), yVelocity() ); | 103 | r.moveBy( static_cast<int>(xVelocity()), static_cast<int>( yVelocity() ) ); |
104 | JezzField* field = (JezzField *)canvas(); | 104 | JezzField* field = (JezzField *)canvas(); |
105 | 105 | ||
106 | int ul = field->tile( r.left() / TILE_SIZE, r.top() / TILE_SIZE ); | 106 | int ul = field->tile( r.left() / TILE_SIZE, r.top() / TILE_SIZE ); |
107 | int ur = field->tile( r.right() / TILE_SIZE, r.top() / TILE_SIZE ); | 107 | int ur = field->tile( r.right() / TILE_SIZE, r.top() / TILE_SIZE ); |
108 | int bl = field->tile( r.left() / TILE_SIZE, r.bottom() / TILE_SIZE ); | 108 | int bl = field->tile( r.left() / TILE_SIZE, r.bottom() / TILE_SIZE ); |
109 | int br = field->tile( r.right() / TILE_SIZE, r.bottom() / TILE_SIZE ); | 109 | int br = field->tile( r.right() / TILE_SIZE, r.bottom() / TILE_SIZE ); |
110 | 110 | ||
111 | if ( ul!=TILE_FREE ) field->emitBallCollisiton( this, r.left() / TILE_SIZE, r.top() / TILE_SIZE, ul ); else | 111 | if ( ul!=TILE_FREE ) field->emitBallCollisiton( this, r.left() / TILE_SIZE, r.top() / TILE_SIZE, ul ); else |
112 | if ( ur!=TILE_FREE ) field->emitBallCollisiton( this, r.right() / TILE_SIZE, r.top() / TILE_SIZE, ur ); else | 112 | if ( ur!=TILE_FREE ) field->emitBallCollisiton( this, r.right() / TILE_SIZE, r.top() / TILE_SIZE, ur ); else |
113 | if ( bl!=TILE_FREE ) field->emitBallCollisiton( this, r.left() / TILE_SIZE, r.bottom() / TILE_SIZE, bl ); else | 113 | if ( bl!=TILE_FREE ) field->emitBallCollisiton( this, r.left() / TILE_SIZE, r.bottom() / TILE_SIZE, bl ); else |
114 | if ( br!=TILE_FREE ) field->emitBallCollisiton( this, r.right() / TILE_SIZE, r.bottom() / TILE_SIZE, br ); | 114 | if ( br!=TILE_FREE ) field->emitBallCollisiton( this, r.right() / TILE_SIZE, r.bottom() / TILE_SIZE, br ); |
115 | 115 | ||
116 | // apply reflection | 116 | // apply reflection |
117 | if ( reflectX ) setXVelocity( -xVelocity() ); | 117 | if ( reflectX ) setXVelocity( -xVelocity() ); |
118 | if ( reflectY ) setYVelocity( -yVelocity() ); | 118 | if ( reflectY ) setYVelocity( -yVelocity() ); |
119 | 119 | ||
120 | // update field | 120 | // update field |
121 | update(); | 121 | update(); |
122 | QCanvasSprite::advance( stage ); | 122 | QCanvasSprite::advance( stage ); |
123 | } | 123 | } |
124 | 124 | ||
125 | bool Ball::collide( double dx, double dy ) | 125 | bool Ball::collide( double dx, double dy ) |
126 | { | 126 | { |
127 | QRect r = boundingRect(); | 127 | QRect r = boundingRect(); |
128 | r.moveBy( dx, dy ); | 128 | r.moveBy( static_cast<int>( dx ), static_cast<int>( dy ) ); |
129 | JezzField* field = (JezzField *)canvas(); | 129 | JezzField* field = (JezzField *)canvas(); |
130 | 130 | ||
131 | int ul = field->tile( r.left() / TILE_SIZE, r.top() / TILE_SIZE ); | 131 | int ul = field->tile( r.left() / TILE_SIZE, r.top() / TILE_SIZE ); |
132 | int ur = field->tile( r.right() / TILE_SIZE, r.top() / TILE_SIZE ); | 132 | int ur = field->tile( r.right() / TILE_SIZE, r.top() / TILE_SIZE ); |
133 | int bl = field->tile( r.left() / TILE_SIZE, r.bottom() / TILE_SIZE ); | 133 | int bl = field->tile( r.left() / TILE_SIZE, r.bottom() / TILE_SIZE ); |
134 | int br = field->tile( r.right() / TILE_SIZE, r.bottom() / TILE_SIZE ); | 134 | int br = field->tile( r.right() / TILE_SIZE, r.bottom() / TILE_SIZE ); |
135 | 135 | ||
136 | return ( ul!=TILE_FREE || ur!=TILE_FREE || bl!=TILE_FREE || br!=TILE_FREE ); | 136 | return ( ul!=TILE_FREE || ur!=TILE_FREE || bl!=TILE_FREE || br!=TILE_FREE ); |
137 | } | 137 | } |
138 | 138 | ||
139 | /*************************************************************************/ | 139 | /*************************************************************************/ |
140 | 140 | ||
141 | Wall::Wall( JezzField *field, int x, int y, Direction dir, int tile, QObject *parent, const char *name ) | 141 | Wall::Wall( JezzField *field, int x, int y, Direction dir, int tile, QObject *parent, const char *name ) |
142 | : QObject( parent, name ), m_dir( dir ), m_field( field ), m_startX( x ), m_startY( y ), | 142 | : QObject( parent, name ), m_dir( dir ), m_field( field ), m_startX( x ), m_startY( y ), |
143 | m_tile( tile ), m_delay( MS2TICKS(WALL_DELAY)/2 ), m_active( true ) | 143 | m_tile( tile ), m_delay( MS2TICKS(WALL_DELAY)/2 ), m_active( true ) |
144 | { | 144 | { |
145 | // setup position and direction | 145 | // setup position and direction |
146 | m_dx = 0; | 146 | m_dx = 0; |
147 | m_dy = 0; | 147 | m_dy = 0; |
148 | switch ( m_dir ) | 148 | switch ( m_dir ) |
149 | { | 149 | { |
150 | case Up: m_dy = -1; break; | 150 | case Up: m_dy = -1; break; |
151 | case Down: m_dy = 1; break; | 151 | case Down: m_dy = 1; break; |
152 | case Left: m_dx = -1; break; | 152 | case Left: m_dx = -1; break; |
153 | case Right: m_dx = 1; break; | 153 | case Right: m_dx = 1; break; |
154 | } | 154 | } |
155 | 155 | ||
156 | m_x = m_startX; | 156 | m_x = m_startX; |
157 | m_y = m_startY; | 157 | m_y = m_startY; |
158 | 158 | ||
159 | m_field->setTile( m_x, m_y, m_tile ); | 159 | m_field->setTile( m_x, m_y, m_tile ); |
160 | } | 160 | } |
161 | 161 | ||
162 | void Wall::finish() | 162 | void Wall::finish() |
163 | { | 163 | { |
164 | m_active = false; | 164 | m_active = false; |
165 | } | 165 | } |
166 | 166 | ||
167 | bool Wall::isFree( int x, int y ) | 167 | bool Wall::isFree( int x, int y ) |
168 | { | 168 | { |
169 | if ( m_field->tile(x, y)==TILE_FREE ) | 169 | if ( m_field->tile(x, y)==TILE_FREE ) |
170 | { | 170 | { |
171 | // check whether there is a ball at the moment | 171 | // check whether there is a ball at the moment |
172 | QCanvasItemList cols = m_field->collisions( QRect(x*TILE_SIZE, y*TILE_SIZE, | 172 | QCanvasItemList cols = m_field->collisions( QRect(x*TILE_SIZE, y*TILE_SIZE, |
173 | TILE_SIZE, TILE_SIZE) ); | 173 | TILE_SIZE, TILE_SIZE) ); |
174 | if ( cols.count()==0 ) | 174 | if ( cols.count()==0 ) |
175 | return true; | 175 | return true; |
176 | } | 176 | } |
@@ -254,211 +254,212 @@ void JezzField::setPixmaps( QPixmap tiles ) | |||
254 | 254 | ||
255 | // handle default tiles | 255 | // handle default tiles |
256 | bitBlt( &allTiles, 0, TILE_SIZE*(FIELD_HEIGHT-2), | 256 | bitBlt( &allTiles, 0, TILE_SIZE*(FIELD_HEIGHT-2), |
257 | &tiles, 0, 0, tiles.width(), tiles.height() ); | 257 | &tiles, 0, 0, tiles.width(), tiles.height() ); |
258 | 258 | ||
259 | // load tiles into canvas | 259 | // load tiles into canvas |
260 | setTiles( allTiles, FIELD_WIDTH, FIELD_HEIGHT, TILE_SIZE, TILE_SIZE ); | 260 | setTiles( allTiles, FIELD_WIDTH, FIELD_HEIGHT, TILE_SIZE, TILE_SIZE ); |
261 | } | 261 | } |
262 | 262 | ||
263 | /*************************************************************************/ | 263 | /*************************************************************************/ |
264 | 264 | ||
265 | JezzView::JezzView(QCanvas* viewing, QWidget* parent, const char* name, WFlags f) | 265 | JezzView::JezzView(QCanvas* viewing, QWidget* parent, const char* name, WFlags f) |
266 | : QCanvasView( viewing, parent, name, f ), m_vertical( false ) | 266 | : QCanvasView( viewing, parent, name, f ), m_vertical( false ) |
267 | { | 267 | { |
268 | setResizePolicy( AutoOne ); | 268 | setResizePolicy( AutoOne ); |
269 | setHScrollBarMode( AlwaysOff ); | 269 | setHScrollBarMode( AlwaysOff ); |
270 | setVScrollBarMode( AlwaysOff ); | 270 | setVScrollBarMode( AlwaysOff ); |
271 | 271 | ||
272 | setCursor( sizeHorCursor ); | 272 | setCursor( sizeHorCursor ); |
273 | } | 273 | } |
274 | 274 | ||
275 | void JezzView::viewportMouseReleaseEvent( QMouseEvent *ev ) | 275 | void JezzView::viewportMouseReleaseEvent( QMouseEvent *ev ) |
276 | { | 276 | { |
277 | if ( ev->button() & LeftButton ) | 277 | if ( ev->button() & LeftButton ) |
278 | { | 278 | { |
279 | emit buildWall( ev->x()/TILE_SIZE, ev->y()/TILE_SIZE, m_vertical ); | 279 | emit buildWall( ev->x()/TILE_SIZE, ev->y()/TILE_SIZE, m_vertical ); |
280 | } | 280 | } |
281 | } | 281 | } |
282 | 282 | ||
283 | void JezzView::changeCursor() | 283 | void JezzView::changeCursor() |
284 | { | 284 | { |
285 | m_vertical = !m_vertical; | 285 | m_vertical = !m_vertical; |
286 | if ( m_vertical ) | 286 | if ( m_vertical ) |
287 | { | 287 | { |
288 | setCursor( sizeVerCursor ); | 288 | setCursor( sizeVerCursor ); |
289 | } | 289 | } |
290 | else | 290 | else |
291 | { | 291 | { |
292 | setCursor( sizeHorCursor ); | 292 | setCursor( sizeHorCursor ); |
293 | } | 293 | } |
294 | } | 294 | } |
295 | 295 | ||
296 | /*************************************************************************/ | 296 | /*************************************************************************/ |
297 | 297 | ||
298 | JezzGame::JezzGame( int ballNum, QWidget *parent, const char *name ) | 298 | JezzGame::JezzGame( int ballNum, QWidget *parent, const char *name ) |
299 | : QWidget( parent, name ), m_wall1( 0 ), m_wall2( 0 ), | 299 | : QWidget( parent, name ), m_wall1( 0 ), m_wall2( 0 ), |
300 | m_text( 0 ), m_running( false ), m_percent( 0 ), m_pictured( false ) | 300 | m_text( 0 ), m_running( false ), m_percent( 0 ), m_pictured( false ) |
301 | { | 301 | { |
302 | QString path = QPEApplication::qpeDir()+"pics/bounce/"; | 302 | QString path = QPEApplication::qpeDir()+"pics/bounce/"; |
303 | 303 | ||
304 | // load gfx | 304 | // load gfx |
305 | m_ballPixmaps = new QCanvasPixmapArray( path + "ball%1.png", 25 ); | 305 | m_ballPixmaps = new QCanvasPixmapArray( path + "ball%1.png", 25 ); |
306 | for ( unsigned n=0; n < m_ballPixmaps->count(); n++ ) | 306 | for ( unsigned n=0; n < m_ballPixmaps->count(); n++ ) |
307 | m_ballPixmaps->image(n)->setOffset( 0, 0 ); | 307 | m_ballPixmaps->image(n)->setOffset( 0, 0 ); |
308 | 308 | ||
309 | m_arrowPixmaps = new QCanvasPixmapArray( path + "arrow%1.png", 2 ); | 309 | m_arrowPixmaps = new QCanvasPixmapArray( path + "arrow%1.png", 2 ); |
310 | for ( unsigned n=0; n < m_arrowPixmaps->count(); n++ ) | 310 | for ( unsigned n=0; n < m_arrowPixmaps->count(); n++ ) |
311 | m_arrowPixmaps->image(n)->setOffset( 0, 0 ); | 311 | m_arrowPixmaps->image(n)->setOffset( 0, 0 ); |
312 | 312 | ||
313 | QPixmap tiles( path + "tiles.png" ); | 313 | QPixmap tiles( path + "tiles.png" ); |
314 | 314 | ||
315 | // create field | 315 | // create field |
316 | m_field = new JezzField( tiles, this, "m_field" ); | 316 | m_field = new JezzField( tiles, this, "m_field" ); |
317 | m_field->resize( TILE_SIZE*FIELD_WIDTH, TILE_SIZE*FIELD_HEIGHT ); | 317 | m_field->resize( TILE_SIZE*FIELD_WIDTH, TILE_SIZE*FIELD_HEIGHT ); |
318 | 318 | ||
319 | for ( int x=0; x<FIELD_WIDTH; x++ ) | 319 | for ( int x=0; x<FIELD_WIDTH; x++ ) |
320 | m_field->setTile( x, 0, TILE_BORDER ); | 320 | m_field->setTile( x, 0, TILE_BORDER ); |
321 | for ( int y=1; y<FIELD_HEIGHT-1; y++ ) | 321 | for ( int y=1; y<FIELD_HEIGHT-1; y++ ) |
322 | { | 322 | { |
323 | m_field->setTile( 0, y, TILE_BORDER ); | 323 | m_field->setTile( 0, y, TILE_BORDER ); |
324 | for ( int x=1; x<FIELD_WIDTH-1; x++ ) | 324 | for ( int x=1; x<FIELD_WIDTH-1; x++ ) |
325 | m_field->setTile( x, y, TILE_FREE ); | 325 | m_field->setTile( x, y, TILE_FREE ); |
326 | m_field->setTile( FIELD_WIDTH-1, y, TILE_BORDER ); | 326 | m_field->setTile( FIELD_WIDTH-1, y, TILE_BORDER ); |
327 | } | 327 | } |
328 | for ( int x=0; x<FIELD_WIDTH; x++ ) | 328 | for ( int x=0; x<FIELD_WIDTH; x++ ) |
329 | m_field->setTile( x, FIELD_HEIGHT-1, TILE_BORDER ); | 329 | m_field->setTile( x, FIELD_HEIGHT-1, TILE_BORDER ); |
330 | 330 | ||
331 | connect( m_field, SIGNAL(ballCollision(Ball*,int,int,int)), this, SLOT(ballCollision(Ball*,int,int,int)) ); | 331 | connect( m_field, SIGNAL(ballCollision(Ball*,int,int,int)), this, SLOT(ballCollision(Ball*,int,int,int)) ); |
332 | 332 | ||
333 | // create view | 333 | // create view |
334 | m_view = new JezzView( m_field, this, "m_view" ); | 334 | m_view = new JezzView( m_field, this, "m_view" ); |
335 | m_view->move( 0, 0 ); | 335 | m_view->move( 0, 0 ); |
336 | m_view->adjustSize(); | 336 | m_view->adjustSize(); |
337 | connect( m_view, SIGNAL(buildWall(int,int,bool)), this, SLOT(buildWall(int,int,bool)) ); | 337 | connect( m_view, SIGNAL(buildWall(int,int,bool)), this, SLOT(buildWall(int,int,bool)) ); |
338 | 338 | ||
339 | // create balls | 339 | // create balls |
340 | for ( int n=0; n<ballNum; n++ ) | 340 | for ( int n=0; n<ballNum; n++ ) |
341 | { | 341 | { |
342 | Ball *ball = new Ball( m_ballPixmaps, m_field ); | 342 | Ball *ball = new Ball( m_ballPixmaps, m_field ); |
343 | m_balls.append( ball ); | 343 | m_balls.append( ball ); |
344 | ball->setVelocity( ((rand() & 1)*2-1)*2, ((rand() & 1)*2-1)*2 ); | 344 | ball->setVelocity( ((rand() & 1)*2-1)*2, ((rand() & 1)*2-1)*2 ); |
345 | ball->setFrame( rand() % 25 ); | 345 | ball->setFrame( rand() % 25 ); |
346 | ball->move( 4*TILE_SIZE + ( rand() - 50 ) % ( (FIELD_WIDTH-8)*TILE_SIZE ), | 346 | ball->move( 4*TILE_SIZE + ( rand() - 50 ) % ( (FIELD_WIDTH-8)*TILE_SIZE ), |
347 | 4*TILE_SIZE + rand() % ( (FIELD_HEIGHT-8)*TILE_SIZE ) ); | 347 | 4*TILE_SIZE + rand() % ( (FIELD_HEIGHT-8)*TILE_SIZE ) ); |
348 | ball->show(); | 348 | ball->show(); |
349 | } | 349 | } |
350 | 350 | ||
351 | // create arrow | 351 | // create arrow |
352 | arrow = new Arrow( m_arrowPixmaps, m_field ); | 352 | arrow = new Arrow( m_arrowPixmaps, m_field ); |
353 | arrow->show(); | 353 | arrow->show(); |
354 | 354 | ||
355 | // create text label | 355 | // create text label |
356 | m_text = new QCanvasText( m_field ); | 356 | m_text = new QCanvasText( m_field ); |
357 | 357 | ||
358 | // create game clock | 358 | // create game clock |
359 | m_clock = new QTimer( this ); | 359 | m_clock = new QTimer( this ); |
360 | connect( m_clock, SIGNAL(timeout()), this, SLOT(tick()) ); | 360 | connect( m_clock, SIGNAL(timeout()), this, SLOT(tick()) ); |
361 | m_clock->start( GAME_DELAY ); | 361 | m_clock->start( GAME_DELAY ); |
362 | 362 | ||
363 | // setup geometry | 363 | // setup geometry |
364 | setFixedSize( m_view->size() ); | 364 | setFixedSize( m_view->size() ); |
365 | } | 365 | } |
366 | 366 | ||
367 | JezzGame::~JezzGame() | 367 | JezzGame::~JezzGame() |
368 | { | 368 | { |
369 | m_balls.clear(); | 369 | m_balls.clear(); |
370 | delete m_view; | 370 | delete m_view; |
371 | delete m_field; | 371 | delete m_field; |
372 | delete m_ballPixmaps; | 372 | delete m_ballPixmaps; |
373 | } | 373 | } |
374 | 374 | ||
375 | void JezzGame::display( QString text, int size ) | 375 | void JezzGame::display( QString text, int size ) |
376 | { | 376 | { |
377 | odebug << "This function \"display\" shouldn't be called!!!" << oendl; | 377 | odebug << "This function \"display\" shouldn't be called!!!" << oendl; |
378 | if ( !text.isEmpty() ) | 378 | if ( !text.isEmpty() ) |
379 | { | 379 | { |
380 | QFont font( "Helvetica", size, QFont::Bold ); | 380 | QFont font( "Helvetica", size, QFont::Bold ); |
381 | font.setStyleHint( QFont::Helvetica ); | 381 | font.setStyleHint( QFont::Helvetica ); |
382 | m_text->setFont( font ); | 382 | m_text->setFont( font ); |
383 | m_text->setText( text ); | 383 | m_text->setText( text ); |
384 | 384 | ||
385 | QRect size = m_text->boundingRect(); | 385 | QRect size = m_text->boundingRect(); |
386 | m_text->move( ( FIELD_WIDTH*TILE_SIZE - size.width() ) / 2, | 386 | m_text->move( ( FIELD_WIDTH*TILE_SIZE - size.width() ) / 2, |
387 | ( FIELD_HEIGHT*TILE_SIZE - size.height() ) / 2 ); | 387 | ( FIELD_HEIGHT*TILE_SIZE - size.height() ) / 2 ); |
388 | 388 | ||
389 | m_text->show(); | 389 | m_text->show(); |
390 | } else | 390 | } else |
391 | { | 391 | { |
392 | m_text->hide(); | 392 | m_text->hide(); |
393 | } | 393 | } |
394 | } | 394 | } |
395 | 395 | ||
396 | void JezzGame::start() | 396 | void JezzGame::start() |
397 | { | 397 | { |
398 | m_running = true; | 398 | m_running = true; |
399 | } | 399 | } |
400 | 400 | ||
401 | void JezzGame::stop() | 401 | void JezzGame::stop() |
402 | { | 402 | { |
403 | m_running = false; | 403 | m_running = false; |
404 | } | 404 | } |
405 | 405 | ||
406 | 406 | ||
407 | void JezzGame::makeBlack() | 407 | void JezzGame::makeBlack() |
408 | { | 408 | { |
409 | // copy current field into buffer | 409 | // copy current field into buffer |
410 | for ( int y=0; y<FIELD_HEIGHT; y++ ) | 410 | for ( int y=0; y<FIELD_HEIGHT; y++ ) |
411 | for ( int x=0; x<FIELD_WIDTH; x++ ) | 411 | for ( int x=0; x<FIELD_WIDTH; x++ ) |
412 | m_buf[x][y] = m_field->tile( x, y ); | 412 | m_buf[x][y] = m_field->tile( x, y ); |
413 | 413 | ||
414 | // fill areas that contains a ball | 414 | // fill areas that contains a ball |
415 | for ( Ball *ball=m_balls.first(); ball!=0; ball=m_balls.next() ) | 415 | for ( Ball *ball=m_balls.first(); ball!=0; ball=m_balls.next() ) |
416 | fill( ball->x()/TILE_SIZE, ball->y()/TILE_SIZE ); | 416 | fill( static_cast<int>( ball->x()/TILE_SIZE ), |
417 | static_cast<int>( ball->y()/TILE_SIZE ) ); | ||
417 | 418 | ||
418 | // areas still free can be blacked now | 419 | // areas still free can be blacked now |
419 | for ( int y=0; y<FIELD_HEIGHT; y++ ) | 420 | for ( int y=0; y<FIELD_HEIGHT; y++ ) |
420 | for ( int x=0; x<FIELD_WIDTH; x++ ) | 421 | for ( int x=0; x<FIELD_WIDTH; x++ ) |
421 | { | 422 | { |
422 | if ( m_buf[x][y]==TILE_FREE ) | 423 | if ( m_buf[x][y]==TILE_FREE ) |
423 | m_field->setGameTile( x, y, true ); | 424 | m_field->setGameTile( x, y, true ); |
424 | } | 425 | } |
425 | 426 | ||
426 | m_field->update(); | 427 | m_field->update(); |
427 | m_view->repaint(); | 428 | m_view->repaint(); |
428 | 429 | ||
429 | // count percent value of occupied area | 430 | // count percent value of occupied area |
430 | int p = percent(); | 431 | int p = percent(); |
431 | if ( p!=m_percent ) | 432 | if ( p!=m_percent ) |
432 | { | 433 | { |
433 | m_percent = p; | 434 | m_percent = p; |
434 | emit newPercent( m_percent ); | 435 | emit newPercent( m_percent ); |
435 | } | 436 | } |
436 | } | 437 | } |
437 | 438 | ||
438 | int JezzGame::percent() | 439 | int JezzGame::percent() |
439 | { | 440 | { |
440 | int notFree = 0; | 441 | int notFree = 0; |
441 | for ( int y=1; y<FIELD_HEIGHT-1; y++ ) | 442 | for ( int y=1; y<FIELD_HEIGHT-1; y++ ) |
442 | for ( int x=1; x<FIELD_WIDTH-1; x++ ) | 443 | for ( int x=1; x<FIELD_WIDTH-1; x++ ) |
443 | { | 444 | { |
444 | if ( m_field->tile(x,y)!=TILE_FREE ) | 445 | if ( m_field->tile(x,y)!=TILE_FREE ) |
445 | notFree++; | 446 | notFree++; |
446 | } | 447 | } |
447 | 448 | ||
448 | return 100 * notFree / ( (FIELD_WIDTH-1) * (FIELD_HEIGHT-1) ); | 449 | return 100 * notFree / ( (FIELD_WIDTH-1) * (FIELD_HEIGHT-1) ); |
449 | } | 450 | } |
450 | 451 | ||
451 | void JezzGame::fill( int x, int y ) | 452 | void JezzGame::fill( int x, int y ) |
452 | { | 453 | { |
453 | if ( m_buf[x][y]!=TILE_FREE) return; | 454 | if ( m_buf[x][y]!=TILE_FREE) return; |
454 | 455 | ||
455 | // go left | 456 | // go left |
456 | int _x=x; | 457 | int _x=x; |
457 | for ( ; m_buf[_x][y]==TILE_FREE; _x-- ) | 458 | for ( ; m_buf[_x][y]==TILE_FREE; _x-- ) |
458 | m_buf[_x][y] = TILE_BORDER; | 459 | m_buf[_x][y] = TILE_BORDER; |
459 | int stopx = _x; | 460 | int stopx = _x; |
460 | 461 | ||
461 | // fill above | 462 | // fill above |
462 | for ( _x=x; _x>stopx; _x-- ) | 463 | for ( _x=x; _x>stopx; _x-- ) |
463 | if ( m_buf[_x][y-1]==TILE_FREE ) fill( _x, y-1 ); | 464 | if ( m_buf[_x][y-1]==TILE_FREE ) fill( _x, y-1 ); |
464 | 465 | ||
diff --git a/noncore/games/kbill/Game.cc b/noncore/games/kbill/Game.cc index 624b50b..4cd5322 100644 --- a/noncore/games/kbill/Game.cc +++ b/noncore/games/kbill/Game.cc | |||
@@ -13,189 +13,189 @@ int Game::RAND(int lb, int ub) { | |||
13 | return (rand()%(ub-lb+1) + lb); | 13 | return (rand()%(ub-lb+1) + lb); |
14 | } | 14 | } |
15 | 15 | ||
16 | int Game::MAX(int x, int y) { | 16 | int Game::MAX(int x, int y) { |
17 | return (x>y ? x : y); | 17 | return (x>y ? x : y); |
18 | } | 18 | } |
19 | 19 | ||
20 | int Game::MIN(int x, int y) { | 20 | int Game::MIN(int x, int y) { |
21 | return (x<y ? x : y); | 21 | return (x<y ? x : y); |
22 | } | 22 | } |
23 | 23 | ||
24 | int Game::INTERSECT(int x1, int y1, int w1, int h1, int x2, int y2, int w2, | 24 | int Game::INTERSECT(int x1, int y1, int w1, int h1, int x2, int y2, int w2, |
25 | int h2) | 25 | int h2) |
26 | { | 26 | { |
27 | return (((x2-x1<=w1 && x2-x1>=0) || (x1-x2<=w2 && x1-x2>=0)) | 27 | return (((x2-x1<=w1 && x2-x1>=0) || (x1-x2<=w2 && x1-x2>=0)) |
28 | && ((y2-y1<=h1 && y2-y1>=0) || (y1-y2<=h2 && y1-y2>=0))); | 28 | && ((y2-y1<=h1 && y2-y1>=0) || (y1-y2<=h2 && y1-y2>=0))); |
29 | } | 29 | } |
30 | 30 | ||
31 | void Game::setup_level (unsigned int lev) { | 31 | void Game::setup_level (unsigned int lev) { |
32 | level = lev; | 32 | level = lev; |
33 | bill.setup(); | 33 | bill.setup(); |
34 | grabbed = EMPTY; | 34 | grabbed = EMPTY; |
35 | ui.set_cursor(DEFAULTC); | 35 | ui.set_cursor(DEFAULTC); |
36 | net.setup(); | 36 | net.setup(); |
37 | iteration = efficiency = 0; | 37 | iteration = efficiency = 0; |
38 | } | 38 | } |
39 | 39 | ||
40 | void Game::start(unsigned int lev) { | 40 | void Game::start(unsigned int lev) { |
41 | state = PLAYING; | 41 | state = PLAYING; |
42 | score = 0; | 42 | score = 0; |
43 | ui.restart_timer(); | 43 | ui.restart_timer(); |
44 | ui.set_pausebutton(true); | 44 | ui.set_pausebutton(true); |
45 | setup_level(lev); | 45 | setup_level(lev); |
46 | } | 46 | } |
47 | 47 | ||
48 | void Game::quit() { | 48 | void Game::quit() { |
49 | 49 | ||
50 | exit(0); | 50 | exit(0); |
51 | } | 51 | } |
52 | 52 | ||
53 | void Game::update_info() { | 53 | void Game::update_info() { |
54 | static char str[80]; | 54 | static char str[80]; |
55 | sprintf (str, "Bill:%d/%d System:%d/%d/%d Level:%d Score:%d", | 55 | sprintf (str, "Bill:%d/%d System:%d/%d/%d Level:%d Score:%d", |
56 | bill.on_screen, bill.off_screen, net.base, net.off, | 56 | bill.on_screen, bill.off_screen, net.base, net.off, |
57 | net.win, level, score); | 57 | net.win, level, score); |
58 | ui.draw_str(str, 5, scrheight-5); | 58 | ui.draw_str(str, 5, scrheight-5); |
59 | efficiency += ((100*net.base-10*net.win)/net.units); | 59 | efficiency += ((100*net.base-10*net.win)/net.units); |
60 | } | 60 | } |
61 | 61 | ||
62 | void Game::update_score (int action) { | 62 | void Game::update_score (int action) { |
63 | switch (action){ | 63 | switch (action){ |
64 | case ENDLEVEL: score+=(level*efficiency/iteration); break; | 64 | case ENDLEVEL: score+=(level*efficiency/iteration); break; |
65 | default: score+=(action*action*BILLPOINTS); | 65 | default: score+=(action*action*BILLPOINTS); |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | void Game::warp_to_level (unsigned int lev) { | 69 | void Game::warp_to_level (unsigned int lev) { |
70 | if (state==PLAYING) { | 70 | if (state==PLAYING) { |
71 | if (lev <= level) return; | 71 | if (lev <= level) return; |
72 | setup_level(lev); | 72 | setup_level(lev); |
73 | } | 73 | } |
74 | else { | 74 | else { |
75 | if (lev<=0) return; | 75 | if (lev <=0) return; |
76 | start(lev); | 76 | start(lev); |
77 | } | 77 | } |
78 | } | 78 | } |
79 | 79 | ||
80 | void Game::button_press(int x, int y) { | 80 | void Game::button_press(int x, int y) { |
81 | int i, counter=0, flag=0; | 81 | int i, counter=0, flag=0; |
82 | if (state != PLAYING) return; | 82 | if (state != PLAYING) return; |
83 | ui.set_cursor(DOWNC); | 83 | ui.set_cursor(DOWNC); |
84 | if (bucket.clicked(x, y)) { | 84 | if (bucket.clicked(x, y)) { |
85 | ui.set_cursor(BUCKETC); | 85 | ui.set_cursor(BUCKETC); |
86 | grabbed = BUCKET; | 86 | grabbed = BUCKET; |
87 | } | 87 | } |
88 | for (i=0; i < bill.MAX_BILLS && !flag; i++) { | 88 | for (i=0; i < bill.MAX_BILLS && !flag; i++) { |
89 | if (bill.list[i].state == bill.list[i].OFF | 89 | if (bill.list[i].state == bill.list[i].OFF |
90 | || bill.list[i].state == bill.list[i].DYING) | 90 | || bill.list[i].state == bill.list[i].DYING) |
91 | continue; | 91 | continue; |
92 | if (bill.list[i].state == bill.list[i].STRAY && | 92 | if (bill.list[i].state == bill.list[i].STRAY && |
93 | bill.list[i].clickedstray(x, y)) | 93 | bill.list[i].clickedstray(x, y)) |
94 | { | 94 | { |
95 | ui.set_cursor (bill.list[i].cargo); | 95 | ui.set_cursor (bill.list[i].cargo); |
96 | grabbed = i; | 96 | grabbed = i; |
97 | flag = 1; | 97 | flag = 1; |
98 | } | 98 | } |
99 | else if (bill.list[i].state != bill.list[i].STRAY && | 99 | else if (bill.list[i].state != bill.list[i].STRAY && |
100 | bill.list[i].clicked(x, y)) | 100 | bill.list[i].clicked(x, y)) |
101 | { | 101 | { |
102 | if (bill.list[i].state == bill.list[i].AT) | 102 | if (bill.list[i].state == bill.list[i].AT) |
103 | net.computers[bill.list[i].target_c].busy=0; | 103 | net.computers[bill.list[i].target_c].busy=0; |
104 | bill.list[i].index = -1; | 104 | bill.list[i].index = -1; |
105 | bill.list[i].cels = bill.dcels; | 105 | bill.list[i].cels = bill.dcels; |
106 | bill.list[i].x_offset = -2; | 106 | bill.list[i].x_offset = -2; |
107 | bill.list[i].y_offset = -15; | 107 | bill.list[i].y_offset = -15; |
108 | bill.list[i].state = bill.list[i].DYING; | 108 | bill.list[i].state = bill.list[i].DYING; |
109 | counter++; | 109 | counter++; |
110 | } | 110 | } |
111 | } | 111 | } |
112 | if (counter) update_score(counter); | 112 | if (counter) update_score(counter); |
113 | } | 113 | } |
114 | 114 | ||
115 | void Game::button_release(int x, int y) { | 115 | void Game::button_release(int x, int y) { |
116 | int i; | 116 | int i; |
117 | ui.set_cursor (DEFAULTC); | 117 | ui.set_cursor (DEFAULTC); |
118 | if (state != PLAYING || grabbed == EMPTY) | 118 | if (state != PLAYING || grabbed == EMPTY) |
119 | return; | 119 | return; |
120 | if (grabbed == BUCKET) { | 120 | if (grabbed == BUCKET) { |
121 | grabbed = EMPTY; | 121 | grabbed = EMPTY; |
122 | for (i=0; i<net.ncables; i++) | 122 | for (i=0; i<net.ncables; i++) |
123 | if (net.cables[i].onspark(x, y)) { | 123 | if (net.cables[i].onspark(x, y)) { |
124 | net.cables[i].active=0; | 124 | net.cables[i].active=0; |
125 | net.cables[i].delay = spark.delay(level); | 125 | net.cables[i].delay = spark.delay(level); |
126 | } | 126 | } |
127 | return; | 127 | return; |
128 | } | 128 | } |
129 | for (i=0; i<net.units; i++) | 129 | for (i=0; i<net.units; i++) |
130 | if (net.computers[i].oncomputer(x, y) | 130 | if (net.computers[i].oncomputer(x, y) |
131 | && | 131 | && |
132 | net.computers[i].compatible (bill.list[grabbed].cargo) | 132 | net.computers[i].compatible (bill.list[grabbed].cargo) |
133 | && | 133 | && |
134 | (net.computers[i].os == OS.WINGDOWS || | 134 | (net.computers[i].os == OS.WINGDOWS || |
135 | net.computers[i].os == OS.OFF)) | 135 | net.computers[i].os == OS.OFF)) |
136 | { | 136 | { |
137 | net.base++; | 137 | net.base++; |
138 | if (net.computers[i].os == OS.WINGDOWS) | 138 | if (net.computers[i].os == OS.WINGDOWS) |
139 | net.win--; | 139 | net.win--; |
140 | else | 140 | else |
141 | net.off--; | 141 | net.off--; |
142 | net.computers[i].os = bill.list[grabbed].cargo; | 142 | net.computers[i].os = bill.list[grabbed].cargo; |
143 | bill.list[grabbed].state = bill.list[grabbed].OFF; | 143 | bill.list[grabbed].state = bill.list[grabbed].OFF; |
144 | grabbed = EMPTY; | 144 | grabbed = EMPTY; |
145 | return; | 145 | return; |
146 | } | 146 | } |
147 | grabbed = EMPTY; | 147 | grabbed = EMPTY; |
148 | } | 148 | } |
149 | 149 | ||
150 | void Game::update() { | 150 | void Game::update() { |
151 | switch (state) { | 151 | switch (state) { |
152 | case PLAYING: | 152 | case PLAYING: |
153 | ui.clear(); | 153 | ui.clear(); |
154 | bucket.draw(); | 154 | bucket.draw(); |
155 | net.update(); | 155 | net.update(); |
156 | net.draw(); | 156 | net.draw(); |
157 | bill.update(); | 157 | bill.update(); |
158 | bill.draw(); | 158 | bill.draw(); |
159 | update_info(); | 159 | update_info(); |
160 | if (!(bill.on_screen+bill.off_screen)) { | 160 | if (!(bill.on_screen+bill.off_screen)) { |
161 | update_score(ENDLEVEL); | 161 | update_score(ENDLEVEL); |
162 | state = BETWEEN; | 162 | state = BETWEEN; |
163 | } | 163 | } |
164 | if ((net.base+net.off)<=1) state = END; | 164 | if ((net.base+net.off)<=1) state = END; |
165 | break; | 165 | break; |
166 | case END: | 166 | case END: |
167 | ui.clear(); | 167 | ui.clear(); |
168 | net.toasters(); | 168 | net.toasters(); |
169 | net.draw(); | 169 | net.draw(); |
170 | ui.refresh(); | 170 | ui.refresh(); |
171 | ui.popup_dialog(ENDGAME); | 171 | ui.popup_dialog(ENDGAME); |
172 | /* if (score > scores.score[9]) ui.popup_dialog(ENTERNAME); | 172 | /* if (score > scores.score[9]) ui.popup_dialog(ENTERNAME); |
173 | scores.update();*/ | 173 | scores.update();*/ |
174 | ui.popup_dialog(HIGHSCORE); | 174 | ui.popup_dialog(HIGHSCORE); |
175 | ui.clear(); | 175 | ui.clear(); |
176 | ui.draw_centered(logo); | 176 | ui.draw_centered(logo); |
177 | ui.kill_timer(); | 177 | ui.kill_timer(); |
178 | ui.set_pausebutton (false); | 178 | ui.set_pausebutton (false); |
179 | state = WAITING; | 179 | state = WAITING; |
180 | break; | 180 | break; |
181 | case BETWEEN: | 181 | case BETWEEN: |
182 | ui.update_scorebox(level, score); | 182 | ui.update_scorebox(level, score); |
183 | ui.popup_dialog (SCORE); | 183 | ui.popup_dialog (SCORE); |
184 | state = PLAYING; | 184 | state = PLAYING; |
185 | setup_level(++level); | 185 | setup_level(++level); |
186 | break; | 186 | break; |
187 | } | 187 | } |
188 | ui.refresh(); | 188 | ui.refresh(); |
189 | iteration++; | 189 | iteration++; |
190 | } | 190 | } |
191 | 191 | ||
192 | void Game::main(int argc, char **argv) { | 192 | void Game::main(int argc, char **argv) { |
193 | int c; | 193 | int c; |
194 | extern char *optarg; | 194 | extern char *optarg; |
195 | 195 | ||
196 | level = 0; | 196 | level = 0; |
197 | ui.initialize(&argc, argv); | 197 | ui.initialize(&argc, argv); |
198 | while (argv && argv[0] && (c = getopt(argc, argv, "l:L:")) != -1) | 198 | while (argv && argv[0] && (c = getopt(argc, argv, "l:L:")) != -1) |
199 | switch(c) { | 199 | switch(c) { |
200 | case 'l': | 200 | case 'l': |
201 | case 'L': level = MAX (1, atoi(optarg)); break; | 201 | case 'L': level = MAX (1, atoi(optarg)); break; |
diff --git a/noncore/games/kbill/Game.h b/noncore/games/kbill/Game.h index 4473936..5c9c497 100644 --- a/noncore/games/kbill/Game.h +++ b/noncore/games/kbill/Game.h | |||
@@ -1,55 +1,55 @@ | |||
1 | #ifndef GAME_H | 1 | #ifndef GAME_H |
2 | #define GAME_H | 2 | #define GAME_H |
3 | 3 | ||
4 | #include "objects.h" | 4 | #include "objects.h" |
5 | 5 | ||
6 | class Game { | 6 | class Game { |
7 | unsigned state; | 7 | int state; |
8 | int efficiency; | 8 | int efficiency; |
9 | public: | 9 | public: |
10 | unsigned score, level, iteration; | 10 | unsigned score, level, iteration; |
11 | Picture logo; | 11 | Picture logo; |
12 | int grabbed; | 12 | int grabbed; |
13 | 13 | ||
14 | static const unsigned short scrwidth = 240; | 14 | static const unsigned short scrwidth = 240; |
15 | static const unsigned short scrheight = 290; | 15 | static const unsigned short scrheight = 290; |
16 | 16 | ||
17 | static const int PLAYING = 1; | 17 | static const int PLAYING = 1; |
18 | static const int BETWEEN = 2; | 18 | static const int BETWEEN = 2; |
19 | static const int END = 3; | 19 | static const int END = 3; |
20 | static const int WAITING = 4; | 20 | static const int WAITING = 4; |
21 | 21 | ||
22 | static const int DEFAULTC = 0; /* cursors */ | 22 | static const int DEFAULTC = 0; /* cursors */ |
23 | static const int DOWNC = -1; | 23 | static const int DOWNC = -1; |
24 | static const int BUCKETC = -2; | 24 | static const int BUCKETC = -2; |
25 | 25 | ||
26 | static const int ENDGAME = 200; /* dialog window IDs */ | 26 | static const int ENDGAME = 200; /* dialog window IDs */ |
27 | static const int ENTERNAME = 201; | 27 | static const int ENTERNAME = 201; |
28 | static const int HIGHSCORE = 202; | 28 | static const int HIGHSCORE = 202; |
29 | static const int SCORE = 203; | 29 | static const int SCORE = 203; |
30 | 30 | ||
31 | static const int ENDLEVEL = -1; /* Codes for updating score */ | 31 | static const int ENDLEVEL = -1; /* Codes for updating score */ |
32 | static const int BILLPOINTS = 5; | 32 | static const int BILLPOINTS = 5; |
33 | 33 | ||
34 | static const int EMPTY = -2; /* Grabbed object */ | 34 | static const int EMPTY = -2; /* Grabbed object */ |
35 | static const int BUCKET = -1; | 35 | static const int BUCKET = -1; |
36 | 36 | ||
37 | int RAND(int lb, int ub); | 37 | int RAND(int lb, int ub); |
38 | int MAX(int x, int y); | 38 | int MAX(int x, int y); |
39 | int MIN(int x, int y); | 39 | int MIN(int x, int y); |
40 | int INTERSECT(int x1, int y1, int w1, int h1, int x2, int y2, int w2, | 40 | int INTERSECT(int x1, int y1, int w1, int h1, int x2, int y2, int w2, |
41 | int h2); | 41 | int h2); |
42 | 42 | ||
43 | void setup_level (unsigned int lev); | 43 | void setup_level (unsigned int lev); |
44 | void start(unsigned int lev); | 44 | void start(unsigned int lev); |
45 | void quit(); | 45 | void quit(); |
46 | void update_info(); | 46 | void update_info(); |
47 | void update_score (int action); | 47 | void update_score (int action); |
48 | void warp_to_level (unsigned int lev); | 48 | void warp_to_level (unsigned int lev); |
49 | void button_press(int x, int y); | 49 | void button_press(int x, int y); |
50 | void button_release(int x, int y); | 50 | void button_release(int x, int y); |
51 | void update(); | 51 | void update(); |
52 | void main(int argc, char **argv); | 52 | void main(int argc, char **argv); |
53 | }; | 53 | }; |
54 | 54 | ||
55 | #endif | 55 | #endif |
diff --git a/noncore/games/kbill/field.cpp b/noncore/games/kbill/field.cpp index a974ab2..0dd8d72 100644 --- a/noncore/games/kbill/field.cpp +++ b/noncore/games/kbill/field.cpp | |||
@@ -35,49 +35,49 @@ Field::~Field(){ | |||
35 | } | 35 | } |
36 | 36 | ||
37 | void Field::setPixmap(QPixmap *pix) { | 37 | void Field::setPixmap(QPixmap *pix) { |
38 | this->pix = pix; | 38 | this->pix = pix; |
39 | } | 39 | } |
40 | 40 | ||
41 | // -------------------------------------------------------- | 41 | // -------------------------------------------------------- |
42 | 42 | ||
43 | void Field::mousePressEvent(QMouseEvent *e){ | 43 | void Field::mousePressEvent(QMouseEvent *e){ |
44 | game.button_press(e->x(), e->y()); | 44 | game.button_press(e->x(), e->y()); |
45 | } | 45 | } |
46 | 46 | ||
47 | void Field::mouseReleaseEvent(QMouseEvent *e){ | 47 | void Field::mouseReleaseEvent(QMouseEvent *e){ |
48 | game.button_release(e->x(), e->y()); | 48 | game.button_release(e->x(), e->y()); |
49 | } | 49 | } |
50 | 50 | ||
51 | void Field::enterEvent(QEvent *) { | 51 | void Field::enterEvent(QEvent *) { |
52 | if (playing && !timer->isActive()) { | 52 | if (playing && !timer->isActive()) { |
53 | playing = true; | 53 | playing = true; |
54 | timer->start(250, FALSE); | 54 | timer->start(250, FALSE); |
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | void Field::leaveEvent(QEvent *) { | 58 | void Field::leaveEvent(QEvent *) { |
59 | if (timer->isActive() && playing) { | 59 | if (timer->isActive() && playing) { |
60 | playing = true; | 60 | playing = true; |
61 | timer->stop(); | 61 | timer->stop(); |
62 | } | 62 | } |
63 | } | 63 | } |
64 | 64 | ||
65 | void Field::stopTimer() { | 65 | void Field::stopTimer() { |
66 | playing = false; | 66 | playing = false; |
67 | if (timer->isActive()) | 67 | if (timer->isActive()) |
68 | timer->stop(); | 68 | timer->stop(); |
69 | } | 69 | } |
70 | 70 | ||
71 | void Field::startTimer() { | 71 | void Field::startTimer() { |
72 | playing = true; | 72 | playing = true; |
73 | if (!timer->isActive()) | 73 | if (!timer->isActive()) |
74 | timer->start(250, FALSE); | 74 | timer->start(250, FALSE); |
75 | } | 75 | } |
76 | 76 | ||
77 | void Field::Timer(){ | 77 | void Field::Timer(){ |
78 | game.update(); | 78 | game.update(); |
79 | } | 79 | } |
80 | 80 | ||
81 | void Field::paintEvent(QPaintEvent *) { | 81 | void Field::paintEvent(QPaintEvent *) { |
82 | bitBlt(this, 0, 0, pix); | 82 | bitBlt(this, 0, 0, pix); |
83 | } \ No newline at end of file | 83 | } |
diff --git a/noncore/games/kbill/inputbox.cpp b/noncore/games/kbill/inputbox.cpp index 5087fbb..7aaebe7 100644 --- a/noncore/games/kbill/inputbox.cpp +++ b/noncore/games/kbill/inputbox.cpp | |||
@@ -1,50 +1,50 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | inputbox.cpp - description | 2 | inputbox.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Sat Jan 1 2000 | 4 | begin : Sat Jan 1 2000 |
5 | copyright : (C) 2000 by Jurrien Loonstra | 5 | copyright : (C) 2000 by Jurrien Loonstra |
6 | email : j.h.loonstra@st.hanze.nl | 6 | email : j.h.loonstra@st.hanze.nl |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #include "inputbox.h" | 18 | #include "inputbox.h" |
19 | InputBox::InputBox(QWidget *parent, const char *name, const char *caption, const char *text) : QDialog(parent, name, TRUE) { | 19 | InputBox::InputBox(QWidget *parent, const char *name, const char *, const char *) : QDialog(parent, name, TRUE) { |
20 | // setCaption(caption); | 20 | // setCaption(caption); |
21 | // | 21 | // |
22 | // question = new QLabel(this); | 22 | // question = new QLabel(this); |
23 | // question->setText(text); | 23 | // question->setText(text); |
24 | // question->setGeometry(10, 10, 240, 50); | 24 | // question->setGeometry(10, 10, 240, 50); |
25 | // | 25 | // |
26 | // input = new QLineEdit(this); | 26 | // input = new QLineEdit(this); |
27 | // input->setGeometry(10, 60, 240, 30); | 27 | // input->setGeometry(10, 60, 240, 30); |
28 | // input->setFocus(); | 28 | // input->setFocus(); |
29 | // input->setMaxLength(19); | 29 | // input->setMaxLength(19); |
30 | // | 30 | // |
31 | // ok = new QPushButton( "Ok", this ); | 31 | // ok = new QPushButton( "Ok", this ); |
32 | // ok->setGeometry(10, 100, 100,30 ); | 32 | // ok->setGeometry(10, 100, 100,30 ); |
33 | // ok->setDefault(TRUE); | 33 | // ok->setDefault(TRUE); |
34 | // connect( ok, SIGNAL(clicked()), SLOT(accept()) ); | 34 | // connect( ok, SIGNAL(clicked()), SLOT(accept()) ); |
35 | // | 35 | // |
36 | // cancel = new QPushButton( "Cancel", this ); | 36 | // cancel = new QPushButton( "Cancel", this ); |
37 | // cancel->setGeometry(150, 100, 100,30 ); | 37 | // cancel->setGeometry(150, 100, 100,30 ); |
38 | // connect( cancel, SIGNAL(clicked()), SLOT(reject()) ); | 38 | // connect( cancel, SIGNAL(clicked()), SLOT(reject()) ); |
39 | } | 39 | } |
40 | 40 | ||
41 | InputBox::~InputBox(){ | 41 | InputBox::~InputBox(){ |
42 | delete ok; | 42 | delete ok; |
43 | delete cancel; | 43 | delete cancel; |
44 | delete question; | 44 | delete question; |
45 | delete input; | 45 | delete input; |
46 | } | 46 | } |
47 | 47 | ||
48 | QString InputBox::getText() const{ | 48 | QString InputBox::getText() const{ |
49 | return input->text(); | 49 | return input->text(); |
50 | } | 50 | } |
diff --git a/noncore/games/kbill/kbill.h b/noncore/games/kbill/kbill.h index fbc0c6c..da1a111 100644 --- a/noncore/games/kbill/kbill.h +++ b/noncore/games/kbill/kbill.h | |||
@@ -1,54 +1,56 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | kbill.h - description | 2 | kbill.h - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Thu Dec 30 16:55:55 CET 1999 | 4 | begin : Thu Dec 30 16:55:55 CET 1999 |
5 | copyright : (C) 1999 by Jurrien Loonstra | 5 | copyright : (C) 1999 by Jurrien Loonstra |
6 | email : j.h.loonstra@st.hanze.nl | 6 | email : j.h.loonstra@st.hanze.nl |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #ifndef KBILL_H | 18 | #ifndef KBILL_H |
19 | #define KBILL_H | 19 | #define KBILL_H |
20 | 20 | ||
21 | 21 | ||
22 | 22 | ||
23 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include <qwidget.h> | 24 | #include <qwidget.h> |
25 | #include <qpopupmenu.h> | 25 | #include <qpopupmenu.h> |
26 | 26 | ||
27 | #include "field.h" | 27 | #include "field.h" |
28 | 28 | ||
29 | class KBill : public QMainWindow | 29 | class KBill : public QMainWindow |
30 | { | 30 | { |
31 | Q_OBJECT | 31 | Q_OBJECT |
32 | public: | 32 | public: |
33 | KBill(); | 33 | KBill(); |
34 | ~KBill(); | 34 | ~KBill(); |
35 | Field* getField(); | 35 | Field* getField(); |
36 | private: | 36 | private: |
37 | QMenuBar *menu; | 37 | QMenuBar *menu; |
38 | QPopupMenu *file, *help; | 38 | QPopupMenu *file, *help; |
39 | Field *field; | 39 | Field *field; |
40 | int pauseid; | 40 | int pauseid; |
41 | protected slots: | 41 | |
42 | void Quit(); | 42 | protected slots: |
43 | void About(); | 43 | void Quit(); |
44 | void NewGame(); | 44 | void About(); |
45 | void Pause(); | 45 | void NewGame(); |
46 | void WarpTo(); | 46 | void Pause(); |
47 | void Story(); | 47 | void WarpTo(); |
48 | void Rules(); | 48 | void Story(); |
49 | void ViewHighScores(); | 49 | void Rules(); |
50 | 50 | void ViewHighScores(); | |
51 | friend class UI; | 51 | |
52 | protected: | ||
53 | friend class UI; | ||
52 | }; | 54 | }; |
53 | 55 | ||
54 | #endif | 56 | #endif |
diff --git a/noncore/games/zsame/ZSameWidget.cpp b/noncore/games/zsame/ZSameWidget.cpp index 4fab0f6..04ad825 100644 --- a/noncore/games/zsame/ZSameWidget.cpp +++ b/noncore/games/zsame/ZSameWidget.cpp | |||
@@ -64,181 +64,181 @@ ZSameWidget::ZSameWidget( QWidget* parent, const char* name, WFlags fl ) | |||
64 | a->addTo( tb ); | 64 | a->addTo( tb ); |
65 | connect(a, SIGNAL(activated()), this, SLOT(m_new())); | 65 | connect(a, SIGNAL(activated()), this, SLOT(m_new())); |
66 | 66 | ||
67 | a = new QAction(tr("Restart This Board"), Resource::loadIconSet("redo"), | 67 | a = new QAction(tr("Restart This Board"), Resource::loadIconSet("redo"), |
68 | QString::null, 0, this, "restart_board" ); | 68 | QString::null, 0, this, "restart_board" ); |
69 | a->addTo( fileMenu ); | 69 | a->addTo( fileMenu ); |
70 | connect( a, SIGNAL(activated()), this, SLOT(m_restart())); | 70 | connect( a, SIGNAL(activated()), this, SLOT(m_restart())); |
71 | restart = a; | 71 | restart = a; |
72 | 72 | ||
73 | a = new QAction( tr("Undo"), Resource::loadIconSet("undo"), | 73 | a = new QAction( tr("Undo"), Resource::loadIconSet("undo"), |
74 | QString::null, 0, this, "undo_action" ); | 74 | QString::null, 0, this, "undo_action" ); |
75 | a->addTo( fileMenu ); | 75 | a->addTo( fileMenu ); |
76 | a->addTo( tb ); | 76 | a->addTo( tb ); |
77 | connect( a, SIGNAL(activated()), this, SLOT(m_undo())); | 77 | connect( a, SIGNAL(activated()), this, SLOT(m_undo())); |
78 | 78 | ||
79 | a = new QAction(tr("Quit"), Resource::loadIconSet("quit_icon"), | 79 | a = new QAction(tr("Quit"), Resource::loadIconSet("quit_icon"), |
80 | QString::null, 0, this, "quit_action"); | 80 | QString::null, 0, this, "quit_action"); |
81 | a->addTo( fileMenu ); | 81 | a->addTo( fileMenu ); |
82 | a->addTo( tb ); | 82 | a->addTo( tb ); |
83 | connect(a, SIGNAL(activated()), this, SLOT(m_quit())); | 83 | connect(a, SIGNAL(activated()), this, SLOT(m_quit())); |
84 | 84 | ||
85 | mb->insertItem(tr("Game" ), fileMenu ); | 85 | mb->insertItem(tr("Game" ), fileMenu ); |
86 | 86 | ||
87 | int foo[2]; | 87 | int foo[2]; |
88 | desktop_widget(foo); | 88 | desktop_widget(foo); |
89 | stone = new StoneWidget(this,foo[0],foo[1]); | 89 | stone = new StoneWidget(this,foo[0],foo[1]); |
90 | 90 | ||
91 | connect( stone, SIGNAL(s_gameover()), this, SLOT(gameover())); | 91 | connect( stone, SIGNAL(s_gameover()), this, SLOT(gameover())); |
92 | 92 | ||
93 | connect( stone, SIGNAL(s_colors(int)), this, SLOT(setColors(int))); | 93 | connect( stone, SIGNAL(s_colors(int)), this, SLOT(setColors(int))); |
94 | connect( stone, SIGNAL(s_board(int)), this, SLOT(setBoard(int))); | 94 | connect( stone, SIGNAL(s_board(int)), this, SLOT(setBoard(int))); |
95 | connect( stone, SIGNAL(s_marked(int)), this, SLOT(setMarked(int))); | 95 | connect( stone, SIGNAL(s_marked(int)), this, SLOT(setMarked(int))); |
96 | connect( stone, SIGNAL(s_score(int)), this, SLOT(setScore(int))); | 96 | connect( stone, SIGNAL(s_score(int)), this, SLOT(setScore(int))); |
97 | connect( stone, SIGNAL(s_remove(int,int)), this, SLOT(stonesRemoved(int,int))); | 97 | connect( stone, SIGNAL(s_remove(int,int)), this, SLOT(stonesRemoved(int,int))); |
98 | 98 | ||
99 | connect(stone, SIGNAL(s_sizechanged()), this, SLOT(sizeChanged())); | 99 | connect(stone, SIGNAL(s_sizechanged()), this, SLOT(sizeChanged())); |
100 | 100 | ||
101 | sizeChanged(); | 101 | sizeChanged(); |
102 | setCentralWidget(stone); | 102 | setCentralWidget(stone); |
103 | 103 | ||
104 | 104 | ||
105 | setScore(0); | 105 | setScore(0); |
106 | } | 106 | } |
107 | 107 | ||
108 | ZSameWidget::~ZSameWidget() { | 108 | ZSameWidget::~ZSameWidget() { |
109 | 109 | ||
110 | } | 110 | } |
111 | 111 | ||
112 | void ZSameWidget::readProperties(Config *conf) { | 112 | void ZSameWidget::readProperties(Config *) { |
113 | /* | 113 | /* |
114 | Q_ASSERT(conf); | 114 | Q_ASSERT(conf); |
115 | stone->readProperties(conf); | 115 | stone->readProperties(conf); |
116 | */ | 116 | */ |
117 | } | 117 | } |
118 | 118 | ||
119 | void ZSameWidget::saveProperties(Config *conf) { | 119 | void ZSameWidget::saveProperties(Config *) { |
120 | /* | 120 | /* |
121 | Q_ASSERT(conf); | 121 | Q_ASSERT(conf); |
122 | stone->saveProperties(conf); | 122 | stone->saveProperties(conf); |
123 | conf->sync(); | 123 | conf->sync(); |
124 | */ | 124 | */ |
125 | } | 125 | } |
126 | 126 | ||
127 | void ZSameWidget::sizeChanged() { | 127 | void ZSameWidget::sizeChanged() { |
128 | //stone->setFixedSize(stone->sizeHint()); | 128 | //stone->setFixedSize(stone->sizeHint()); |
129 | } | 129 | } |
130 | 130 | ||
131 | void ZSameWidget::newGame(unsigned int board,int colors) { | 131 | void ZSameWidget::newGame(unsigned int board,int colors) { |
132 | while (board>=1000000) board-=1000000; | 132 | while (board>=1000000) board-=1000000; |
133 | // kdDebug() << "newgame board " << board << " colors " << colors << endl; | 133 | // kdDebug() << "newgame board " << board << " colors " << colors << endl; |
134 | stone->newGame(board,colors); | 134 | stone->newGame(board,colors); |
135 | setScore(0); | 135 | setScore(0); |
136 | } | 136 | } |
137 | 137 | ||
138 | bool ZSameWidget::confirmAbort() { | 138 | bool ZSameWidget::confirmAbort() { |
139 | return stone->isGameover() || | 139 | return stone->isGameover() || |
140 | stone->isOriginalBoard() || | 140 | stone->isOriginalBoard() || |
141 | (QMessageBox::warning(this, i18n("Resign"), i18n("<qt>Do you want to resign?</qt>"), | 141 | (QMessageBox::warning(this, i18n("Resign"), i18n("<qt>Do you want to resign?</qt>"), |
142 | QMessageBox::Yes, | 142 | QMessageBox::Yes, |
143 | QMessageBox::No|QMessageBox::Default|QMessageBox::Escape, 0) == QMessageBox::Yes ); | 143 | QMessageBox::No|QMessageBox::Default|QMessageBox::Escape, 0) == QMessageBox::Yes ); |
144 | } | 144 | } |
145 | 145 | ||
146 | void ZSameWidget::m_new() { | 146 | void ZSameWidget::m_new() { |
147 | if (confirmAbort()) | 147 | if (confirmAbort()) |
148 | newGame(_random(),default_colors); | 148 | newGame(_random(),default_colors); |
149 | 149 | ||
150 | } | 150 | } |
151 | 151 | ||
152 | void ZSameWidget::m_restart() { | 152 | void ZSameWidget::m_restart() { |
153 | if (confirmAbort()) | 153 | if (confirmAbort()) |
154 | newGame(stone->board(),default_colors); | 154 | newGame(stone->board(),default_colors); |
155 | } | 155 | } |
156 | 156 | ||
157 | void ZSameWidget::m_load() { | 157 | void ZSameWidget::m_load() { |
158 | // kdDebug() << "menu load not supported" << endl; | 158 | // kdDebug() << "menu load not supported" << endl; |
159 | } | 159 | } |
160 | 160 | ||
161 | void ZSameWidget::m_save() { | 161 | void ZSameWidget::m_save() { |
162 | // kdDebug() << "menu save not supported" << endl; | 162 | // kdDebug() << "menu save not supported" << endl; |
163 | } | 163 | } |
164 | 164 | ||
165 | void ZSameWidget::m_undo() { | 165 | void ZSameWidget::m_undo() { |
166 | //Q_ASSERT(stone); | 166 | //Q_ASSERT(stone); |
167 | stone->undo(); | 167 | stone->undo(); |
168 | } | 168 | } |
169 | 169 | ||
170 | 170 | ||
171 | void ZSameWidget::m_showhs() { | 171 | void ZSameWidget::m_showhs() { |
172 | /* Q_ASSERT(stone); | 172 | /* Q_ASSERT(stone); |
173 | stone->unmark(); | 173 | stone->unmark(); |
174 | KScoreDialog d(KScoreDialog::Name | KScoreDialog::Score, this); | 174 | KScoreDialog d(KScoreDialog::Name | KScoreDialog::Score, this); |
175 | d.addField(Board, i18n("Board"), "Board"); | 175 | d.addField(Board, i18n("Board"), "Board"); |
176 | d.exec(); | 176 | d.exec(); |
177 | */ | 177 | */ |
178 | } | 178 | } |
179 | 179 | ||
180 | void ZSameWidget::m_quit() { | 180 | void ZSameWidget::m_quit() { |
181 | // Q_ASSERT(stone); | 181 | // Q_ASSERT(stone); |
182 | stone->unmark(); | 182 | stone->unmark(); |
183 | qApp->quit(); | 183 | qApp->quit(); |
184 | // delete this; | 184 | // delete this; |
185 | } | 185 | } |
186 | 186 | ||
187 | void ZSameWidget::m_tglboard() { | 187 | void ZSameWidget::m_tglboard() { |
188 | //kdDebug() << "toggled" << endl; | 188 | //kdDebug() << "toggled" << endl; |
189 | } | 189 | } |
190 | 190 | ||
191 | 191 | ||
192 | void ZSameWidget::setColors(int colors) { | 192 | void ZSameWidget::setColors(int ) { |
193 | //status->changeItem(i18n("%1 Colors").arg(colors),1); | 193 | //status->changeItem(i18n("%1 Colors").arg(colors),1); |
194 | } | 194 | } |
195 | 195 | ||
196 | void ZSameWidget::setBoard(int board) { | 196 | void ZSameWidget::setBoard(int ) { |
197 | //status->changeItem(i18n("Board: %1").arg(board, 6), 2); | 197 | //status->changeItem(i18n("Board: %1").arg(board, 6), 2); |
198 | } | 198 | } |
199 | 199 | ||
200 | void ZSameWidget::setMarked(int m) { | 200 | void ZSameWidget::setMarked(int ) { |
201 | // status->changeItem(i18n("Marked: %1").arg(m, 6),3); | 201 | // status->changeItem(i18n("Marked: %1").arg(m, 6),3); |
202 | } | 202 | } |
203 | 203 | ||
204 | void ZSameWidget::stonesRemoved(int,int) { | 204 | void ZSameWidget::stonesRemoved(int,int) { |
205 | //KNotifyClient::event("stones removed", | 205 | //KNotifyClient::event("stones removed", |
206 | // i18n("%1 stones removed.").arg(stone->marked())); | 206 | // i18n("%1 stones removed.").arg(stone->marked())); |
207 | } | 207 | } |
208 | 208 | ||
209 | void ZSameWidget::setScore(int score) { | 209 | void ZSameWidget::setScore(int ) { |
210 | // status->changeItem(i18n("Score: %1").arg(score, 6),4); | 210 | // status->changeItem(i18n("Score: %1").arg(score, 6),4); |
211 | // undo->setEnabled(stone->undoPossible()); | 211 | // undo->setEnabled(stone->undoPossible()); |
212 | // restart->setEnabled(!stone->isOriginalBoard()); | 212 | // restart->setEnabled(!stone->isOriginalBoard()); |
213 | } | 213 | } |
214 | 214 | ||
215 | void ZSameWidget::gameover() { | 215 | void ZSameWidget::gameover() { |
216 | // kdDebug() << "GameOver" << endl; | 216 | // kdDebug() << "GameOver" << endl; |
217 | if (stone->hasBonus()) { | 217 | if (stone->hasBonus()) { |
218 | QMessageBox::information(this,i18n("Game won"), | 218 | QMessageBox::information(this,i18n("Game won"), |
219 | i18n("<qt>You even removed the last stone, great job! " | 219 | i18n("<qt>You even removed the last stone, great job! " |
220 | "This gave you a score of %1 in total.</qt>").arg(stone->score())); | 220 | "This gave you a score of %1 in total.</qt>").arg(stone->score())); |
221 | } else { | 221 | } else { |
222 | QMessageBox::information(this,i18n("Game over"), | 222 | QMessageBox::information(this,i18n("Game over"), |
223 | i18n("<qt>There are no more removeable stones. " | 223 | i18n("<qt>There are no more removeable stones. " |
224 | "You got a score of %1 in total.</qt>").arg(stone->score())); | 224 | "You got a score of %1 in total.</qt>").arg(stone->score())); |
225 | } | 225 | } |
226 | stone->unmark(); | 226 | stone->unmark(); |
227 | } | 227 | } |
228 | 228 | ||
229 | void ZSameWidget::desktop_widget(int *f)const{ | 229 | void ZSameWidget::desktop_widget(int *f)const{ |
230 | 230 | ||
231 | QWidget* wid = QApplication::desktop(); | 231 | QWidget* wid = QApplication::desktop(); |
232 | /* width > height landscape mode */ | 232 | /* width > height landscape mode */ |
233 | if ( wid->width() > wid->height() ) { | 233 | if ( wid->width() > wid->height() ) { |
234 | f[0]=15; | 234 | f[0]=15; |
235 | f[1]=9; | 235 | f[1]=9; |
236 | } | 236 | } |
237 | /* normal */ | 237 | /* normal */ |
238 | else{ | 238 | else{ |
239 | f[0]=12; | 239 | f[0]=12; |
240 | f[1]=13; | 240 | f[1]=13; |
241 | } | 241 | } |
242 | } | 242 | } |
243 | 243 | ||
244 | 244 | ||