Diffstat (limited to 'noncore/games/wordgame/wordgame.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/games/wordgame/wordgame.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/noncore/games/wordgame/wordgame.cpp b/noncore/games/wordgame/wordgame.cpp index 47d6725..52e2be2 100644 --- a/noncore/games/wordgame/wordgame.cpp +++ b/noncore/games/wordgame/wordgame.cpp | |||
@@ -12,26 +12,27 @@ | |||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | 21 | ||
22 | #include "wordgame.h" | 22 | #include "wordgame.h" |
23 | 23 | ||
24 | #include <opie2/oresource.h> | ||
25 | |||
24 | #include <qpe/global.h> | 26 | #include <qpe/global.h> |
25 | #include <qpe/resource.h> | ||
26 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
27 | 28 | ||
28 | #include <qapplication.h> | 29 | #include <qapplication.h> |
29 | #include <qmessagebox.h> | 30 | #include <qmessagebox.h> |
30 | #include <qcombobox.h> | 31 | #include <qcombobox.h> |
31 | #include <qdir.h> | 32 | #include <qdir.h> |
32 | #include <qlineedit.h> | 33 | #include <qlineedit.h> |
33 | #include <qpushbutton.h> | 34 | #include <qpushbutton.h> |
34 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
35 | #include <qtimer.h> | 36 | #include <qtimer.h> |
36 | #include <qtoolbar.h> | 37 | #include <qtoolbar.h> |
37 | #include <qtoolbutton.h> | 38 | #include <qtoolbutton.h> |
@@ -109,38 +110,45 @@ const char* sampleWGR= | |||
109 | WordGame::WordGame( QWidget* parent, const char* name, WFlags fl ) : | 110 | WordGame::WordGame( QWidget* parent, const char* name, WFlags fl ) : |
110 | QMainWindow(parent, name, fl) | 111 | QMainWindow(parent, name, fl) |
111 | { | 112 | { |
112 | if ( qApp->desktop()->width() < 240 ) { | 113 | if ( qApp->desktop()->width() < 240 ) { |
113 | tile_smallw = 10; | 114 | tile_smallw = 10; |
114 | tile_smallh = 10; | 115 | tile_smallh = 10; |
115 | tile_bigw = 16; | 116 | tile_bigw = 16; |
116 | tile_bigh = 16; | 117 | tile_bigh = 16; |
117 | tile_stweak = 0; | 118 | tile_stweak = 0; |
118 | tile_btweak = 0; | 119 | tile_btweak = 0; |
119 | } | 120 | } |
120 | 121 | ||
121 | setIcon( Resource::loadPixmap( "wordgame/WordGame.png" ) ); | 122 | setIcon( Opie::Core::OResource::loadPixmap( "wordgame/WordGame" ) ); |
122 | setCaption( tr("Word Game") ); | 123 | setCaption( tr("Word Game") ); |
123 | 124 | ||
124 | setToolBarsMovable( FALSE ); | 125 | setToolBarsMovable( FALSE ); |
125 | vbox = new QVBox(this); | 126 | vbox = new QVBox(this); |
126 | 127 | ||
127 | setCentralWidget(vbox); | 128 | setCentralWidget(vbox); |
128 | toolbar = new QToolBar(this); | 129 | toolbar = new QToolBar(this); |
129 | addToolBar(toolbar, Bottom); | 130 | addToolBar(toolbar, Bottom); |
130 | reset = new QToolButton(Resource::loadPixmap("back"), tr("Back"), "", this, SLOT(resetTurn()), toolbar); | 131 | bool useBigIcon = qApp->desktop()->size().width() > 330; |
131 | done = new QToolButton(Resource::loadPixmap("done"), tr("Done"), "", this, SLOT(endTurn()), toolbar); | 132 | reset = new QToolButton(Opie::Core::OResource::loadPixmap("back", Opie::Core::OResource::SmallIcon), |
133 | tr("Back"), "", this, SLOT(resetTurn()), toolbar); | ||
134 | reset->setUsesBigPixmap( useBigIcon ); | ||
135 | done = new QToolButton(Opie::Core::OResource::loadPixmap("done", Opie::Core::OResource::SmallIcon), | ||
136 | tr("Done"), "", this, SLOT(endTurn()), toolbar); | ||
137 | done->setUsesBigPixmap( useBigIcon ); | ||
132 | scoreinfo = new ScoreInfo(toolbar); | 138 | scoreinfo = new ScoreInfo(toolbar); |
133 | scoreinfo->setFont(QFont("Helvetica",10)); | 139 | scoreinfo->setFont(QFont("Helvetica",10)); |
134 | new QToolButton(Resource::loadPixmap("finish"), tr("Close"), "", this, SLOT(endGame()), toolbar); | 140 | QToolButton *btn = new QToolButton(Opie::Core::OResource::loadPixmap("finish", Opie::Core::OResource::SmallIcon), |
141 | tr("Close"), "", this, SLOT(endGame()), toolbar); | ||
142 | btn->setUsesBigPixmap( useBigIcon ); | ||
135 | toolbar->setStretchableWidget(scoreinfo); | 143 | toolbar->setStretchableWidget(scoreinfo); |
136 | 144 | ||
137 | cpu = 0; | 145 | cpu = 0; |
138 | board = 0; | 146 | board = 0; |
139 | bag = 0; | 147 | bag = 0; |
140 | racks = 0; | 148 | racks = 0; |
141 | 149 | ||
142 | aiheart = new QTimer(this); | 150 | aiheart = new QTimer(this); |
143 | connect(aiheart, SIGNAL(timeout()), this, SLOT(think())); | 151 | connect(aiheart, SIGNAL(timeout()), this, SLOT(think())); |
144 | 152 | ||
145 | readConfig(); | 153 | readConfig(); |
146 | } | 154 | } |
@@ -296,25 +304,25 @@ bool WordGame::loadRules(const QString &name) | |||
296 | QString line; | 304 | QString line; |
297 | ts >> line; | 305 | ts >> line; |
298 | rule_shapes += line; | 306 | rule_shapes += line; |
299 | } | 307 | } |
300 | static int rule_effects[12]; | 308 | static int rule_effects[12]; |
301 | int re=0,e; | 309 | int re=0,e; |
302 | ts >> e; | 310 | ts >> e; |
303 | while ( e && re < 10 ) { | 311 | while ( e && re < 10 ) { |
304 | rule_effects[re] = e; | 312 | rule_effects[re] = e; |
305 | if ( re++ < 10 ) ts >> e; | 313 | if ( re++ < 10 ) ts >> e; |
306 | } | 314 | } |
307 | 315 | ||
308 | QImage shim = Resource::loadImage("wordgame/wordgame_shapes"); | 316 | QImage shim = Opie::Core::OResource::loadImage("wordgame/wordgame_shapes"); |
309 | shim = shim.smoothScale((re-1)*TileItem::smallWidth(),TileItem::smallHeight()); | 317 | shim = shim.smoothScale((re-1)*TileItem::smallWidth(),TileItem::smallHeight()); |
310 | QPixmap bgshapes; | 318 | QPixmap bgshapes; |
311 | bgshapes.convertFromImage(shim); | 319 | bgshapes.convertFromImage(shim); |
312 | 320 | ||
313 | rule_effects[re++] = 100; // default bonus | 321 | rule_effects[re++] = 100; // default bonus |
314 | board = new Board(bgshapes, htiles, vtiles, vbox); | 322 | board = new Board(bgshapes, htiles, vtiles, vbox); |
315 | board->setRules(rule_shapes, rule_effects); | 323 | board->setRules(rule_shapes, rule_effects); |
316 | connect(board, SIGNAL(temporaryScore(int)), scoreinfo, SLOT(showTemporaryScore(int))); | 324 | connect(board, SIGNAL(temporaryScore(int)), scoreinfo, SLOT(showTemporaryScore(int))); |
317 | 325 | ||
318 | bag = new Bag; | 326 | bag = new Bag; |
319 | 327 | ||
320 | int count; | 328 | int count; |
@@ -1353,25 +1361,25 @@ void Rack::contentsMouseMoveEvent(QMouseEvent* e) | |||
1353 | if ( computerized() ) | 1361 | if ( computerized() ) |
1354 | return; | 1362 | return; |
1355 | //int w = TileItem::bigWidth()+2; | 1363 | //int w = TileItem::bigWidth()+2; |
1356 | if ( dragging ) { | 1364 | if ( dragging ) { |
1357 | dragging_adj = TileItem::bigWidth()/2; | 1365 | dragging_adj = TileItem::bigWidth()/2; |
1358 | if ( dragging->x() > e->x()-dragstart.x() ) | 1366 | if ( dragging->x() > e->x()-dragstart.x() ) |
1359 | dragging_adj = -dragging_adj; | 1367 | dragging_adj = -dragging_adj; |
1360 | dragging->move(e->x()-dragstart.x(),0); | 1368 | dragging->move(e->x()-dragstart.x(),0); |
1361 | layoutTiles(); | 1369 | layoutTiles(); |
1362 | } | 1370 | } |
1363 | } | 1371 | } |
1364 | 1372 | ||
1365 | void Rack::contentsMouseReleaseEvent(QMouseEvent* e) | 1373 | void Rack::contentsMouseReleaseEvent(QMouseEvent* /*e*/) |
1366 | { | 1374 | { |
1367 | if ( computerized() ) | 1375 | if ( computerized() ) |
1368 | return; | 1376 | return; |
1369 | if ( dragging ) { | 1377 | if ( dragging ) { |
1370 | dragging=0; | 1378 | dragging=0; |
1371 | layoutTiles(); | 1379 | layoutTiles(); |
1372 | } | 1380 | } |
1373 | } | 1381 | } |
1374 | 1382 | ||
1375 | Tile::Tile(const QString& key) | 1383 | Tile::Tile(const QString& key) |
1376 | { | 1384 | { |
1377 | int a=key.find('@'); | 1385 | int a=key.find('@'); |