-rw-r--r-- | noncore/games/wordgame/wordgame.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/games/wordgame/wordgame.cpp b/noncore/games/wordgame/wordgame.cpp index 16d37b3..d3160f4 100644 --- a/noncore/games/wordgame/wordgame.cpp +++ b/noncore/games/wordgame/wordgame.cpp @@ -82,97 +82,97 @@ const char* sampleWGR= "000000202000000\n" "102001000100201\n" "000020000020000\n" "000300020003000\n" "002002000200200\n" "030000000000030\n" "400001040100004\n" "1 2 3 66 67 194 100 0\n" "1 j 8\n" "1 q 7\n" "1 x 6\n" "1 z 6\n" "1 w 4\n" "1 k 4\n" "1 v 3\n" "1 f 3\n" "2 y 3\n" "2 h 2\n" "2 b 2\n" "2 m 2\n" "3 p 2\n" "3 g 2\n" "3 u 2\n" "4 d 2\n" "4 c 2\n" "5 l 1\n" "5 o 1\n" "7 t 1\n" "7 n 1\n" "7 a 1\n" "7 r 1\n" "8 s 1\n" "8 i 1\n" "11 e 1\n" "0\n"; WordGame::WordGame( QWidget* parent, const char* name, WFlags fl ) : QMainWindow(parent, name, fl) { if ( qApp->desktop()->width() < 240 ) { tile_smallw = 10; tile_smallh = 10; tile_bigw = 16; tile_bigh = 16; tile_stweak = 0; tile_btweak = 0; } - setIcon( Resource::loadPixmap( "wordgame" ) ); + setIcon( Resource::loadPixmap( "wordgame/WordGame.png" ) ); setCaption( tr("Word Game") ); setToolBarsMovable( FALSE ); vbox = new QVBox(this); setCentralWidget(vbox); toolbar = new QPEToolBar(this); addToolBar(toolbar, Bottom); reset = new QToolButton(Resource::loadPixmap("back"), tr("Back"), "", this, SLOT(resetTurn()), toolbar); done = new QToolButton(Resource::loadPixmap("done"), tr("Done"), "", this, SLOT(endTurn()), toolbar); scoreinfo = new ScoreInfo(toolbar); scoreinfo->setFont(QFont("Helvetica",10)); new QToolButton(Resource::loadPixmap("finish"), tr("Close"), "", this, SLOT(endGame()), toolbar); toolbar->setStretchableWidget(scoreinfo); cpu = 0; board = 0; bag = 0; racks = 0; aiheart = new QTimer(this); connect(aiheart, SIGNAL(timeout()), this, SLOT(think())); readConfig(); } WordGame::~WordGame() { writeConfig(); } void WordGame::writeConfig() { Config cfg("WordGame"); cfg.setGroup("Game"); cfg.writeEntry("NameList",namelist,';'); cfg.writeEntry("CurrentPlayer",gameover ? 0 : player+1); if ( !gameover ) { cfg.writeEntry("Rules",rules); bag->writeConfig(cfg); board->writeConfig(cfg); scoreinfo->writeConfig(cfg); } for (int p=0; p<nplayers; p++) { cfg.setGroup("Player"+QString::number(p+1)); if ( gameover ) cfg.clearGroup(); else rack(p)->writeConfig(cfg); } } @@ -269,97 +269,97 @@ void WordGame::startGame(const QStringList& playerlist) for (QStringList::ConstIterator it=playerlist.begin(); it!=playerlist.end(); ++it) addPlayer(*it); scoreinfo->init(namelist); if ( nplayers ) { player=0; readyRack(player); } board->show(); racks->show(); } bool WordGame::loadRules(const QString &name) { QString filename = Global::applicationFileName( "wordgame", name ); QFile file( filename ); if ( !file.open( IO_ReadOnly ) ) return FALSE; QTextStream ts( &file ); QString title = name; title.truncate( title.length() - 6 ); setCaption( title ); QString shapepixmap; ts >> shapepixmap; int htiles,vtiles; ts >> htiles >> vtiles; if ( htiles < 3 || vtiles < 3 ) return FALSE; QString rule_shapes; for (int i=0; i<vtiles; i++) { QString line; ts >> line; rule_shapes += line; } static int rule_effects[12]; int re=0,e; ts >> e; while ( e && re < 10 ) { rule_effects[re] = e; if ( re++ < 10 ) ts >> e; } - QImage shim = Resource::loadImage(shapepixmap); + QImage shim = Resource::loadImage("wordgame/wordgame_shapes.xpm"); shim = shim.smoothScale((re-1)*TileItem::smallWidth(),TileItem::smallHeight()); QPixmap bgshapes; bgshapes.convertFromImage(shim); rule_effects[re++] = 100; // default bonus board = new Board(bgshapes, htiles, vtiles, vbox); board->setRules(rule_shapes, rule_effects); connect(board, SIGNAL(temporaryScore(int)), scoreinfo, SLOT(showTemporaryScore(int))); bag = new Bag; int count; ts >> count; while ( count ) { QString text; int value; ts >> text >> value; if ( text == "_" ) text = ""; Tile t(text, value); for (int n=count; n--; ) bag->add(t); ts >> count; } return TRUE; } NewGame::NewGame(QWidget* parent) : NewGameBase(parent) { } void NewGame::updateRuleSets() { rules->clear(); QString rulesDir = Global::applicationFileName( "wordgame", "" ); QDir dir( rulesDir, "*.rules" ); ruleslist = dir.entryList(); if ( ruleslist.isEmpty() ) { // Provide a sample QFile file( rulesDir + "Sample.rules" ); if ( file.open( IO_WriteOnly ) ) { file.writeBlock( sampleWGR, strlen(sampleWGR) ); |