author | imm <imm> | 2002-08-30 22:03:20 (UTC) |
---|---|---|
committer | imm <imm> | 2002-08-30 22:03:20 (UTC) |
commit | c3fbc3f07c4deb54a3c5efd7cd91beaba875d57c (patch) (side-by-side diff) | |
tree | c08b80f938953dff0a25798bae77b623b9024932 | |
parent | 8c26b7fe6b3afc8c3de2ee48bfb50bb041dadede (diff) | |
download | opie-c3fbc3f07c4deb54a3c5efd7cd91beaba875d57c.zip opie-c3fbc3f07c4deb54a3c5efd7cd91beaba875d57c.tar.gz opie-c3fbc3f07c4deb54a3c5efd7cd91beaba875d57c.tar.bz2 |
fix by sandman
STL -> qt
-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 @@ -11,61 +11,52 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <qlayout.h> #include <qmessagebox.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 <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) { 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()) ); } @@ -75,79 +66,79 @@ void BuzzItem::flip() setLineWidth( 1 ); label->setBackgroundColor(label->colorGroup().highlight()); emit clicked(_row, _column); } BuzzWord::BuzzWord() : QMainWindow(0) { setCaption(tr("buZzword")); menu = menuBar(); game = new QPopupMenu; game->insertItem(tr("&New game"), this, SLOT(newGame()), Key_N ); game->insertSeparator(); game->insertItem(tr("&About"), this, SLOT(about())); menu->insertItem( tr("&Game"), game ); gridVal = 4; grid = NULL; 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) { 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(); } |