-rw-r--r-- | noncore/games/buzzword/buzzword.cpp | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/noncore/games/buzzword/buzzword.cpp b/noncore/games/buzzword/buzzword.cpp index 447396b..324b5bd 100644 --- a/noncore/games/buzzword/buzzword.cpp +++ b/noncore/games/buzzword/buzzword.cpp @@ -29,25 +29,16 @@ #include <qmessagebox.h> #include <qdir.h> #include <math.h> #include <stdlib.h> -#include <list> -#include <string> - #include <qpe/qpeapplication.h> #include "buzzword.h" -// sponsered by rikkus :) -bool random_compare(const QString &, const QString &) -{ - return (rand() % 2) > 0.5; -} - BuzzLabel::BuzzLabel( QWidget *parent, const char *name ) : QLabel( parent, name ) { } void BuzzLabel::mousePressEvent(QMouseEvent *e) @@ -93,43 +84,43 @@ BuzzWord::BuzzWord() : QMainWindow(0) gameOver = false; newGame(); } void BuzzWord::drawGrid() { - std::list<QString> l; + 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.push_back(t.readLine()); + l << t.readLine(); } f.close(); - l.sort(random_compare); - grid = new QGrid(gridVal, this); grid->setFixedSize(240,240); for( int c = 0 ; c < gridVal ; c++ ) { for( int r = 0 ; r < gridVal ; r++ ) { - QString word = QStringList::split(" ", l.front()).join("\n"); + 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)) ); map[c][r] = 0; - l.pop_front(); + l.remove( l.at( pos )); } } } void BuzzWord::clicked(int row, int column) { |