-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 @@ -228,199 +228,199 @@ void Wall::fill( bool black ) } /*************************************************************************/ JezzField::JezzField( QPixmap tiles, QObject* parent, const char* name ) : QCanvas( parent, name ), m_tiles( tiles ) { setPixmaps( tiles ); } void JezzField::setGameTile( int x, int y, bool black ) { setTile( x, y, black ? TILE_BORDER : TILE_FREE ); } void JezzField::setPixmaps( QPixmap tiles ) { // create new tiles QPixmap allTiles( TILE_SIZE*(FIELD_WIDTH-2), TILE_SIZE*(FIELD_HEIGHT-1) ); // handle default tiles bitBlt( &allTiles, 0, TILE_SIZE*(FIELD_HEIGHT-2), &tiles, 0, 0, tiles.width(), tiles.height() ); // load tiles into canvas setTiles( allTiles, FIELD_WIDTH, FIELD_HEIGHT, TILE_SIZE, TILE_SIZE ); } /*************************************************************************/ JezzView::JezzView(QCanvas* viewing, QWidget* parent, const char* name, WFlags f) : QCanvasView( viewing, parent, name, f ), m_vertical( false ) { setResizePolicy( AutoOne ); setHScrollBarMode( AlwaysOff ); setVScrollBarMode( AlwaysOff ); setCursor( sizeHorCursor ); } void JezzView::viewportMouseReleaseEvent( QMouseEvent *ev ) { if ( ev->button() & LeftButton ) { emit buildWall( ev->x()/TILE_SIZE, ev->y()/TILE_SIZE, m_vertical ); } } void JezzView::changeCursor() { m_vertical = !m_vertical; if ( m_vertical ) { setCursor( sizeVerCursor ); } else { setCursor( sizeHorCursor ); } } /*************************************************************************/ JezzGame::JezzGame( int ballNum, QWidget *parent, const char *name ) : QWidget( parent, name ), m_wall1( 0 ), m_wall2( 0 ), m_text( 0 ), m_running( false ), m_percent( 0 ), m_pictured( false ) { QString path = QPEApplication::qpeDir()+"pics/bounce/"; // load gfx m_ballPixmaps = new QCanvasPixmapArray( path + "ball%1.png", 25 ); for ( unsigned n=0; n < m_ballPixmaps->count(); n++ ) m_ballPixmaps->image(n)->setOffset( 0, 0 ); m_arrowPixmaps = new QCanvasPixmapArray( path + "arrow%1.png", 2 ); for ( unsigned n=0; n < m_arrowPixmaps->count(); n++ ) m_arrowPixmaps->image(n)->setOffset( 0, 0 ); QPixmap tiles( path + "tiles.png" ); // create field m_field = new JezzField( tiles, this, "m_field" ); m_field->resize( TILE_SIZE*FIELD_WIDTH, TILE_SIZE*FIELD_HEIGHT ); for ( int x=0; x<FIELD_WIDTH; x++ ) m_field->setTile( x, 0, TILE_BORDER ); for ( int y=1; y<FIELD_HEIGHT-1; y++ ) { m_field->setTile( 0, y, TILE_BORDER ); for ( int x=1; x<FIELD_WIDTH-1; x++ ) m_field->setTile( x, y, TILE_FREE ); m_field->setTile( FIELD_WIDTH-1, y, TILE_BORDER ); } for ( int x=0; x<FIELD_WIDTH; x++ ) m_field->setTile( x, FIELD_HEIGHT-1, TILE_BORDER ); - connect( m_field, SIGNAL(ballCollision(Ball *, int, int, int)), this, SLOT(ballCollision(Ball *, int, int, int)) ); + connect( m_field, SIGNAL(ballCollision(Ball*,int,int,int)), this, SLOT(ballCollision(Ball*,int,int,int)) ); // create view m_view = new JezzView( m_field, this, "m_view" ); m_view->move( 0, 0 ); m_view->adjustSize(); - connect( m_view, SIGNAL(buildWall(int, int, bool)), this, SLOT(buildWall(int, int, bool)) ); + connect( m_view, SIGNAL(buildWall(int,int,bool)), this, SLOT(buildWall(int,int,bool)) ); // create balls for ( int n=0; n<ballNum; n++ ) { Ball *ball = new Ball( m_ballPixmaps, m_field ); m_balls.append( ball ); ball->setVelocity( ((rand() & 1)*2-1)*2, ((rand() & 1)*2-1)*2 ); ball->setFrame( rand() % 25 ); ball->move( 4*TILE_SIZE + ( rand() - 50 ) % ( (FIELD_WIDTH-8)*TILE_SIZE ), 4*TILE_SIZE + rand() % ( (FIELD_HEIGHT-8)*TILE_SIZE ) ); ball->show(); } // create arrow arrow = new Arrow( m_arrowPixmaps, m_field ); arrow->show(); // create text label m_text = new QCanvasText( m_field ); // create game clock m_clock = new QTimer( this ); connect( m_clock, SIGNAL(timeout()), this, SLOT(tick()) ); m_clock->start( GAME_DELAY ); // setup geometry setFixedSize( m_view->size() ); } JezzGame::~JezzGame() { m_balls.clear(); delete m_view; delete m_field; delete m_ballPixmaps; } void JezzGame::display( QString text, int size ) { qDebug("This function \"display\" shouldn't be called!!!"); if ( !text.isEmpty() ) { QFont font( "Helvetica", size, QFont::Bold ); font.setStyleHint( QFont::Helvetica ); m_text->setFont( font ); m_text->setText( text ); QRect size = m_text->boundingRect(); m_text->move( ( FIELD_WIDTH*TILE_SIZE - size.width() ) / 2, ( FIELD_HEIGHT*TILE_SIZE - size.height() ) / 2 ); m_text->show(); } else { m_text->hide(); } } void JezzGame::start() { m_running = true; } void JezzGame::stop() { m_running = false; } void JezzGame::makeBlack() { // copy current field into buffer for ( int y=0; y<FIELD_HEIGHT; y++ ) for ( int x=0; x<FIELD_WIDTH; x++ ) m_buf[x][y] = m_field->tile( x, y ); // fill areas that contains a ball for ( Ball *ball=m_balls.first(); ball!=0; ball=m_balls.next() ) fill( ball->x()/TILE_SIZE, ball->y()/TILE_SIZE ); // areas still free can be blacked now for ( int y=0; y<FIELD_HEIGHT; y++ ) for ( int x=0; x<FIELD_WIDTH; x++ ) { if ( m_buf[x][y]==TILE_FREE ) m_field->setGameTile( x, y, true ); } m_field->update(); m_view->repaint(); // count percent value of occupied area int p = percent(); if ( p!=m_percent ) { m_percent = p; @@ -432,174 +432,174 @@ int JezzGame::percent() { int notFree = 0; for ( int y=1; y<FIELD_HEIGHT-1; y++ ) for ( int x=1; x<FIELD_WIDTH-1; x++ ) { if ( m_field->tile(x,y)!=TILE_FREE ) notFree++; } return 100 * notFree / ( (FIELD_WIDTH-1) * (FIELD_HEIGHT-1) ); } void JezzGame::fill( int x, int y ) { if ( m_buf[x][y]!=TILE_FREE) return; // go left int _x=x; for ( ; m_buf[_x][y]==TILE_FREE; _x-- ) m_buf[_x][y] = TILE_BORDER; int stopx = _x; // fill above for ( _x=x; _x>stopx; _x-- ) if ( m_buf[_x][y-1]==TILE_FREE ) fill( _x, y-1 ); // fill below for ( _x=x; _x>stopx; _x-- ) if ( m_buf[_x][y+1]==TILE_FREE ) fill( _x, y+1 ); // go right for ( _x=x+1; m_buf[_x][y]==TILE_FREE; _x++ ) m_buf[_x][y] = TILE_BORDER; stopx = _x; // fill above for ( _x=x+1; _x<stopx; _x++ ) if ( m_buf[_x][y-1]==TILE_FREE ) fill( _x, y-1 ); // fill below; for ( _x=x+1; _x<stopx; _x++ ) if ( m_buf[_x][y+1]==TILE_FREE ) fill( _x, y+1 ); } void JezzGame::ballCollision( Ball*, int, int, int tile ) { if ( tile!=TILE_BORDER && tile>TILE_FREE && tile!=TILE_WALLEND ) { // stop walls if ( (tile==TILE_WALLUP || tile==TILE_WALLLEFT) && m_wall1 ) { m_wall1->finish(); m_wall1->fill( false ); delete m_wall1; m_wall1 = 0; } if ( (tile==TILE_WALLDOWN || tile==TILE_WALLRIGHT) && m_wall2 ) { m_wall2->finish(); m_wall2->fill( false ); delete m_wall2; m_wall2 = 0; } // update view m_field->update(); m_view->repaint(); // send death msg emit died(); } } void JezzGame::buildWall( int x, int y, bool vertical ) { if ( !m_running ) return; if ( m_field->tile(x, y)==TILE_FREE ) { // check whether there is a ball at the moment QCanvasItemList cols = m_field->collisions( QRect(x*TILE_SIZE, y*TILE_SIZE, TILE_SIZE, TILE_SIZE) ); if ( cols.count()>0 ) { //kdDebug() << "Direct collision" << endl; emit ballCollision( (Ball*)cols.first(), x, y, TILE_WALLUP ); return; } // start walls if ( !m_wall1 ) { m_wall1 = new Wall( m_field, x, y, vertical? Wall::Up : Wall::Left, vertical? TILE_WALLUP : TILE_WALLLEFT, this, "m_wall1" ); - connect( m_wall1, SIGNAL(finished(Wall *, int)), - this, SLOT(wallFinished(Wall *, int)) ); } + connect( m_wall1, SIGNAL(finished(Wall*,int)), + this, SLOT(wallFinished(Wall*,int)) ); } if ( !m_wall2 ) { m_wall2 = new Wall( m_field, x, y, vertical? Wall::Down: Wall::Right, vertical? TILE_WALLDOWN : TILE_WALLRIGHT, this, "m_wall2" ); - connect( m_wall2, SIGNAL(finished(Wall *, int)), - this, SLOT(wallFinished(Wall *, int)) ); + connect( m_wall2, SIGNAL(finished(Wall*,int)), + this, SLOT(wallFinished(Wall*,int)) ); } } } void JezzGame::wallFinished( Wall *wall, int tile ) { if ( tile==TILE_WALLEND ) { if ( m_wall1 ) { m_wall1->fill( false ); delete m_wall1; m_wall1 = 0; } if ( m_wall2 ) { m_wall2->fill( false ); delete m_wall2; m_wall2 = 0; } } else { if ( m_wall1==wall && m_wall1 ) { m_wall1->fill( true ); delete m_wall1; m_wall1 = 0; } if ( m_wall2==wall && m_wall2 ) { m_wall2->fill( true ); delete m_wall2; m_wall2 = 0; } } m_field->update(); m_view->repaint(); makeBlack(); } void JezzGame::tick() { if ( m_running ) { if ( m_field ) m_field->advance(); if ( m_wall1 ) m_wall1->advance(); if ( m_wall2 ) m_wall2->advance(); } else { for ( Ball *ball=m_balls.first(); ball!=0; ball=m_balls.next() ) ball->update(); if ( m_field ) m_field->update(); if ( m_wall1 ) m_wall1->update(); if ( m_wall2 ) m_wall2->update(); } } void JezzGame::changeCursor() { arrow->changeDirection(); m_view->changeCursor(); } 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 @@ -18,164 +18,164 @@ #include <qlayout.h> #include <qmainwindow.h> #include <qlabel.h> #include <qgrid.h> #include <qcolor.h> #include <qbutton.h> #include <qfile.h> #include <qtextstream.h> #include <qstringlist.h> #include <qmessagebox.h> #include <qdir.h> #include <math.h> #include <stdlib.h> #include <qpe/qpeapplication.h> #include "buzzword.h" BuzzLabel::BuzzLabel( QWidget *parent, const char *name ) : QLabel( parent, name ) { } void BuzzLabel::mousePressEvent(QMouseEvent *e) { if(e->button() == LeftButton) { emit clicked(); } } BuzzItem::BuzzItem( int row, int column, QString text, QWidget *parent, const char *name ) : QVBox( parent, name ), _row(row), _column(column) { setFrameStyle( QFrame::Panel | QFrame::Raised ); setLineWidth( 1 ); label = new BuzzLabel(this, "label"); label->setText(text); label->setAlignment( int( QLabel::AlignCenter ) ); connect( label, SIGNAL(clicked()), this, SLOT(flip()) ); } void BuzzItem::flip() { setLineWidth( 1 ); label->setBackgroundColor(label->colorGroup().highlight()); emit clicked(_row, _column); } BuzzWord::BuzzWord(QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) { setCaption(tr("buZzword")); menu = menuBar(); game = new QPopupMenu; game->insertItem(tr("&New game"), this, SLOT(newGame()), Key_N ); menu->insertItem( tr("&Game"), game ); gridVal = 4; grid = NULL; gameOver = false; newGame(); } void BuzzWord::drawGrid() { QStringList l; QString path = QPEApplication::qpeDir()+"share/buzzword/"; QFile f( path + "buzzwords" ); if ( !f.open( IO_ReadOnly ) ) return; QTextStream t( &f ); while (!t.atEnd()) { l << t.readLine(); } f.close(); grid = new QGrid(gridVal, this); // grid->setFixedSize( 480, 480 ); for( int c = 0 ; c < gridVal ; c++ ) { for( int r = 0 ; r < gridVal ; r++ ) { uint pos = rand() % l. count(); QString word = QStringList::split(" ", l[pos]).join("\n"); BuzzItem* bi = new BuzzItem( c, r, word, grid ); - connect( bi, SIGNAL(clicked(int, int)), this, SLOT(clicked(int,int)) ); + connect( bi, SIGNAL(clicked(int,int)), this, SLOT(clicked(int,int)) ); map[c][r] = 0; l.remove( l.at( pos )); } } } void BuzzWord::clicked(int row, int column) { if ( ! gameOver ) { int rowTotal = 0; int columnTotal = 0; map[column][row] = 1; for( int c = 0 ; c < gridVal ; c++ ) { for( int r = 0 ; r < gridVal ; r++ ) { if ( map[c][r] == 1 ) rowTotal++; if ( rowTotal == 4 ) { bingo(); } } rowTotal = 0; } for( int r = 0 ; r < gridVal ; r++ ) { for( int c = 0 ; c < gridVal ; c++ ) { if ( map[c][r] == 1 ) columnTotal++; if ( columnTotal == 4 ) { bingo(); } } columnTotal = 0; } if ( map[0][0] && map[1][1] && map[2][2] && map[3][3] ) bingo(); if ( map[0][3] && map[1][2] && map[2][1] && map[3][0] ) bingo(); } } void BuzzWord::bingo() { gameOver = true; QMessageBox::information( this, "BUZZWORD", tr("<h1><b>BINGO !</b></h1>")); } void BuzzWord::newGame() { gameOver = false; delete grid; drawGrid(); setCentralWidget(grid); } 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,133 +1,133 @@ #include "portable.h" #if defined( KDE2_PORT ) #include <kpacman.h> #include <kpacman.moc> #include <kcolordlg.h> #elif defined( QPE_PORT ) #include <qmenubar.h> #include <qpe/config.h> #include <qapplication.h> #include "kpacman.h" #endif Kpacman::Kpacman(QWidget *parent, const char *name) : KTMainWindow(parent, name) { schemesPopup = new QList<QPopupMenu>; schemesPopup->setAutoDelete(TRUE); menu(); m_view = new QWidget( this, "m_view" ); m_view->setBackgroundColor( black ); m_layout = new QGridLayout( m_view ); m_layout->setMargin( 7 ); view = new KpacmanWidget( this, QString(name)+"widget"); m_layout->addWidget( view, 0, 0 ); setCaption( tr("KPacman") ); view->referee->setFocus(); - connect(view->referee, SIGNAL(setScore(int, int)), - view->score, SLOT(setScore(int, int))); + connect(view->referee, SIGNAL(setScore(int,int)), + view->score, SLOT(setScore(int,int))); connect(view->referee, SIGNAL(setPoints(int)), view->score, SLOT(set(int))); connect(view->referee, SIGNAL(setLifes(int)), view->status, SLOT(setLifes(int))); connect(view->referee, SIGNAL(setLevel(int)), view->status, SLOT(setLevel(int))); connect(view->referee, SIGNAL(forcedHallOfFame(bool)), this, SLOT(forcedHallOfFame(bool))); connect(view->referee, SIGNAL(togglePaused()), this, SLOT(togglePaused())); connect(view->referee, SIGNAL(toggleNew()), this, SLOT(toggleNew())); connect(view->score, SIGNAL(toggleNew()), this, SLOT(toggleNew())); connect(view->score, SIGNAL(forcedHallOfFame(bool)), this, SLOT(forcedHallOfFame(bool))); APP_CONFIG_BEGIN( cfg ); focusOutPause = !cfg->readBoolEntry("FocusOutPause", TRUE); focusInContinue = !cfg->readBoolEntry("FocusInContinue", TRUE); hideMouseCursor = !cfg->readBoolEntry("HideMouseCursor", TRUE); APP_CONFIG_END( cfg ); toggleFocusOutPause(); toggleFocusInContinue(); toggleHideMouseCursor(); setCentralWidget( m_view ); } Kpacman::~Kpacman() { /* APP_CONFIG_BEGIN( cfg ); cfg->writeEntry("FocusOutPause", focusOutPause); cfg->writeEntry("FocusInContinue", focusInContinue); cfg->writeEntry("HideMouseCursor", hideMouseCursor); APP_CONFIG_END( cfg ); */ delete _menuBar; } void Kpacman::menu() { gamePopup = new QPopupMenu(); CHECK_PTR( gamePopup ); newID = gamePopup->insertItem(tr("&New"), this, SLOT(newKpacman()),Key_F2); pauseID = gamePopup->insertItem(tr("&Pause"), this, SLOT(pauseKpacman()), Key_F3); hofID = gamePopup->insertItem(tr("&Hall of fame"), this, SLOT(toggleHallOfFame()), Key_F4); gamePopup->insertSeparator(); gamePopup->insertItem(tr("&Quit"), this, SLOT(quitKpacman()), CTRL+Key_Q); gamePopup->setCheckable(TRUE); optionsPopup = new QPopupMenu(); CHECK_PTR(optionsPopup); modesPopup = new QPopupMenu(); CHECK_PTR(modesPopup); hideMouseCursorID = optionsPopup->insertItem(tr("&Hide Mousecursor"), this, SLOT(toggleHideMouseCursor()), CTRL+Key_H); optionsPopup->insertSeparator(); if (lookupSchemes() > 0) { optionsPopup->insertItem(tr("&Select graphic scheme"), modesPopup); optionsPopup->insertSeparator(); } focusOutPauseID = optionsPopup->insertItem(tr("&Pause in Background"), this, SLOT(toggleFocusOutPause())); focusInContinueID = optionsPopup->insertItem(tr("&Continue in Foreground"), this, SLOT(toggleFocusInContinue())); optionsPopup->insertSeparator(); optionsPopup->insertItem(tr("Change &keys..."), this, SLOT(confKeys())); #ifndef QPE_PORT QString aboutText = tr("@PACKAGE@ - @VERSION@\n\n" "Joerg Thoennissen (joe@dsite.de)\n\n" "A pacman game for the KDE Desktop\n\n" "The program based on the source of ksnake\n" "by Michel Filippi (mfilippi@sade.rhein-main.de).\n" "The design was strongly influenced by the pacman\n" "(c) 1980 MIDWAY MFG.CO.\n\n" "I like to thank my girlfriend Elke Krueers for\n" "the last 10 years of her friendship.\n"); aboutText.replace(QRegExp("@PACKAGE@"), PACKAGE); aboutText.replace(QRegExp("@VERSION@"), VERSION); QPopupMenu *helpPopup = helpMenu(aboutText, FALSE); #endif //_menuBar = new KMenuBar(this); //CHECK_PTR( _menuBar ); //_menuBar->insertItem(tr("&Game"), gamePopup); //_menuBar->insertItem(tr("&Options"), optionsPopup); //_menuBar->insertSeparator(); 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,128 +1,128 @@ #include "oyatzee.h" #include <qmessagebox.h> #include <qpushbutton.h> #include <qpainter.h> #include <qlayout.h> #include <stdlib.h> OYatzee::OYatzee( QWidget *parent , const char *name, WFlags fl ) : QMainWindow( parent , name , fl ) { QWidget *thing = new QWidget( this ); setCentralWidget( thing ); setCaption( tr( "OYatzee" ) ); setPlayerNumber( 4 ); setRoundsNumber( 1 ); lastPlayerFinished = false; currentPlayer = 1; ps.append( new Player( "Carsten" ) ); ps.append( new Player( "Julia" ) ); ps.append( new Player( "Christine" ) ); ps.append( new Player( "Stephan" ) ); QVBoxLayout *vbox = new QVBoxLayout( thing ); sb = new Scoreboard( ps, thing , "sb" ); - connect( sb->pb , SIGNAL( item( int ) ), this , SLOT( slotEndRound( int ) ) ); + connect( sb->pb , SIGNAL( item(int) ), this , SLOT( slotEndRound(int) ) ); dw = new DiceWidget( thing , "dw" ); dw->setMaximumHeight( this->height()/4 ); connect( dw->rollButton, SIGNAL( clicked() ), this , SLOT( slotRollDices() ) ); vbox->addWidget( sb ); vbox->addWidget( dw ); } void OYatzee::slotEndRound( int item ) { qDebug( "Der User hat Nummer %d ausgewählt" , item ); /* * if the user clicked on Total, Bonus or Score and thus not on a * selectable item return and do nothing */ if ( item == 7 || item == 8 || item == 16 ) return; /* * check if the user can really click on that item */ if ( posibilities.find( item ) == posibilities.end() ) return; QValueListInt numbers; Dice *d = dw->diceList.first(); for ( ; d != 0 ; d = dw->diceList.next() ) { numbers.append( d->hasValue() ); } int points = 0; switch ( item ) { case Ones: points = getPoints( 1 , numbers ); break; case Twos: points = getPoints( 2 , numbers ); break; case Threes: points = getPoints( 3 , numbers ); break; case Fours: points = getPoints( 4 , numbers ); break; case Fives: points = getPoints( 5 , numbers ); break; case Sixes: points = getPoints( 6 , numbers ); break; case ThreeOfAKind: points = oakPoints; break; case FourOfAKind: points = oakPoints; break; case FullHouse: points = 25; break; case SStraight: points = 30; break; case LStraight: points = 40; break; case Yatzee: points = 50; break; case Chance: points = getPoints ( Chance , numbers ); } sb->nextRB(currentPlayer-1)->updateMap( item , points ); nextPlayer(); qDebug( "Punkte: %d" , points ); } void OYatzee::nextPlayer() { currentPlayer++; if ( currentPlayer > numOfPlayers ) { currentPlayer = 1; } ps.at(currentPlayer-1)->turn = 0; } int OYatzee::getPoints( const int num , QValueListInt l) { @@ -553,135 +553,135 @@ void Player::setupResultList() { pResults.append( 0 ); } } /* * TODO: muss noch genutzt werden */ void Player::updateTotalPoints( pointMap m ) { pointMap::Iterator it = m.begin(); for ( ; it != m.end() ; ++it ) { totalPoints += it.data(); } } void Player::setResults( const int cat , const int points ) { QValueListInt::Iterator it = pResults.at( cat ); *it = points; } /* * Board */ Board::Board( QWidget *parent , const char* name ) : QWidget ( parent , name ) { } void Board::mousePressEvent( QMouseEvent *e ) { emit clicked( e->pos() ); } /* * Resultboard */ Resultboard::Resultboard( QString playerName , QWidget *parent , const char* name ) : Board ( parent , name ) { pName = playerName; } void Resultboard::paintEvent( QPaintEvent* ) { QPainter p; p.begin( this ); const int cell_width = this->width(); const int cell_height = this->height()/17; pointMap::Iterator it = pMap.begin(); for ( ; it != pMap.end() ; ++it ) { int i = it.key(); qDebug( "ok: %d , %d" , i , it.data() ); p.drawText( 0, i*cell_height , cell_width , cell_height , Qt::AlignCenter , QString::number( it.data() ) ); } p.drawText( 0,0,cell_width,cell_height, Qt::AlignCenter , pName ); //Playername } void Resultboard::updateMap( int item , int points ) { pMap.insert( item , points ); update(); } /* * Possibilityboard */ Possibilityboard::Possibilityboard( QWidget *parent , const char* name ) : Board ( parent , name ) { begriffe.append( "1er" ); begriffe.append( "2er" ); begriffe.append( "3er" ); begriffe.append( "4er" ); begriffe.append( "5er" ); begriffe.append( "6er" ); begriffe.append( "Total" ); begriffe.append( "Bonus" ); begriffe.append( "3oaK" ); begriffe.append( "4oaK" ); begriffe.append( "Full House" ); begriffe.append( "Short S" ); begriffe.append( "Long S" ); begriffe.append( "Yatzee!" ); begriffe.append( "Chance" ); begriffe.append( "Score" ); - connect( this , SIGNAL( clicked( QPoint ) ), this , SLOT( slotClicked( QPoint ) ) ); + connect( this , SIGNAL( clicked(QPoint) ), this , SLOT( slotClicked(QPoint) ) ); } void Possibilityboard::slotClicked( QPoint p) { emit item( p.y()/(this->height()/17) ); } void Possibilityboard::paintEvent( QPaintEvent* ) { QPainter p; p.begin( this ); const int cell_width = this->width(); const int cell_height = this->height()/17; p.setBrush( Qt::blue ); QValueListInt::Iterator listIt = list.begin(); for ( ; listIt != list.end() ; ++listIt ) { p.drawRect( 0 , (*listIt) * cell_height , cell_width , cell_height ); } p.setBrush( Qt::black ); p.setBrush( Qt::NoBrush ); QStringList::Iterator begriffeIt = begriffe.begin(); for ( int i = 1 ; i < 18 ; ++i ) { p.drawText( 0 , i*cell_height , cell_width , cell_height , Qt::AlignCenter , *begriffeIt ); ++begriffeIt; } } void Possibilityboard::setIntlist( QValueListInt &l ) { list = l; } |