author | zecke <zecke> | 2004-02-06 12:14:56 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-02-06 12:14:56 (UTC) |
commit | 0c74629e8f5c12a9b5a282b817f884fa10dee491 (patch) (side-by-side diff) | |
tree | 3294663b92023f8d24d68a01022e011a3c94002d | |
parent | 46ce5afcfbe7be19f4d5ac0fed6886a0759f1a25 (diff) | |
download | opie-0c74629e8f5c12a9b5a282b817f884fa10dee491.zip opie-0c74629e8f5c12a9b5a282b817f884fa10dee491.tar.gz opie-0c74629e8f5c12a9b5a282b817f884fa10dee491.tar.bz2 |
Merge from the 1.0.x release
63 files changed, 489 insertions, 405 deletions
diff --git a/noncore/games/backgammon/backgammon.control b/noncore/games/backgammon/backgammon.control index 6468181..d78b547 100644 --- a/noncore/games/backgammon/backgammon.control +++ b/noncore/games/backgammon/backgammon.control @@ -1,8 +1,8 @@ Package: backgammon -Files: bin/backgammon apps/Games/backgammon.desktop pics/backgammon help/en/html/backgammon.html +Files: plugins/application/libbackgammon.so* bin/backgammon apps/Games/backgammon.desktop pics/backgammon help/en/html/backgammon.html Priority: optional Section: opie/games Maintainer: Ralf Waspe <rwaspe@web.de> Architecture: arm Depends: task-opie-minimal Description: Backgammon Game diff --git a/noncore/games/backgammon/backgammon.h b/noncore/games/backgammon/backgammon.h index e3276f1..fb50500 100644 --- a/noncore/games/backgammon/backgammon.h +++ b/noncore/games/backgammon/backgammon.h @@ -82,12 +82,13 @@ private: //display settings Display display; //is the game finished ? bool gameFinished; public: + static QString appName() { return QString::fromLatin1("backgammon"); } BackGammon( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~BackGammon(); private slots: void newgame(); void playerselect(); void loadgame(); diff --git a/noncore/games/backgammon/backgammon.pro b/noncore/games/backgammon/backgammon.pro index 4be9491..063d617 100644 --- a/noncore/games/backgammon/backgammon.pro +++ b/noncore/games/backgammon/backgammon.pro @@ -1,8 +1,7 @@ -TEMPLATE = app -CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app HEADERS = backgammon.h \ backgammonview.h \ canvasimageitem.h \ themedialog.h \ moveengine.h \ @@ -25,10 +24,9 @@ SOURCES = main.cpp \ definition.cpp TARGET = backgammon INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lstdc++ -DESTDIR = $(OPIEDIR)/bin include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/games/backgammon/main.cpp b/noncore/games/backgammon/main.cpp index 86b452d..58ced10 100644 --- a/noncore/games/backgammon/main.cpp +++ b/noncore/games/backgammon/main.cpp @@ -1,14 +1,8 @@ #include <qpe/qpeapplication.h> #include "backgammon.h" +#include <opie/oapplicationfactory.h> -int main( int argc, char** argv ) -{ - QPEApplication app( argc, argv ); +OPIE_EXPORT_APP( OApplicationFactory<BackGammon> ) - BackGammon* view= new BackGammon(); - app.showMainWidget(view); - - return app.exec(); -} diff --git a/noncore/games/bounce/bounce.pro b/noncore/games/bounce/bounce.pro index 338daf6..75e4a6b 100644 --- a/noncore/games/bounce/bounce.pro +++ b/noncore/games/bounce/bounce.pro @@ -1,12 +1,10 @@ -TEMPLATE = app #CONFIG = qt warn_on debug -CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app HEADERS = game.h kbounce.h SOURCES = game.cpp kbounce.cpp main.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -DESTDIR = $(OPIEDIR)/bin TARGET = bounce include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/games/bounce/kbounce.cpp b/noncore/games/bounce/kbounce.cpp index 50f4ef6..211f0ff 100644 --- a/noncore/games/bounce/kbounce.cpp +++ b/noncore/games/bounce/kbounce.cpp @@ -24,13 +24,14 @@ #include <qpe/qpeapplication.h> #include "kbounce.h" #include "game.h" #include <qlabel.h> -KJezzball::KJezzball() : QMainWindow(0), m_gameWidget( 0 ) +KJezzball::KJezzball(QWidget *p, const char* n, WFlags f) + : QMainWindow(p,n,f), m_gameWidget( 0 ) { setCaption(tr("Bounce")); // setup variables m_game.level = 1; m_game.score = 0; m_state = Idle; diff --git a/noncore/games/bounce/kbounce.h b/noncore/games/bounce/kbounce.h index de41710..c59109f 100644 --- a/noncore/games/bounce/kbounce.h +++ b/noncore/games/bounce/kbounce.h @@ -29,13 +29,14 @@ class QGridLayout; class KJezzball : public QMainWindow { Q_OBJECT public: - KJezzball(); + static QString appName() { return QString::fromLatin1("bounce"); } + KJezzball(QWidget *, const char*, WFlags ); public slots: void newGame(); void pauseGame(); void closeGame(); void about(); diff --git a/noncore/games/bounce/main.cpp b/noncore/games/bounce/main.cpp index a6b7c1a..9ea86a6 100644 --- a/noncore/games/bounce/main.cpp +++ b/noncore/games/bounce/main.cpp @@ -15,15 +15,10 @@ * License along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <qpe/qpeapplication.h> #include "kbounce.h" +#include <opie/oapplicationfactory.h> -int main(int argc, char **argv) -{ - QPEApplication a( argc, argv ); - KJezzball *top = new KJezzball; - a.showMainWidget(top); +OPIE_EXPORT_APP( OApplicationFactory<KJezzball> ) - return a.exec(); -} diff --git a/noncore/games/bounce/opie-bounce.control b/noncore/games/bounce/opie-bounce.control index 8b3fdb9..bfe85d3 100644 --- a/noncore/games/bounce/opie-bounce.control +++ b/noncore/games/bounce/opie-bounce.control @@ -1,8 +1,8 @@ Package: opie-bounce -Files: bin/bounce apps/Games/bounce.desktop pics/bounce/*.png +Files: plugins/application/libbounce.so* bin/bounce apps/Games/bounce.desktop pics/bounce/*.png Version: 0.6-$SUB_VERSION Depends: task-opie-minimal Priority: optional Section: opie/games Maintainer: Martin Imobersteg <imm@gmx.ch> Architecture: arm diff --git a/noncore/games/buzzword/buzzword.cpp b/noncore/games/buzzword/buzzword.cpp index 97a17a1..f746065 100644 --- a/noncore/games/buzzword/buzzword.cpp +++ b/noncore/games/buzzword/buzzword.cpp @@ -65,13 +65,13 @@ void BuzzItem::flip() { setLineWidth( 1 ); label->setBackgroundColor(label->colorGroup().highlight()); emit clicked(_row, _column); } -BuzzWord::BuzzWord() : QMainWindow(0) +BuzzWord::BuzzWord(QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) { setCaption(tr("buZzword")); menu = menuBar(); game = new QPopupMenu; game->insertItem(tr("&New game"), this, SLOT(newGame()), Key_N ); diff --git a/noncore/games/buzzword/buzzword.h b/noncore/games/buzzword/buzzword.h index 37dd5b4..c0e43d0 100644 --- a/noncore/games/buzzword/buzzword.h +++ b/noncore/games/buzzword/buzzword.h @@ -61,13 +61,14 @@ signals: class BuzzWord : public QMainWindow { Q_OBJECT public: - BuzzWord(); + BuzzWord( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + static QString appName() { return QString::fromLatin1("buzzword"); } private: void drawGrid(); void bingo(); QString getWord(); diff --git a/noncore/games/buzzword/buzzword.pro b/noncore/games/buzzword/buzzword.pro index 0faede8..247b593 100644 --- a/noncore/games/buzzword/buzzword.pro +++ b/noncore/games/buzzword/buzzword.pro @@ -1,11 +1,10 @@ -TEMPLATE = app -CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app HEADERS = buzzword.h SOURCES = buzzword.cpp main.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -DESTDIR = $(OPIEDIR)/bin LIBS += -lqpe -TARGET = buzzword + +TARGET = buzzword include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/games/buzzword/main.cpp b/noncore/games/buzzword/main.cpp index 2d9ff81..67f2c26 100644 --- a/noncore/games/buzzword/main.cpp +++ b/noncore/games/buzzword/main.cpp @@ -14,22 +14,11 @@ * 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 <qpe/qpeapplication.h> - -#include <stdlib.h> -#include <time.h> +#include <opie/oapplicationfactory.h> #include "buzzword.h" -int main(int argc, char **argv) -{ - srand(time(0)); - - QPEApplication a( argc, argv ); - BuzzWord *top = new BuzzWord; - a.showMainWidget(top); - - return a.exec(); -} +OPIE_EXPORT_APP( OApplicationFactory<BuzzWord> ) diff --git a/noncore/games/buzzword/opie-buzzword.control b/noncore/games/buzzword/opie-buzzword.control index 08b442b..b3e2496 100644 --- a/noncore/games/buzzword/opie-buzzword.control +++ b/noncore/games/buzzword/opie-buzzword.control @@ -1,8 +1,8 @@ Package: opie-buzzword -Files: bin/buzzword apps/Games/buzzword.desktop pics/buzzword/buzzword.png share/buzzword/buzzwords +Files: plugins/application/libbuzzword.so* bin/buzzword apps/Games/buzzword.desktop pics/buzzword/buzzword.png share/buzzword/buzzwords Version: 1.1-$SUB_VERSION Depends: task-opie-minimal Priority: optional Section: opie/games Maintainer: Martin Imobersteg <imm@gmx.ch> Architecture: arm diff --git a/noncore/games/fifteen/opie-fifteen.control b/noncore/games/fifteen/opie-fifteen.control index 8fa355f..a6e8314 100644 --- a/noncore/games/fifteen/opie-fifteen.control +++ b/noncore/games/fifteen/opie-fifteen.control @@ -1,8 +1,8 @@ Package: opie-fifteen -Files: bin/fifteen apps/Games/fifteen.desktop pics/fifteen +Files: plugins/application/libfifteen.so* bin/fifteen apps/Games/fifteen.desktop pics/fifteen Priority: optional Section: opie/games Maintainer: Martin Imobersteg <imm@gmx.ch> Architecture: arm Arch: iPAQ Depends: task-opie-minimal diff --git a/noncore/games/go/go.pro b/noncore/games/go/go.pro index 2bc0787..f6c6a54 100644 --- a/noncore/games/go/go.pro +++ b/noncore/games/go/go.pro @@ -1,9 +1,7 @@ -DESTDIR = $(OPIEDIR)/bin -TEMPLATE = app -CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app HEADERS = amigo.h \ go.h \ goplayutils.h \ gowidget.h SOURCES = amigo.c \ goplayer.c \ @@ -13,7 +11,9 @@ SOURCES = amigo.c \ main.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe TARGET = go + + include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/games/go/gowidget.cpp b/noncore/games/go/gowidget.cpp index 6d06f3b..cf89267 100644 --- a/noncore/games/go/gowidget.cpp +++ b/noncore/games/go/gowidget.cpp @@ -48,14 +48,14 @@ static QBrush *goBrush; static QPixmap *newBlackStone; static QPixmap *blackStone; static QPixmap *whiteStone; static bool smallStones = FALSE; -GoMainWidget::GoMainWidget( QWidget *parent, const char* name) : - QMainWindow( parent, name ) +GoMainWidget::GoMainWidget( QWidget *parent, const char* name, WFlags fl) : + QMainWindow( parent, name, fl ) { setToolBarsMovable( FALSE ); GoWidget *go = new GoWidget(this); setCentralWidget(go); toolbar = new QToolBar(this); diff --git a/noncore/games/go/gowidget.h b/noncore/games/go/gowidget.h index 94de2cc..429dc33 100644 --- a/noncore/games/go/gowidget.h +++ b/noncore/games/go/gowidget.h @@ -28,13 +28,14 @@ class QToolBar; class GoMainWidget : public QMainWindow { Q_OBJECT public: - GoMainWidget( QWidget *parent=0, const char* name=0); + static QString appName() { return QString::fromLatin1("go"); } + GoMainWidget( QWidget *parent=0, const char* name=0, WFlags fl = 0); protected: void resizeEvent( QResizeEvent * ); private: QToolBar *toolbar; }; diff --git a/noncore/games/go/main.cpp b/noncore/games/go/main.cpp index c7e2669..f24e3c3 100644 --- a/noncore/games/go/main.cpp +++ b/noncore/games/go/main.cpp @@ -19,17 +19,10 @@ **********************************************************************/ #include "gowidget.h" #include <qpe/qpeapplication.h> -#include <stdio.h> +#include <opie/oapplicationfactory.h> + +OPIE_EXPORT_APP( OApplicationFactory<GoMainWidget> ) -int main( int argc, char ** argv) -{ - QPEApplication app( argc, argv ); - - GoMainWidget m; - m.setCaption( GoWidget::tr("Go") ); - app.showMainWidget( &m ); - return app.exec(); -} diff --git a/noncore/games/go/opie-go.control b/noncore/games/go/opie-go.control index b07e8be..95b319e 100644 --- a/noncore/games/go/opie-go.control +++ b/noncore/games/go/opie-go.control @@ -1,10 +1,10 @@ Package: opie-go -Files: bin/go apps/Games/go.desktop pics/go +Files: plugins/application/libgo.so* bin/go apps/Games/go.desktop pics/go Priority: optional Section: opie/games -Maintainer: Opie Project <opie@handhelds.org> +Maintainer: Warwick Allison <warwick@trolltech.com> Architecture: arm Depends: task-opie-minimal Description: The game of Go A game for the Opie environment. Version: $QPE_VERSION$EXTRAVERSION diff --git a/noncore/games/kcheckers/kcheckers.cpp b/noncore/games/kcheckers/kcheckers.cpp index c2eba0d..2eb37e5 100644 --- a/noncore/games/kcheckers/kcheckers.cpp +++ b/noncore/games/kcheckers/kcheckers.cpp @@ -39,15 +39,16 @@ QString KCheckers::enNumeration="1 2 3 4 5 6 7 8 9 10111213141516171819202122232 QString KCheckers::ruNumeration="B8D8F8H8A7C7E7G7B6D6F6H6A5C5E5G5B4D4F4H4A3C3E3G3B2D2F2H2A1C1E1G1"; const int KCheckers::t[]={6,7,8,9,11,12,13,14,17,18,19,20,22,23, 24,25,28,29,30,31,33,34,35,36,39,40,41,42,44,45,46,47}; -KCheckers::KCheckers():QMainWindow(0,0,WStyle_DialogBorder) +KCheckers::KCheckers(QWidget *p, const char* n, WFlags ) + :QMainWindow(p,n,WStyle_DialogBorder) { - setCaption("KCheckers"); + setCaption(tr("KCheckers") ); setIcon(QPixmap(biglogo_xpm)); setToolBarsMovable(false); // Make a menubar diff --git a/noncore/games/kcheckers/kcheckers.h b/noncore/games/kcheckers/kcheckers.h index ccf5bae..bd4afc7 100644 --- a/noncore/games/kcheckers/kcheckers.h +++ b/noncore/games/kcheckers/kcheckers.h @@ -26,13 +26,14 @@ class QToolButton; class KCheckers:public QMainWindow { Q_OBJECT public: - KCheckers(); + static QString appName() { return QString::fromLatin1("kcheckers"); } + KCheckers(QWidget *parent, const char* name, WFlags fl); protected: void closeEvent(QCloseEvent*); private slots: diff --git a/noncore/games/kcheckers/kcheckers.pro b/noncore/games/kcheckers/kcheckers.pro index a23e83a..0d417bf 100644 --- a/noncore/games/kcheckers/kcheckers.pro +++ b/noncore/games/kcheckers/kcheckers.pro @@ -1,8 +1,7 @@ -TEMPLATE = app -CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app HEADERS = checkers.h \ echeckers.h \ field.h \ kcheckers.h \ rcheckers.h SOURCES = checkers.cpp \ @@ -11,10 +10,10 @@ SOURCES = checkers.cpp \ kcheckers.cpp \ main.cpp \ rcheckers.cpp INTERFACES = INCLUDEPATH += $(OPIEDIR)/include LIBS += -lqpe -DESTDIR = $(OPIEDIR)/bin TARGET = kcheckers + include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/games/kcheckers/main.cpp b/noncore/games/kcheckers/main.cpp index b8dd620..6ac570a 100644 --- a/noncore/games/kcheckers/main.cpp +++ b/noncore/games/kcheckers/main.cpp @@ -1,18 +1,10 @@ #include <qpe/qpeapplication.h> #include <qfont.h> #include "kcheckers.h" +#include <opie/oapplicationfactory.h> +OPIE_EXPORT_APP( OApplicationFactory<KCheckers> ) -int main(int argc, char *argv[]) -{ - QPEApplication app(argc,argv); - - KCheckers kcheckers; - app.setMainWidget(&kcheckers); - kcheckers.showMaximized(); - - return app.exec(); -} diff --git a/noncore/games/kcheckers/opie-kcheckers.control b/noncore/games/kcheckers/opie-kcheckers.control index e228209..71f83af 100644 --- a/noncore/games/kcheckers/opie-kcheckers.control +++ b/noncore/games/kcheckers/opie-kcheckers.control @@ -1,8 +1,8 @@ Package: opie-kcheckers -Files: bin/kcheckers apps/Games/kcheckers.desktop pics/kcheckers +Files: plugins/application/libkcheckers.so* bin/kcheckers apps/Games/kcheckers.desktop pics/kcheckers Priority: optional Section: opie/games Maintainer: leseb <prudhomme@laposte.net> Architecture: arm Version: 0.3-$SUB_VERSION Depends: task-opie-minimal 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,10 +1,10 @@ /********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** @@ -17,19 +17,19 @@ ** not clear to you. ** **********************************************************************/ #include "mindbreaker.h" -#include <qpe/qpeapplication.h> +#include <qtopia/qpeapplication.h> int main( int argc, char **argv ) { QPEApplication a( argc, argv ); - MindBreaker w(0, "new window"); - w.setCaption("Mind Breaker"); + MindBreaker w; + w.setCaption(MindBreaker::tr("Mind Breaker")); QPEApplication::setInputMethodHint( &w, QPEApplication::AlwaysOff ); a.showMainWidget(&w); return a.exec(); } 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,10 +1,10 @@ /********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** @@ -17,41 +17,101 @@ ** not clear to you. ** **********************************************************************/ #include "mindbreaker.h" -#include <qpe/resource.h> -#include <qpe/config.h> +#include <qtopia/resource.h> +#include <qtopia/config.h> +#include <qtopia/qpeapplication.h> +#include <qtoolbar.h> #include <qpainter.h> #include <qpixmap.h> -#include <qpe/qpetoolbar.h> #include <qtoolbutton.h> #include <qpushbutton.h> #include <qmessagebox.h> #include <qlabel.h> -#include <qstyle.h> +#include <qlayout.h> +#include <qtimer.h> #include <stdlib.h> #include <sys/time.h> #include <unistd.h> static int pegRTTI = 3393393; +static int adjusted_panel_height; +static int adjusted_panel_width; + +static int adjusted_bin_margin; +static int adjusted_peg_size; +static int adjusted_answerpeg_size; + +static int adjusted_title_height; +static int adjusted_title_width; + +static int adjusted_first_peg_x_diff; +static int adjusted_first_peg_y_diff; +static int adjusted_peg_spacing; + +static int adjusted_answerpegx; +static int adjusted_answerpegy; +static int adjusted_answerpeg_xdiff; +static int adjusted_answerpeg_ydiff; + +static int adjusted_board_height; +static int adjusted_board_width; + +static void setupBoardSize(int w, int h) +{ + adjusted_panel_width = w * 3/4; + adjusted_title_width = w * 3/4; + + adjusted_title_height = h/10; + adjusted_panel_height = (h-adjusted_title_height)/9; + + adjusted_bin_margin = w * 10/240; + adjusted_peg_size = adjusted_panel_height*3/4; + adjusted_answerpeg_size = QMIN(adjusted_panel_width*15/180,adjusted_panel_height*15/25); + + // looks a bit dodgy on larger sizes + if ( adjusted_peg_size > 40 ) + adjusted_peg_size = 40; + + adjusted_first_peg_x_diff = w * 31/240-adjusted_peg_size/2; + adjusted_first_peg_y_diff = (adjusted_panel_height - adjusted_peg_size)/2; + adjusted_peg_spacing = w * 30/240; + + // looks a bit dodgy on larger sizes (still does though, but not as much...) + if ( adjusted_answerpeg_size > 22 ) + adjusted_answerpeg_size = 22; + + adjusted_answerpegx = adjusted_panel_width * 159/180 - adjusted_answerpeg_size/2; + adjusted_answerpegy = adjusted_panel_height/3 - adjusted_answerpeg_size/2; + adjusted_answerpeg_xdiff = adjusted_panel_width * 10/180; + adjusted_answerpeg_ydiff = adjusted_panel_height * 9/25; + + adjusted_board_height = adjusted_title_height + (adjusted_panel_height * 9); + adjusted_board_width = adjusted_panel_width + (adjusted_bin_margin * 2) + adjusted_peg_size; + +// qDebug("Adjusted width %d height %d", adjusted_board_width, adjusted_board_height); +} + + /* helper class, */ class Peg : public QCanvasRectangle { public: Peg(QCanvas *canvas, int type, int go = -1, int pos = -1); int rtti() const {return pegRTTI; } void advance(int phase); bool hit( const QPoint &) const; -/* a placed peg is one that has been set down on the board correctly and +/* a placed peg is one that has been set down on the board correctly and should not be moved, only copied */ bool placed() const; void setPlaced(bool); int pegGo() const; int pegPos() const; @@ -74,69 +134,75 @@ private: int pegtype; int peg_go; int peg_pos; int aniStep; }; - int Peg::eggLevel = 0; QVector<QImage> Peg::normalPegs; QVector<QImage> Peg::specialPegs; void Peg::buildImages() { - QImage pegs = Resource::loadImage("mindbreaker/pegs"); - int x = 0; + int x = 0; int y = 0; int i; eggLevel = 0; normalPegs.resize(10); for (i = 0; i < 6; i++) { - normalPegs.insert(i, new QImage(pegs.copy(x, y, peg_size, peg_size))); + normalPegs.insert(i, new QImage(pegs.copy(x, y, peg_size, peg_size). + smoothScale(adjusted_peg_size, adjusted_peg_size) )); x += peg_size; } specialPegs.resize(5); for (i = 0; i < 5; i++) { - specialPegs.insert(i, new QImage(pegs.copy(x,y,peg_size, peg_size))); + specialPegs.insert(i, new QImage(pegs.copy(x,y,peg_size, peg_size). + smoothScale(adjusted_peg_size, adjusted_peg_size) )); x += peg_size; } QImage image = Resource::loadImage("mindbreaker/mindbreaker"); /* copy from master image to functional images */ x = 0; y = panel_height; - normalPegs.insert(8, - new QImage(image.copy(x, y, panel_width, panel_height))); + normalPegs.insert(8, + new QImage( image.copy(x, y, panel_width, panel_height). + smoothScale( adjusted_panel_width, adjusted_panel_height) + )); y += panel_height; y += title_height; - normalPegs.insert(9, - new QImage(image.copy(x, y, title_width, title_height))); + normalPegs.insert(9, + new QImage(image.copy(x, y, title_width, title_height). + smoothScale( adjusted_title_width, adjusted_title_height) + )); y += title_height; x = 6 * peg_size; - normalPegs.insert(6, - new QImage(image.copy(x, y, answerpeg_size, answerpeg_size))); + normalPegs.insert(6, + new QImage(image.copy(x, y, answerpeg_size, answerpeg_size). + smoothScale( adjusted_answerpeg_size, adjusted_answerpeg_size) )); x += answerpeg_size; - normalPegs.insert(7, - new QImage(image.copy(x, y, answerpeg_size, answerpeg_size))); + normalPegs.insert(7, + new QImage(image.copy(x, y, answerpeg_size, answerpeg_size). + smoothScale( adjusted_answerpeg_size, adjusted_answerpeg_size) )); } -QImage Peg::imageForType(int t) +QImage Peg::imageForType(int t) { if (eggLevel > t ) { if( t < 5) { return *specialPegs[t]; } else { return *normalPegs[rand() % 6]; } } return *normalPegs[t]; } -Peg::Peg(QCanvas *canvas , int t, int g, int p) +Peg::Peg(QCanvas *canvas , int t, int g, int p) : QCanvasRectangle(canvas) { setSize(normalPegs[t]->width(), normalPegs[t]->height() ); pegtype = t; isplaced = FALSE; peg_pos = p; @@ -154,15 +220,15 @@ void Peg::advance(int phase) { } } void Peg::drawShape(QPainter &p ) { if ((pegtype == 5) && eggLevel > 5) { - p.drawImage(x(), y(), *normalPegs[aniStep]); - } else - p.drawImage(x(), y(), imageForType(pegtype)); + p.drawImage(int(x()), int(y()), *normalPegs[aniStep]); + } else + p.drawImage(int(x()), int(y()), imageForType(pegtype)); } bool Peg::hit( const QPoint &p ) const { int ix = p.x() - int(x()); int iy = p.y() - int(y()); @@ -184,114 +250,127 @@ inline int Peg::pegGo() const inline int Peg::pegPos() const { return peg_pos; } -inline void Peg::setPegPos(int p) +inline void Peg::setPegPos(int p) { peg_pos = p; } -inline void Peg::setPlaced(bool p) +inline void Peg::setPlaced(bool p) { isplaced = p; } -inline int Peg::type() const +inline int Peg::type() const { return pegtype; } -/* Load the main image, copy from it the pegs, the board, and the answer image +/* Load the main image, copy from it the pegs, the board, and the answer image * and use these to create the tray, answer and board */ MindBreaker::MindBreaker( QWidget *parent, const char *name, int wFlags ) -: QMainWindow(parent, name, wFlags), - canvas(board_height, board_width) + : QMainWindow(parent, name, wFlags) { - MindBreakerBoard *m = new MindBreakerBoard(canvas, this); - setCentralWidget(m); - + setCaption( tr("Mind Breaker")); + QPEApplication::setInputMethodHint( this, QPEApplication::AlwaysOff ); + setMinimumSize(160,210); + + QWidget *w = new QWidget( this ); + w->setBackgroundColor( black ); + QHBoxLayout *hb = new QHBoxLayout( w ); + hb->addStretch(); + board = new MindBreakerBoard(w); + hb->addWidget( board, 100 ); + hb->addStretch(); + + setCentralWidget(w); + setToolBarsMovable( FALSE ); QToolBar *tb = new QToolBar(this); tb->setHorizontalStretchable( TRUE ); - QPixmap newicon = Resource::loadPixmap("new"); - new QToolButton(newicon, tr("New Game"), 0, - m, SLOT(clear()), tb, "NewGame"); + QIconSet newicon = Resource::loadIconSet("new"); + new QToolButton(newicon, tr("New Game"), 0, + board, SLOT(clear()), tb, "NewGame"); score = new QToolButton(tb); score->setText(""); score->setMaximumHeight(20); score->setUsesTextLabel(TRUE); tb->setStretchableWidget(score); - connect(m, SIGNAL(scoreChanged(int, int)), this, SLOT(setScore(int, int))); - connect(score, SIGNAL(clicked()), m, SLOT(resetScore())); + connect(board, SIGNAL(scoreChanged(int,int)), this, SLOT(setScore(int,int))); + connect(score, SIGNAL(clicked()), board, SLOT(resetScore())); int a, b; - m->getScore(&a, &b); + board->getScore(&a, &b); setScore(a,b); + + layout()->setResizeMode(QLayout::FreeResize); } void MindBreaker::setScore(int turns, int games) { double average; double total_turns = turns; double total_games = games; - if(total_games > 0) + if(total_games > 0) average = total_turns / total_games; - else + else average = 0.0; score->setText(tr("win avg: %1 turns (%2 games)").arg(average).arg(games)); } +void MindBreaker::resizeEvent( QResizeEvent *e ) +{ + board->fixSize(); + QMainWindow::resizeEvent( e ); +} + -MindBreakerBoard::MindBreakerBoard( QCanvas &canv, QWidget *parent, +MindBreakerBoard::MindBreakerBoard( QWidget *parent, const char *name, int wFlags ) - : QCanvasView(&canv, parent, name, wFlags) + : QCanvasView(0, parent, name, wFlags), + moving(0), game_over(FALSE), total_turns(0), total_games(0) { - int i, x, y; + setFrameStyle( NoFrame ); + setupBoardSize(qApp->desktop()->width(),qApp->desktop()->height()); + cnv.resize(100,100); + setCanvas(&cnv); + setBackgroundColor( black ); + struct timeval tv; current_go = 0; gettimeofday(&tv, 0); - srand(tv.tv_usec); canvas()->setAdvancePeriod(500); + current_highlight = 0; - QImage image = Resource::loadImage("mindbreaker/mindbreaker"); - - /* copy from master image to functional images */ - x = 0; - y = 0; - panelImage = image.copy(x,y, panel_width, panel_height); - y += panel_height; - y += panel_height; - - titleImage = image.copy(x, y, title_width, title_height); - - Peg::buildImages(); // must be done BEFORE any pegs are made - - current_highlight = new Peg(canvas(), 8); - current_highlight->setPlaced(TRUE); - current_highlight->setX(0); - current_highlight->setY(board_height - ((current_go + 1) * panel_height)); - current_highlight->setZ(0); - current_highlight->show(); + widthTimer = new QTimer( this ); + connect(widthTimer, SIGNAL(timeout()), this, SLOT(doFixSize()) ); + setMaximumWidth( QMIN(qApp->desktop()->height(),qApp->desktop()->width()) ); + //doFixSize(); // build images... needs to be done before reading config. + //readConfig(); // first read... to ensure initial labels and side look right. +} - /* set up the game */ +void MindBreakerBoard::readConfig() +{ Config c("MindBreaker", Config::User); c.setGroup("Board"); game_over = FALSE; + int i; if (c.readNumEntry("Answer0") < 0) { for (i = 0; i < 4; i++) { answer[i] = rand() % 6; current_guess[i] = 6; } total_turns = 0; @@ -306,13 +385,13 @@ MindBreakerBoard::MindBreakerBoard( QCanvas &canv, QWidget *parent, if(total_games < 0) total_games = 0; checkScores(); c.setGroup("Board"); - for(i = 0; i < 4; i++) + for(i = 0; i < 4; i++) answer[i] = c.readNumEntry(QString("Answer%1").arg(i)); /* read, and parse past guesses */ current_go = 0; for(j=0; j < 9; j++) { current_guess[0] = c.readNumEntry(QString("Go%1p0").arg(j)); if (current_guess[0] < 0) @@ -325,46 +404,47 @@ MindBreakerBoard::MindBreakerBoard( QCanvas &canv, QWidget *parent, current_guess[3] = c.readNumEntry(QString("Go%1p3").arg(j)); placeGuessPeg(3, current_guess[3]); checkGuess(); } for(i = 0; i < 4; i++) { current_guess[i] = c.readNumEntry(QString("CurrentGo%1").arg(i)); - if (current_guess[i] != 6) + if (current_guess[i] != 6) placeGuessPeg(i, current_guess[i]); } } - - /* draw initial screen */ - drawBackground(); - canvas()->update(); } MindBreakerBoard::~MindBreakerBoard() { - int i, j; + int i; if (game_over) { current_go = 0; /* clear the answer, clear the guess */ for (i = 0; i < 4; i++) { answer[i] = rand() % 6; current_guess[i] = 6; } } - + writeConfig(); +} + +void MindBreakerBoard::writeConfig() +{ Config c("MindBreaker", Config::User); c.setGroup("Board"); c.clearGroup(); /* write the board */ + int i,j; for (i = 0; i < current_go; i++) { for(j = 0; j < 4; j++) - c.writeEntry(tr("Go%1p%2").arg(i).arg(j), past_guesses[4*i+j]); + c.writeEntry(QString("Go%1p%2").arg(i).arg(j), past_guesses[4*i+j]); } - for(j = 0; j < 4; j++) - c.writeEntry(tr("CurrentGo%1").arg(j), current_guess[j]); - for(j = 0; j < 4; j++) - c.writeEntry(tr("Answer%1").arg(j), answer[j]); + for(j = 0; j < 4; j++) + c.writeEntry(QString("CurrentGo%1").arg(j), current_guess[j]); + for(j = 0; j < 4; j++) + c.writeEntry(QString("Answer%1").arg(j), answer[j]); c.setGroup("Score"); /* write the score */ c.writeEntry("Turns", total_turns); c.writeEntry("Games", total_games); @@ -374,17 +454,81 @@ void MindBreakerBoard::getScore(int *a, int *b) { *a = total_turns; *b = total_games; return; } +void MindBreakerBoard::fixSize() +{ + hide(); + setMaximumWidth( parentWidget()->height() ); + widthTimer->start( 20, TRUE ); +} + +void MindBreakerBoard::doFixSize() +{ + QSize s = size(); + int fw = frameWidth(); + s.setWidth(s.width() - fw); + s.setHeight(s.height() - fw); + + /* min size is 200 x 260 */ +/* + if (s.width() < adjusted_board_width) + s.setWidth(adjusted_board_width); + + if (s.height() < adjusted_board_height) + s.setHeight(adjusted_board_height); +*/ + + if ( current_highlight ) // non-first resize + writeConfig(); + + setupBoardSize(s.width() - fw, s.height() - fw); + canvas()->resize(s.width() - fw, s.height() - fw); + Peg::buildImages(); // must be done BEFORE any pegs are made + + QImage image = Resource::loadImage("mindbreaker/mindbreaker"); + + /* copy from master image to functional images */ + int x = 0; + int y = 0; + panelImage = image.copy(x, y, panel_width, panel_height). + smoothScale( adjusted_panel_width, adjusted_panel_height); + + y += panel_height; + y += panel_height; + + titleImage = image.copy(x, y, title_width, title_height). + smoothScale( adjusted_title_width, adjusted_title_height); + show(); + + delete current_highlight; + current_highlight = new Peg(canvas(), 8); + current_highlight->setPlaced(TRUE); + current_highlight->setX(0); + current_highlight->setY(adjusted_board_height - ((current_go + 1) * adjusted_panel_height)); + current_highlight->setZ(0); + current_highlight->show(); + + /* set up the game */ + //readConfig(); + + /* draw initial screen */ + //drawBackground(); + //canvas()->update(); + clear(); + + readConfig(); +} + void MindBreakerBoard::placeGuessPeg(int pos, int pegId) { - int x = first_peg_x_diff + (pos * peg_spacing); - int y = board_height - ((current_go + 1) * panel_height) - + first_peg_y_diff; + int x = adjusted_first_peg_x_diff + (pos * adjusted_peg_spacing); + int y = adjusted_board_height - ((current_go + 1) * adjusted_panel_height) + + adjusted_first_peg_y_diff; Peg *peg = new Peg(canvas(), pegId, current_go, pos); peg->setPegPos(pos); peg->setPlaced(TRUE); peg->setX(x); peg->setY(y); @@ -402,54 +546,54 @@ void MindBreakerBoard::drawBackground() painter.fillRect(0, 0, canvas()->width(), canvas()->height(), QColor(0,0,0)); /* very first thing is to draw the bins, as everything else needs * to be drawn over them */ QPen pen(QColor(85, 45, 27), 4); painter.setPen(pen); - x_gap = canvas()->width() - (panel_width + (2 * bin_margin)); + x_gap = canvas()->width() - (adjusted_panel_width + (2 * adjusted_bin_margin)); //x_gap += peg_size >> 1; - if (x_gap < 1) + if (x_gap < 1) x_gap = 1; - y_gap = board_height / 6; - y_gap -= (2 * bin_margin); + y_gap = adjusted_board_height / 6; + y_gap -= (2 * adjusted_bin_margin); //y_gap += peg_size >> 1; - if (y_gap < 1) + if (y_gap < 1) y_gap = 1; - x = panel_width + bin_margin - (peg_size >> 1); - y = bin_margin - (peg_size >> 1) + 2; + x = adjusted_panel_width + adjusted_bin_margin - (adjusted_peg_size >> 1); + y = adjusted_bin_margin - (adjusted_peg_size >> 1) + 2; for (i = 0; i < 6; i++) { for (j = 0; j < 10; j++) { int rx = x + (rand() % x_gap); int ry = y + (rand() % y_gap); painter.drawImage(rx,ry, Peg::imageForType(i)); } - y += board_height / 6; + y += adjusted_board_height / 6; } /* now draw the surrounding boxes */ - x_gap = canvas()->width() - panel_width; + x_gap = canvas()->width() - adjusted_panel_width; if (x_gap < 1) x_gap = 1; - y_gap = board_height / 6; - x = panel_width; + y_gap = adjusted_board_height / 6; + x = adjusted_panel_width; y = 1; for (i = 0; i < 6; i++) { - painter.drawRect(x, y, x_gap, y_gap); + painter.drawRect(x, y, x_gap, y_gap); y += y_gap; } x = 0; y = 0; painter.drawImage(x,y, titleImage); - y = title_height; + y = adjusted_title_height; /* now nine gues panels */ for (i = 0; i < 9; i ++) { painter.drawImage(x, y, panelImage); - y += panel_height; + y += adjusted_panel_height; } painter.flush(); canvas()->setBackgroundPixmap(background); } @@ -466,13 +610,13 @@ void MindBreakerBoard::checkGuess() copy_guess[i] = current_guess[i]; if (current_guess[i] == 6) return; if (answer[i] == current_guess[i]) { num_black++; copy_answer[i] = 6; - copy_guess[i] = 7; + copy_guess[i] = 7; } } /* now sure that user has completed a 'guess' */ for (i = 0; i < 4; i++) { if (copy_guess[i] == 7) @@ -483,48 +627,48 @@ void MindBreakerBoard::checkGuess() num_white++; break; } } } - int x = answerpegx; - int y = (board_height - ((current_go + 1) * panel_height)) + answerpegy; - + int x = adjusted_answerpegx; + int y = (adjusted_board_height - ((current_go + 1) * adjusted_panel_height)) + adjusted_answerpegy; + if (num_black == 4) game_over = TRUE; while(num_black > 0) { Peg *p = new Peg(canvas(), 7); p->setPlaced(TRUE); p->setX(x); p->setY(y); p->setZ(1); p->show(); num_black--; - - if (x == answerpegx) - x = answerpegx + answerpeg_diff; + + if (x == adjusted_answerpegx) + x = adjusted_answerpegx + adjusted_answerpeg_xdiff; else { - x = answerpegx; - y += answerpeg_diff; + x = adjusted_answerpegx; + y += adjusted_answerpeg_ydiff; } } while(num_white > 0){ Peg *p = new Peg(canvas(), 6); p->setPlaced(TRUE); p->setX(x); p->setY(y); p->setZ(1); p->show(); num_white--; - - if (x == answerpegx) - x = answerpegx + answerpeg_diff; + + if (x == adjusted_answerpegx) + x = adjusted_answerpegx + adjusted_answerpeg_xdiff; else { - x = answerpegx; - y += answerpeg_diff; + x = adjusted_answerpegx; + y += adjusted_answerpeg_ydiff; } } /* move to next go */ for(i = 0; i < 4; i++) { past_guesses[4*current_go+i] = current_guess[i]; current_guess[i] = 6; @@ -532,33 +676,33 @@ void MindBreakerBoard::checkGuess() current_go++; if((current_go > 8) || game_over) { total_games++; if(!game_over) total_turns += 10; - else + else total_turns += current_go; emit scoreChanged(total_turns, total_games); Peg *p = new Peg(canvas(), 9); game_over = TRUE; p->setPlaced(TRUE); p->setX(0); p->setY(0); p->setZ(0); p->show(); - + for (i = 0; i < 4; i++) { p = new Peg(canvas(), answer[i], -1); - p->setX(first_peg_x_diff + (i * peg_spacing)); - p->setY(5); + p->setX(adjusted_first_peg_x_diff + (i * adjusted_peg_spacing)); + p->setY(adjusted_first_peg_y_diff); p->setZ(3); p->show(); } } else { - current_highlight->setY(board_height - ((current_go + 1) * panel_height)); + current_highlight->setY(adjusted_board_height - ((current_go + 1) * adjusted_panel_height)); } canvas()->update(); } void MindBreakerBoard::clear() { @@ -583,23 +727,23 @@ void MindBreakerBoard::clear() if (*it == current_highlight) continue; if (*it) delete *it; } - current_highlight->setY(board_height - ((current_go + 1) * panel_height)); + current_highlight->setY(adjusted_board_height - ((current_go + 1) * adjusted_panel_height)); checkScores(); drawBackground(); canvas()->update(); } -void MindBreakerBoard::resetScore() +void MindBreakerBoard::resetScore() { /* are u sure */ - if (QMessageBox::information(this, tr( "Reset Statistics" ), + if (QMessageBox::information(this, tr( "Reset Statistics" ), tr( "Reset the win ratio?" ), tr( "OK" ), tr( "Cancel" ) ) == 0) { total_turns = 0; total_games = 0; Peg::eggLevel = 0; drawBackground(); @@ -609,27 +753,34 @@ void MindBreakerBoard::resetScore() } /* EVENTS */ void MindBreakerBoard::contentsMousePressEvent(QMouseEvent *e) { + if (game_over) { + null_press = TRUE; + null_point = e->pos(); + moving = 0; + return; + } + copy_press = FALSE; null_press = FALSE; /* ok, first work out if it is one of the bins that got clicked */ - if (e->x() > panel_width) { + if (e->x() > adjusted_panel_width) { /* its a bin, but which bin */ - if(e->y() > board_height) + int bin = (e->y() + 2) / (adjusted_board_height / 6); + if (bin > 5) return; // missed everything - int bin = (e->y() + 2) / (board_height / 6); /* make new peg... set it moving */ moving_pos = e->pos(); moving = new Peg(canvas(), bin, current_go); - moving->setX(e->x() - (peg_size >> 1)); - moving->setY(e->y() - (peg_size >> 1)); + moving->setX(e->x() - (adjusted_peg_size >> 1)); + moving->setY(e->y() - (adjusted_peg_size >> 1)); moving->setZ(5); moving->show(); canvas()->update(); return; } @@ -649,16 +800,16 @@ void MindBreakerBoard::contentsMousePressEvent(QMouseEvent *e) if(item->pegGo() == -1) return; if(item->pegGo() == current_go) { copy_press = TRUE; copy_peg = item; } - moving = new Peg(canvas(), + moving = new Peg(canvas(), item->type(), current_go); - moving->setX(e->x() - (peg_size >> 1)); - moving->setY(e->y() - (peg_size >> 1)); + moving->setX(e->x() - (adjusted_peg_size >> 1)); + moving->setY(e->y() - (adjusted_peg_size >> 1)); moving->setZ(5); moving->show(); moving_pos = QPoint(e->x(), e->y()); canvas()->update(); return; } @@ -678,25 +829,25 @@ void MindBreakerBoard::contentsMouseMoveEvent(QMouseEvent* e) if (moving ) { moving->moveBy(e->pos().x() - moving_pos.x(), e->pos().y() - moving_pos.y()); moving_pos = e->pos(); canvas()->update(); return; - } + } } void MindBreakerBoard::contentsMouseReleaseEvent(QMouseEvent* e) { /* time to put down the peg */ if(moving) { if(copy_press) { /* check if collided with original. if so, delete both */ copy_press = FALSE; QCanvasItemList l = canvas()->collisions(e->pos()); for (QCanvasItemList::Iterator it=l.begin(); it !=l.end(); ++it) { - if (*it == copy_peg) + if (*it == copy_peg) copy_press = TRUE; } if (copy_press) { current_guess[copy_peg->pegPos()] = 6; delete copy_peg; delete moving; @@ -704,51 +855,51 @@ void MindBreakerBoard::contentsMouseReleaseEvent(QMouseEvent* e) moving = 0; copy_peg = 0; canvas()->update(); return; } } - + /* first work out if in y */ - if (e->y() > (board_height - (current_go * panel_height))) { + if (e->y() > (adjusted_board_height - (current_go * adjusted_panel_height))) { delete moving; moving = 0; canvas()->update(); return; } - if (e->y() < (board_height - ((current_go + 1) * panel_height))) { + if (e->y() < (adjusted_board_height - ((current_go + 1) * adjusted_panel_height))) { delete moving; moving = 0; canvas()->update(); return; } /* ok, a valid go, but which peg */ - int x_bar = first_peg_x_diff - (peg_size >> 1); - x_bar += peg_spacing; + int x_bar = adjusted_first_peg_x_diff - (adjusted_peg_size >> 1); + x_bar += adjusted_peg_spacing; int pos = 0; - if (e->x() > x_bar) + if (e->x() > x_bar) pos = 1; - x_bar += peg_spacing; + x_bar += adjusted_peg_spacing; if (e->x() > x_bar) pos = 2; - x_bar += peg_spacing; + x_bar += adjusted_peg_spacing; if (e->x() > x_bar) pos = 3; - x_bar += peg_spacing; + x_bar += adjusted_peg_spacing; if (e->x() > x_bar) { /* invalid x */ delete moving; moving = 0; canvas()->update(); return; } - int x = first_peg_x_diff + (pos * peg_spacing); - int y = board_height - ((current_go + 1) * panel_height) - + first_peg_y_diff; + int x = adjusted_first_peg_x_diff + (pos * adjusted_peg_spacing); + int y = adjusted_board_height - ((current_go + 1) * adjusted_panel_height) + + adjusted_first_peg_y_diff; moving->setPegPos(pos); moving->setX(x); moving->setY(y); moving->setZ(2); /* remove all other pegs from this position */ @@ -766,53 +917,41 @@ void MindBreakerBoard::contentsMouseReleaseEvent(QMouseEvent* e) canvas()->update(); return; } moving = 0; null_point -= e->pos(); if(null_point.manhattanLength() < 6) { - if (game_over) + if (game_over) clear(); - else + else checkGuess(); } } void MindBreakerBoard::resizeEvent(QResizeEvent *e) { - QSize s = e->size(); - int fw = style().defaultFrameWidth(); - s.setWidth(s.width() - fw); - s.setHeight(s.height() - fw); - - /* min size is 200 x 260 */ - if (s.width() < board_width) - s.setWidth(board_width); - - if (s.height() < board_height) - s.setHeight(board_height); - - canvas()->resize(s.width() - fw, s.height() - fw); - drawBackground(); + QCanvasView::resizeEvent(e); + fixSize(); } /* Easter egg function... beat the clock */ void MindBreakerBoard::checkScores() { double games = total_games; double turns = total_turns; double g = games / 10.0; Peg::eggLevel = 0; double break_even = 5.0; - if (g < 1.0) + if (g < 1.0) return; double avg = turns / games; g--; while (break_even >= 0.0) { - if (avg >= (break_even + g)) + if (avg >= (break_even + g)) return; // score a peg. break_even -= 1.0; Peg::eggLevel = int(5.0 - break_even); } } 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,10 +1,10 @@ /********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** @@ -48,35 +48,47 @@ static const int answerpeg_diff = 9; static const int board_height = (title_height + (panel_height * 9)); static const int board_width = (panel_width + (bin_margin * 2) + peg_size); class Peg; class QToolButton; +class QTimer; class MindBreakerBoard : public QCanvasView // QWidget { Q_OBJECT public: - MindBreakerBoard(QCanvas &c, QWidget *parent=0, const char *name=0, int wFlags=0 ); + MindBreakerBoard(QWidget *parent=0, const char *name=0, int wFlags=0 ); ~MindBreakerBoard(); void getScore(int *, int *); + + void resizeEvent(QResizeEvent*); + void fixSize(); + signals: void scoreChanged(int, int); public slots: void clear(); void resetScore(); +private slots: + void doFixSize(); + protected: void contentsMousePressEvent(QMouseEvent *); void contentsMouseMoveEvent(QMouseEvent *); void contentsMouseReleaseEvent(QMouseEvent *); - void resizeEvent(QResizeEvent *); private: + QCanvas cnv; + + void readConfig(); + void writeConfig(); + void drawBackground(); void checkGuess(); void checkScores(); void placeGuessPeg(int pos, int pegId); QImage panelImage; @@ -97,23 +109,28 @@ private: bool copy_press; Peg *copy_peg; bool game_over; int total_turns; int total_games; + + QTimer *widthTimer; }; class MindBreaker : public QMainWindow // QWidget { Q_OBJECT public: MindBreaker(QWidget *parent=0, const char *name=0, int wFlags=0 ); - + static QString appName() { return QString::fromLatin1("mindbreaker"); } public slots: void setScore(int, int); +protected: + void resizeEvent( QResizeEvent * ); + private: QCanvas canvas; MindBreakerBoard *board; QToolButton *score; }; 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,12 +1,11 @@ -TEMPLATE = app -CONFIG += qt warn_on release -DESTDIR = $(OPIEDIR)/bin +CONFIG += qt warn_on release quick-app HEADERS = mindbreaker.h SOURCES = main.cpp \ mindbreaker.cpp TARGET = mindbreaker INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe + include ( $(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,8 +1,8 @@ Package: opie-mindbreaker -Files: bin/mindbreaker apps/Games/mindbreaker.desktop pics/mindbreaker +Files: plugins/application/libmindbreaker.so* bin/mindbreaker apps/Games/mindbreaker.desktop pics/mindbreaker Priority: optional Section: opie/games Maintainer: Martin Imobersteg <imm@gmx.ch> Architecture: arm Depends: task-opie-minimal Description: Game: crack the coloured code diff --git a/noncore/games/minesweep/main.cpp b/noncore/games/minesweep/main.cpp index 83de9a3..bd70f7c 100644 --- a/noncore/games/minesweep/main.cpp +++ b/noncore/games/minesweep/main.cpp @@ -18,17 +18,10 @@ ** **********************************************************************/ #include "minesweep.h" #include <qpe/qpeapplication.h> +#include <opie/oapplicationfactory.h> -int main( int argc, char** argv ) -{ - QPEApplication a( argc, argv ); +OPIE_EXPORT_APP( OApplicationFactory<MineSweep> ) - MineSweep ms; - QPEApplication::setInputMethodHint( &ms, QPEApplication::AlwaysOff ); - a.showMainWidget( &ms ); - - return a.exec(); -} diff --git a/noncore/games/minesweep/minefield.cpp b/noncore/games/minesweep/minefield.cpp index eca1a36..04cfb97 100644 --- a/noncore/games/minesweep/minefield.cpp +++ b/noncore/games/minesweep/minefield.cpp @@ -350,13 +350,13 @@ void MineField::setup( int level ) case 3: numCols = 18; numRows = 18; minecount = 66 ; break; } - mines = new (Mine*)[numRows*numCols]; + mines = new Mine*[numRows*numCols]; for ( i = 0; i < numCols*numRows; i++ ) mines[i] = new Mine( this ); nonminecount = numRows*numCols - minecount; mineguess = minecount; diff --git a/noncore/games/minesweep/minesweep.cpp b/noncore/games/minesweep/minesweep.cpp index 48644b3..7214a73 100644 --- a/noncore/games/minesweep/minesweep.cpp +++ b/noncore/games/minesweep/minesweep.cpp @@ -18,12 +18,13 @@ ** **********************************************************************/ #include "minesweep.h" #include "minefield.h" +#include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/qpetoolbar.h> #include <qmenubar.h> #include <qpopupmenu.h> @@ -152,28 +153,28 @@ static const char * dead_xpm[] = { " ###### ", " "}; class ResultIndicator : private QLabel { -public: +public: static void showResult( QWidget *ref, bool won ); -private: +private: ResultIndicator( QWidget *parent, const char *name, WFlags f) :QLabel( parent, name, f ) {} - + void timerEvent( QTimerEvent *); void center(); bool twoStage; int timerId; }; void ResultIndicator::showResult( QWidget *ref, bool won ) { ResultIndicator *r = new ResultIndicator( ref, 0, WStyle_Customize | WStyle_Tool | WType_TopLevel ); - + r->setAlignment( AlignCenter ); r->setFrameStyle( Sunken|StyledPanel ); if ( won ) { r->setText( MineSweep::tr("You won!") ); r->center(); r->show(); @@ -192,19 +193,19 @@ void ResultIndicator::showResult( QWidget *ref, bool won ) } void ResultIndicator::center() { QWidget *w = parentWidget(); - QPoint pp = w->mapToGlobal( QPoint(0,0) ); + QPoint pp = w->mapToGlobal( QPoint(0,0) ); QSize s = sizeHint()*3; pp = QPoint( pp.x() + w->width()/2 - s.width()/2, pp.y() + w->height()/ 2 - s.height()/2 ); setGeometry( QRect(pp, s) ); - + } void ResultIndicator::timerEvent( QTimerEvent *te ) { if ( te->timerId() != timerId ) return; @@ -225,23 +226,24 @@ public: MineFrame( QWidget *parent, const char *name = 0 ) :QFrame( parent, name ) {} void setField( MineField *f ) { field = f; } protected: void resizeEvent( QResizeEvent *e ) { field->setAvailableRect( contentsRect()); - QFrame::resizeEvent(e); + QFrame::resizeEvent(e); } private: MineField *field; }; MineSweep::MineSweep( QWidget* parent, const char* name, WFlags f ) : QMainWindow( parent, name, f ) { + QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff ); srand(::time(0)); setCaption( tr("Mine Hunt") ); setIcon( Resource::loadPixmap( "minesweep_icon" ) ); QToolBar *toolBar = new QToolBar( this ); toolBar->setHorizontalStretchable( TRUE ); @@ -251,37 +253,37 @@ MineSweep::MineSweep( QWidget* parent, const char* name, WFlags f ) QPopupMenu *gameMenu = new QPopupMenu( this ); gameMenu->insertItem( tr("Beginner"), this, SLOT( beginner() ) ); gameMenu->insertItem( tr("Advanced"), this, SLOT( advanced() ) ); gameMenu->insertItem( tr("Expert"), this, SLOT( expert() ) ); menuBar->insertItem( tr("Game"), gameMenu ); - + guessLCD = new QLCDNumber( toolBar ); toolBar->setStretchableWidget( guessLCD ); QPalette lcdPal( red ); lcdPal.setColor( QColorGroup::Background, QApplication::palette().active().background() ); lcdPal.setColor( QColorGroup::Button, QApplication::palette().active().button() ); - + // guessLCD->setPalette( lcdPal ); guessLCD->setSegmentStyle( QLCDNumber::Flat ); guessLCD->setFrameStyle( QFrame::NoFrame ); guessLCD->setNumDigits( 2 ); guessLCD->setBackgroundMode( PaletteButton ); newGameButton = new QPushButton( toolBar ); newGameButton->setPixmap( QPixmap( pix_new ) ); newGameButton->setFocusPolicy(QWidget::NoFocus); connect( newGameButton, SIGNAL(clicked()), this, SLOT(newGame()) ); - + timeLCD = new QLCDNumber( toolBar ); // timeLCD->setPalette( lcdPal ); timeLCD->setSegmentStyle( QLCDNumber::Flat ); timeLCD->setFrameStyle( QFrame::NoFrame ); timeLCD->setNumDigits( 5 ); // "mm:ss" timeLCD->setBackgroundMode( PaletteButton ); - + setToolBarsMovable ( FALSE ); addToolBar( toolBar ); MineFrame *mainframe = new MineFrame( this ); mainframe->setFrameShape( QFrame::Box ); @@ -293,13 +295,13 @@ MineSweep::MineSweep( QWidget* parent, const char* name, WFlags f ) mainframe->setField( field ); QFont fnt = field->font(); fnt.setBold( TRUE ); field->setFont( QFont( fnt ) ); field->setFocus(); setCentralWidget( mainframe ); - + connect( field, SIGNAL( gameOver( bool ) ), this, SLOT( gameOver( bool ) ) ); connect( field, SIGNAL( mineCount( int ) ), this, SLOT( setCounter( int ) ) ); connect( field, SIGNAL( gameStarted()), this, SLOT( startPlaying() ) ); timer = new QTimer( this ); diff --git a/noncore/games/minesweep/minesweep.h b/noncore/games/minesweep/minesweep.h index e860573..527dc9e 100644 --- a/noncore/games/minesweep/minesweep.h +++ b/noncore/games/minesweep/minesweep.h @@ -28,12 +28,13 @@ class QLCDNumber; class QPushButton; class MineSweep : public QMainWindow { Q_OBJECT public: + static QString appName() { return QString::fromLatin1("minesweep"); } MineSweep( QWidget* parent = 0, const char* name = 0, WFlags f = 0 ); ~MineSweep(); public slots: void gameOver( bool won ); void newGame(); diff --git a/noncore/games/minesweep/minesweep.pro b/noncore/games/minesweep/minesweep.pro index 8e4001e..9746651 100644 --- a/noncore/games/minesweep/minesweep.pro +++ b/noncore/games/minesweep/minesweep.pro @@ -1,15 +1,13 @@ -TEMPLATE = app
-CONFIG = qt warn_on release
-DESTDIR = $(OPIEDIR)/bin
-HEADERS = minefield.h \
- minesweep.h
-SOURCES = main.cpp \
- minefield.cpp \
- minesweep.cpp
-INCLUDEPATH += $(OPIEDIR)/include
-DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe
-INTERFACES =
-TARGET = minesweep
-
-include ( $(OPIEDIR)/include.pro )
+CONFIG = qt warn_on release quick-app +HEADERS = minefield.h \ + minesweep.h +SOURCES = main.cpp \ + minefield.cpp \ + minesweep.cpp +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include +LIBS += -lqpe +INTERFACES = +TARGET = minesweep + +include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/games/minesweep/opie-minesweep.control b/noncore/games/minesweep/opie-minesweep.control index 32f0352..91343ea 100644 --- a/noncore/games/minesweep/opie-minesweep.control +++ b/noncore/games/minesweep/opie-minesweep.control @@ -1,8 +1,8 @@ Package: opie-minesweep -Files: bin/minesweep apps/Games/minesweep.desktop pics/minesweep +Files: plugins/application/libminesweep.so* bin/minesweep apps/Games/minesweep.desktop pics/minesweep Priority: optional Section: opie/games Maintainer: Martin Imobersteg <imm@gmx.ch> Architecture: arm Depends: task-opie-minimal Description: Game: find the mines diff --git a/noncore/games/parashoot/interface.cpp b/noncore/games/parashoot/interface.cpp index db98720..a40426d 100644 --- a/noncore/games/parashoot/interface.cpp +++ b/noncore/games/parashoot/interface.cpp @@ -19,26 +19,29 @@ **********************************************************************/ #include "interface.h" #include "man.h" #include <qpe/resource.h> +#include <qpe/qpeapplication.h> #include <qlabel.h> #include <qmessagebox.h> #include <qapplication.h> #include <qstyle.h> #include <qpe/qpetoolbar.h> #include <qtoolbutton.h> - + ParaShoot::ParaShoot(QWidget* parent, const char* name, WFlags f) : QMainWindow(parent,name,f), canvas(232, 258), fanfare("level_up"), score(0) { + QPEApplication::grabKeyboard(); + QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff ); canvas.setAdvancePeriod(80); QPixmap bg = Resource::loadPixmap("parashoot/sky"); canvas.setBackgroundPixmap(bg); pb = new QCanvasView(&canvas, this); pb->setFocus(); @@ -56,20 +59,20 @@ ParaShoot::ParaShoot(QWidget* parent, const char* name, WFlags f) : levelscore = new QLabel(toolbar); levelscore->setBackgroundMode( PaletteButton ); levelscore->setAlignment( AlignRight | AlignVCenter | ExpandTabs ); toolbar->setStretchableWidget( levelscore ); showScore(0,0); - + setCentralWidget(pb); autoDropTimer = new QTimer(this); connect (autoDropTimer, SIGNAL(timeout()), this, SLOT(play()) ); - + pauseTimer = new QTimer(this); - connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) ); + connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) ); setFocusPolicy(StrongFocus); newGame(); } @@ -88,13 +91,13 @@ void ParaShoot::showScore( int score, int level ) } void ParaShoot::newGame() { clear(); - if (pauseTimer->isActive()) + if (pauseTimer->isActive()) pauseTimer->stop(); clear(); Man::setManCount(0); score = 0; Bullet::setShotCount(0); Bullet::setNobullets(0); @@ -116,38 +119,38 @@ void ParaShoot::newGame() void ParaShoot::clear() { autoDropTimer->stop(); // QCanvasItem* item; QCanvasItemList l = canvas.allItems(); for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) { - delete *it; + delete *it; } } void ParaShoot::gameOver() { QCanvasItem* item; QCanvasItemList l = canvas.allItems(); - for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) { + for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) { item = *it; if ((item->rtti()==1500) || (item->rtti()==1600) || item->rtti()==1900) item->setAnimated(false); } autoDropTimer->stop(); Helicopter::silenceAll(); int shots = Bullet::getShotCount(); int shotsFired = cannon->shotsFired(); - if ( shotsFired == 0 ) + if ( shotsFired == 0 ) shotsFired = 1; QCanvasText* gameover = new QCanvasText( tr( " GAME OVER!\n" " Your Score: %1\n" " Parachuters Killed: %2\n" - " Accuracy: %3% " ).arg(score).arg(shots).arg(shots * 100 / shotsFired ), + " Accuracy: %3% " ).arg(score).arg(shots).arg(shots * 100 / shotsFired ), &canvas); gameover->setColor(red); gameover->setFont( QFont("times", 18, QFont::Bold) ); gameover->move(canvas.width()/2 -110, canvas.height()/2 -50); gameover->setZ(500); gameover->show(); @@ -160,13 +163,13 @@ void ParaShoot::wait() { waitover = true; pauseTimer->stop(); } void ParaShoot::play() -{ +{ if (Man::getManCount() < nomen ) { new Man(&canvas); } if (Base::baseDestroyed()) { gameOver(); return; @@ -174,33 +177,33 @@ void ParaShoot::play() } void ParaShoot::increaseScore(int x) { score += x; if ( score / 150 != (score-x) / 150 ) - levelUp(); + levelUp(); showScore(level,score); } void ParaShoot::levelUp() { - level++; + level++; int stage = level % 3; switch(stage) { case 0: nomen++; Bullet::setLimit(nomen); fanfare.play(); break; case 1: new Helicopter(&canvas); - break; + break; case 2: moveFaster(); fanfare.play(); - break; + break; default: return; } } void ParaShoot::moveFaster() { @@ -213,13 +216,13 @@ void ParaShoot::moveFaster() void ParaShoot::keyPressEvent(QKeyEvent* event) { if (gamestopped) { if (waitover) newGame(); - else + else return; } else { switch(event->key()) { case Key_Up: case Key_F1: case Key_F9: diff --git a/noncore/games/parashoot/interface.h b/noncore/games/parashoot/interface.h index 3f36d0b..5abbe0b 100644 --- a/noncore/games/parashoot/interface.h +++ b/noncore/games/parashoot/interface.h @@ -35,12 +35,13 @@ class Helicopter; // left, right, up, down }; class ParaShoot : public QMainWindow { Q_OBJECT public: + static QString appName() { return QString::fromLatin1("parashoot"); } ParaShoot(QWidget* parent=0, const char* name=0, WFlags f=0); void clear(); void gameOver(); int mancount; void levelUp(); diff --git a/noncore/games/parashoot/main.cpp b/noncore/games/parashoot/main.cpp index 60eea18..ee36d26 100644 --- a/noncore/games/parashoot/main.cpp +++ b/noncore/games/parashoot/main.cpp @@ -18,19 +18,10 @@ ** **********************************************************************/ #include "interface.h" #include <qpe/qpeapplication.h> +#include <opie/oapplicationfactory.h> -int main(int argc, char **argv) -{ - QPEApplication app(argc,argv); +OPIE_EXPORT_APP( OApplicationFactory<ParaShoot> ) - QPEApplication::grabKeyboard(); - - ParaShoot m; - QPEApplication::setInputMethodHint( &m, QPEApplication::AlwaysOff ); - app.showMainWidget(&m); - - return app.exec(); -} diff --git a/noncore/games/parashoot/opie-parashoot.control b/noncore/games/parashoot/opie-parashoot.control index 758d24d..139dd3c 100644 --- a/noncore/games/parashoot/opie-parashoot.control +++ b/noncore/games/parashoot/opie-parashoot.control @@ -1,8 +1,8 @@ Package: opie-parashoot -Files: bin/parashoot apps/Games/parashoot.desktop pics/parashoot +Files: plugins/application/libparashoot.so* bin/parashoot apps/Games/parashoot.desktop pics/parashoot Priority: optional Section: opie/games Maintainer: Martin Imobersteg <imm@gmx.ch> Architecture: arm Depends: task-opie-minimal Description: Game: shoot the parachutists diff --git a/noncore/games/parashoot/parashoot.pro b/noncore/games/parashoot/parashoot.pro index c2746f9..f5d103a 100644 --- a/noncore/games/parashoot/parashoot.pro +++ b/noncore/games/parashoot/parashoot.pro @@ -1,11 +1,11 @@ -TEMPLATE = app -CONFIG += qt warn_on release -DESTDIR = $(OPIEDIR)/bin +CONFIG += qt warn_on release quick-app HEADERS = interface.h man.h cannon.h base.h bullet.h helicopter.h SOURCES = main.cpp interface.cpp man.cpp cannon.cpp base.cpp bullet.cpp helicopter.cpp TARGET = parashoot INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe + + include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/games/qasteroids/main.cpp b/noncore/games/qasteroids/main.cpp index 7d1682c..c762990 100644 --- a/noncore/games/qasteroids/main.cpp +++ b/noncore/games/qasteroids/main.cpp @@ -18,19 +18,10 @@ ** **********************************************************************/ #include "toplevel.h" #include <qpe/qpeapplication.h> +#include <opie/oapplicationfactory.h> -int main( int argc, char *argv[] ) -{ - QPEApplication app( argc, argv ); - - QPEApplication::grabKeyboard(); - - KAstTopLevel *mainWidget = new KAstTopLevel(); - app.showMainWidget( mainWidget ); - - app.exec(); -} +OPIE_EXPORT_APP( OApplicationFactory<KAstTopLevel> ) diff --git a/noncore/games/qasteroids/opie-qasteroids.control b/noncore/games/qasteroids/opie-qasteroids.control index 25a49b4..8764578 100644 --- a/noncore/games/qasteroids/opie-qasteroids.control +++ b/noncore/games/qasteroids/opie-qasteroids.control @@ -1,8 +1,8 @@ Package: opie-qasteroids -Files: bin/qasteroids apps/Games/qasteroids.desktop pics/qasteroids/* +Files: plugins/application/libqasteroids.so* bin/qasteroids apps/Games/qasteroids.desktop pics/qasteroids/* Priority: optional Section: opie/games Maintainer: Martin Jones <mjones@trolltech.com> Architecture: arm Depends: task-opie-minimal Description: Game: shoot the asteroids diff --git a/noncore/games/qasteroids/qasteroids.pro b/noncore/games/qasteroids/qasteroids.pro index 1a3a8d5..aafc701 100644 --- a/noncore/games/qasteroids/qasteroids.pro +++ b/noncore/games/qasteroids/qasteroids.pro @@ -1,11 +1,11 @@ -TEMPLATE = app -CONFIG += qt warn_on release -DESTDIR = $(OPIEDIR)/bin +CONFIG += qt warn_on release quick-app HEADERS = ledmeter.h sprites.h toplevel.h view.h SOURCES = ledmeter.cpp toplevel.cpp view.cpp main.cpp TARGET = qasteroids INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe + + include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/games/qasteroids/toplevel.cpp b/noncore/games/qasteroids/toplevel.cpp index 71daf60..c4fea89 100644 --- a/noncore/games/qasteroids/toplevel.cpp +++ b/noncore/games/qasteroids/toplevel.cpp @@ -66,37 +66,40 @@ SLevel levels[MAX_LEVELS] = { 5, 0.7 }, { 5, 0.8 }, { 5, 0.9 }, { 5, 1.0 } }; -const char *soundEvents[] = +const char *soundEvents[] = { "ShipDestroyed", "RockDestroyed", 0 }; -const char *soundDefaults[] = +const char *soundDefaults[] = { "Explosion.wav", "ploop.wav", 0 }; - -KAstTopLevel::KAstTopLevel( QWidget *parent, const char *_name ) - : QMainWindow( parent, _name ) + +KAstTopLevel::KAstTopLevel( QWidget *parent, const char *_name, WFlags fl ) + : QMainWindow( parent, _name, fl ) { setCaption( tr("Asteroids") ); + + QPEApplication::grabKeyboard(); + QWidget *border = new QWidget( this ); border->setBackgroundColor( black ); setCentralWidget( border ); QVBoxLayout *borderLayout = new QVBoxLayout( border ); - + QWidget *mainWin = new QWidget( border ); borderLayout->addWidget( mainWin, 2, AlignHCenter ); view = new KAsteroidsView( mainWin ); connect( view, SIGNAL( shipKilled() ), SLOT( slotShipKilled() ) ); connect( view, SIGNAL( rockHit(int) ), SLOT( slotRockHit(int) ) ); @@ -254,13 +257,13 @@ KAstTopLevel::KAstTopLevel( QWidget *parent, const char *_name ) actions.insert( Qt::Key_Enter, Shoot ); actions.insert( Qt::Key_Z, Teleport ); actions.insert( Qt::Key_Down, Brake ); actions.insert( Qt::Key_P, Pause ); - struct utsname name; /* check for embedix kernel running on the zaurus, if + struct utsname name; /* check for embedix kernel running on the zaurus, if lineo change string, this break */ if (uname(&name) != -1) { QString release=name.release; if(release.find("embedix",0,TRUE) !=-1) { actions.insert( Key_F12, Launch ); @@ -392,13 +395,13 @@ void KAstTopLevel::keyReleaseEvent( QKeyEvent *event ) else { event->ignore(); return; } break; - + case NewGame: slotNewGame(); break; /* case Pause: { diff --git a/noncore/games/qasteroids/toplevel.h b/noncore/games/qasteroids/toplevel.h index 4e1ac9c..0270763 100644 --- a/noncore/games/qasteroids/toplevel.h +++ b/noncore/games/qasteroids/toplevel.h @@ -36,14 +36,16 @@ class KALedMeter; class QLCDNumber; class KAstTopLevel : public QMainWindow { Q_OBJECT public: - KAstTopLevel( QWidget *parent=0, const char *name=0 ); + KAstTopLevel( QWidget *parent=0, const char *name=0, WFlags fl = 0 ); virtual ~KAstTopLevel(); + static QString appName() { return QString::fromLatin1("qasteroids"); } + private: void playSound( const char *snd ); void readSoundMapping(); void doStats(); diff --git a/noncore/games/snake/interface.cpp b/noncore/games/snake/interface.cpp index f1227cb..2c60693 100644 --- a/noncore/games/snake/interface.cpp +++ b/noncore/games/snake/interface.cpp @@ -18,24 +18,26 @@ ** **********************************************************************/ #include "interface.h" #include <qpe/resource.h> +#include <qpe/qpeapplication.h> #include <qpe/qpetoolbar.h> #include <qtoolbutton.h> #include <qstyle.h> #include <qapplication.h> #include <qmessagebox.h> SnakeGame::SnakeGame(QWidget* parent, const char* name, WFlags f) : QMainWindow(parent,name,f), canvas(232, 258) { setCaption( tr("Snake") ); + QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff ); QPixmap bg = Resource::loadPixmap("snake/grass"); canvas.setBackgroundPixmap(bg); canvas.setUpdatePeriod(100); snake = 0; cv = new QCanvasView(&canvas, this); diff --git a/noncore/games/snake/interface.h b/noncore/games/snake/interface.h index 454d4ee..fa1dee4 100644 --- a/noncore/games/snake/interface.h +++ b/noncore/games/snake/interface.h @@ -15,12 +15,13 @@ ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include <qmainwindow.h> +#include <qpe/qpeapplication.h> #include <qcanvas.h> #include <qlabel.h> #include "snake.h" #include "target.h" #include "obstacle.h" @@ -30,16 +31,18 @@ class SnakeGame : public QMainWindow { Q_OBJECT public: SnakeGame(QWidget* parent=0, const char* name=0, WFlags f=0); ~SnakeGame(); - + void clear(); void createTargets(); + static QString appName() { return QString::fromLatin1("snake"); } + protected: virtual void keyPressEvent(QKeyEvent*); virtual void resizeEvent(QResizeEvent *e); signals: void moveFaster(); diff --git a/noncore/games/snake/main.cpp b/noncore/games/snake/main.cpp index 90a93b7..77a2769 100644 --- a/noncore/games/snake/main.cpp +++ b/noncore/games/snake/main.cpp @@ -14,22 +14,16 @@ ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ - + #include "interface.h" #include <qpe/qpeapplication.h> +#include <opie/oapplicationfactory.h> + +OPIE_EXPORT_APP( OApplicationFactory<SnakeGame> ) -int main(int argc, char **argv) -{ - QPEApplication app(argc,argv); - SnakeGame* m = new SnakeGame; - QPEApplication::setInputMethodHint( m, QPEApplication::AlwaysOff ); - app.showMainWidget(m); - - return app.exec(); -} diff --git a/noncore/games/snake/opie-snake.control b/noncore/games/snake/opie-snake.control index ef4fc61..f110acd 100644 --- a/noncore/games/snake/opie-snake.control +++ b/noncore/games/snake/opie-snake.control @@ -1,8 +1,8 @@ Package: opie-snake -Files: bin/snake apps/Games/snake.desktop pics/snake +Files: plugins/application/libsnake.so* bin/snake apps/Games/snake.desktop pics/snake Priority: optional Section: opie/games Maintainer: Martin Imobersteg <imm@gmx.ch> Architecture: arm Depends: task-opie-minimal Description: Game: control the snake diff --git a/noncore/games/snake/snake.pro b/noncore/games/snake/snake.pro index 3da8631..2b7444c 100644 --- a/noncore/games/snake/snake.pro +++ b/noncore/games/snake/snake.pro @@ -1,11 +1,10 @@ -TEMPLATE = app -CONFIG += qt warn_on release -DESTDIR = $(OPIEDIR)/bin +CONFIG += qt warn_on release quick-app HEADERS = snake.h target.h obstacle.h interface.h codes.h SOURCES = snake.cpp target.cpp obstacle.cpp interface.cpp main.cpp TARGET = snake INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe + include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/games/solitaire/canvascardwindow.cpp b/noncore/games/solitaire/canvascardwindow.cpp index dec5591..c12344a 100644 --- a/noncore/games/solitaire/canvascardwindow.cpp +++ b/noncore/games/solitaire/canvascardwindow.cpp @@ -34,21 +34,22 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) : QMainWindow(parent, name, f), canvas(230, 260), snapOn(TRUE), cardBack(4), gameType(0), cardGame(NULL) { setIcon( Resource::loadPixmap( "cards" ) ); + setCaption(tr("Patience")); // Create Playing Area for Games if ( QPixmap::defaultDepth() < 12 ) { // canvas.setBackgroundColor(QColor(0x51, 0x74, 0x6B)); // canvas.setBackgroundColor(QColor(0x20, 0xb0, 0x50)); canvas.setBackgroundColor(QColor(0x08, 0x98, 0x2D)); } else { QPixmap bg; - bg.convertFromImage( Resource::loadImage( "table_pattern" ), ThresholdDither ); + bg.convertFromImage( Resource::loadImage( "table_pattern" ), ThresholdDither ); canvas.setBackgroundPixmap(bg); } #if defined( QT_QWS_CASSIOPEIA ) canvas.setAdvancePeriod(70); #else @@ -63,13 +64,13 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) file->insertItem(tr("Patience"), this, SLOT(initPatience()), CTRL+Key_F); file->insertItem(tr("Freecell"), this, SLOT(initFreecell()), CTRL+Key_F); file->insertItem(tr("Chicane"), this, SLOT(initChicane()), CTRL+Key_F); file->insertItem(tr("Harp"), this, SLOT(initHarp()), CTRL+Key_F); file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub()), CTRL+Key_F); menu->insertItem(tr("&Game"), file); - + menu->insertSeparator(); settings = new QPopupMenu; settings->insertItem(tr("&Change card backs"), this, SLOT(changeCardBacks()), Key_F2); snap_id = settings->insertItem(tr("&Snap to position"), this, SLOT(snapToggle()), Key_F3); settings->setCheckable(TRUE); @@ -88,13 +89,13 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) file->insertItem(tr("Patience"), this, SLOT(initPatience())); file->insertItem(tr("Freecell"), this, SLOT(initFreecell())); file->insertItem(tr("Chicane"), this, SLOT(initChicane())); file->insertItem(tr("Harp"), this, SLOT(initHarp())); file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub())); menu->insertItem(tr("Play"), file); - + menu->insertSeparator(); settings = new QPopupMenu; settings->setCheckable(TRUE); settings->insertItem(tr("Change card backs"), this, SLOT(changeCardBacks())); snap_id = settings->insertItem(tr("Snap to position"), this, SLOT(snapToggle())); @@ -115,13 +116,13 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) gameType = cfg.readNumEntry( "GameType", -1 ); drawThree = cfg.readBoolEntry( "DrawThree", FALSE); if ( gameType == 0 ) { cardGame = new PatienceCardGame( &canvas, snapOn, this ); cardGame->setNumberToDraw(drawThree ? 3 : 1); - + setCaption(tr("Patience")); setCentralWidget(cardGame); cardGame->readConfig( cfg ); setCardBacks(); } else if ( gameType == 1 ) { cardGame = new FreecellCardGame( &canvas, snapOn, this ); @@ -183,13 +184,13 @@ void CanvasCardWindow::resizeEvent(QResizeEvent *) canvas.resize( s.width() - fw - 2, s.height() - fw - 2); } void CanvasCardWindow::initPatience() { - // Create New Game + // Create New Game if ( cardGame ) delete cardGame; cardGame = new PatienceCardGame( &canvas, snapOn, this ); cardGame->setNumberToDraw(drawThree ? 3 : 1); gameType = 0; setCaption(tr("Patience")); @@ -250,19 +251,19 @@ void CanvasCardWindow::initTeeclub() { // Create New Game if ( cardGame ) { delete cardGame; } cardGame = new TeeclubCardGame( &canvas, snapOn, this ); - cardGame->setNumberToDraw(1); + cardGame->setNumberToDraw(1); gameType = 4; setCaption(tr("Teeclub")); setCentralWidget(cardGame); cardGame->newGame(); setCardBacks(); -} +} void CanvasCardWindow::snapToggle() { snapOn = !snapOn; settings->setItemChecked(snap_id, snapOn); diff --git a/noncore/games/solitaire/canvascardwindow.h b/noncore/games/solitaire/canvascardwindow.h index eddb184..abd6af6 100644 --- a/noncore/games/solitaire/canvascardwindow.h +++ b/noncore/games/solitaire/canvascardwindow.h @@ -30,12 +30,13 @@ class QPopupMenu; class CanvasCardWindow : public QMainWindow { Q_OBJECT public: + static QString appName() { return QString::fromLatin1("patience"); } CanvasCardWindow(QWidget* parent=0, const char* name=0, WFlags f=0); virtual ~CanvasCardWindow(); public slots: void setCardBacks(); void changeCardBacks(); diff --git a/noncore/games/solitaire/carddeck.cpp b/noncore/games/solitaire/carddeck.cpp index a2d0076..b130131 100644 --- a/noncore/games/solitaire/carddeck.cpp +++ b/noncore/games/solitaire/carddeck.cpp @@ -22,13 +22,13 @@ #include "card.h" #include "carddeck.h" CardDeck::CardDeck(int jokers, int numOfDecks) : numberOfJokers(jokers), numberOfDecks(numOfDecks), deckCreated(FALSE) { - cards = new (Card *)[getNumberOfCards()]; + cards = new Card *[getNumberOfCards()]; } CardDeck::~CardDeck() { for (int i = 0; i < getNumberOfCards(); i++) diff --git a/noncore/games/solitaire/main.cpp b/noncore/games/solitaire/main.cpp index f81aa3c..bd3cf8b 100644 --- a/noncore/games/solitaire/main.cpp +++ b/noncore/games/solitaire/main.cpp @@ -18,19 +18,9 @@ ** **********************************************************************/ #include "canvascardwindow.h" #include <qpe/qpeapplication.h> +#include <opie/oapplicationfactory.h> - -int main( int argc, char ** argv ) -{ - QPEApplication a( argc, argv ); - - CanvasCardWindow m; - m.setCaption( CanvasCardWindow::tr("Patience") ); - a.showMainWidget( &m ); - - return a.exec(); -} - +OPIE_EXPORT_APP( OApplicationFactory<CanvasCardWindow> )
\ No newline at end of file diff --git a/noncore/games/solitaire/solitaire.pro b/noncore/games/solitaire/solitaire.pro index 1ac62c3..b1b8bda 100755 --- a/noncore/games/solitaire/solitaire.pro +++ b/noncore/games/solitaire/solitaire.pro @@ -1,10 +1,8 @@ -TEMPLATE = app -CONFIG += qt warn_on release -DESTDIR = $(OPIEDIR)/bin +CONFIG += qt warn_on release quick-app HEADERS = canvascard.h canvasshapes.h cardgame.h cardgamelayout.h cardpile.h card.h carddeck.h \ canvascardgame.h freecellcardgame.h chicanecardgame.h harpcardgame.h teeclubcardgame.h \ patiencecardgame.h canvascardwindow.h SOURCES = canvascard.cpp canvasshapes.cpp cardgame.cpp cardgamelayout.cpp \ @@ -15,7 +13,8 @@ SOURCES = canvascard.cpp canvasshapes.cpp cardgame.cpp cardgamelayout.cpp \ TARGET = patience INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe + include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/games/tetrix/main.cpp b/noncore/games/tetrix/main.cpp index e36d52d..fcf4b33 100644 --- a/noncore/games/tetrix/main.cpp +++ b/noncore/games/tetrix/main.cpp @@ -19,15 +19,10 @@ **********************************************************************/ #include "qtetrix.h" #include <qpe/qpeapplication.h> -int main( int argc, char **argv ) -{ - QPEApplication a(argc,argv); +#include <opie/oapplicationfactory.h> - QTetrix *tetrix = new QTetrix; - a.showMainWidget(tetrix); +OPIE_EXPORT_APP( OApplicationFactory<QTetrix> ) - return a.exec(); -} diff --git a/noncore/games/tetrix/opie-tetrix.control b/noncore/games/tetrix/opie-tetrix.control index e901dbf..b1e0bcf 100644 --- a/noncore/games/tetrix/opie-tetrix.control +++ b/noncore/games/tetrix/opie-tetrix.control @@ -1,8 +1,8 @@ Package: opie-tetrix -Files: bin/tetrix apps/Games/tetrix.desktop pics/tetrix/* +Files: plugins/application/libtetrix.so* bin/tetrix apps/Games/tetrix.desktop pics/tetrix/* Priority: optional Section: opie/games Maintainer: Martin Imobersteg <imm@gmx.ch> Architecture: arm Arch: iPAQ Depends: task-opie-minimal diff --git a/noncore/games/tetrix/qtetrix.h b/noncore/games/tetrix/qtetrix.h index cb33941..c8959c5 100644 --- a/noncore/games/tetrix/qtetrix.h +++ b/noncore/games/tetrix/qtetrix.h @@ -49,12 +49,13 @@ private: class QTetrix : public QMainWindow { Q_OBJECT public: + static QString appName() { return QString::fromLatin1("tetrix"); } QTetrix( QWidget *parent=0, const char *name=0, WFlags f=0 ); void startGame() { board->startGame(); } public slots: void gameOver(); void quit(); diff --git a/noncore/games/tetrix/tetrix.pro b/noncore/games/tetrix/tetrix.pro index 35fe82b..3b95c84 100644 --- a/noncore/games/tetrix/tetrix.pro +++ b/noncore/games/tetrix/tetrix.pro @@ -1,9 +1,7 @@ -TEMPLATE = app -CONFIG = qt warn_on release -DESTDIR = $(OPIEDIR)/bin +CONFIG = qt warn_on release quick-app HEADERS = gtetrix.h \ qtetrix.h \ qtetrixb.h \ tpiece.h \ ohighscoredlg.h SOURCES = main.cpp \ @@ -15,7 +13,10 @@ SOURCES = main.cpp \ INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lstdc++ INTERFACES = TARGET = tetrix + + + include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/games/wordgame/main.cpp b/noncore/games/wordgame/main.cpp index cd4600e..f32acff 100644 --- a/noncore/games/wordgame/main.cpp +++ b/noncore/games/wordgame/main.cpp @@ -18,17 +18,11 @@ ** **********************************************************************/ #include "wordgame.h" #include <qpe/qpeapplication.h> +#include <opie/oapplicationfactory.h> -int main( int argc, char ** argv ) -{ - QPEApplication a( argc, argv ); - WordGame mw; - //QPEApplication::setInputMethodHint( &mw, QPEApplication::AlwaysOff ); - a.showMainWidget(&mw); +OPIE_EXPORT_APP( OApplicationFactory<WordGame> ) - return a.exec(); -} diff --git a/noncore/games/wordgame/wordgame.h b/noncore/games/wordgame/wordgame.h index f73c85a..020a4b5 100644 --- a/noncore/games/wordgame/wordgame.h +++ b/noncore/games/wordgame/wordgame.h @@ -306,12 +306,13 @@ class NewGame; class WordGame : public QMainWindow { Q_OBJECT public: WordGame( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~WordGame(); + static QString appName() { return QString::fromLatin1("wordgame"); } private slots: void endTurn(); void resetTurn(); void passTurn(); void think(); diff --git a/noncore/games/wordgame/wordgame.pro b/noncore/games/wordgame/wordgame.pro index e997adc..7ef2bfd 100644 --- a/noncore/games/wordgame/wordgame.pro +++ b/noncore/games/wordgame/wordgame.pro @@ -1,13 +1,12 @@ -TEMPLATE = app -CONFIG = qt warn_on release -DESTDIR = $(OPIEDIR)/bin +CONFIG = qt warn_on release quick-app HEADERS = wordgame.h SOURCES = main.cpp \ wordgame.cpp INTERFACES = newgamebase.ui rulesbase.ui TARGET = wordgame INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe + include ( $(OPIEDIR)/include.pro ) |