author | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
commit | b6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (unidiff) | |
tree | d3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /noncore/games | |
parent | 0d59c780513da78033f4d9040475dee9db0256d4 (diff) | |
download | opie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2 |
applied the patch generated by the optimize_connect script from
TT.
-rw-r--r-- | noncore/games/bounce/game.cpp | 12 | ||||
-rw-r--r-- | noncore/games/buzzword/buzzword.cpp | 2 | ||||
-rw-r--r-- | noncore/games/kpacman/kpacman.cpp | 4 | ||||
-rw-r--r-- | noncore/games/oyatzee/oyatzee.cpp | 4 |
4 files changed, 11 insertions, 11 deletions
diff --git a/noncore/games/bounce/game.cpp b/noncore/games/bounce/game.cpp index c07f453..1f1f8cd 100644 --- a/noncore/games/bounce/game.cpp +++ b/noncore/games/bounce/game.cpp | |||
@@ -276,103 +276,103 @@ void JezzView::viewportMouseReleaseEvent( QMouseEvent *ev ) | |||
276 | void JezzView::changeCursor() | 276 | void JezzView::changeCursor() |
277 | { | 277 | { |
278 | m_vertical = !m_vertical; | 278 | m_vertical = !m_vertical; |
279 | if ( m_vertical ) | 279 | if ( m_vertical ) |
280 | { | 280 | { |
281 | setCursor( sizeVerCursor ); | 281 | setCursor( sizeVerCursor ); |
282 | } | 282 | } |
283 | else | 283 | else |
284 | { | 284 | { |
285 | setCursor( sizeHorCursor ); | 285 | setCursor( sizeHorCursor ); |
286 | } | 286 | } |
287 | } | 287 | } |
288 | 288 | ||
289 | /*************************************************************************/ | 289 | /*************************************************************************/ |
290 | 290 | ||
291 | JezzGame::JezzGame( int ballNum, QWidget *parent, const char *name ) | 291 | JezzGame::JezzGame( int ballNum, QWidget *parent, const char *name ) |
292 | : QWidget( parent, name ), m_wall1( 0 ), m_wall2( 0 ), | 292 | : QWidget( parent, name ), m_wall1( 0 ), m_wall2( 0 ), |
293 | m_text( 0 ), m_running( false ), m_percent( 0 ), m_pictured( false ) | 293 | m_text( 0 ), m_running( false ), m_percent( 0 ), m_pictured( false ) |
294 | { | 294 | { |
295 | QString path = QPEApplication::qpeDir()+"pics/bounce/"; | 295 | QString path = QPEApplication::qpeDir()+"pics/bounce/"; |
296 | 296 | ||
297 | // load gfx | 297 | // load gfx |
298 | m_ballPixmaps = new QCanvasPixmapArray( path + "ball%1.png", 25 ); | 298 | m_ballPixmaps = new QCanvasPixmapArray( path + "ball%1.png", 25 ); |
299 | for ( unsigned n=0; n < m_ballPixmaps->count(); n++ ) | 299 | for ( unsigned n=0; n < m_ballPixmaps->count(); n++ ) |
300 | m_ballPixmaps->image(n)->setOffset( 0, 0 ); | 300 | m_ballPixmaps->image(n)->setOffset( 0, 0 ); |
301 | 301 | ||
302 | m_arrowPixmaps = new QCanvasPixmapArray( path + "arrow%1.png", 2 ); | 302 | m_arrowPixmaps = new QCanvasPixmapArray( path + "arrow%1.png", 2 ); |
303 | for ( unsigned n=0; n < m_arrowPixmaps->count(); n++ ) | 303 | for ( unsigned n=0; n < m_arrowPixmaps->count(); n++ ) |
304 | m_arrowPixmaps->image(n)->setOffset( 0, 0 ); | 304 | m_arrowPixmaps->image(n)->setOffset( 0, 0 ); |
305 | 305 | ||
306 | QPixmap tiles( path + "tiles.png" ); | 306 | QPixmap tiles( path + "tiles.png" ); |
307 | 307 | ||
308 | // create field | 308 | // create field |
309 | m_field = new JezzField( tiles, this, "m_field" ); | 309 | m_field = new JezzField( tiles, this, "m_field" ); |
310 | m_field->resize( TILE_SIZE*FIELD_WIDTH, TILE_SIZE*FIELD_HEIGHT ); | 310 | m_field->resize( TILE_SIZE*FIELD_WIDTH, TILE_SIZE*FIELD_HEIGHT ); |
311 | 311 | ||
312 | for ( int x=0; x<FIELD_WIDTH; x++ ) | 312 | for ( int x=0; x<FIELD_WIDTH; x++ ) |
313 | m_field->setTile( x, 0, TILE_BORDER ); | 313 | m_field->setTile( x, 0, TILE_BORDER ); |
314 | for ( int y=1; y<FIELD_HEIGHT-1; y++ ) | 314 | for ( int y=1; y<FIELD_HEIGHT-1; y++ ) |
315 | { | 315 | { |
316 | m_field->setTile( 0, y, TILE_BORDER ); | 316 | m_field->setTile( 0, y, TILE_BORDER ); |
317 | for ( int x=1; x<FIELD_WIDTH-1; x++ ) | 317 | for ( int x=1; x<FIELD_WIDTH-1; x++ ) |
318 | m_field->setTile( x, y, TILE_FREE ); | 318 | m_field->setTile( x, y, TILE_FREE ); |
319 | m_field->setTile( FIELD_WIDTH-1, y, TILE_BORDER ); | 319 | m_field->setTile( FIELD_WIDTH-1, y, TILE_BORDER ); |
320 | } | 320 | } |
321 | for ( int x=0; x<FIELD_WIDTH; x++ ) | 321 | for ( int x=0; x<FIELD_WIDTH; x++ ) |
322 | m_field->setTile( x, FIELD_HEIGHT-1, TILE_BORDER ); | 322 | m_field->setTile( x, FIELD_HEIGHT-1, TILE_BORDER ); |
323 | 323 | ||
324 | connect( m_field, SIGNAL(ballCollision(Ball *, int, int, int)), this, SLOT(ballCollision(Ball *, int, int, int)) ); | 324 | connect( m_field, SIGNAL(ballCollision(Ball*,int,int,int)), this, SLOT(ballCollision(Ball*,int,int,int)) ); |
325 | 325 | ||
326 | // create view | 326 | // create view |
327 | m_view = new JezzView( m_field, this, "m_view" ); | 327 | m_view = new JezzView( m_field, this, "m_view" ); |
328 | m_view->move( 0, 0 ); | 328 | m_view->move( 0, 0 ); |
329 | m_view->adjustSize(); | 329 | m_view->adjustSize(); |
330 | connect( m_view, SIGNAL(buildWall(int, int, bool)), this, SLOT(buildWall(int, int, bool)) ); | 330 | connect( m_view, SIGNAL(buildWall(int,int,bool)), this, SLOT(buildWall(int,int,bool)) ); |
331 | 331 | ||
332 | // create balls | 332 | // create balls |
333 | for ( int n=0; n<ballNum; n++ ) | 333 | for ( int n=0; n<ballNum; n++ ) |
334 | { | 334 | { |
335 | Ball *ball = new Ball( m_ballPixmaps, m_field ); | 335 | Ball *ball = new Ball( m_ballPixmaps, m_field ); |
336 | m_balls.append( ball ); | 336 | m_balls.append( ball ); |
337 | ball->setVelocity( ((rand() & 1)*2-1)*2, ((rand() & 1)*2-1)*2 ); | 337 | ball->setVelocity( ((rand() & 1)*2-1)*2, ((rand() & 1)*2-1)*2 ); |
338 | ball->setFrame( rand() % 25 ); | 338 | ball->setFrame( rand() % 25 ); |
339 | ball->move( 4*TILE_SIZE + ( rand() - 50 ) % ( (FIELD_WIDTH-8)*TILE_SIZE ), | 339 | ball->move( 4*TILE_SIZE + ( rand() - 50 ) % ( (FIELD_WIDTH-8)*TILE_SIZE ), |
340 | 4*TILE_SIZE + rand() % ( (FIELD_HEIGHT-8)*TILE_SIZE ) ); | 340 | 4*TILE_SIZE + rand() % ( (FIELD_HEIGHT-8)*TILE_SIZE ) ); |
341 | ball->show(); | 341 | ball->show(); |
342 | } | 342 | } |
343 | 343 | ||
344 | // create arrow | 344 | // create arrow |
345 | arrow = new Arrow( m_arrowPixmaps, m_field ); | 345 | arrow = new Arrow( m_arrowPixmaps, m_field ); |
346 | arrow->show(); | 346 | arrow->show(); |
347 | 347 | ||
348 | // create text label | 348 | // create text label |
349 | m_text = new QCanvasText( m_field ); | 349 | m_text = new QCanvasText( m_field ); |
350 | 350 | ||
351 | // create game clock | 351 | // create game clock |
352 | m_clock = new QTimer( this ); | 352 | m_clock = new QTimer( this ); |
353 | connect( m_clock, SIGNAL(timeout()), this, SLOT(tick()) ); | 353 | connect( m_clock, SIGNAL(timeout()), this, SLOT(tick()) ); |
354 | m_clock->start( GAME_DELAY ); | 354 | m_clock->start( GAME_DELAY ); |
355 | 355 | ||
356 | // setup geometry | 356 | // setup geometry |
357 | setFixedSize( m_view->size() ); | 357 | setFixedSize( m_view->size() ); |
358 | } | 358 | } |
359 | 359 | ||
360 | JezzGame::~JezzGame() | 360 | JezzGame::~JezzGame() |
361 | { | 361 | { |
362 | m_balls.clear(); | 362 | m_balls.clear(); |
363 | delete m_view; | 363 | delete m_view; |
364 | delete m_field; | 364 | delete m_field; |
365 | delete m_ballPixmaps; | 365 | delete m_ballPixmaps; |
366 | } | 366 | } |
367 | 367 | ||
368 | void JezzGame::display( QString text, int size ) | 368 | void JezzGame::display( QString text, int size ) |
369 | { | 369 | { |
370 | qDebug("This function \"display\" shouldn't be called!!!"); | 370 | qDebug("This function \"display\" shouldn't be called!!!"); |
371 | if ( !text.isEmpty() ) | 371 | if ( !text.isEmpty() ) |
372 | { | 372 | { |
373 | QFont font( "Helvetica", size, QFont::Bold ); | 373 | QFont font( "Helvetica", size, QFont::Bold ); |
374 | font.setStyleHint( QFont::Helvetica ); | 374 | font.setStyleHint( QFont::Helvetica ); |
375 | m_text->setFont( font ); | 375 | m_text->setFont( font ); |
376 | m_text->setText( text ); | 376 | m_text->setText( text ); |
377 | 377 | ||
378 | QRect size = m_text->boundingRect(); | 378 | QRect size = m_text->boundingRect(); |
@@ -480,107 +480,107 @@ void JezzGame::ballCollision( Ball*, int, int, int tile ) | |||
480 | // stop walls | 480 | // stop walls |
481 | if ( (tile==TILE_WALLUP || tile==TILE_WALLLEFT) && m_wall1 ) | 481 | if ( (tile==TILE_WALLUP || tile==TILE_WALLLEFT) && m_wall1 ) |
482 | { | 482 | { |
483 | m_wall1->finish(); | 483 | m_wall1->finish(); |
484 | m_wall1->fill( false ); | 484 | m_wall1->fill( false ); |
485 | delete m_wall1; | 485 | delete m_wall1; |
486 | m_wall1 = 0; | 486 | m_wall1 = 0; |
487 | } | 487 | } |
488 | 488 | ||
489 | if ( (tile==TILE_WALLDOWN || tile==TILE_WALLRIGHT) && m_wall2 ) | 489 | if ( (tile==TILE_WALLDOWN || tile==TILE_WALLRIGHT) && m_wall2 ) |
490 | { | 490 | { |
491 | m_wall2->finish(); | 491 | m_wall2->finish(); |
492 | m_wall2->fill( false ); | 492 | m_wall2->fill( false ); |
493 | delete m_wall2; | 493 | delete m_wall2; |
494 | m_wall2 = 0; | 494 | m_wall2 = 0; |
495 | } | 495 | } |
496 | 496 | ||
497 | // update view | 497 | // update view |
498 | m_field->update(); | 498 | m_field->update(); |
499 | m_view->repaint(); | 499 | m_view->repaint(); |
500 | 500 | ||
501 | // send death msg | 501 | // send death msg |
502 | emit died(); | 502 | emit died(); |
503 | } | 503 | } |
504 | } | 504 | } |
505 | 505 | ||
506 | void JezzGame::buildWall( int x, int y, bool vertical ) | 506 | void JezzGame::buildWall( int x, int y, bool vertical ) |
507 | { | 507 | { |
508 | if ( !m_running ) return; | 508 | if ( !m_running ) return; |
509 | 509 | ||
510 | if ( m_field->tile(x, y)==TILE_FREE ) | 510 | if ( m_field->tile(x, y)==TILE_FREE ) |
511 | { | 511 | { |
512 | // check whether there is a ball at the moment | 512 | // check whether there is a ball at the moment |
513 | QCanvasItemList cols = m_field->collisions( QRect(x*TILE_SIZE, y*TILE_SIZE, TILE_SIZE, TILE_SIZE) ); | 513 | QCanvasItemList cols = m_field->collisions( QRect(x*TILE_SIZE, y*TILE_SIZE, TILE_SIZE, TILE_SIZE) ); |
514 | if ( cols.count()>0 ) | 514 | if ( cols.count()>0 ) |
515 | { | 515 | { |
516 | //kdDebug() << "Direct collision" << endl; | 516 | //kdDebug() << "Direct collision" << endl; |
517 | emit ballCollision( (Ball*)cols.first(), x, y, TILE_WALLUP ); | 517 | emit ballCollision( (Ball*)cols.first(), x, y, TILE_WALLUP ); |
518 | return; | 518 | return; |
519 | } | 519 | } |
520 | 520 | ||
521 | // start walls | 521 | // start walls |
522 | if ( !m_wall1 ) | 522 | if ( !m_wall1 ) |
523 | { | 523 | { |
524 | m_wall1 = new Wall( m_field, x, y, | 524 | m_wall1 = new Wall( m_field, x, y, |
525 | vertical? Wall::Up : Wall::Left, | 525 | vertical? Wall::Up : Wall::Left, |
526 | vertical? TILE_WALLUP : TILE_WALLLEFT, | 526 | vertical? TILE_WALLUP : TILE_WALLLEFT, |
527 | this, "m_wall1" ); | 527 | this, "m_wall1" ); |
528 | connect( m_wall1, SIGNAL(finished(Wall *, int)), | 528 | connect( m_wall1, SIGNAL(finished(Wall*,int)), |
529 | this, SLOT(wallFinished(Wall *, int)) ); } | 529 | this, SLOT(wallFinished(Wall*,int)) ); } |
530 | 530 | ||
531 | if ( !m_wall2 ) | 531 | if ( !m_wall2 ) |
532 | { | 532 | { |
533 | m_wall2 = new Wall( m_field, x, y, | 533 | m_wall2 = new Wall( m_field, x, y, |
534 | vertical? Wall::Down: Wall::Right, | 534 | vertical? Wall::Down: Wall::Right, |
535 | vertical? TILE_WALLDOWN : TILE_WALLRIGHT, | 535 | vertical? TILE_WALLDOWN : TILE_WALLRIGHT, |
536 | this, "m_wall2" ); | 536 | this, "m_wall2" ); |
537 | connect( m_wall2, SIGNAL(finished(Wall *, int)), | 537 | connect( m_wall2, SIGNAL(finished(Wall*,int)), |
538 | this, SLOT(wallFinished(Wall *, int)) ); | 538 | this, SLOT(wallFinished(Wall*,int)) ); |
539 | } | 539 | } |
540 | } | 540 | } |
541 | } | 541 | } |
542 | 542 | ||
543 | void JezzGame::wallFinished( Wall *wall, int tile ) | 543 | void JezzGame::wallFinished( Wall *wall, int tile ) |
544 | { | 544 | { |
545 | if ( tile==TILE_WALLEND ) | 545 | if ( tile==TILE_WALLEND ) |
546 | { | 546 | { |
547 | if ( m_wall1 ) | 547 | if ( m_wall1 ) |
548 | { | 548 | { |
549 | m_wall1->fill( false ); | 549 | m_wall1->fill( false ); |
550 | delete m_wall1; | 550 | delete m_wall1; |
551 | m_wall1 = 0; | 551 | m_wall1 = 0; |
552 | } | 552 | } |
553 | 553 | ||
554 | if ( m_wall2 ) | 554 | if ( m_wall2 ) |
555 | { | 555 | { |
556 | m_wall2->fill( false ); | 556 | m_wall2->fill( false ); |
557 | delete m_wall2; | 557 | delete m_wall2; |
558 | m_wall2 = 0; | 558 | m_wall2 = 0; |
559 | } | 559 | } |
560 | } else | 560 | } else |
561 | { | 561 | { |
562 | if ( m_wall1==wall && m_wall1 ) | 562 | if ( m_wall1==wall && m_wall1 ) |
563 | { | 563 | { |
564 | m_wall1->fill( true ); | 564 | m_wall1->fill( true ); |
565 | delete m_wall1; | 565 | delete m_wall1; |
566 | m_wall1 = 0; | 566 | m_wall1 = 0; |
567 | } | 567 | } |
568 | 568 | ||
569 | if ( m_wall2==wall && m_wall2 ) | 569 | if ( m_wall2==wall && m_wall2 ) |
570 | { | 570 | { |
571 | m_wall2->fill( true ); | 571 | m_wall2->fill( true ); |
572 | delete m_wall2; | 572 | delete m_wall2; |
573 | m_wall2 = 0; | 573 | m_wall2 = 0; |
574 | } | 574 | } |
575 | } | 575 | } |
576 | 576 | ||
577 | m_field->update(); | 577 | m_field->update(); |
578 | m_view->repaint(); | 578 | m_view->repaint(); |
579 | 579 | ||
580 | makeBlack(); | 580 | makeBlack(); |
581 | } | 581 | } |
582 | 582 | ||
583 | void JezzGame::tick() | 583 | void JezzGame::tick() |
584 | { | 584 | { |
585 | if ( m_running ) | 585 | if ( m_running ) |
586 | { | 586 | { |
diff --git a/noncore/games/buzzword/buzzword.cpp b/noncore/games/buzzword/buzzword.cpp index 13eb481..b7f2573 100644 --- a/noncore/games/buzzword/buzzword.cpp +++ b/noncore/games/buzzword/buzzword.cpp | |||
@@ -66,97 +66,97 @@ void BuzzItem::flip() | |||
66 | label->setBackgroundColor(label->colorGroup().highlight()); | 66 | label->setBackgroundColor(label->colorGroup().highlight()); |
67 | emit clicked(_row, _column); | 67 | emit clicked(_row, _column); |
68 | } | 68 | } |
69 | 69 | ||
70 | BuzzWord::BuzzWord(QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) | 70 | BuzzWord::BuzzWord(QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) |
71 | { | 71 | { |
72 | setCaption(tr("buZzword")); | 72 | setCaption(tr("buZzword")); |
73 | 73 | ||
74 | menu = menuBar(); | 74 | menu = menuBar(); |
75 | game = new QPopupMenu; | 75 | game = new QPopupMenu; |
76 | game->insertItem(tr("&New game"), this, SLOT(newGame()), Key_N ); | 76 | game->insertItem(tr("&New game"), this, SLOT(newGame()), Key_N ); |
77 | menu->insertItem( tr("&Game"), game ); | 77 | menu->insertItem( tr("&Game"), game ); |
78 | 78 | ||
79 | gridVal = 4; | 79 | gridVal = 4; |
80 | grid = NULL; | 80 | grid = NULL; |
81 | gameOver = false; | 81 | gameOver = false; |
82 | newGame(); | 82 | newGame(); |
83 | } | 83 | } |
84 | 84 | ||
85 | void BuzzWord::drawGrid() | 85 | void BuzzWord::drawGrid() |
86 | { | 86 | { |
87 | QStringList l; | 87 | QStringList l; |
88 | 88 | ||
89 | QString path = QPEApplication::qpeDir()+"share/buzzword/"; | 89 | QString path = QPEApplication::qpeDir()+"share/buzzword/"; |
90 | QFile f( path + "buzzwords" ); | 90 | QFile f( path + "buzzwords" ); |
91 | if ( !f.open( IO_ReadOnly ) ) | 91 | if ( !f.open( IO_ReadOnly ) ) |
92 | return; | 92 | return; |
93 | 93 | ||
94 | QTextStream t( &f ); | 94 | QTextStream t( &f ); |
95 | 95 | ||
96 | while (!t.atEnd()) | 96 | while (!t.atEnd()) |
97 | { | 97 | { |
98 | l << t.readLine(); | 98 | l << t.readLine(); |
99 | } | 99 | } |
100 | 100 | ||
101 | f.close(); | 101 | f.close(); |
102 | 102 | ||
103 | grid = new QGrid(gridVal, this); | 103 | grid = new QGrid(gridVal, this); |
104 | //grid->setFixedSize( 480, 480 ); | 104 | //grid->setFixedSize( 480, 480 ); |
105 | 105 | ||
106 | for( int c = 0 ; c < gridVal ; c++ ) | 106 | for( int c = 0 ; c < gridVal ; c++ ) |
107 | { | 107 | { |
108 | for( int r = 0 ; r < gridVal ; r++ ) | 108 | for( int r = 0 ; r < gridVal ; r++ ) |
109 | { | 109 | { |
110 | uint pos = rand() % l. count(); | 110 | uint pos = rand() % l. count(); |
111 | 111 | ||
112 | QString word = QStringList::split(" ", l[pos]).join("\n"); | 112 | QString word = QStringList::split(" ", l[pos]).join("\n"); |
113 | BuzzItem* bi = new BuzzItem( c, r, word, grid ); | 113 | BuzzItem* bi = new BuzzItem( c, r, word, grid ); |
114 | connect( bi, SIGNAL(clicked(int, int)), this, SLOT(clicked(int,int)) ); | 114 | connect( bi, SIGNAL(clicked(int,int)), this, SLOT(clicked(int,int)) ); |
115 | map[c][r] = 0; | 115 | map[c][r] = 0; |
116 | 116 | ||
117 | l.remove( l.at( pos )); | 117 | l.remove( l.at( pos )); |
118 | } | 118 | } |
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | void BuzzWord::clicked(int row, int column) | 122 | void BuzzWord::clicked(int row, int column) |
123 | { | 123 | { |
124 | if ( ! gameOver ) | 124 | if ( ! gameOver ) |
125 | { | 125 | { |
126 | int rowTotal = 0; | 126 | int rowTotal = 0; |
127 | int columnTotal = 0; | 127 | int columnTotal = 0; |
128 | 128 | ||
129 | map[column][row] = 1; | 129 | map[column][row] = 1; |
130 | 130 | ||
131 | for( int c = 0 ; c < gridVal ; c++ ) | 131 | for( int c = 0 ; c < gridVal ; c++ ) |
132 | { | 132 | { |
133 | for( int r = 0 ; r < gridVal ; r++ ) | 133 | for( int r = 0 ; r < gridVal ; r++ ) |
134 | { | 134 | { |
135 | if ( map[c][r] == 1 ) | 135 | if ( map[c][r] == 1 ) |
136 | rowTotal++; | 136 | rowTotal++; |
137 | 137 | ||
138 | if ( rowTotal == 4 ) | 138 | if ( rowTotal == 4 ) |
139 | { | 139 | { |
140 | bingo(); | 140 | bingo(); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | rowTotal = 0; | 143 | rowTotal = 0; |
144 | } | 144 | } |
145 | 145 | ||
146 | for( int r = 0 ; r < gridVal ; r++ ) | 146 | for( int r = 0 ; r < gridVal ; r++ ) |
147 | { | 147 | { |
148 | for( int c = 0 ; c < gridVal ; c++ ) | 148 | for( int c = 0 ; c < gridVal ; c++ ) |
149 | { | 149 | { |
150 | if ( map[c][r] == 1 ) | 150 | if ( map[c][r] == 1 ) |
151 | columnTotal++; | 151 | columnTotal++; |
152 | 152 | ||
153 | if ( columnTotal == 4 ) | 153 | if ( columnTotal == 4 ) |
154 | { | 154 | { |
155 | bingo(); | 155 | bingo(); |
156 | } | 156 | } |
157 | } | 157 | } |
158 | columnTotal = 0; | 158 | columnTotal = 0; |
159 | } | 159 | } |
160 | 160 | ||
161 | if ( map[0][0] && map[1][1] && map[2][2] && map[3][3] ) | 161 | if ( map[0][0] && map[1][1] && map[2][2] && map[3][3] ) |
162 | bingo(); | 162 | bingo(); |
diff --git a/noncore/games/kpacman/kpacman.cpp b/noncore/games/kpacman/kpacman.cpp index be2e46d..9820e5a 100644 --- a/noncore/games/kpacman/kpacman.cpp +++ b/noncore/games/kpacman/kpacman.cpp | |||
@@ -1,85 +1,85 @@ | |||
1 | 1 | ||
2 | #include "portable.h" | 2 | #include "portable.h" |
3 | 3 | ||
4 | #if defined( KDE2_PORT ) | 4 | #if defined( KDE2_PORT ) |
5 | #include <kpacman.h> | 5 | #include <kpacman.h> |
6 | #include <kpacman.moc> | 6 | #include <kpacman.moc> |
7 | #include <kcolordlg.h> | 7 | #include <kcolordlg.h> |
8 | #elif defined( QPE_PORT ) | 8 | #elif defined( QPE_PORT ) |
9 | #include <qmenubar.h> | 9 | #include <qmenubar.h> |
10 | #include <qpe/config.h> | 10 | #include <qpe/config.h> |
11 | #include <qapplication.h> | 11 | #include <qapplication.h> |
12 | #include "kpacman.h" | 12 | #include "kpacman.h" |
13 | #endif | 13 | #endif |
14 | 14 | ||
15 | 15 | ||
16 | Kpacman::Kpacman(QWidget *parent, const char *name) | 16 | Kpacman::Kpacman(QWidget *parent, const char *name) |
17 | : KTMainWindow(parent, name) | 17 | : KTMainWindow(parent, name) |
18 | { | 18 | { |
19 | schemesPopup = new QList<QPopupMenu>; | 19 | schemesPopup = new QList<QPopupMenu>; |
20 | schemesPopup->setAutoDelete(TRUE); | 20 | schemesPopup->setAutoDelete(TRUE); |
21 | 21 | ||
22 | menu(); | 22 | menu(); |
23 | 23 | ||
24 | m_view = new QWidget( this, "m_view" ); | 24 | m_view = new QWidget( this, "m_view" ); |
25 | m_view->setBackgroundColor( black ); | 25 | m_view->setBackgroundColor( black ); |
26 | m_layout = new QGridLayout( m_view ); | 26 | m_layout = new QGridLayout( m_view ); |
27 | m_layout->setMargin( 7 ); | 27 | m_layout->setMargin( 7 ); |
28 | 28 | ||
29 | view = new KpacmanWidget( this, QString(name)+"widget"); | 29 | view = new KpacmanWidget( this, QString(name)+"widget"); |
30 | m_layout->addWidget( view, 0, 0 ); | 30 | m_layout->addWidget( view, 0, 0 ); |
31 | 31 | ||
32 | setCaption( tr("KPacman") ); | 32 | setCaption( tr("KPacman") ); |
33 | 33 | ||
34 | view->referee->setFocus(); | 34 | view->referee->setFocus(); |
35 | 35 | ||
36 | connect(view->referee, SIGNAL(setScore(int, int)), | 36 | connect(view->referee, SIGNAL(setScore(int,int)), |
37 | view->score, SLOT(setScore(int, int))); | 37 | view->score, SLOT(setScore(int,int))); |
38 | connect(view->referee, SIGNAL(setPoints(int)), | 38 | connect(view->referee, SIGNAL(setPoints(int)), |
39 | view->score, SLOT(set(int))); | 39 | view->score, SLOT(set(int))); |
40 | connect(view->referee, SIGNAL(setLifes(int)), | 40 | connect(view->referee, SIGNAL(setLifes(int)), |
41 | view->status, SLOT(setLifes(int))); | 41 | view->status, SLOT(setLifes(int))); |
42 | connect(view->referee, SIGNAL(setLevel(int)), | 42 | connect(view->referee, SIGNAL(setLevel(int)), |
43 | view->status, SLOT(setLevel(int))); | 43 | view->status, SLOT(setLevel(int))); |
44 | connect(view->referee, SIGNAL(forcedHallOfFame(bool)), | 44 | connect(view->referee, SIGNAL(forcedHallOfFame(bool)), |
45 | this, SLOT(forcedHallOfFame(bool))); | 45 | this, SLOT(forcedHallOfFame(bool))); |
46 | connect(view->referee, SIGNAL(togglePaused()), this, SLOT(togglePaused())); | 46 | connect(view->referee, SIGNAL(togglePaused()), this, SLOT(togglePaused())); |
47 | connect(view->referee, SIGNAL(toggleNew()), this, SLOT(toggleNew())); | 47 | connect(view->referee, SIGNAL(toggleNew()), this, SLOT(toggleNew())); |
48 | 48 | ||
49 | connect(view->score, SIGNAL(toggleNew()), this, SLOT(toggleNew())); | 49 | connect(view->score, SIGNAL(toggleNew()), this, SLOT(toggleNew())); |
50 | connect(view->score, SIGNAL(forcedHallOfFame(bool)), | 50 | connect(view->score, SIGNAL(forcedHallOfFame(bool)), |
51 | this, SLOT(forcedHallOfFame(bool))); | 51 | this, SLOT(forcedHallOfFame(bool))); |
52 | 52 | ||
53 | APP_CONFIG_BEGIN( cfg ); | 53 | APP_CONFIG_BEGIN( cfg ); |
54 | focusOutPause = !cfg->readBoolEntry("FocusOutPause", TRUE); | 54 | focusOutPause = !cfg->readBoolEntry("FocusOutPause", TRUE); |
55 | focusInContinue = !cfg->readBoolEntry("FocusInContinue", TRUE); | 55 | focusInContinue = !cfg->readBoolEntry("FocusInContinue", TRUE); |
56 | hideMouseCursor = !cfg->readBoolEntry("HideMouseCursor", TRUE); | 56 | hideMouseCursor = !cfg->readBoolEntry("HideMouseCursor", TRUE); |
57 | APP_CONFIG_END( cfg ); | 57 | APP_CONFIG_END( cfg ); |
58 | 58 | ||
59 | toggleFocusOutPause(); | 59 | toggleFocusOutPause(); |
60 | toggleFocusInContinue(); | 60 | toggleFocusInContinue(); |
61 | toggleHideMouseCursor(); | 61 | toggleHideMouseCursor(); |
62 | 62 | ||
63 | setCentralWidget( m_view ); | 63 | setCentralWidget( m_view ); |
64 | } | 64 | } |
65 | 65 | ||
66 | Kpacman::~Kpacman() | 66 | Kpacman::~Kpacman() |
67 | { | 67 | { |
68 | /* APP_CONFIG_BEGIN( cfg ); | 68 | /* APP_CONFIG_BEGIN( cfg ); |
69 | cfg->writeEntry("FocusOutPause", focusOutPause); | 69 | cfg->writeEntry("FocusOutPause", focusOutPause); |
70 | cfg->writeEntry("FocusInContinue", focusInContinue); | 70 | cfg->writeEntry("FocusInContinue", focusInContinue); |
71 | cfg->writeEntry("HideMouseCursor", hideMouseCursor); | 71 | cfg->writeEntry("HideMouseCursor", hideMouseCursor); |
72 | APP_CONFIG_END( cfg ); | 72 | APP_CONFIG_END( cfg ); |
73 | */ | 73 | */ |
74 | delete _menuBar; | 74 | delete _menuBar; |
75 | } | 75 | } |
76 | 76 | ||
77 | void Kpacman::menu() | 77 | void Kpacman::menu() |
78 | { | 78 | { |
79 | gamePopup = new QPopupMenu(); | 79 | gamePopup = new QPopupMenu(); |
80 | CHECK_PTR( gamePopup ); | 80 | CHECK_PTR( gamePopup ); |
81 | newID = gamePopup->insertItem(tr("&New"), this, SLOT(newKpacman()),Key_F2); | 81 | newID = gamePopup->insertItem(tr("&New"), this, SLOT(newKpacman()),Key_F2); |
82 | pauseID = gamePopup->insertItem(tr("&Pause"), | 82 | pauseID = gamePopup->insertItem(tr("&Pause"), |
83 | this, SLOT(pauseKpacman()), Key_F3); | 83 | this, SLOT(pauseKpacman()), Key_F3); |
84 | hofID = gamePopup->insertItem(tr("&Hall of fame"), | 84 | hofID = gamePopup->insertItem(tr("&Hall of fame"), |
85 | this, SLOT(toggleHallOfFame()), Key_F4); | 85 | this, SLOT(toggleHallOfFame()), Key_F4); |
diff --git a/noncore/games/oyatzee/oyatzee.cpp b/noncore/games/oyatzee/oyatzee.cpp index 86318db..a55aa73 100644 --- a/noncore/games/oyatzee/oyatzee.cpp +++ b/noncore/games/oyatzee/oyatzee.cpp | |||
@@ -1,80 +1,80 @@ | |||
1 | #include "oyatzee.h" | 1 | #include "oyatzee.h" |
2 | 2 | ||
3 | #include <qmessagebox.h> | 3 | #include <qmessagebox.h> |
4 | #include <qpushbutton.h> | 4 | #include <qpushbutton.h> |
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | #include <qlayout.h> | 6 | #include <qlayout.h> |
7 | 7 | ||
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | 9 | ||
10 | OYatzee::OYatzee( QWidget *parent , const char *name, WFlags fl ) : QMainWindow( parent , name , fl ) | 10 | OYatzee::OYatzee( QWidget *parent , const char *name, WFlags fl ) : QMainWindow( parent , name , fl ) |
11 | { | 11 | { |
12 | QWidget *thing = new QWidget( this ); | 12 | QWidget *thing = new QWidget( this ); |
13 | setCentralWidget( thing ); | 13 | setCentralWidget( thing ); |
14 | 14 | ||
15 | setCaption( tr( "OYatzee" ) ); | 15 | setCaption( tr( "OYatzee" ) ); |
16 | 16 | ||
17 | setPlayerNumber( 4 ); | 17 | setPlayerNumber( 4 ); |
18 | setRoundsNumber( 1 ); | 18 | setRoundsNumber( 1 ); |
19 | 19 | ||
20 | lastPlayerFinished = false; | 20 | lastPlayerFinished = false; |
21 | currentPlayer = 1; | 21 | currentPlayer = 1; |
22 | 22 | ||
23 | ps.append( new Player( "Carsten" ) ); | 23 | ps.append( new Player( "Carsten" ) ); |
24 | ps.append( new Player( "Julia" ) ); | 24 | ps.append( new Player( "Julia" ) ); |
25 | ps.append( new Player( "Christine" ) ); | 25 | ps.append( new Player( "Christine" ) ); |
26 | ps.append( new Player( "Stephan" ) ); | 26 | ps.append( new Player( "Stephan" ) ); |
27 | 27 | ||
28 | 28 | ||
29 | QVBoxLayout *vbox = new QVBoxLayout( thing ); | 29 | QVBoxLayout *vbox = new QVBoxLayout( thing ); |
30 | 30 | ||
31 | sb = new Scoreboard( ps, thing , "sb" ); | 31 | sb = new Scoreboard( ps, thing , "sb" ); |
32 | connect( sb->pb , SIGNAL( item( int ) ), this , SLOT( slotEndRound( int ) ) ); | 32 | connect( sb->pb , SIGNAL( item(int) ), this , SLOT( slotEndRound(int) ) ); |
33 | 33 | ||
34 | dw = new DiceWidget( thing , "dw" ); | 34 | dw = new DiceWidget( thing , "dw" ); |
35 | dw->setMaximumHeight( this->height()/4 ); | 35 | dw->setMaximumHeight( this->height()/4 ); |
36 | connect( dw->rollButton, SIGNAL( clicked() ), this , SLOT( slotRollDices() ) ); | 36 | connect( dw->rollButton, SIGNAL( clicked() ), this , SLOT( slotRollDices() ) ); |
37 | 37 | ||
38 | vbox->addWidget( sb ); | 38 | vbox->addWidget( sb ); |
39 | vbox->addWidget( dw ); | 39 | vbox->addWidget( dw ); |
40 | } | 40 | } |
41 | 41 | ||
42 | void OYatzee::slotEndRound( int item ) | 42 | void OYatzee::slotEndRound( int item ) |
43 | { | 43 | { |
44 | qDebug( "Der User hat Nummer %d ausgewählt" , item ); | 44 | qDebug( "Der User hat Nummer %d ausgewählt" , item ); |
45 | 45 | ||
46 | /* | 46 | /* |
47 | * if the user clicked on Total, Bonus or Score and thus not on a | 47 | * if the user clicked on Total, Bonus or Score and thus not on a |
48 | * selectable item return and do nothing | 48 | * selectable item return and do nothing |
49 | */ | 49 | */ |
50 | if ( item == 7 || item == 8 || item == 16 ) return; | 50 | if ( item == 7 || item == 8 || item == 16 ) return; |
51 | 51 | ||
52 | /* | 52 | /* |
53 | * check if the user can really click on that item | 53 | * check if the user can really click on that item |
54 | */ | 54 | */ |
55 | if ( posibilities.find( item ) == posibilities.end() ) return; | 55 | if ( posibilities.find( item ) == posibilities.end() ) return; |
56 | 56 | ||
57 | QValueListInt numbers; | 57 | QValueListInt numbers; |
58 | 58 | ||
59 | Dice *d = dw->diceList.first(); | 59 | Dice *d = dw->diceList.first(); |
60 | for ( ; d != 0 ; d = dw->diceList.next() ) | 60 | for ( ; d != 0 ; d = dw->diceList.next() ) |
61 | { | 61 | { |
62 | numbers.append( d->hasValue() ); | 62 | numbers.append( d->hasValue() ); |
63 | } | 63 | } |
64 | 64 | ||
65 | int points = 0; | 65 | int points = 0; |
66 | 66 | ||
67 | switch ( item ) | 67 | switch ( item ) |
68 | { | 68 | { |
69 | case Ones: | 69 | case Ones: |
70 | points = getPoints( 1 , numbers ); | 70 | points = getPoints( 1 , numbers ); |
71 | break; | 71 | break; |
72 | case Twos: | 72 | case Twos: |
73 | points = getPoints( 2 , numbers ); | 73 | points = getPoints( 2 , numbers ); |
74 | break; | 74 | break; |
75 | case Threes: | 75 | case Threes: |
76 | points = getPoints( 3 , numbers ); | 76 | points = getPoints( 3 , numbers ); |
77 | break; | 77 | break; |
78 | case Fours: | 78 | case Fours: |
79 | points = getPoints( 4 , numbers ); | 79 | points = getPoints( 4 , numbers ); |
80 | break; | 80 | break; |
@@ -601,87 +601,87 @@ void Resultboard::paintEvent( QPaintEvent* ) | |||
601 | QPainter p; | 601 | QPainter p; |
602 | p.begin( this ); | 602 | p.begin( this ); |
603 | 603 | ||
604 | const int cell_width = this->width(); | 604 | const int cell_width = this->width(); |
605 | const int cell_height = this->height()/17; | 605 | const int cell_height = this->height()/17; |
606 | 606 | ||
607 | pointMap::Iterator it = pMap.begin(); | 607 | pointMap::Iterator it = pMap.begin(); |
608 | for ( ; it != pMap.end() ; ++it ) | 608 | for ( ; it != pMap.end() ; ++it ) |
609 | { | 609 | { |
610 | int i = it.key(); | 610 | int i = it.key(); |
611 | qDebug( "ok: %d , %d" , i , it.data() ); | 611 | qDebug( "ok: %d , %d" , i , it.data() ); |
612 | p.drawText( 0, i*cell_height , cell_width , cell_height , Qt::AlignCenter , QString::number( it.data() ) ); | 612 | p.drawText( 0, i*cell_height , cell_width , cell_height , Qt::AlignCenter , QString::number( it.data() ) ); |
613 | } | 613 | } |
614 | 614 | ||
615 | p.drawText( 0,0,cell_width,cell_height, Qt::AlignCenter , pName ); //Playername | 615 | p.drawText( 0,0,cell_width,cell_height, Qt::AlignCenter , pName ); //Playername |
616 | } | 616 | } |
617 | 617 | ||
618 | 618 | ||
619 | void Resultboard::updateMap( int item , int points ) | 619 | void Resultboard::updateMap( int item , int points ) |
620 | { | 620 | { |
621 | pMap.insert( item , points ); | 621 | pMap.insert( item , points ); |
622 | 622 | ||
623 | update(); | 623 | update(); |
624 | } | 624 | } |
625 | 625 | ||
626 | /* | 626 | /* |
627 | * Possibilityboard | 627 | * Possibilityboard |
628 | */ | 628 | */ |
629 | 629 | ||
630 | Possibilityboard::Possibilityboard( QWidget *parent , const char* name ) : Board ( parent , name ) | 630 | Possibilityboard::Possibilityboard( QWidget *parent , const char* name ) : Board ( parent , name ) |
631 | { | 631 | { |
632 | begriffe.append( "1er" ); | 632 | begriffe.append( "1er" ); |
633 | begriffe.append( "2er" ); | 633 | begriffe.append( "2er" ); |
634 | begriffe.append( "3er" ); | 634 | begriffe.append( "3er" ); |
635 | begriffe.append( "4er" ); | 635 | begriffe.append( "4er" ); |
636 | begriffe.append( "5er" ); | 636 | begriffe.append( "5er" ); |
637 | begriffe.append( "6er" ); | 637 | begriffe.append( "6er" ); |
638 | begriffe.append( "Total" ); | 638 | begriffe.append( "Total" ); |
639 | begriffe.append( "Bonus" ); | 639 | begriffe.append( "Bonus" ); |
640 | begriffe.append( "3oaK" ); | 640 | begriffe.append( "3oaK" ); |
641 | begriffe.append( "4oaK" ); | 641 | begriffe.append( "4oaK" ); |
642 | begriffe.append( "Full House" ); | 642 | begriffe.append( "Full House" ); |
643 | begriffe.append( "Short S" ); | 643 | begriffe.append( "Short S" ); |
644 | begriffe.append( "Long S" ); | 644 | begriffe.append( "Long S" ); |
645 | begriffe.append( "Yatzee!" ); | 645 | begriffe.append( "Yatzee!" ); |
646 | begriffe.append( "Chance" ); | 646 | begriffe.append( "Chance" ); |
647 | begriffe.append( "Score" ); | 647 | begriffe.append( "Score" ); |
648 | 648 | ||
649 | connect( this , SIGNAL( clicked( QPoint ) ), this , SLOT( slotClicked( QPoint ) ) ); | 649 | connect( this , SIGNAL( clicked(QPoint) ), this , SLOT( slotClicked(QPoint) ) ); |
650 | } | 650 | } |
651 | 651 | ||
652 | void Possibilityboard::slotClicked( QPoint p) | 652 | void Possibilityboard::slotClicked( QPoint p) |
653 | { | 653 | { |
654 | emit item( p.y()/(this->height()/17) ); | 654 | emit item( p.y()/(this->height()/17) ); |
655 | } | 655 | } |
656 | 656 | ||
657 | void Possibilityboard::paintEvent( QPaintEvent* ) | 657 | void Possibilityboard::paintEvent( QPaintEvent* ) |
658 | { | 658 | { |
659 | QPainter p; | 659 | QPainter p; |
660 | p.begin( this ); | 660 | p.begin( this ); |
661 | 661 | ||
662 | const int cell_width = this->width(); | 662 | const int cell_width = this->width(); |
663 | const int cell_height = this->height()/17; | 663 | const int cell_height = this->height()/17; |
664 | 664 | ||
665 | p.setBrush( Qt::blue ); | 665 | p.setBrush( Qt::blue ); |
666 | 666 | ||
667 | QValueListInt::Iterator listIt = list.begin(); | 667 | QValueListInt::Iterator listIt = list.begin(); |
668 | for ( ; listIt != list.end() ; ++listIt ) | 668 | for ( ; listIt != list.end() ; ++listIt ) |
669 | { | 669 | { |
670 | p.drawRect( 0 , (*listIt) * cell_height , cell_width , cell_height ); | 670 | p.drawRect( 0 , (*listIt) * cell_height , cell_width , cell_height ); |
671 | } | 671 | } |
672 | 672 | ||
673 | p.setBrush( Qt::black ); | 673 | p.setBrush( Qt::black ); |
674 | p.setBrush( Qt::NoBrush ); | 674 | p.setBrush( Qt::NoBrush ); |
675 | QStringList::Iterator begriffeIt = begriffe.begin(); | 675 | QStringList::Iterator begriffeIt = begriffe.begin(); |
676 | for ( int i = 1 ; i < 18 ; ++i ) | 676 | for ( int i = 1 ; i < 18 ; ++i ) |
677 | { | 677 | { |
678 | p.drawText( 0 , i*cell_height , cell_width , cell_height , Qt::AlignCenter , *begriffeIt ); | 678 | p.drawText( 0 , i*cell_height , cell_width , cell_height , Qt::AlignCenter , *begriffeIt ); |
679 | ++begriffeIt; | 679 | ++begriffeIt; |
680 | } | 680 | } |
681 | } | 681 | } |
682 | 682 | ||
683 | void Possibilityboard::setIntlist( QValueListInt &l ) | 683 | void Possibilityboard::setIntlist( QValueListInt &l ) |
684 | { | 684 | { |
685 | list = l; | 685 | list = l; |
686 | } | 686 | } |
687 | 687 | ||