summaryrefslogtreecommitdiff
authordrw <drw>2005-05-20 21:23:29 (UTC)
committer drw <drw>2005-05-20 21:23:29 (UTC)
commitdfdc651b989550e30f2b72f535ce0cd3431fc9f4 (patch) (unidiff)
tree1f5e64509fe2ef75a14c1909a8f981779b7b5acb
parent5e7bbe42671f565bef961b44862ddbf68beed774 (diff)
downloadopie-dfdc651b989550e30f2b72f535ce0cd3431fc9f4.zip
opie-dfdc651b989550e30f2b72f535ce0cd3431fc9f4.tar.gz
opie-dfdc651b989550e30f2b72f535ce0cd3431fc9f4.tar.bz2
Resource -> OResource, remove some unnecessary includes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/zsame/StoneWidget.cpp12
-rw-r--r--noncore/games/zsame/ZSameWidget.cpp13
2 files changed, 8 insertions, 17 deletions
diff --git a/noncore/games/zsame/StoneWidget.cpp b/noncore/games/zsame/StoneWidget.cpp
index 5dd0252..f370714 100644
--- a/noncore/games/zsame/StoneWidget.cpp
+++ b/noncore/games/zsame/StoneWidget.cpp
@@ -1,349 +1,343 @@
1/* 1/*
2 * ksame 0.4 - simple Game 2 * ksame 0.4 - simple Game
3 * Copyright (C) 1997,1998 Marcus Kreutzberger 3 * Copyright (C) 1997,1998 Marcus Kreutzberger
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 * 18 *
19 */ 19 */
20 20
21#include <stdio.h> 21#include <opie2/oresource.h>
22#include <stdlib.h>
23 22
24 23#include <qbitmap.h>
25
26#include <qpe/resource.h>
27 24
28#include <time.h> 25#include <time.h>
29#include <assert.h> 26#include <assert.h>
30 27
31#include "StoneWidget.h" 28#include "StoneWidget.h"
32 29
33 30
34 31
35struct StoneSlice { 32struct StoneSlice {
36 QPixmap stone; 33 QPixmap stone;
37}; 34};
38 35
39 36
40StoneWidget::StoneWidget( QWidget *parent, int x, int y ) 37StoneWidget::StoneWidget( QWidget *parent, int x, int y )
41 : QWidget(parent,"StoneWidget"), stonefield(x,y) 38 : QWidget(parent,"StoneWidget"), stonefield(x,y)
42{ 39{
43// setBackgroundPixmap(QPixmap(locate("wallpaper", "Time-For-Lunch-2.jpg"))); 40 QPixmap stonemap = Opie::Core::OResource::loadPixmap( "zsame/stones" );
44// QPixmap stonemap(locate("appdata", "stones.png"));
45
46 QPixmap stonemap = Resource::loadPixmap("zsame/stones" );
47 assert(!stonemap.isNull()); 41 assert(!stonemap.isNull());
48 42
49 slice=0; 43 slice=0;
50 maxslices=30; 44 maxslices=30;
51 maxcolors=4; 45 maxcolors=4;
52 46
53 sizex=x; 47 sizex=x;
54 sizey=y; 48 sizey=y;
55 49
56 stone_width=stonemap.width()/(maxslices+1); 50 stone_width=stonemap.width()/(maxslices+1);
57 stone_height=stonemap.height()/maxcolors; 51 stone_height=stonemap.height()/maxcolors;
58 52
59 map = new StoneSlice*[maxcolors]; 53 map = new StoneSlice*[maxcolors];
60 QBitmap mask; 54 QBitmap mask;
61 for (int c = 0; c < maxcolors; c++) { 55 for (int c = 0; c < maxcolors; c++) {
62 map[c] = new StoneSlice[maxslices]; 56 map[c] = new StoneSlice[maxslices];
63 57
64 for (int s = 0; s < maxslices; s++) { 58 for (int s = 0; s < maxslices; s++) {
65 map[c][s].stone.resize(stone_width, stone_height); 59 map[c][s].stone.resize(stone_width, stone_height);
66 assert(!map[c][s].stone.isNull()); 60 assert(!map[c][s].stone.isNull());
67 bitBlt(&map[c][s].stone, 0, 0, 61 bitBlt(&map[c][s].stone, 0, 0,
68 &stonemap, stone_width * s, 62 &stonemap, stone_width * s,
69 c*stone_height, 63 c*stone_height,
70 stone_width,stone_height,CopyROP,false); 64 stone_width,stone_height,CopyROP,false);
71 QImage im = map[c][s].stone.convertToImage(); 65 QImage im = map[c][s].stone.convertToImage();
72 mask = im.createHeuristicMask(); 66 mask = im.createHeuristicMask();
73 map[c][s].stone.setMask(mask); 67 map[c][s].stone.setMask(mask);
74 } 68 }
75 } 69 }
76 70
77 field_height=stone_height*sizey; 71 field_height=stone_height*sizey;
78 field_width=stone_width*sizex; 72 field_width=stone_width*sizex;
79 73
80 setMouseTracking(true); 74 setMouseTracking(true);
81 75
82 // QColor c(115,115,115); 76 // QColor c(115,115,115);
83 // setBackgroundColor(c); 77 // setBackgroundColor(c);
84 78
85 // emit s_sizechanged(); 79 // emit s_sizechanged();
86 startTimer( 100 ); 80 startTimer( 100 );
87 history.setAutoDelete(true); 81 history.setAutoDelete(true);
88} 82}
89 83
90StoneWidget::~StoneWidget() { 84StoneWidget::~StoneWidget() {
91 for (int c = 0; c < maxcolors; c++) { 85 for (int c = 0; c < maxcolors; c++) {
92 delete [] map[c]; 86 delete [] map[c];
93 } 87 }
94 delete [] map; 88 delete [] map;
95 89
96 setMouseTracking(false); 90 setMouseTracking(false);
97 killTimers(); 91 killTimers();
98} 92}
99 93
100unsigned int 94unsigned int
101StoneWidget::board() { 95StoneWidget::board() {
102 return stonefield.getBoard(); 96 return stonefield.getBoard();
103} 97}
104 98
105int 99int
106StoneWidget::score() { 100StoneWidget::score() {
107 return stonefield.getScore(); 101 return stonefield.getScore();
108} 102}
109 103
110int 104int
111StoneWidget::marked() { 105StoneWidget::marked() {
112 return stonefield.getMarked(); 106 return stonefield.getMarked();
113} 107}
114 108
115QSize 109QSize
116StoneWidget::size() { 110StoneWidget::size() {
117 return QSize(sizex,sizey); 111 return QSize(sizex,sizey);
118} 112}
119 113
120int 114int
121StoneWidget::colors() { 115StoneWidget::colors() {
122 return stonefield.getColors(); 116 return stonefield.getColors();
123} 117}
124 118
125QSize 119QSize
126StoneWidget::sizeHint () const { 120StoneWidget::sizeHint () const {
127 return QSize(field_width,field_height); 121 return QSize(field_width,field_height);
128} 122}
129 123
130void 124void
131StoneWidget::newGame(unsigned int board,int colors) { 125StoneWidget::newGame(unsigned int board,int colors) {
132 stonefield.newGame(board,colors); 126 stonefield.newGame(board,colors);
133 history.clear(); 127 history.clear();
134 modified= false; 128 modified= false;
135 emit s_newgame(); 129 emit s_newgame();
136 emit s_colors(stonefield.getColors()); 130 emit s_colors(stonefield.getColors());
137 emit s_board(stonefield.getBoard()); 131 emit s_board(stonefield.getBoard());
138} 132}
139 133
140void 134void
141StoneWidget::reset() { 135StoneWidget::reset() {
142 stonefield.reset(); 136 stonefield.reset();
143 history.clear(); 137 history.clear();
144 emit s_newgame(); 138 emit s_newgame();
145} 139}
146 140
147void 141void
148StoneWidget::unmark() { 142StoneWidget::unmark() {
149 stonefield.unmark(); 143 stonefield.unmark();
150 emit s_marked(0); 144 emit s_marked(0);
151} 145}
152 146
153bool StoneWidget::undoPossible() const { 147bool StoneWidget::undoPossible() const {
154 if (stonefield.isGameover()) return false; 148 if (stonefield.isGameover()) return false;
155 return stonefield.undoPossible(); 149 return stonefield.undoPossible();
156} 150}
157 151
158int 152int
159StoneWidget::undo(int count) { 153StoneWidget::undo(int count) {
160 if (stonefield.isGameover()) return 0; 154 if (stonefield.isGameover()) return 0;
161 155
162 int ret_val=stonefield.undo(count); 156 int ret_val=stonefield.undo(count);
163 157
164 QPoint p=mapFromGlobal(cursor().pos()); 158 QPoint p=mapFromGlobal(cursor().pos());
165 int x=p.x(); 159 int x=p.x();
166 int y=p.y(); 160 int y=p.y();
167 if (x<0||y<0||x>=field_width||y>=field_height) { 161 if (x<0||y<0||x>=field_width||y>=field_height) {
168 emit s_score(stonefield.getMarked()); 162 emit s_score(stonefield.getMarked());
169 return ret_val; 163 return ret_val;
170 } 164 }
171 165
172 int marked=stonefield.mark(x/stone_width,y/stone_height); 166 int marked=stonefield.mark(x/stone_width,y/stone_height);
173 emit s_marked(marked); 167 emit s_marked(marked);
174 slice=0; 168 slice=0;
175 emit s_score(stonefield.getScore()); 169 emit s_score(stonefield.getScore());
176 modified= (stonefield.getScore()>0); 170 modified= (stonefield.getScore()>0);
177 return ret_val; 171 return ret_val;
178} 172}
179 173
180bool StoneWidget::isGameover() { 174bool StoneWidget::isGameover() {
181 return stonefield.isGameover(); 175 return stonefield.isGameover();
182} 176}
183 177
184bool StoneWidget::hasBonus() { 178bool StoneWidget::hasBonus() {
185 return stonefield.gotBonus(); // don't ask me why the names differ... ;-| [hlm] 179 return stonefield.gotBonus(); // don't ask me why the names differ... ;-| [hlm]
186} 180}
187 181
188void StoneWidget::clearBonus() { 182void StoneWidget::clearBonus() {
189 stonefield.clearBonus(); 183 stonefield.clearBonus();
190} 184}
191 185
192bool StoneWidget::isOriginalBoard() { 186bool StoneWidget::isOriginalBoard() {
193 return !modified; 187 return !modified;
194} 188}
195 189
196void StoneWidget::readProperties(Config *) { 190void StoneWidget::readProperties(Config *) {
197/* Q_ASSERT(conf); 191/* Q_ASSERT(conf);
198 192
199 history.clear(); 193 history.clear();
200 194
201 if (!conf->hasKey("Board")|| 195 if (!conf->hasKey("Board")||
202 !conf->hasKey("Colors")|| 196 !conf->hasKey("Colors")||
203 !conf->hasKey("Stones")) { 197 !conf->hasKey("Stones")) {
204 return; 198 return;
205 } 199 }
206 newGame(conf->readNumEntry("Board"),conf->readNumEntry("Colors")); 200 newGame(conf->readNumEntry("Board"),conf->readNumEntry("Colors"));
207 201
208 QStrList list; 202 QStrList list;
209 conf->readListEntry("Stones",list); 203 conf->readListEntry("Stones",list);
210 204
211 for (const char *item=list.first();item;item=list.next()) { 205 for (const char *item=list.first();item;item=list.next()) {
212 int x=-1,y=-1; 206 int x=-1,y=-1;
213 if (sscanf(item,"%02X%02X",&x,&y)!=2) break; 207 if (sscanf(item,"%02X%02X",&x,&y)!=2) break;
214 history.append(new QPoint(x,y)); 208 history.append(new QPoint(x,y));
215 stonefield.remove(x,y); 209 stonefield.remove(x,y);
216 } 210 }
217*/ 211*/
218} 212}
219 213
220 214
221void 215void
222StoneWidget::saveProperties(Config *) { 216StoneWidget::saveProperties(Config *) {
223/* 217/*
224 Q_ASSERT(conf); 218 Q_ASSERT(conf);
225 219
226 QStrList list(true); 220 QStrList list(true);
227 QString tmp; 221 QString tmp;
228 222
229 for (QPoint *item=history.first();item;item=history.next()) { 223 for (QPoint *item=history.first();item;item=history.next()) {
230 tmp.sprintf("%02X%02X",item->x(),item->y()); 224 tmp.sprintf("%02X%02X",item->x(),item->y());
231 list.append(tmp.ascii()); 225 list.append(tmp.ascii());
232 } 226 }
233 227
234 conf->writeEntry("Stones",list); 228 conf->writeEntry("Stones",list);
235 conf->writeEntry("Board",stonefield.getBoard()); 229 conf->writeEntry("Board",stonefield.getBoard());
236 conf->writeEntry("Colors",stonefield.getColors()); 230 conf->writeEntry("Colors",stonefield.getColors());
237*/ 231*/
238} 232}
239 233
240void 234void
241StoneWidget::timerEvent( QTimerEvent * ) { 235StoneWidget::timerEvent( QTimerEvent * ) {
242 QPoint p=mapFromGlobal(cursor().pos()); 236 QPoint p=mapFromGlobal(cursor().pos());
243 int x=p.x(); 237 int x=p.x();
244 int y=p.y(); 238 int y=p.y();
245 if (x<0||y<0||x>=field_width||y>=field_height) 239 if (x<0||y<0||x>=field_width||y>=field_height)
246 stonefield.unmark(); 240 stonefield.unmark();
247 slice=(slice+1)%maxslices; 241 slice=(slice+1)%maxslices;
248 paintEvent(0); 242 paintEvent(0);
249} 243}
250 244
251void 245void
252StoneWidget::paintEvent( QPaintEvent *e ) { 246StoneWidget::paintEvent( QPaintEvent *e ) {
253 247
254 Stone *stone=stonefield.getField(); 248 Stone *stone=stonefield.getField();
255 249
256 for (int y=0;y<sizey;y++) { 250 for (int y=0;y<sizey;y++) {
257 int cy = y * stone_height; 251 int cy = y * stone_height;
258 252
259 for (int x=0;x<sizex;x++) { 253 for (int x=0;x<sizex;x++) {
260 int cx = stone_width * x; 254 int cx = stone_width * x;
261 255
262 bool redraw=stone->marked||stone->changed; 256 bool redraw=stone->marked||stone->changed;
263 257
264 if (!redraw&&e) { 258 if (!redraw&&e) {
265 QRect r(cx,cy,stone_width,stone_height); 259 QRect r(cx,cy,stone_width,stone_height);
266 redraw=r.intersects(e->rect()); 260 redraw=r.intersects(e->rect());
267 } 261 }
268 if (redraw) { 262 if (redraw) {
269 stone->changed=false; 263 stone->changed=false;
270 if (stone->color) { 264 if (stone->color) {
271 265
272 int tslice = stone->marked?slice:0; 266 int tslice = stone->marked?slice:0;
273 bitBlt(this,cx,cy, 267 bitBlt(this,cx,cy,
274 &map[stone->color-1][tslice].stone, 268 &map[stone->color-1][tslice].stone,
275 0, 0, 269 0, 0,
276 stone_width,stone_height,CopyROP,FALSE); 270 stone_width,stone_height,CopyROP,FALSE);
277 271
278 } else { 272 } else {
279 erase(cx, cy, stone_width, stone_height); 273 erase(cx, cy, stone_width, stone_height);
280 } 274 }
281 } 275 }
282 stone++; // naechster Stein. 276 stone++; // naechster Stein.
283 } 277 }
284 } 278 }
285} 279}
286 280
287void 281void
288StoneWidget::mousePressEvent ( QMouseEvent *e) { 282StoneWidget::mousePressEvent ( QMouseEvent *e) {
289 283
290 if (stonefield.isGameover()) return; 284 if (stonefield.isGameover()) return;
291 285
292 int x=e->pos().x(); 286 int x=e->pos().x();
293 int y=e->pos().y(); 287 int y=e->pos().y();
294 if (x<0||y<0||x>=field_width||y>=field_height) return; 288 if (x<0||y<0||x>=field_width||y>=field_height) return;
295 289
296 int sx=x/stone_width; 290 int sx=x/stone_width;
297 int sy=y/stone_height; 291 int sy=y/stone_height;
298 292
299 int mar =stonefield.mark(sx, sy); 293 int mar =stonefield.mark(sx, sy);
300 294
301 if ( mar != -1 ) { 295 if ( mar != -1 ) {
302 myMoveEvent(e); 296 myMoveEvent(e);
303 return; 297 return;
304 } 298 }
305 299
306 300
307 if (stonefield.remove(sx, sy)) { 301 if (stonefield.remove(sx, sy)) {
308 history.append(new QPoint(sx, sy)); 302 history.append(new QPoint(sx, sy));
309 303
310 emit s_remove(sx, sy); 304 emit s_remove(sx, sy);
311 305
312 stonefield.mark(sx,sy); 306 stonefield.mark(sx,sy);
313 emit s_marked(stonefield.getMarked()); 307 emit s_marked(stonefield.getMarked());
314 modified= true; 308 modified= true;
315 309
316 emit s_score(stonefield.getScore()); 310 emit s_score(stonefield.getScore());
317 if (stonefield.isGameover()) emit s_gameover(); 311 if (stonefield.isGameover()) emit s_gameover();
318 } 312 }
319} 313}
320 314
321void 315void
322StoneWidget::myMoveEvent ( QMouseEvent *e) 316StoneWidget::myMoveEvent ( QMouseEvent *e)
323{ 317{
324 return; 318 return;
325 319
326 if (stonefield.isGameover()) { 320 if (stonefield.isGameover()) {
327 stonefield.unmark(); 321 stonefield.unmark();
328 emit s_marked(0); 322 emit s_marked(0);
329 return; 323 return;
330 } 324 }
331 325
332 int x=e->pos().x(); 326 int x=e->pos().x();
333 int y=e->pos().y(); 327 int y=e->pos().y();
334 if (x<0||y<0||x>=field_width||y>=field_height) return; 328 if (x<0||y<0||x>=field_width||y>=field_height) return;
335 329
336 int marked=stonefield.mark(x/stone_width,y/stone_height); 330 int marked=stonefield.mark(x/stone_width,y/stone_height);
337 if (marked>=0) { 331 if (marked>=0) {
338 emit s_marked(marked); 332 emit s_marked(marked);
339 slice=0; 333 slice=0;
340 } 334 }
341} 335}
342 336
343 337
344 338
345 339
346 340
347 341
348 342
349 343
diff --git a/noncore/games/zsame/ZSameWidget.cpp b/noncore/games/zsame/ZSameWidget.cpp
index dee4a1c..7bcbee1 100644
--- a/noncore/games/zsame/ZSameWidget.cpp
+++ b/noncore/games/zsame/ZSameWidget.cpp
@@ -1,245 +1,242 @@
1/* Yo Emacs, this is -*- C++ -*- */ 1/* Yo Emacs, this is -*- C++ -*- */
2/* 2/*
3 * ksame 0.4 - simple Game 3 * ksame 0.4 - simple Game
4 * Copyright (C) 1997,1998 Marcus Kreutzberger 4 * Copyright (C) 1997,1998 Marcus Kreutzberger
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or 8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version. 9 * (at your option) any later version.
10 * 10 *
11 * This program is distributed in the hope that it will be useful, 11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License 16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 * 19 *
20 */ 20 */
21 21
22#include <stdio.h>
23
24#include <opie2/oapplicationfactory.h> 22#include <opie2/oapplicationfactory.h>
25 23#include <opie2/oresource.h>
26#include <qpe/resource.h>
27 24
28#include <qtoolbar.h> 25#include <qtoolbar.h>
29#include <qmenubar.h> 26#include <qmenubar.h>
30#include <qapplication.h> 27#include <qapplication.h>
31#include <qaction.h> 28#include <qaction.h>
32#include <qmessagebox.h> 29#include <qmessagebox.h>
33 30
34#include <kapplication.h> 31#include <kapplication.h>
35 32
36#include "ZSameWidget.h" 33#include "ZSameWidget.h"
37 34
38static int default_colors=3; 35static int default_colors=3;
39 36
40#define i18n tr 37#define i18n tr
41 38
42 39
43using namespace Opie::Core; 40using namespace Opie::Core;
44OPIE_EXPORT_APP( OApplicationFactory<ZSameWidget> ) 41OPIE_EXPORT_APP( OApplicationFactory<ZSameWidget> )
45 42
46 43
47 44
48ZSameWidget::ZSameWidget( QWidget* parent, const char* name, WFlags fl ) 45ZSameWidget::ZSameWidget( QWidget* parent, const char* name, WFlags fl )
49 : QMainWindow( parent, name, fl ) 46 : QMainWindow( parent, name, fl )
50{ 47{
51 setCaption(tr("ZSame")); 48 setCaption(tr("ZSame"));
52 49
53 setToolBarsMovable( false ); 50 setToolBarsMovable( false );
54 QToolBar* con = new QToolBar( this ); 51 QToolBar* con = new QToolBar( this );
55 con->setHorizontalStretchable( true ); 52 con->setHorizontalStretchable( true );
56 QMenuBar* mb = new QMenuBar( con ); 53 QMenuBar* mb = new QMenuBar( con );
57 QToolBar* tb = new QToolBar( this ); 54 QToolBar* tb = new QToolBar( this );
58 55
59 QPopupMenu* fileMenu = new QPopupMenu( this ); 56 QPopupMenu* fileMenu = new QPopupMenu( this );
60 57
61 QAction* a = new QAction(tr("New Game"), Resource::loadIconSet("new") , 58 QAction* a = new QAction(tr("New Game"), Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ),
62 QString::null, 0, this, "new_icon"); 59 QString::null, 0, this, "new_icon");
63 a->addTo( fileMenu ); 60 a->addTo( fileMenu );
64 a->addTo( tb ); 61 a->addTo( tb );
65 connect(a, SIGNAL(activated()), this, SLOT(m_new())); 62 connect(a, SIGNAL(activated()), this, SLOT(m_new()));
66 63
67 a = new QAction(tr("Restart This Board"), Resource::loadIconSet("redo"), 64 a = new QAction(tr("Restart This Board"), Opie::Core::OResource::loadPixmap( "redo", Opie::Core::OResource::SmallIcon ),
68 QString::null, 0, this, "restart_board" ); 65 QString::null, 0, this, "restart_board" );
69 a->addTo( fileMenu ); 66 a->addTo( fileMenu );
70 connect( a, SIGNAL(activated()), this, SLOT(m_restart())); 67 connect( a, SIGNAL(activated()), this, SLOT(m_restart()));
71 restart = a; 68 restart = a;
72 69
73 a = new QAction( tr("Undo"), Resource::loadIconSet("undo"), 70 a = new QAction( tr("Undo"), Opie::Core::OResource::loadPixmap( "undo", Opie::Core::OResource::SmallIcon ),
74 QString::null, 0, this, "undo_action" ); 71 QString::null, 0, this, "undo_action" );
75 a->addTo( fileMenu ); 72 a->addTo( fileMenu );
76 a->addTo( tb ); 73 a->addTo( tb );
77 connect( a, SIGNAL(activated()), this, SLOT(m_undo())); 74 connect( a, SIGNAL(activated()), this, SLOT(m_undo()));
78 75
79 a = new QAction(tr("Quit"), Resource::loadIconSet("quit_icon"), 76 a = new QAction(tr("Quit"), Opie::Core::OResource::loadPixmap( "quit_icon", Opie::Core::OResource::SmallIcon ),
80 QString::null, 0, this, "quit_action"); 77 QString::null, 0, this, "quit_action");
81 a->addTo( fileMenu ); 78 a->addTo( fileMenu );
82 a->addTo( tb ); 79 a->addTo( tb );
83 connect(a, SIGNAL(activated()), this, SLOT(m_quit())); 80 connect(a, SIGNAL(activated()), this, SLOT(m_quit()));
84 81
85 mb->insertItem(tr("Game" ), fileMenu ); 82 mb->insertItem(tr("Game" ), fileMenu );
86 83
87 int foo[2]; 84 int foo[2];
88 desktop_widget(foo); 85 desktop_widget(foo);
89 stone = new StoneWidget(this,foo[0],foo[1]); 86 stone = new StoneWidget(this,foo[0],foo[1]);
90 87
91 connect( stone, SIGNAL(s_gameover()), this, SLOT(gameover())); 88 connect( stone, SIGNAL(s_gameover()), this, SLOT(gameover()));
92 89
93 connect( stone, SIGNAL(s_colors(int)), this, SLOT(setColors(int))); 90 connect( stone, SIGNAL(s_colors(int)), this, SLOT(setColors(int)));
94 connect( stone, SIGNAL(s_board(int)), this, SLOT(setBoard(int))); 91 connect( stone, SIGNAL(s_board(int)), this, SLOT(setBoard(int)));
95 connect( stone, SIGNAL(s_marked(int)), this, SLOT(setMarked(int))); 92 connect( stone, SIGNAL(s_marked(int)), this, SLOT(setMarked(int)));
96 connect( stone, SIGNAL(s_score(int)), this, SLOT(setScore(int))); 93 connect( stone, SIGNAL(s_score(int)), this, SLOT(setScore(int)));
97 connect( stone, SIGNAL(s_remove(int,int)), this, SLOT(stonesRemoved(int,int))); 94 connect( stone, SIGNAL(s_remove(int,int)), this, SLOT(stonesRemoved(int,int)));
98 95
99 connect(stone, SIGNAL(s_sizechanged()), this, SLOT(sizeChanged())); 96 connect(stone, SIGNAL(s_sizechanged()), this, SLOT(sizeChanged()));
100 97
101 sizeChanged(); 98 sizeChanged();
102 setCentralWidget(stone); 99 setCentralWidget(stone);
103 100
104 101
105 setScore(0); 102 setScore(0);
106} 103}
107 104
108ZSameWidget::~ZSameWidget() { 105ZSameWidget::~ZSameWidget() {
109 106
110} 107}
111 108
112void ZSameWidget::readProperties(Config *) { 109void ZSameWidget::readProperties(Config *) {
113/* 110/*
114 Q_ASSERT(conf); 111 Q_ASSERT(conf);
115 stone->readProperties(conf); 112 stone->readProperties(conf);
116*/ 113*/
117} 114}
118 115
119void ZSameWidget::saveProperties(Config *) { 116void ZSameWidget::saveProperties(Config *) {
120/* 117/*
121 Q_ASSERT(conf); 118 Q_ASSERT(conf);
122 stone->saveProperties(conf); 119 stone->saveProperties(conf);
123 conf->sync(); 120 conf->sync();
124*/ 121*/
125} 122}
126 123
127void ZSameWidget::sizeChanged() { 124void ZSameWidget::sizeChanged() {
128 //stone->setFixedSize(stone->sizeHint()); 125 //stone->setFixedSize(stone->sizeHint());
129} 126}
130 127
131void ZSameWidget::newGame(unsigned int board,int colors) { 128void ZSameWidget::newGame(unsigned int board,int colors) {
132 while (board>=1000000) board-=1000000; 129 while (board>=1000000) board-=1000000;
133 // kdDebug() << "newgame board " << board << " colors " << colors << endl; 130 // kdDebug() << "newgame board " << board << " colors " << colors << endl;
134 stone->newGame(board,colors); 131 stone->newGame(board,colors);
135 setScore(0); 132 setScore(0);
136} 133}
137 134
138bool ZSameWidget::confirmAbort() { 135bool ZSameWidget::confirmAbort() {
139 return stone->isGameover() || 136 return stone->isGameover() ||
140 stone->isOriginalBoard() || 137 stone->isOriginalBoard() ||
141 (QMessageBox::warning(this, i18n("Resign"), i18n("<qt>Do you want to resign?</qt>"), 138 (QMessageBox::warning(this, i18n("Resign"), i18n("<qt>Do you want to resign?</qt>"),
142 QMessageBox::Yes, 139 QMessageBox::Yes,
143 QMessageBox::No|QMessageBox::Default|QMessageBox::Escape, 0) == QMessageBox::Yes ); 140 QMessageBox::No|QMessageBox::Default|QMessageBox::Escape, 0) == QMessageBox::Yes );
144} 141}
145 142
146void ZSameWidget::m_new() { 143void ZSameWidget::m_new() {
147 if (confirmAbort()) 144 if (confirmAbort())
148 newGame(_random(),default_colors); 145 newGame(_random(),default_colors);
149 146
150} 147}
151 148
152void ZSameWidget::m_restart() { 149void ZSameWidget::m_restart() {
153 if (confirmAbort()) 150 if (confirmAbort())
154 newGame(stone->board(),default_colors); 151 newGame(stone->board(),default_colors);
155} 152}
156 153
157void ZSameWidget::m_load() { 154void ZSameWidget::m_load() {
158// kdDebug() << "menu load not supported" << endl; 155// kdDebug() << "menu load not supported" << endl;
159} 156}
160 157
161void ZSameWidget::m_save() { 158void ZSameWidget::m_save() {
162// kdDebug() << "menu save not supported" << endl; 159// kdDebug() << "menu save not supported" << endl;
163} 160}
164 161
165void ZSameWidget::m_undo() { 162void ZSameWidget::m_undo() {
166 //Q_ASSERT(stone); 163 //Q_ASSERT(stone);
167 stone->undo(); 164 stone->undo();
168} 165}
169 166
170 167
171void ZSameWidget::m_showhs() { 168void ZSameWidget::m_showhs() {
172/* Q_ASSERT(stone); 169/* Q_ASSERT(stone);
173 stone->unmark(); 170 stone->unmark();
174 KScoreDialog d(KScoreDialog::Name | KScoreDialog::Score, this); 171 KScoreDialog d(KScoreDialog::Name | KScoreDialog::Score, this);
175 d.addField(Board, i18n("Board"), "Board"); 172 d.addField(Board, i18n("Board"), "Board");
176 d.exec(); 173 d.exec();
177*/ 174*/
178} 175}
179 176
180void ZSameWidget::m_quit() { 177void ZSameWidget::m_quit() {
181// Q_ASSERT(stone); 178// Q_ASSERT(stone);
182 stone->unmark(); 179 stone->unmark();
183 qApp->quit(); 180 qApp->quit();
184// delete this; 181// delete this;
185} 182}
186 183
187void ZSameWidget::m_tglboard() { 184void ZSameWidget::m_tglboard() {
188 //kdDebug() << "toggled" << endl; 185 //kdDebug() << "toggled" << endl;
189} 186}
190 187
191 188
192void ZSameWidget::setColors(int ) { 189void ZSameWidget::setColors(int ) {
193 //status->changeItem(i18n("%1 Colors").arg(colors),1); 190 //status->changeItem(i18n("%1 Colors").arg(colors),1);
194} 191}
195 192
196void ZSameWidget::setBoard(int ) { 193void ZSameWidget::setBoard(int ) {
197 //status->changeItem(i18n("Board: %1").arg(board, 6), 2); 194 //status->changeItem(i18n("Board: %1").arg(board, 6), 2);
198} 195}
199 196
200void ZSameWidget::setMarked(int ) { 197void ZSameWidget::setMarked(int ) {
201// status->changeItem(i18n("Marked: %1").arg(m, 6),3); 198// status->changeItem(i18n("Marked: %1").arg(m, 6),3);
202} 199}
203 200
204void ZSameWidget::stonesRemoved(int,int) { 201void ZSameWidget::stonesRemoved(int,int) {
205 //KNotifyClient::event("stones removed", 202 //KNotifyClient::event("stones removed",
206 // i18n("%1 stones removed.").arg(stone->marked())); 203 // i18n("%1 stones removed.").arg(stone->marked()));
207} 204}
208 205
209void ZSameWidget::setScore(int ) { 206void ZSameWidget::setScore(int ) {
210// status->changeItem(i18n("Score: %1").arg(score, 6),4); 207// status->changeItem(i18n("Score: %1").arg(score, 6),4);
211// undo->setEnabled(stone->undoPossible()); 208// undo->setEnabled(stone->undoPossible());
212// restart->setEnabled(!stone->isOriginalBoard()); 209// restart->setEnabled(!stone->isOriginalBoard());
213} 210}
214 211
215void ZSameWidget::gameover() { 212void ZSameWidget::gameover() {
216// kdDebug() << "GameOver" << endl; 213// kdDebug() << "GameOver" << endl;
217 if (stone->hasBonus()) { 214 if (stone->hasBonus()) {
218 QMessageBox::information(this,i18n("Game won"), 215 QMessageBox::information(this,i18n("Game won"),
219 i18n("<qt>You even removed the last stone, great job! " 216 i18n("<qt>You even removed the last stone, great job! "
220 "This gave you a score of %1 in total.</qt>").arg(stone->score())); 217 "This gave you a score of %1 in total.</qt>").arg(stone->score()));
221 stone->clearBonus(); 218 stone->clearBonus();
222 } else { 219 } else {
223 QMessageBox::information(this,i18n("Game over"), 220 QMessageBox::information(this,i18n("Game over"),
224 i18n("<qt>There are no more removeable stones. " 221 i18n("<qt>There are no more removeable stones. "
225 "You got a score of %1 in total.</qt>").arg(stone->score())); 222 "You got a score of %1 in total.</qt>").arg(stone->score()));
226 } 223 }
227 stone->unmark(); 224 stone->unmark();
228} 225}
229 226
230void ZSameWidget::desktop_widget(int *f)const{ 227void ZSameWidget::desktop_widget(int *f)const{
231 228
232 QWidget* wid = QApplication::desktop(); 229 QWidget* wid = QApplication::desktop();
233 /* width > height landscape mode */ 230 /* width > height landscape mode */
234 if ( wid->width() > wid->height() ) { 231 if ( wid->width() > wid->height() ) {
235 f[0]=15; 232 f[0]=15;
236 f[1]=9; 233 f[1]=9;
237 } 234 }
238 /* normal */ 235 /* normal */
239 else{ 236 else{
240 f[0]=12; 237 f[0]=12;
241 f[1]=13; 238 f[1]=13;
242 } 239 }
243} 240}
244 241
245 242