summaryrefslogtreecommitdiff
path: root/noncore/games/mindbreaker
Unidiff
Diffstat (limited to 'noncore/games/mindbreaker') (more/less context) (show whitespace changes)
-rw-r--r--noncore/games/mindbreaker/main.cpp10
-rw-r--r--noncore/games/mindbreaker/mindbreaker.cpp371
-rw-r--r--noncore/games/mindbreaker/mindbreaker.h27
-rw-r--r--noncore/games/mindbreaker/mindbreaker.pro5
-rw-r--r--noncore/games/mindbreaker/opie-mindbreaker.control2
5 files changed, 285 insertions, 130 deletions
diff --git a/noncore/games/mindbreaker/main.cpp b/noncore/games/mindbreaker/main.cpp
index 8ba0fde..2ca16e3 100644
--- a/noncore/games/mindbreaker/main.cpp
+++ b/noncore/games/mindbreaker/main.cpp
@@ -1,5 +1,5 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
@@ -22,3 +22,3 @@
22 22
23#include <qpe/qpeapplication.h> 23#include <qtopia/qpeapplication.h>
24 24
@@ -28,4 +28,4 @@ int main( int argc, char **argv )
28 28
29 MindBreaker w(0, "new window"); 29 MindBreaker w;
30 w.setCaption("Mind Breaker"); 30 w.setCaption(MindBreaker::tr("Mind Breaker"));
31 QPEApplication::setInputMethodHint( &w, QPEApplication::AlwaysOff ); 31 QPEApplication::setInputMethodHint( &w, QPEApplication::AlwaysOff );
diff --git a/noncore/games/mindbreaker/mindbreaker.cpp b/noncore/games/mindbreaker/mindbreaker.cpp
index 7802e38..e1f43d0 100644
--- a/noncore/games/mindbreaker/mindbreaker.cpp
+++ b/noncore/games/mindbreaker/mindbreaker.cpp
@@ -1,5 +1,5 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
@@ -22,4 +22,6 @@
22 22
23#include <qpe/resource.h> 23#include <qtopia/resource.h>
24#include <qpe/config.h> 24#include <qtopia/config.h>
25#include <qtopia/qpeapplication.h>
26#include <qtoolbar.h>
25 27
@@ -27,3 +29,2 @@
27#include <qpixmap.h> 29#include <qpixmap.h>
28#include <qpe/qpetoolbar.h>
29#include <qtoolbutton.h> 30#include <qtoolbutton.h>
@@ -32,3 +33,4 @@
32#include <qlabel.h> 33#include <qlabel.h>
33#include <qstyle.h> 34#include <qlayout.h>
35#include <qtimer.h>
34 36
@@ -40,2 +42,60 @@ static int pegRTTI = 3393393;
40 42
43static int adjusted_panel_height;
44static int adjusted_panel_width;
45
46static int adjusted_bin_margin;
47static int adjusted_peg_size;
48static int adjusted_answerpeg_size;
49
50static int adjusted_title_height;
51static int adjusted_title_width;
52
53static int adjusted_first_peg_x_diff;
54static int adjusted_first_peg_y_diff;
55static int adjusted_peg_spacing;
56
57static int adjusted_answerpegx;
58static int adjusted_answerpegy;
59static int adjusted_answerpeg_xdiff;
60static int adjusted_answerpeg_ydiff;
61
62static int adjusted_board_height;
63static int adjusted_board_width;
64
65static void setupBoardSize(int w, int h)
66{
67 adjusted_panel_width = w * 3/4;
68 adjusted_title_width = w * 3/4;
69
70 adjusted_title_height = h/10;
71 adjusted_panel_height = (h-adjusted_title_height)/9;
72
73 adjusted_bin_margin = w * 10/240;
74 adjusted_peg_size = adjusted_panel_height*3/4;
75 adjusted_answerpeg_size = QMIN(adjusted_panel_width*15/180,adjusted_panel_height*15/25);
76
77 // looks a bit dodgy on larger sizes
78 if ( adjusted_peg_size > 40 )
79 adjusted_peg_size = 40;
80
81 adjusted_first_peg_x_diff = w * 31/240-adjusted_peg_size/2;
82 adjusted_first_peg_y_diff = (adjusted_panel_height - adjusted_peg_size)/2;
83 adjusted_peg_spacing = w * 30/240;
84
85 // looks a bit dodgy on larger sizes (still does though, but not as much...)
86 if ( adjusted_answerpeg_size > 22 )
87 adjusted_answerpeg_size = 22;
88
89 adjusted_answerpegx = adjusted_panel_width * 159/180 - adjusted_answerpeg_size/2;
90 adjusted_answerpegy = adjusted_panel_height/3 - adjusted_answerpeg_size/2;
91 adjusted_answerpeg_xdiff = adjusted_panel_width * 10/180;
92 adjusted_answerpeg_ydiff = adjusted_panel_height * 9/25;
93
94 adjusted_board_height = adjusted_title_height + (adjusted_panel_height * 9);
95 adjusted_board_width = adjusted_panel_width + (adjusted_bin_margin * 2) + adjusted_peg_size;
96
97// qDebug("Adjusted width %d height %d", adjusted_board_width, adjusted_board_height);
98}
99
100
41/* helper class, */ 101/* helper class, */
@@ -79,3 +139,2 @@ private:
79}; 139};
80
81int Peg::eggLevel = 0; 140int Peg::eggLevel = 0;
@@ -86,3 +145,2 @@ void Peg::buildImages()
86{ 145{
87
88 QImage pegs = Resource::loadImage("mindbreaker/pegs"); 146 QImage pegs = Resource::loadImage("mindbreaker/pegs");
@@ -94,3 +152,4 @@ void Peg::buildImages()
94 for (i = 0; i < 6; i++) { 152 for (i = 0; i < 6; i++) {
95 normalPegs.insert(i, new QImage(pegs.copy(x, y, peg_size, peg_size))); 153 normalPegs.insert(i, new QImage(pegs.copy(x, y, peg_size, peg_size).
154 smoothScale(adjusted_peg_size, adjusted_peg_size) ));
96 x += peg_size; 155 x += peg_size;
@@ -99,3 +158,4 @@ void Peg::buildImages()
99 for (i = 0; i < 5; i++) { 158 for (i = 0; i < 5; i++) {
100 specialPegs.insert(i, new QImage(pegs.copy(x,y,peg_size, peg_size))); 159 specialPegs.insert(i, new QImage(pegs.copy(x,y,peg_size, peg_size).
160 smoothScale(adjusted_peg_size, adjusted_peg_size) ));
101 x += peg_size; 161 x += peg_size;
@@ -108,3 +168,5 @@ void Peg::buildImages()
108 normalPegs.insert(8, 168 normalPegs.insert(8,
109 new QImage(image.copy(x, y, panel_width, panel_height))); 169 new QImage( image.copy(x, y, panel_width, panel_height).
170 smoothScale( adjusted_panel_width, adjusted_panel_height)
171 ));
110 y += panel_height; 172 y += panel_height;
@@ -112,3 +174,5 @@ void Peg::buildImages()
112 normalPegs.insert(9, 174 normalPegs.insert(9,
113 new QImage(image.copy(x, y, title_width, title_height))); 175 new QImage(image.copy(x, y, title_width, title_height).
176 smoothScale( adjusted_title_width, adjusted_title_height)
177 ));
114 y += title_height; 178 y += title_height;
@@ -117,6 +181,8 @@ void Peg::buildImages()
117 normalPegs.insert(6, 181 normalPegs.insert(6,
118 new QImage(image.copy(x, y, answerpeg_size, answerpeg_size))); 182 new QImage(image.copy(x, y, answerpeg_size, answerpeg_size).
183 smoothScale( adjusted_answerpeg_size, adjusted_answerpeg_size) ));
119 x += answerpeg_size; 184 x += answerpeg_size;
120 normalPegs.insert(7, 185 normalPegs.insert(7,
121 new QImage(image.copy(x, y, answerpeg_size, answerpeg_size))); 186 new QImage(image.copy(x, y, answerpeg_size, answerpeg_size).
187 smoothScale( adjusted_answerpeg_size, adjusted_answerpeg_size) ));
122} 188}
@@ -159,5 +225,5 @@ void Peg::drawShape(QPainter &p )
159 if ((pegtype == 5) && eggLevel > 5) { 225 if ((pegtype == 5) && eggLevel > 5) {
160 p.drawImage(x(), y(), *normalPegs[aniStep]); 226 p.drawImage(int(x()), int(y()), *normalPegs[aniStep]);
161 } else 227 } else
162 p.drawImage(x(), y(), imageForType(pegtype)); 228 p.drawImage(int(x()), int(y()), imageForType(pegtype));
163} 229}
@@ -208,7 +274,17 @@ inline int Peg::type() const
208MindBreaker::MindBreaker( QWidget *parent, const char *name, int wFlags ) 274MindBreaker::MindBreaker( QWidget *parent, const char *name, int wFlags )
209: QMainWindow(parent, name, wFlags), 275 : QMainWindow(parent, name, wFlags)
210 canvas(board_height, board_width)
211{ 276{
212 MindBreakerBoard *m = new MindBreakerBoard(canvas, this); 277 setCaption( tr("Mind Breaker"));
213 setCentralWidget(m); 278 QPEApplication::setInputMethodHint( this, QPEApplication::AlwaysOff );
279 setMinimumSize(160,210);
280
281 QWidget *w = new QWidget( this );
282 w->setBackgroundColor( black );
283 QHBoxLayout *hb = new QHBoxLayout( w );
284 hb->addStretch();
285 board = new MindBreakerBoard(w);
286 hb->addWidget( board, 100 );
287 hb->addStretch();
288
289 setCentralWidget(w);
214 290
@@ -219,5 +295,5 @@ MindBreaker::MindBreaker( QWidget *parent, const char *name, int wFlags )
219 295
220 QPixmap newicon = Resource::loadPixmap("new"); 296 QIconSet newicon = Resource::loadIconSet("new");
221 new QToolButton(newicon, tr("New Game"), 0, 297 new QToolButton(newicon, tr("New Game"), 0,
222 m, SLOT(clear()), tb, "NewGame"); 298 board, SLOT(clear()), tb, "NewGame");
223 299
@@ -229,8 +305,10 @@ MindBreaker::MindBreaker( QWidget *parent, const char *name, int wFlags )
229 305
230 connect(m, SIGNAL(scoreChanged(int, int)), this, SLOT(setScore(int, int))); 306 connect(board, SIGNAL(scoreChanged(int,int)), this, SLOT(setScore(int,int)));
231 connect(score, SIGNAL(clicked()), m, SLOT(resetScore())); 307 connect(score, SIGNAL(clicked()), board, SLOT(resetScore()));
232 308
233 int a, b; 309 int a, b;
234 m->getScore(&a, &b); 310 board->getScore(&a, &b);
235 setScore(a,b); 311 setScore(a,b);
312
313 layout()->setResizeMode(QLayout::FreeResize);
236} 314}
@@ -251,8 +329,20 @@ void MindBreaker::setScore(int turns, int games)
251 329
330void MindBreaker::resizeEvent( QResizeEvent *e )
331{
332 board->fixSize();
333 QMainWindow::resizeEvent( e );
334}
335
252 336
253MindBreakerBoard::MindBreakerBoard( QCanvas &canv, QWidget *parent, 337MindBreakerBoard::MindBreakerBoard( QWidget *parent,
254 const char *name, int wFlags ) 338 const char *name, int wFlags )
255 : QCanvasView(&canv, parent, name, wFlags) 339 : QCanvasView(0, parent, name, wFlags),
340 moving(0), game_over(FALSE), total_turns(0), total_games(0)
256{ 341{
257 int i, x, y; 342 setFrameStyle( NoFrame );
343 setupBoardSize(qApp->desktop()->width(),qApp->desktop()->height());
344 cnv.resize(100,100);
345 setCanvas(&cnv);
346 setBackgroundColor( black );
347
258 struct timeval tv; 348 struct timeval tv;
@@ -261,3 +351,2 @@ MindBreakerBoard::MindBreakerBoard( QCanvas &canv, QWidget *parent,
261 gettimeofday(&tv, 0); 351 gettimeofday(&tv, 0);
262
263 srand(tv.tv_usec); 352 srand(tv.tv_usec);
@@ -265,25 +354,14 @@ MindBreakerBoard::MindBreakerBoard( QCanvas &canv, QWidget *parent,
265 canvas()->setAdvancePeriod(500); 354 canvas()->setAdvancePeriod(500);
355 current_highlight = 0;
266 356
267 QImage image = Resource::loadImage("mindbreaker/mindbreaker"); 357 widthTimer = new QTimer( this );
268 358 connect(widthTimer, SIGNAL(timeout()), this, SLOT(doFixSize()) );
269 /* copy from master image to functional images */
270 x = 0;
271 y = 0;
272 panelImage = image.copy(x,y, panel_width, panel_height);
273 y += panel_height;
274 y += panel_height;
275
276 titleImage = image.copy(x, y, title_width, title_height);
277
278 Peg::buildImages(); // must be done BEFORE any pegs are made
279
280 current_highlight = new Peg(canvas(), 8);
281 current_highlight->setPlaced(TRUE);
282 current_highlight->setX(0);
283 current_highlight->setY(board_height - ((current_go + 1) * panel_height));
284 current_highlight->setZ(0);
285 current_highlight->show();
286 359
360 setMaximumWidth( QMIN(qApp->desktop()->height(),qApp->desktop()->width()) );
361 //doFixSize(); // build images... needs to be done before reading config.
362 //readConfig(); // first read... to ensure initial labels and side look right.
363}
287 364
288 /* set up the game */ 365void MindBreakerBoard::readConfig()
366{
289 Config c("MindBreaker", Config::User); 367 Config c("MindBreaker", Config::User);
@@ -291,2 +369,3 @@ MindBreakerBoard::MindBreakerBoard( QCanvas &canv, QWidget *parent,
291 game_over = FALSE; 369 game_over = FALSE;
370 int i;
292 if (c.readNumEntry("Answer0") < 0) { 371 if (c.readNumEntry("Answer0") < 0) {
@@ -334,6 +413,2 @@ MindBreakerBoard::MindBreakerBoard( QCanvas &canv, QWidget *parent,
334 } 413 }
335
336 /* draw initial screen */
337 drawBackground();
338 canvas()->update();
339} 414}
@@ -342,3 +417,3 @@ MindBreakerBoard::~MindBreakerBoard()
342{ 417{
343 int i, j; 418 int i;
344 if (game_over) { 419 if (game_over) {
@@ -351,3 +426,7 @@ MindBreakerBoard::~MindBreakerBoard()
351 } 426 }
427 writeConfig();
428}
352 429
430void MindBreakerBoard::writeConfig()
431{
353 Config c("MindBreaker", Config::User); 432 Config c("MindBreaker", Config::User);
@@ -356,10 +435,11 @@ MindBreakerBoard::~MindBreakerBoard()
356 /* write the board */ 435 /* write the board */
436 int i,j;
357 for (i = 0; i < current_go; i++) { 437 for (i = 0; i < current_go; i++) {
358 for(j = 0; j < 4; j++) 438 for(j = 0; j < 4; j++)
359 c.writeEntry(tr("Go%1p%2").arg(i).arg(j), past_guesses[4*i+j]); 439 c.writeEntry(QString("Go%1p%2").arg(i).arg(j), past_guesses[4*i+j]);
360 } 440 }
361 for(j = 0; j < 4; j++) 441 for(j = 0; j < 4; j++)
362 c.writeEntry(tr("CurrentGo%1").arg(j), current_guess[j]); 442 c.writeEntry(QString("CurrentGo%1").arg(j), current_guess[j]);
363 for(j = 0; j < 4; j++) 443 for(j = 0; j < 4; j++)
364 c.writeEntry(tr("Answer%1").arg(j), answer[j]); 444 c.writeEntry(QString("Answer%1").arg(j), answer[j]);
365 445
@@ -379,7 +459,71 @@ void MindBreakerBoard::getScore(int *a, int *b)
379 459
460void MindBreakerBoard::fixSize()
461{
462 hide();
463 setMaximumWidth( parentWidget()->height() );
464 widthTimer->start( 20, TRUE );
465}
466
467void MindBreakerBoard::doFixSize()
468{
469 QSize s = size();
470 int fw = frameWidth();
471 s.setWidth(s.width() - fw);
472 s.setHeight(s.height() - fw);
473
474 /* min size is 200 x 260 */
475/*
476 if (s.width() < adjusted_board_width)
477 s.setWidth(adjusted_board_width);
478
479 if (s.height() < adjusted_board_height)
480 s.setHeight(adjusted_board_height);
481*/
482
483 if ( current_highlight ) // non-first resize
484 writeConfig();
485
486 setupBoardSize(s.width() - fw, s.height() - fw);
487 canvas()->resize(s.width() - fw, s.height() - fw);
488 Peg::buildImages(); // must be done BEFORE any pegs are made
489
490 QImage image = Resource::loadImage("mindbreaker/mindbreaker");
491
492 /* copy from master image to functional images */
493 int x = 0;
494 int y = 0;
495 panelImage = image.copy(x, y, panel_width, panel_height).
496 smoothScale( adjusted_panel_width, adjusted_panel_height);
497
498 y += panel_height;
499 y += panel_height;
500
501 titleImage = image.copy(x, y, title_width, title_height).
502 smoothScale( adjusted_title_width, adjusted_title_height);
503 show();
504
505 delete current_highlight;
506 current_highlight = new Peg(canvas(), 8);
507 current_highlight->setPlaced(TRUE);
508 current_highlight->setX(0);
509 current_highlight->setY(adjusted_board_height - ((current_go + 1) * adjusted_panel_height));
510 current_highlight->setZ(0);
511 current_highlight->show();
512
513 /* set up the game */
514 //readConfig();
515
516 /* draw initial screen */
517 //drawBackground();
518 //canvas()->update();
519 clear();
520
521 readConfig();
522}
523
380void MindBreakerBoard::placeGuessPeg(int pos, int pegId) 524void MindBreakerBoard::placeGuessPeg(int pos, int pegId)
381{ 525{
382 int x = first_peg_x_diff + (pos * peg_spacing); 526 int x = adjusted_first_peg_x_diff + (pos * adjusted_peg_spacing);
383 int y = board_height - ((current_go + 1) * panel_height) 527 int y = adjusted_board_height - ((current_go + 1) * adjusted_panel_height)
384 + first_peg_y_diff; 528 + adjusted_first_peg_y_diff;
385 529
@@ -407,3 +551,3 @@ void MindBreakerBoard::drawBackground()
407 painter.setPen(pen); 551 painter.setPen(pen);
408 x_gap = canvas()->width() - (panel_width + (2 * bin_margin)); 552 x_gap = canvas()->width() - (adjusted_panel_width + (2 * adjusted_bin_margin));
409 //x_gap += peg_size >> 1; 553 //x_gap += peg_size >> 1;
@@ -412,4 +556,4 @@ void MindBreakerBoard::drawBackground()
412 556
413 y_gap = board_height / 6; 557 y_gap = adjusted_board_height / 6;
414 y_gap -= (2 * bin_margin); 558 y_gap -= (2 * adjusted_bin_margin);
415 //y_gap += peg_size >> 1; 559 //y_gap += peg_size >> 1;
@@ -417,4 +561,4 @@ void MindBreakerBoard::drawBackground()
417 y_gap = 1; 561 y_gap = 1;
418 x = panel_width + bin_margin - (peg_size >> 1); 562 x = adjusted_panel_width + adjusted_bin_margin - (adjusted_peg_size >> 1);
419 y = bin_margin - (peg_size >> 1) + 2; 563 y = adjusted_bin_margin - (adjusted_peg_size >> 1) + 2;
420 564
@@ -426,9 +570,9 @@ void MindBreakerBoard::drawBackground()
426 } 570 }
427 y += board_height / 6; 571 y += adjusted_board_height / 6;
428 } 572 }
429 /* now draw the surrounding boxes */ 573 /* now draw the surrounding boxes */
430 x_gap = canvas()->width() - panel_width; 574 x_gap = canvas()->width() - adjusted_panel_width;
431 if (x_gap < 1) x_gap = 1; 575 if (x_gap < 1) x_gap = 1;
432 y_gap = board_height / 6; 576 y_gap = adjusted_board_height / 6;
433 x = panel_width; 577 x = adjusted_panel_width;
434 y = 1; 578 y = 1;
@@ -444,3 +588,3 @@ void MindBreakerBoard::drawBackground()
444 painter.drawImage(x,y, titleImage); 588 painter.drawImage(x,y, titleImage);
445 y = title_height; 589 y = adjusted_title_height;
446 /* now nine gues panels */ 590 /* now nine gues panels */
@@ -448,3 +592,3 @@ void MindBreakerBoard::drawBackground()
448 painter.drawImage(x, y, panelImage); 592 painter.drawImage(x, y, panelImage);
449 y += panel_height; 593 y += adjusted_panel_height;
450 } 594 }
@@ -488,4 +632,4 @@ void MindBreakerBoard::checkGuess()
488 632
489 int x = answerpegx; 633 int x = adjusted_answerpegx;
490 int y = (board_height - ((current_go + 1) * panel_height)) + answerpegy; 634 int y = (adjusted_board_height - ((current_go + 1) * adjusted_panel_height)) + adjusted_answerpegy;
491 635
@@ -503,7 +647,7 @@ void MindBreakerBoard::checkGuess()
503 647
504 if (x == answerpegx) 648 if (x == adjusted_answerpegx)
505 x = answerpegx + answerpeg_diff; 649 x = adjusted_answerpegx + adjusted_answerpeg_xdiff;
506 else { 650 else {
507 x = answerpegx; 651 x = adjusted_answerpegx;
508 y += answerpeg_diff; 652 y += adjusted_answerpeg_ydiff;
509 } 653 }
@@ -519,7 +663,7 @@ void MindBreakerBoard::checkGuess()
519 663
520 if (x == answerpegx) 664 if (x == adjusted_answerpegx)
521 x = answerpegx + answerpeg_diff; 665 x = adjusted_answerpegx + adjusted_answerpeg_xdiff;
522 else { 666 else {
523 x = answerpegx; 667 x = adjusted_answerpegx;
524 y += answerpeg_diff; 668 y += adjusted_answerpeg_ydiff;
525 } 669 }
@@ -551,4 +695,4 @@ void MindBreakerBoard::checkGuess()
551 p = new Peg(canvas(), answer[i], -1); 695 p = new Peg(canvas(), answer[i], -1);
552 p->setX(first_peg_x_diff + (i * peg_spacing)); 696 p->setX(adjusted_first_peg_x_diff + (i * adjusted_peg_spacing));
553 p->setY(5); 697 p->setY(adjusted_first_peg_y_diff);
554 p->setZ(3); 698 p->setZ(3);
@@ -557,3 +701,3 @@ void MindBreakerBoard::checkGuess()
557 } else { 701 } else {
558 current_highlight->setY(board_height - ((current_go + 1) * panel_height)); 702 current_highlight->setY(adjusted_board_height - ((current_go + 1) * adjusted_panel_height));
559 } 703 }
@@ -588,3 +732,3 @@ void MindBreakerBoard::clear()
588 732
589 current_highlight->setY(board_height - ((current_go + 1) * panel_height)); 733 current_highlight->setY(adjusted_board_height - ((current_go + 1) * adjusted_panel_height));
590 checkScores(); 734 checkScores();
@@ -614,2 +758,9 @@ void MindBreakerBoard::contentsMousePressEvent(QMouseEvent *e)
614{ 758{
759 if (game_over) {
760 null_press = TRUE;
761 null_point = e->pos();
762 moving = 0;
763 return;
764 }
765
615 copy_press = FALSE; 766 copy_press = FALSE;
@@ -618,7 +769,7 @@ void MindBreakerBoard::contentsMousePressEvent(QMouseEvent *e)
618 got clicked */ 769 got clicked */
619 if (e->x() > panel_width) { 770 if (e->x() > adjusted_panel_width) {
620 /* its a bin, but which bin */ 771 /* its a bin, but which bin */
621 if(e->y() > board_height) 772 int bin = (e->y() + 2) / (adjusted_board_height / 6);
773 if (bin > 5)
622 return; // missed everything 774 return; // missed everything
623 int bin = (e->y() + 2) / (board_height / 6);
624 775
@@ -627,4 +778,4 @@ void MindBreakerBoard::contentsMousePressEvent(QMouseEvent *e)
627 moving = new Peg(canvas(), bin, current_go); 778 moving = new Peg(canvas(), bin, current_go);
628 moving->setX(e->x() - (peg_size >> 1)); 779 moving->setX(e->x() - (adjusted_peg_size >> 1));
629 moving->setY(e->y() - (peg_size >> 1)); 780 moving->setY(e->y() - (adjusted_peg_size >> 1));
630 moving->setZ(5); 781 moving->setZ(5);
@@ -656,4 +807,4 @@ void MindBreakerBoard::contentsMousePressEvent(QMouseEvent *e)
656 item->type(), current_go); 807 item->type(), current_go);
657 moving->setX(e->x() - (peg_size >> 1)); 808 moving->setX(e->x() - (adjusted_peg_size >> 1));
658 moving->setY(e->y() - (peg_size >> 1)); 809 moving->setY(e->y() - (adjusted_peg_size >> 1));
659 moving->setZ(5); 810 moving->setZ(5);
@@ -711,3 +862,3 @@ void MindBreakerBoard::contentsMouseReleaseEvent(QMouseEvent* e)
711 /* first work out if in y */ 862 /* first work out if in y */
712 if (e->y() > (board_height - (current_go * panel_height))) { 863 if (e->y() > (adjusted_board_height - (current_go * adjusted_panel_height))) {
713 delete moving; 864 delete moving;
@@ -717,3 +868,3 @@ void MindBreakerBoard::contentsMouseReleaseEvent(QMouseEvent* e)
717 } 868 }
718 if (e->y() < (board_height - ((current_go + 1) * panel_height))) { 869 if (e->y() < (adjusted_board_height - ((current_go + 1) * adjusted_panel_height))) {
719 delete moving; 870 delete moving;
@@ -724,4 +875,4 @@ void MindBreakerBoard::contentsMouseReleaseEvent(QMouseEvent* e)
724 /* ok, a valid go, but which peg */ 875 /* ok, a valid go, but which peg */
725 int x_bar = first_peg_x_diff - (peg_size >> 1); 876 int x_bar = adjusted_first_peg_x_diff - (adjusted_peg_size >> 1);
726 x_bar += peg_spacing; 877 x_bar += adjusted_peg_spacing;
727 int pos = 0; 878 int pos = 0;
@@ -729,9 +880,9 @@ void MindBreakerBoard::contentsMouseReleaseEvent(QMouseEvent* e)
729 pos = 1; 880 pos = 1;
730 x_bar += peg_spacing; 881 x_bar += adjusted_peg_spacing;
731 if (e->x() > x_bar) 882 if (e->x() > x_bar)
732 pos = 2; 883 pos = 2;
733 x_bar += peg_spacing; 884 x_bar += adjusted_peg_spacing;
734 if (e->x() > x_bar) 885 if (e->x() > x_bar)
735 pos = 3; 886 pos = 3;
736 x_bar += peg_spacing; 887 x_bar += adjusted_peg_spacing;
737 888
@@ -745,5 +896,5 @@ void MindBreakerBoard::contentsMouseReleaseEvent(QMouseEvent* e)
745 896
746 int x = first_peg_x_diff + (pos * peg_spacing); 897 int x = adjusted_first_peg_x_diff + (pos * adjusted_peg_spacing);
747 int y = board_height - ((current_go + 1) * panel_height) 898 int y = adjusted_board_height - ((current_go + 1) * adjusted_panel_height)
748 + first_peg_y_diff; 899 + adjusted_first_peg_y_diff;
749 moving->setPegPos(pos); 900 moving->setPegPos(pos);
@@ -780,16 +931,4 @@ void MindBreakerBoard::resizeEvent(QResizeEvent *e)
780{ 931{
781 QSize s = e->size(); 932 QCanvasView::resizeEvent(e);
782 int fw = style().defaultFrameWidth(); 933 fixSize();
783 s.setWidth(s.width() - fw);
784 s.setHeight(s.height() - fw);
785
786 /* min size is 200 x 260 */
787 if (s.width() < board_width)
788 s.setWidth(board_width);
789
790 if (s.height() < board_height)
791 s.setHeight(board_height);
792
793 canvas()->resize(s.width() - fw, s.height() - fw);
794 drawBackground();
795} 934}
diff --git a/noncore/games/mindbreaker/mindbreaker.h b/noncore/games/mindbreaker/mindbreaker.h
index fca649a..3132e80 100644
--- a/noncore/games/mindbreaker/mindbreaker.h
+++ b/noncore/games/mindbreaker/mindbreaker.h
@@ -1,5 +1,5 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
@@ -53,2 +53,3 @@ class Peg;
53class QToolButton; 53class QToolButton;
54class QTimer;
54 55
@@ -58,3 +59,3 @@ class MindBreakerBoard : public QCanvasView // QWidget
58public: 59public:
59 MindBreakerBoard(QCanvas &c, QWidget *parent=0, const char *name=0, int wFlags=0 ); 60 MindBreakerBoard(QWidget *parent=0, const char *name=0, int wFlags=0 );
60 ~MindBreakerBoard(); 61 ~MindBreakerBoard();
@@ -62,2 +63,6 @@ public:
62 void getScore(int *, int *); 63 void getScore(int *, int *);
64
65 void resizeEvent(QResizeEvent*);
66 void fixSize();
67
63signals: 68signals:
@@ -69,2 +74,5 @@ public slots:
69 74
75private slots:
76 void doFixSize();
77
70protected: 78protected:
@@ -73,5 +81,9 @@ protected:
73 void contentsMouseReleaseEvent(QMouseEvent *); 81 void contentsMouseReleaseEvent(QMouseEvent *);
74 void resizeEvent(QResizeEvent *);
75 82
76private: 83private:
84 QCanvas cnv;
85
86 void readConfig();
87 void writeConfig();
88
77 void drawBackground(); 89 void drawBackground();
@@ -102,2 +114,4 @@ private:
102 int total_games; 114 int total_games;
115
116 QTimer *widthTimer;
103}; 117};
@@ -109,3 +123,3 @@ public:
109 MindBreaker(QWidget *parent=0, const char *name=0, int wFlags=0 ); 123 MindBreaker(QWidget *parent=0, const char *name=0, int wFlags=0 );
110 124 static QString appName() { return QString::fromLatin1("mindbreaker"); }
111public slots: 125public slots:
@@ -113,2 +127,5 @@ public slots:
113 127
128protected:
129 void resizeEvent( QResizeEvent * );
130
114private: 131private:
diff --git a/noncore/games/mindbreaker/mindbreaker.pro b/noncore/games/mindbreaker/mindbreaker.pro
index 4ca3b84..0a37fa7 100644
--- a/noncore/games/mindbreaker/mindbreaker.pro
+++ b/noncore/games/mindbreaker/mindbreaker.pro
@@ -1,4 +1,2 @@
1TEMPLATE = app 1CONFIG += qt warn_on release quick-app
2CONFIG += qt warn_on release
3DESTDIR = $(OPIEDIR)/bin
4 HEADERS = mindbreaker.h 2 HEADERS = mindbreaker.h
@@ -11,2 +9,3 @@ LIBS += -lqpe
11 9
10
12include ( $(OPIEDIR)/include.pro ) 11include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/games/mindbreaker/opie-mindbreaker.control b/noncore/games/mindbreaker/opie-mindbreaker.control
index 7b5ead6..5b342da 100644
--- a/noncore/games/mindbreaker/opie-mindbreaker.control
+++ b/noncore/games/mindbreaker/opie-mindbreaker.control
@@ -1,3 +1,3 @@
1Package: opie-mindbreaker 1Package: opie-mindbreaker
2Files: bin/mindbreaker apps/Games/mindbreaker.desktop pics/mindbreaker 2Files: plugins/application/libmindbreaker.so* bin/mindbreaker apps/Games/mindbreaker.desktop pics/mindbreaker
3Priority: optional 3Priority: optional