summaryrefslogtreecommitdiff
authorzecke <zecke>2004-02-06 12:14:56 (UTC)
committer zecke <zecke>2004-02-06 12:14:56 (UTC)
commit0c74629e8f5c12a9b5a282b817f884fa10dee491 (patch) (unidiff)
tree3294663b92023f8d24d68a01022e011a3c94002d
parent46ce5afcfbe7be19f4d5ac0fed6886a0759f1a25 (diff)
downloadopie-0c74629e8f5c12a9b5a282b817f884fa10dee491.zip
opie-0c74629e8f5c12a9b5a282b817f884fa10dee491.tar.gz
opie-0c74629e8f5c12a9b5a282b817f884fa10dee491.tar.bz2
Merge from the 1.0.x release
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/backgammon/backgammon.control2
-rw-r--r--noncore/games/backgammon/backgammon.h1
-rw-r--r--noncore/games/backgammon/backgammon.pro4
-rw-r--r--noncore/games/backgammon/main.cpp10
-rw-r--r--noncore/games/bounce/bounce.pro4
-rw-r--r--noncore/games/bounce/kbounce.cpp3
-rw-r--r--noncore/games/bounce/kbounce.h3
-rw-r--r--noncore/games/bounce/main.cpp9
-rw-r--r--noncore/games/bounce/opie-bounce.control2
-rw-r--r--noncore/games/buzzword/buzzword.cpp2
-rw-r--r--noncore/games/buzzword/buzzword.h3
-rw-r--r--noncore/games/buzzword/buzzword.pro7
-rw-r--r--noncore/games/buzzword/main.cpp15
-rw-r--r--noncore/games/buzzword/opie-buzzword.control2
-rw-r--r--noncore/games/fifteen/opie-fifteen.control2
-rw-r--r--noncore/games/go/go.pro6
-rw-r--r--noncore/games/go/gowidget.cpp4
-rw-r--r--noncore/games/go/gowidget.h3
-rw-r--r--noncore/games/go/main.cpp13
-rw-r--r--noncore/games/go/opie-go.control4
-rw-r--r--noncore/games/kcheckers/kcheckers.cpp5
-rw-r--r--noncore/games/kcheckers/kcheckers.h3
-rw-r--r--noncore/games/kcheckers/kcheckers.pro5
-rw-r--r--noncore/games/kcheckers/main.cpp12
-rw-r--r--noncore/games/kcheckers/opie-kcheckers.control2
-rw-r--r--noncore/games/mindbreaker/main.cpp10
-rw-r--r--noncore/games/mindbreaker/mindbreaker.cpp455
-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
-rw-r--r--noncore/games/minesweep/main.cpp11
-rw-r--r--noncore/games/minesweep/minefield.cpp2
-rw-r--r--noncore/games/minesweep/minesweep.cpp26
-rw-r--r--noncore/games/minesweep/minesweep.h1
-rw-r--r--noncore/games/minesweep/minesweep.pro28
-rw-r--r--noncore/games/minesweep/opie-minesweep.control2
-rw-r--r--noncore/games/parashoot/interface.cpp33
-rw-r--r--noncore/games/parashoot/interface.h1
-rw-r--r--noncore/games/parashoot/main.cpp13
-rw-r--r--noncore/games/parashoot/opie-parashoot.control2
-rw-r--r--noncore/games/parashoot/parashoot.pro6
-rw-r--r--noncore/games/qasteroids/main.cpp13
-rw-r--r--noncore/games/qasteroids/opie-qasteroids.control2
-rw-r--r--noncore/games/qasteroids/qasteroids.pro6
-rw-r--r--noncore/games/qasteroids/toplevel.cpp19
-rw-r--r--noncore/games/qasteroids/toplevel.h4
-rw-r--r--noncore/games/snake/interface.cpp2
-rw-r--r--noncore/games/snake/interface.h5
-rw-r--r--noncore/games/snake/main.cpp14
-rw-r--r--noncore/games/snake/opie-snake.control2
-rw-r--r--noncore/games/snake/snake.pro5
-rw-r--r--noncore/games/solitaire/canvascardwindow.cpp15
-rw-r--r--noncore/games/solitaire/canvascardwindow.h1
-rw-r--r--noncore/games/solitaire/carddeck.cpp2
-rw-r--r--noncore/games/solitaire/main.cpp14
-rwxr-xr-xnoncore/games/solitaire/solitaire.pro5
-rw-r--r--noncore/games/tetrix/main.cpp9
-rw-r--r--noncore/games/tetrix/opie-tetrix.control2
-rw-r--r--noncore/games/tetrix/qtetrix.h1
-rw-r--r--noncore/games/tetrix/tetrix.pro7
-rw-r--r--noncore/games/wordgame/main.cpp10
-rw-r--r--noncore/games/wordgame/wordgame.h1
-rw-r--r--noncore/games/wordgame/wordgame.pro5
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,10 +1,10 @@
1Package: backgammon 1Package: backgammon
2Files: bin/backgammon apps/Games/backgammon.desktop pics/backgammon help/en/html/backgammon.html 2Files: plugins/application/libbackgammon.so* bin/backgammon apps/Games/backgammon.desktop pics/backgammon help/en/html/backgammon.html
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Ralf Waspe <rwaspe@web.de> 5Maintainer: Ralf Waspe <rwaspe@web.de>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal 7Depends: task-opie-minimal
8Description: Backgammon Game 8Description: Backgammon Game
9 A Backgammon game for the Opie environment. 9 A Backgammon game for the Opie environment.
10Version: $QPE_VERSION$EXTRAVERSION 10Version: $QPE_VERSION$EXTRAVERSION
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
@@ -1,120 +1,121 @@
1#ifndef BACKGAMMON_H 1#ifndef BACKGAMMON_H
2#define BACKGAMMON_H 2#define BACKGAMMON_H
3 3
4#include "backgammonview.h" 4#include "backgammonview.h"
5#include "canvasimageitem.h" 5#include "canvasimageitem.h"
6//#include "rulesdialog.h" 6//#include "rulesdialog.h"
7#include "moveengine.h" 7#include "moveengine.h"
8 8
9 9
10#include <qlabel.h> 10#include <qlabel.h>
11#include <qmainwindow.h> 11#include <qmainwindow.h>
12//#include <qwidget.h> 12//#include <qwidget.h>
13 13
14 14
15 15
16 16
17class BackGammon : public QMainWindow 17class BackGammon : public QMainWindow
18{ 18{
19 Q_OBJECT 19 Q_OBJECT
20private: 20private:
21 //GUI 21 //GUI
22 //the "status" bar 22 //the "status" bar
23 QLabel* message; 23 QLabel* message;
24 //the main drawing area 24 //the main drawing area
25 QCanvas* area; 25 QCanvas* area;
26 BackGammonView* boardview; 26 BackGammonView* boardview;
27 CanvasImageItem* board; 27 CanvasImageItem* board;
28 CanvasImageItem* table; 28 CanvasImageItem* table;
29 CanvasImageItem** p1; 29 CanvasImageItem** p1;
30 CanvasImageItem** p2; 30 CanvasImageItem** p2;
31 CanvasImageItem** p1_side; 31 CanvasImageItem** p1_side;
32 CanvasImageItem** p2_side; 32 CanvasImageItem** p2_side;
33 33
34 CanvasImageItem** diceA1; 34 CanvasImageItem** diceA1;
35 CanvasImageItem** diceA2; 35 CanvasImageItem** diceA2;
36 CanvasImageItem** diceB1; 36 CanvasImageItem** diceB1;
37 CanvasImageItem** diceB2; 37 CanvasImageItem** diceB2;
38 //CanvasImageItem** oddsDice; 38 //CanvasImageItem** oddsDice;
39 CanvasImageItem* nomove_marker; 39 CanvasImageItem* nomove_marker;
40 40
41 QCanvasRectangle* marker_current; 41 QCanvasRectangle* marker_current;
42 QCanvasRectangle* marker_next[4]; 42 QCanvasRectangle* marker_next[4];
43 43
44 //ENGINE 44 //ENGINE
45 MoveEngine* move; 45 MoveEngine* move;
46 //the dice values 46 //the dice values
47 int diceA1_value; 47 int diceA1_value;
48 int diceA2_value; 48 int diceA2_value;
49 int diceA3_value; 49 int diceA3_value;
50 int diceA4_value; 50 int diceA4_value;
51 int diceB1_value; 51 int diceB1_value;
52 int diceB2_value; 52 int diceB2_value;
53 int diceB3_value; 53 int diceB3_value;
54 int diceB4_value; 54 int diceB4_value;
55 55
56 int player; 56 int player;
57 bool dice1_played; 57 bool dice1_played;
58 bool dice2_played; 58 bool dice2_played;
59 bool dice3_played; 59 bool dice3_played;
60 bool dice4_played; 60 bool dice4_played;
61 bool dice_rolled; 61 bool dice_rolled;
62 //computer opponent 62 //computer opponent
63 bool player1_auto; 63 bool player1_auto;
64 bool player2_auto; 64 bool player2_auto;
65 65
66 //the images; 66 //the images;
67 QString theme_name; 67 QString theme_name;
68 QString board_name; 68 QString board_name;
69 QString piecesA_name; 69 QString piecesA_name;
70 QString piecesB_name; 70 QString piecesB_name;
71 QString diceA_name; 71 QString diceA_name;
72 QString diceB_name; 72 QString diceB_name;
73 QString odds_name; 73 QString odds_name;
74 QString table_name; 74 QString table_name;
75 75
76 //save game 76 //save game
77 QString game_name; 77 QString game_name;
78 78
79 //the rules 79 //the rules
80 Rules rules; 80 Rules rules;
81 81
82 //display settings 82 //display settings
83 Display display; 83 Display display;
84 //is the game finished ? 84 //is the game finished ?
85 bool gameFinished; 85 bool gameFinished;
86 86
87public: 87public:
88 static QString appName() { return QString::fromLatin1("backgammon"); }
88 BackGammon( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 89 BackGammon( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
89 ~BackGammon(); 90 ~BackGammon();
90private slots: 91private slots:
91 void newgame(); 92 void newgame();
92 void playerselect(); 93 void playerselect();
93 void loadgame(); 94 void loadgame();
94 void savegame(); 95 void savegame();
95 void deletegame(); 96 void deletegame();
96 void newtheme(); 97 void newtheme();
97 void loadtheme(); 98 void loadtheme();
98 void savetheme(); 99 void savetheme();
99 void themedefault(); 100 void themedefault();
100 void deletetheme(); 101 void deletetheme();
101 void modify_AI(); 102 void modify_AI();
102 void setrules(); 103 void setrules();
103 void mouse(int x,int y); 104 void mouse(int x,int y);
104 void done_dice1(); 105 void done_dice1();
105 void done_dice2(); 106 void done_dice2();
106 void done_dice3(); 107 void done_dice3();
107 void done_dice4(); 108 void done_dice4();
108 void nomove(); 109 void nomove();
109 void nomove2(); 110 void nomove2();
110 void finished(int theplayer); 111 void finished(int theplayer);
111 void autoroll_dice1(); 112 void autoroll_dice1();
112 void autoroll_dice2(); 113 void autoroll_dice2();
113private: 114private:
114 void draw(); 115 void draw();
115 void showdice(); 116 void showdice();
116 void setplayer(); 117 void setplayer();
117 void applytheme(); 118 void applytheme();
118}; 119};
119 120
120#endif //BACKGAMMON_H 121#endif //BACKGAMMON_H
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,34 +1,32 @@
1 TEMPLATE = app 1 CONFIG = qt warn_on release quick-app
2 CONFIG = qt warn_on release
3 2
4HEADERS = backgammon.h \ 3HEADERS = backgammon.h \
5 backgammonview.h \ 4 backgammonview.h \
6 canvasimageitem.h \ 5 canvasimageitem.h \
7 themedialog.h \ 6 themedialog.h \
8 moveengine.h \ 7 moveengine.h \
9 filedialog.h \ 8 filedialog.h \
10 playerdialog.h \ 9 playerdialog.h \
11 aidialog.h \ 10 aidialog.h \
12 rulesdialog.h \ 11 rulesdialog.h \
13 definition.h 12 definition.h
14 13
15SOURCES = main.cpp \ 14SOURCES = main.cpp \
16 backgammon.cpp \ 15 backgammon.cpp \
17 backgammonview.cpp \ 16 backgammonview.cpp \
18 canvasimageitem.cpp \ 17 canvasimageitem.cpp \
19 themedialog.cpp \ 18 themedialog.cpp \
20 moveengine.cpp \ 19 moveengine.cpp \
21 filedialog.cpp \ 20 filedialog.cpp \
22 playerdialog.cpp \ 21 playerdialog.cpp \
23 aidialog.cpp \ 22 aidialog.cpp \
24 rulesdialog.cpp \ 23 rulesdialog.cpp \
25 definition.cpp 24 definition.cpp
26 25
27 TARGET = backgammon 26 TARGET = backgammon
28 INCLUDEPATH+= $(OPIEDIR)/include 27 INCLUDEPATH+= $(OPIEDIR)/include
29 DEPENDPATH+= $(OPIEDIR)/include 28 DEPENDPATH+= $(OPIEDIR)/include
30 LIBS += -lqpe -lstdc++ 29 LIBS += -lqpe -lstdc++
31 DESTDIR = $(OPIEDIR)/bin
32 30
33 31
34include ( $(OPIEDIR)/include.pro ) 32include ( $(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 @@
1#include <qpe/qpeapplication.h> 1#include <qpe/qpeapplication.h>
2#include "backgammon.h" 2#include "backgammon.h"
3 3
4#include <opie/oapplicationfactory.h>
4 5
5int main( int argc, char** argv ) 6OPIE_EXPORT_APP( OApplicationFactory<BackGammon> )
6{
7 QPEApplication app( argc, argv );
8 7
9 BackGammon* view= new BackGammon();
10 app.showMainWidget(view);
11
12 return app.exec();
13}
14 8
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 @@
1 TEMPLATE= app
2 #CONFIG = qt warn_on debug 1 #CONFIG = qt warn_on debug
3 CONFIG = qt warn_on release 2 CONFIG = qt warn_on release quick-app
4 HEADERS = game.h kbounce.h 3 HEADERS = game.h kbounce.h
5 SOURCES = game.cpp kbounce.cpp main.cpp 4 SOURCES = game.cpp kbounce.cpp main.cpp
6 INCLUDEPATH+= $(OPIEDIR)/include 5 INCLUDEPATH+= $(OPIEDIR)/include
7 DEPENDPATH+= $(OPIEDIR)/include 6 DEPENDPATH+= $(OPIEDIR)/include
8LIBS += -lqpe 7LIBS += -lqpe
9DESTDIR = $(OPIEDIR)/bin
10 TARGET = bounce 8 TARGET = bounce
11 9
12include ( $(OPIEDIR)/include.pro ) 10include ( $(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
@@ -1,222 +1,223 @@
1/* 1/*
2 * Copyright (C) 2000 Stefan Schimanski <1Stein@gmx.de> 2 * Copyright (C) 2000 Stefan Schimanski <1Stein@gmx.de>
3 * 3 *
4 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License,Life or (at your option) any later version. 7 * version 2 of the License,Life or (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public 14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the Free 15 * License along with this program; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 17 */
18 18
19#include <qlayout.h> 19#include <qlayout.h>
20#include <qtimer.h> 20#include <qtimer.h>
21#include <qlcdnumber.h> 21#include <qlcdnumber.h>
22#include <qmessagebox.h> 22#include <qmessagebox.h>
23#include <qmainwindow.h> 23#include <qmainwindow.h>
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25 25
26#include "kbounce.h" 26#include "kbounce.h"
27#include "game.h" 27#include "game.h"
28#include <qlabel.h> 28#include <qlabel.h>
29 29
30KJezzball::KJezzball() : QMainWindow(0), m_gameWidget( 0 ) 30KJezzball::KJezzball(QWidget *p, const char* n, WFlags f)
31 : QMainWindow(p,n,f), m_gameWidget( 0 )
31{ 32{
32 setCaption(tr("Bounce")); 33 setCaption(tr("Bounce"));
33 // setup variables 34 // setup variables
34 m_game.level = 1; 35 m_game.level = 1;
35 m_game.score = 0; 36 m_game.score = 0;
36 m_state = Idle; 37 m_state = Idle;
37 38
38 39
39 menu = menuBar(); 40 menu = menuBar();
40 game = new QPopupMenu; 41 game = new QPopupMenu;
41 game->insertItem(tr("&New game"), this, SLOT(newGame()), Key_N ); 42 game->insertItem(tr("&New game"), this, SLOT(newGame()), Key_N );
42 game->insertItem(tr("&Pause game"), this, SLOT(pauseGame()), Key_P ); 43 game->insertItem(tr("&Pause game"), this, SLOT(pauseGame()), Key_P );
43 game->insertSeparator(); 44 game->insertSeparator();
44 game->insertItem(tr("&About"), this, SLOT(about())); 45 game->insertItem(tr("&About"), this, SLOT(about()));
45 menu->insertItem( tr("&Game"), game ); 46 menu->insertItem( tr("&Game"), game );
46 47
47 // create widgets 48 // create widgets
48 m_view = new QWidget( this, "m_view" ); 49 m_view = new QWidget( this, "m_view" );
49 setCentralWidget( m_view ); 50 setCentralWidget( m_view );
50 51
51 m_layout = new QGridLayout( m_view ); 52 m_layout = new QGridLayout( m_view );
52 m_layout->setSpacing( 0 ); 53 m_layout->setSpacing( 0 );
53 m_layout->setMargin( 0 ); 54 m_layout->setMargin( 0 );
54 55
55 ScoreLabel = new QLabel( m_view, "ScoreLabel" ); 56 ScoreLabel = new QLabel( m_view, "ScoreLabel" );
56 ScoreLabel->setText( tr( "Score: 00" ) ); 57 ScoreLabel->setText( tr( "Score: 00" ) );
57 ScoreLabel->setAlignment( int( QLabel::AlignCenter ) ); 58 ScoreLabel->setAlignment( int( QLabel::AlignCenter ) );
58 59
59 m_layout->addWidget( ScoreLabel, 1, 0 ); 60 m_layout->addWidget( ScoreLabel, 1, 0 );
60 61
61 LivesLabel = new QLabel( m_view, "LivesLabel" ); 62 LivesLabel = new QLabel( m_view, "LivesLabel" );
62 LivesLabel->setText( tr( "Lives: 0%" ) ); 63 LivesLabel->setText( tr( "Lives: 0%" ) );
63 LivesLabel->setAlignment( int( QLabel::AlignCenter ) ); 64 LivesLabel->setAlignment( int( QLabel::AlignCenter ) );
64 65
65 m_layout->addWidget( LivesLabel, 1, 2 ); 66 m_layout->addWidget( LivesLabel, 1, 2 );
66 67
67 FilledLabel = new QLabel( m_view, "FilledLabel" ); 68 FilledLabel = new QLabel( m_view, "FilledLabel" );
68 FilledLabel->setText( tr( "Filled: 00%" ) ); 69 FilledLabel->setText( tr( "Filled: 00%" ) );
69 FilledLabel->setAlignment( int( QLabel::AlignCenter ) ); 70 FilledLabel->setAlignment( int( QLabel::AlignCenter ) );
70 71
71 m_layout->addWidget( FilledLabel, 1, 1 ); 72 m_layout->addWidget( FilledLabel, 1, 1 );
72 73
73 TimeLabel = new QLabel( m_view, "TimeLabel" ); 74 TimeLabel = new QLabel( m_view, "TimeLabel" );
74 TimeLabel->setText( tr( "Time: 00" ) ); 75 TimeLabel->setText( tr( "Time: 00" ) );
75 TimeLabel->setAlignment( int( QLabel::AlignCenter ) ); 76 TimeLabel->setAlignment( int( QLabel::AlignCenter ) );
76 77
77 m_layout->addWidget( TimeLabel, 1, 3 ); 78 m_layout->addWidget( TimeLabel, 1, 3 );
78 79
79 // create timers 80 // create timers
80 m_nextLevelTimer = new QTimer( this, "m_nextLevelTimer" ); 81 m_nextLevelTimer = new QTimer( this, "m_nextLevelTimer" );
81 connect( m_nextLevelTimer, SIGNAL(timeout()), this, SLOT(switchLevel()) ); 82 connect( m_nextLevelTimer, SIGNAL(timeout()), this, SLOT(switchLevel()) );
82 83
83 m_gameOverTimer = new QTimer( this, "m_gameOverTimer" ); 84 m_gameOverTimer = new QTimer( this, "m_gameOverTimer" );
84 connect( m_gameOverTimer, SIGNAL(timeout()), this, SLOT(gameOverNow()) ); 85 connect( m_gameOverTimer, SIGNAL(timeout()), this, SLOT(gameOverNow()) );
85 86
86 m_timer = new QTimer( this, "m_timer" ); 87 m_timer = new QTimer( this, "m_timer" );
87 connect( m_timer, SIGNAL(timeout()), this, SLOT(second()) ); 88 connect( m_timer, SIGNAL(timeout()), this, SLOT(second()) );
88 89
89 // create demo game 90 // create demo game
90 createLevel( 1 ); 91 createLevel( 1 );
91} 92}
92 93
93void KJezzball::newGame() 94void KJezzball::newGame()
94{ 95{
95 // Check for running game 96 // Check for running game
96 closeGame(); 97 closeGame();
97 if ( m_state==Idle ) 98 if ( m_state==Idle )
98 { 99 {
99 // update displays 100 // update displays
100 m_game.level = 1; 101 m_game.level = 1;
101 m_game.score = 0; 102 m_game.score = 0;
102 103
103 setCaption(tr("Bounce Level %1").arg(m_game.level)); 104 setCaption(tr("Bounce Level %1").arg(m_game.level));
104 ScoreLabel->setText( tr( "Score: %1" ).arg(m_game.score) ); 105 ScoreLabel->setText( tr( "Score: %1" ).arg(m_game.score) );
105 106
106 // start new game 107 // start new game
107 m_state = Running; 108 m_state = Running;
108 109
109 createLevel( m_game.level ); 110 createLevel( m_game.level );
110 startLevel(); 111 startLevel();
111 } 112 }
112} 113}
113 114
114void KJezzball::about() 115void KJezzball::about()
115{ 116{
116 QMessageBox::information( this, tr("About"), 117 QMessageBox::information( this, tr("About"),
117 tr("Written by: Stefan Schimanski\n" 118 tr("Written by: Stefan Schimanski\n"
118 "Ported by: Martin Imobersteg\n" 119 "Ported by: Martin Imobersteg\n"
119 "\n" 120 "\n"
120 "Click to form walls.\n" 121 "Click to form walls.\n"
121 "Hit space to switch wall direction.\n" 122 "Hit space to switch wall direction.\n"
122 "Try to reduce total space by 75%.\n" 123 "Try to reduce total space by 75%.\n"
123 "\n" 124 "\n"
124 "This program is distributed under\n" 125 "This program is distributed under\n"
125 "the terms of the GPL v2.") ); 126 "the terms of the GPL v2.") );
126} 127}
127 128
128void KJezzball::closeGame() 129void KJezzball::closeGame()
129{ 130{
130 if ( m_state!=Idle ) 131 if ( m_state!=Idle )
131 { 132 {
132 stopLevel(); 133 stopLevel();
133 m_state = Idle; 134 m_state = Idle;
134 } 135 }
135} 136}
136 137
137void KJezzball::pauseGame() 138void KJezzball::pauseGame()
138{ 139{
139 switch ( m_state ) 140 switch ( m_state )
140 { 141 {
141 case Running: 142 case Running:
142 m_state = Paused; 143 m_state = Paused;
143 m_gameWidget->display( tr("Game paused.\nPress P to continue!") ); 144 m_gameWidget->display( tr("Game paused.\nPress P to continue!") );
144 stopLevel(); 145 stopLevel();
145 break; 146 break;
146 147
147 case Paused: 148 case Paused:
148 case Suspend: 149 case Suspend:
149 m_state = Running; 150 m_state = Running;
150 m_gameWidget->display( QString::null ); 151 m_gameWidget->display( QString::null );
151 startLevel(); 152 startLevel();
152 break; 153 break;
153 154
154 case Idle: 155 case Idle:
155 break; 156 break;
156 } 157 }
157} 158}
158 159
159void KJezzball::gameOver() 160void KJezzball::gameOver()
160{ 161{
161 stopLevel(); 162 stopLevel();
162 m_gameOverTimer->start( 100, TRUE ); 163 m_gameOverTimer->start( 100, TRUE );
163} 164}
164 165
165 166
166void KJezzball::gameOverNow() 167void KJezzball::gameOverNow()
167{ 168{
168 m_state = Idle; 169 m_state = Idle;
169 170
170 QString score; 171 QString score;
171 score.setNum( m_game.score ); 172 score.setNum( m_game.score );
172 QMessageBox::information( this, "Game Over", tr("Game Over!\nScore: %1").arg(score) ); 173 QMessageBox::information( this, "Game Over", tr("Game Over!\nScore: %1").arg(score) );
173} 174}
174 175
175void KJezzball::focusOutEvent( QFocusEvent *ev ) 176void KJezzball::focusOutEvent( QFocusEvent *ev )
176{ 177{
177 if ( m_state==Running ) 178 if ( m_state==Running )
178 { 179 {
179 stopLevel(); 180 stopLevel();
180 m_state = Suspend; 181 m_state = Suspend;
181 } 182 }
182 183
183 QMainWindow::focusOutEvent( ev ); 184 QMainWindow::focusOutEvent( ev );
184} 185}
185 186
186void KJezzball::focusInEvent ( QFocusEvent *ev ) 187void KJezzball::focusInEvent ( QFocusEvent *ev )
187{ 188{
188 if ( m_state==Suspend ) 189 if ( m_state==Suspend )
189 { 190 {
190 startLevel(); 191 startLevel();
191 m_state = Running; 192 m_state = Running;
192 } 193 }
193 194
194 QMainWindow::focusInEvent( ev ); 195 QMainWindow::focusInEvent( ev );
195} 196}
196 197
197void KJezzball::second() 198void KJezzball::second()
198{ 199{
199 m_level.time--; 200 m_level.time--;
200 TimeLabel->setText( tr( "Time: %1" ).arg(m_level.time) ); 201 TimeLabel->setText( tr( "Time: %1" ).arg(m_level.time) );
201 if ( m_level.time<=0 ) 202 if ( m_level.time<=0 )
202 { 203 {
203 gameOver(); 204 gameOver();
204 } 205 }
205} 206}
206 207
207void KJezzball::died() 208void KJezzball::died()
208{ 209{
209 m_level.lifes--; 210 m_level.lifes--;
210 LivesLabel->setText( tr( "Lives: %1" ).arg(m_level.lifes) ); 211 LivesLabel->setText( tr( "Lives: %1" ).arg(m_level.lifes) );
211 if ( m_level.lifes==0 ) gameOver(); 212 if ( m_level.lifes==0 ) gameOver();
212} 213}
213 214
214void KJezzball::newPercent( int percent ) 215void KJezzball::newPercent( int percent )
215{ 216{
216 FilledLabel->setText( tr( "Filled: %1%" ).arg(percent) ); 217 FilledLabel->setText( tr( "Filled: %1%" ).arg(percent) );
217 if ( percent>=75 ) 218 if ( percent>=75 )
218 { 219 {
219 m_level.score = m_level.lifes*15 + (percent-75)*2*(m_game.level+5); 220 m_level.score = m_level.lifes*15 + (percent-75)*2*(m_game.level+5);
220 nextLevel(); 221 nextLevel();
221 } 222 }
222} 223}
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
@@ -1,99 +1,100 @@
1/* 1/*
2 * Copyright (C) 2000 Stefan Schimanski <1Stein@gmx.de> 2 * Copyright (C) 2000 Stefan Schimanski <1Stein@gmx.de>
3 * 3 *
4 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public 14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the Free 15 * License along with this program; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 17 */
18 18
19#ifndef KJEZZBALL_H_INCLUDED 19#ifndef KJEZZBALL_H_INCLUDED
20#define KJEZZBALL_H_INCLUDED 20#define KJEZZBALL_H_INCLUDED
21 21
22#include <qmainwindow.h> 22#include <qmainwindow.h>
23#include <qmenubar.h> 23#include <qmenubar.h>
24#include <qlabel.h> 24#include <qlabel.h>
25 25
26class JezzGame; 26class JezzGame;
27class QLCDNumber; 27class QLCDNumber;
28class QGridLayout; 28class QGridLayout;
29 29
30class KJezzball : public QMainWindow 30class KJezzball : public QMainWindow
31{ 31{
32 Q_OBJECT 32 Q_OBJECT
33 33
34public: 34public:
35 KJezzball(); 35 static QString appName() { return QString::fromLatin1("bounce"); }
36 KJezzball(QWidget *, const char*, WFlags );
36 37
37public slots: 38public slots:
38 void newGame(); 39 void newGame();
39 void pauseGame(); 40 void pauseGame();
40 void closeGame(); 41 void closeGame();
41 void about(); 42 void about();
42 43
43protected slots: 44protected slots:
44 void died(); 45 void died();
45 void newPercent( int percent ); 46 void newPercent( int percent );
46 void second(); 47 void second();
47 void switchLevel(); 48 void switchLevel();
48 void gameOverNow(); 49 void gameOverNow();
49 50
50protected: 51protected:
51 void createLevel( int level ); 52 void createLevel( int level );
52 void startLevel(); 53 void startLevel();
53 void stopLevel(); 54 void stopLevel();
54 void nextLevel(); 55 void nextLevel();
55 void gameOver(); 56 void gameOver();
56 void initXMLUI(); 57 void initXMLUI();
57 58
58 void focusOutEvent( QFocusEvent * ); 59 void focusOutEvent( QFocusEvent * );
59 void focusInEvent ( QFocusEvent * ); 60 void focusInEvent ( QFocusEvent * );
60 void keyPressEvent( QKeyEvent *ev ); 61 void keyPressEvent( QKeyEvent *ev );
61 62
62 JezzGame *m_gameWidget; 63 JezzGame *m_gameWidget;
63 QWidget *m_view; 64 QWidget *m_view;
64 QGridLayout *m_layout; 65 QGridLayout *m_layout;
65 QLCDNumber *m_levelLCD; 66 QLCDNumber *m_levelLCD;
66 QLCDNumber *m_lifesLCD; 67 QLCDNumber *m_lifesLCD;
67 QLCDNumber *m_scoreLCD; 68 QLCDNumber *m_scoreLCD;
68 QLCDNumber *m_percentLCD; 69 QLCDNumber *m_percentLCD;
69 QLCDNumber *m_timeLCD; 70 QLCDNumber *m_timeLCD;
70 71
71 QTimer *m_timer; 72 QTimer *m_timer;
72 QTimer *m_nextLevelTimer; 73 QTimer *m_nextLevelTimer;
73 QTimer *m_gameOverTimer; 74 QTimer *m_gameOverTimer;
74 75
75 enum { Idle, Running, Paused, Suspend } m_state; 76 enum { Idle, Running, Paused, Suspend } m_state;
76 77
77 struct 78 struct
78 { 79 {
79 int lifes; 80 int lifes;
80 int time; 81 int time;
81 int score; 82 int score;
82 } m_level; 83 } m_level;
83 84
84 struct 85 struct
85 { 86 {
86 int level; 87 int level;
87 int score; 88 int score;
88 } m_game; 89 } m_game;
89private: 90private:
90 QMenuBar *menu; 91 QMenuBar *menu;
91 QPopupMenu *game; 92 QPopupMenu *game;
92 QLabel* ScoreLabel; 93 QLabel* ScoreLabel;
93 QLabel* LivesLabel; 94 QLabel* LivesLabel;
94 QLabel* FilledLabel; 95 QLabel* FilledLabel;
95 QLabel* TimeLabel; 96 QLabel* TimeLabel;
96 97
97}; 98};
98 99
99#endif 100#endif
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
@@ -1,29 +1,24 @@
1/* 1/*
2 * Copyright (C) 2000 Stefan Schimanski <schimmi@kde.org> 2 * Copyright (C) 2000 Stefan Schimanski <schimmi@kde.org>
3 * 3 *
4 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public 14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the Free 15 * License along with this program; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 17 */
18 18
19#include <qpe/qpeapplication.h> 19#include <qpe/qpeapplication.h>
20#include "kbounce.h" 20#include "kbounce.h"
21#include <opie/oapplicationfactory.h>
21 22
22int main(int argc, char **argv) 23OPIE_EXPORT_APP( OApplicationFactory<KJezzball> )
23{
24 QPEApplication a( argc, argv );
25 KJezzball *top = new KJezzball;
26 a.showMainWidget(top);
27 24
28 return a.exec();
29}
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,11 +1,11 @@
1Package: opie-bounce 1Package: opie-bounce
2Files: bin/bounce apps/Games/bounce.desktop pics/bounce/*.png 2Files: plugins/application/libbounce.so* bin/bounce apps/Games/bounce.desktop pics/bounce/*.png
3Version: 0.6-$SUB_VERSION 3Version: 0.6-$SUB_VERSION
4Depends: task-opie-minimal 4Depends: task-opie-minimal
5Priority: optional 5Priority: optional
6Section: opie/games 6Section: opie/games
7Maintainer: Martin Imobersteg <imm@gmx.ch> 7Maintainer: Martin Imobersteg <imm@gmx.ch>
8Architecture: arm 8Architecture: arm
9License: GPL 9License: GPL
10Description: bounce 10Description: bounce
11 A JezzGame like game for Qtopia. 11 A JezzGame like game for Qtopia.
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
@@ -1,182 +1,182 @@
1/* 1/*
2 * Copyright (C) 2002 Martin Imobersteg <imm@gmx.ch> 2 * Copyright (C) 2002 Martin Imobersteg <imm@gmx.ch>
3 * 3 *
4 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public 5 * modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License,Life or (at your option) any later version. 7 * version 2 of the License,Life or (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public 14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the Free 15 * License along with this program; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 17 */
18 18
19#include <qlayout.h> 19#include <qlayout.h>
20#include <qmessagebox.h> 20#include <qmessagebox.h>
21#include <qmainwindow.h> 21#include <qmainwindow.h>
22#include <qlabel.h> 22#include <qlabel.h>
23#include <qgrid.h> 23#include <qgrid.h>
24#include <qcolor.h> 24#include <qcolor.h>
25#include <qbutton.h> 25#include <qbutton.h>
26#include <qfile.h> 26#include <qfile.h>
27#include <qtextstream.h> 27#include <qtextstream.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <qmessagebox.h> 29#include <qmessagebox.h>
30#include <qdir.h> 30#include <qdir.h>
31 31
32#include <math.h> 32#include <math.h>
33#include <stdlib.h> 33#include <stdlib.h>
34 34
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36 36
37#include "buzzword.h" 37#include "buzzword.h"
38 38
39BuzzLabel::BuzzLabel( QWidget *parent, const char *name ) 39BuzzLabel::BuzzLabel( QWidget *parent, const char *name )
40: QLabel( parent, name ) 40: QLabel( parent, name )
41{ 41{
42} 42}
43 43
44void BuzzLabel::mousePressEvent(QMouseEvent *e) 44void BuzzLabel::mousePressEvent(QMouseEvent *e)
45{ 45{
46 if(e->button() == LeftButton) 46 if(e->button() == LeftButton)
47 { 47 {
48 emit clicked(); 48 emit clicked();
49 } 49 }
50} 50}
51 51
52BuzzItem::BuzzItem( int row, int column, QString text, QWidget *parent, const char *name ) 52BuzzItem::BuzzItem( int row, int column, QString text, QWidget *parent, const char *name )
53: QVBox( parent, name ), _row(row), _column(column) 53: QVBox( parent, name ), _row(row), _column(column)
54{ 54{
55 setFrameStyle( QFrame::Panel | QFrame::Raised ); 55 setFrameStyle( QFrame::Panel | QFrame::Raised );
56 setLineWidth( 1 ); 56 setLineWidth( 1 );
57 label = new BuzzLabel(this, "label"); 57 label = new BuzzLabel(this, "label");
58 label->setText(text); 58 label->setText(text);
59 label->setAlignment( int( QLabel::AlignCenter ) ); 59 label->setAlignment( int( QLabel::AlignCenter ) );
60 60
61 connect( label, SIGNAL(clicked()), this, SLOT(flip()) ); 61 connect( label, SIGNAL(clicked()), this, SLOT(flip()) );
62} 62}
63 63
64void BuzzItem::flip() 64void BuzzItem::flip()
65{ 65{
66 setLineWidth( 1 ); 66 setLineWidth( 1 );
67 label->setBackgroundColor(label->colorGroup().highlight()); 67 label->setBackgroundColor(label->colorGroup().highlight());
68 emit clicked(_row, _column); 68 emit clicked(_row, _column);
69} 69}
70 70
71BuzzWord::BuzzWord() : QMainWindow(0) 71BuzzWord::BuzzWord(QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl )
72{ 72{
73 setCaption(tr("buZzword")); 73 setCaption(tr("buZzword"));
74 74
75 menu = menuBar(); 75 menu = menuBar();
76 game = new QPopupMenu; 76 game = new QPopupMenu;
77 game->insertItem(tr("&New game"), this, SLOT(newGame()), Key_N ); 77 game->insertItem(tr("&New game"), this, SLOT(newGame()), Key_N );
78 menu->insertItem( tr("&Game"), game ); 78 menu->insertItem( tr("&Game"), game );
79 79
80 gridVal = 4; 80 gridVal = 4;
81 grid = NULL; 81 grid = NULL;
82 gameOver = false; 82 gameOver = false;
83 newGame(); 83 newGame();
84} 84}
85 85
86void BuzzWord::drawGrid() 86void BuzzWord::drawGrid()
87{ 87{
88 QStringList l; 88 QStringList l;
89 89
90 QString path = QPEApplication::qpeDir()+"share/buzzword/"; 90 QString path = QPEApplication::qpeDir()+"share/buzzword/";
91 QFile f( path + "buzzwords" ); 91 QFile f( path + "buzzwords" );
92 if ( !f.open( IO_ReadOnly ) ) 92 if ( !f.open( IO_ReadOnly ) )
93 return; 93 return;
94 94
95 QTextStream t( &f ); 95 QTextStream t( &f );
96 96
97 while (!t.atEnd()) 97 while (!t.atEnd())
98 { 98 {
99 l << t.readLine(); 99 l << t.readLine();
100 } 100 }
101 101
102 f.close(); 102 f.close();
103 103
104 grid = new QGrid(gridVal, this); 104 grid = new QGrid(gridVal, this);
105 //grid->setFixedSize( 480, 480 ); 105 //grid->setFixedSize( 480, 480 );
106 106
107 for( int c = 0 ; c < gridVal ; c++ ) 107 for( int c = 0 ; c < gridVal ; c++ )
108 { 108 {
109 for( int r = 0 ; r < gridVal ; r++ ) 109 for( int r = 0 ; r < gridVal ; r++ )
110 { 110 {
111 uint pos = rand() % l. count(); 111 uint pos = rand() % l. count();
112 112
113 QString word = QStringList::split(" ", l[pos]).join("\n"); 113 QString word = QStringList::split(" ", l[pos]).join("\n");
114 BuzzItem* bi = new BuzzItem( c, r, word, grid ); 114 BuzzItem* bi = new BuzzItem( c, r, word, grid );
115 connect( bi, SIGNAL(clicked(int, int)), this, SLOT(clicked(int,int)) ); 115 connect( bi, SIGNAL(clicked(int, int)), this, SLOT(clicked(int,int)) );
116 map[c][r] = 0; 116 map[c][r] = 0;
117 117
118 l.remove( l.at( pos )); 118 l.remove( l.at( pos ));
119 } 119 }
120 } 120 }
121} 121}
122 122
123void BuzzWord::clicked(int row, int column) 123void BuzzWord::clicked(int row, int column)
124{ 124{
125 if ( ! gameOver ) 125 if ( ! gameOver )
126 { 126 {
127 int rowTotal = 0; 127 int rowTotal = 0;
128 int columnTotal = 0; 128 int columnTotal = 0;
129 129
130 map[column][row] = 1; 130 map[column][row] = 1;
131 131
132 for( int c = 0 ; c < gridVal ; c++ ) 132 for( int c = 0 ; c < gridVal ; c++ )
133 { 133 {
134 for( int r = 0 ; r < gridVal ; r++ ) 134 for( int r = 0 ; r < gridVal ; r++ )
135 { 135 {
136 if ( map[c][r] == 1 ) 136 if ( map[c][r] == 1 )
137 rowTotal++; 137 rowTotal++;
138 138
139 if ( rowTotal == 4 ) 139 if ( rowTotal == 4 )
140 { 140 {
141 bingo(); 141 bingo();
142 } 142 }
143 } 143 }
144 rowTotal = 0; 144 rowTotal = 0;
145 } 145 }
146 146
147 for( int r = 0 ; r < gridVal ; r++ ) 147 for( int r = 0 ; r < gridVal ; r++ )
148 { 148 {
149 for( int c = 0 ; c < gridVal ; c++ ) 149 for( int c = 0 ; c < gridVal ; c++ )
150 { 150 {
151 if ( map[c][r] == 1 ) 151 if ( map[c][r] == 1 )
152 columnTotal++; 152 columnTotal++;
153 153
154 if ( columnTotal == 4 ) 154 if ( columnTotal == 4 )
155 { 155 {
156 bingo(); 156 bingo();
157 } 157 }
158 } 158 }
159 columnTotal = 0; 159 columnTotal = 0;
160 } 160 }
161 161
162 if ( map[0][0] && map[1][1] && map[2][2] && map[3][3] ) 162 if ( map[0][0] && map[1][1] && map[2][2] && map[3][3] )
163 bingo(); 163 bingo();
164 164
165 if ( map[0][3] && map[1][2] && map[2][1] && map[3][0] ) 165 if ( map[0][3] && map[1][2] && map[2][1] && map[3][0] )
166 bingo(); 166 bingo();
167 } 167 }
168} 168}
169 169
170void BuzzWord::bingo() 170void BuzzWord::bingo()
171{ 171{
172 gameOver = true; 172 gameOver = true;
173 QMessageBox::information( this, "BUZZWORD", tr("<h1><b>BINGO !</b></h1>")); 173 QMessageBox::information( this, "BUZZWORD", tr("<h1><b>BINGO !</b></h1>"));
174} 174}
175 175
176void BuzzWord::newGame() 176void BuzzWord::newGame()
177{ 177{
178 gameOver = false; 178 gameOver = false;
179 delete grid; 179 delete grid;
180 drawGrid(); 180 drawGrid();
181 setCentralWidget(grid); 181 setCentralWidget(grid);
182} 182}
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
@@ -1,88 +1,89 @@
1/* 1/*
2 * Copyright (C) 2002 Martin Imobersteg <imm@gmx.ch> 2 * Copyright (C) 2002 Martin Imobersteg <imm@gmx.ch>
3 * 3 *
4 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public 5 * modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License,Life or (at your option) any later version. 7 * version 2 of the License,Life or (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public 14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the Free 15 * License along with this program; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 17 */
18 18
19#ifndef BUZZWORD_H 19#ifndef BUZZWORD_H
20#define BUZZWORD_H 20#define BUZZWORD_H
21 21
22#include <qmainwindow.h> 22#include <qmainwindow.h>
23#include <qmenubar.h> 23#include <qmenubar.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qvbox.h> 25#include <qvbox.h>
26 26
27class QGrid; 27class QGrid;
28 28
29class BuzzLabel : public QLabel 29class BuzzLabel : public QLabel
30{ 30{
31 Q_OBJECT 31 Q_OBJECT
32 32
33public: 33public:
34 BuzzLabel( QWidget *parent=0, const char *name=0 ); 34 BuzzLabel( QWidget *parent=0, const char *name=0 );
35 35
36protected: 36protected:
37 virtual void mousePressEvent(QMouseEvent *e); 37 virtual void mousePressEvent(QMouseEvent *e);
38 38
39signals: 39signals:
40 void clicked(); 40 void clicked();
41}; 41};
42 42
43class BuzzItem : public QVBox 43class BuzzItem : public QVBox
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46 46
47public: 47public:
48 BuzzItem( int row, int column, QString text, QWidget *parent=0, const char *name=0 ); 48 BuzzItem( int row, int column, QString text, QWidget *parent=0, const char *name=0 );
49 49
50private: 50private:
51 QLabel* label; 51 QLabel* label;
52 int _row; 52 int _row;
53 int _column; 53 int _column;
54 54
55public slots: 55public slots:
56 void flip(); 56 void flip();
57 57
58signals: 58signals:
59 void clicked(int row,int column); 59 void clicked(int row,int column);
60}; 60};
61 61
62class BuzzWord : public QMainWindow 62class BuzzWord : public QMainWindow
63{ 63{
64 Q_OBJECT 64 Q_OBJECT
65 65
66public: 66public:
67 BuzzWord(); 67 BuzzWord( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
68 static QString appName() { return QString::fromLatin1("buzzword"); }
68 69
69private: 70private:
70 void drawGrid(); 71 void drawGrid();
71 void bingo(); 72 void bingo();
72 QString getWord(); 73 QString getWord();
73 74
74 QMenuBar *menu; 75 QMenuBar *menu;
75 QPopupMenu *game; 76 QPopupMenu *game;
76 QGrid *grid; 77 QGrid *grid;
77 78
78 int gridVal; 79 int gridVal;
79 int map[4][4]; 80 int map[4][4];
80 bool gameOver; 81 bool gameOver;
81 82
82public slots: 83public slots:
83 void newGame(); 84 void newGame();
84 void clicked(int row, int column); 85 void clicked(int row, int column);
85 86
86}; 87};
87 88
88#endif 89#endif
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 @@
1 TEMPLATE= app 1 CONFIG = qt warn_on release quick-app
2 CONFIG = qt warn_on release
3 HEADERS = buzzword.h 2 HEADERS = buzzword.h
4 SOURCES = buzzword.cpp main.cpp 3 SOURCES = buzzword.cpp main.cpp
5 INCLUDEPATH+= $(OPIEDIR)/include 4 INCLUDEPATH+= $(OPIEDIR)/include
6 DEPENDPATH+= $(OPIEDIR)/include 5 DEPENDPATH+= $(OPIEDIR)/include
7DESTDIR = $(OPIEDIR)/bin
8LIBS += -lqpe 6LIBS += -lqpe
9 TARGET = buzzword 7
8 TARGET = buzzword
10 9
11include ( $(OPIEDIR)/include.pro ) 10include ( $(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
@@ -1,35 +1,24 @@
1/* 1/*
2 * Copyright (C) 2002 Martin Imobersteg <imm@gmx.ch> 2 * Copyright (C) 2002 Martin Imobersteg <imm@gmx.ch>
3 * 3 *
4 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public 5 * modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License,Life or (at your option) any later version. 7 * version 2 of the License,Life or (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public 14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the Free 15 * License along with this program; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 17 */
18 18
19#include <qpe/qpeapplication.h> 19#include <qpe/qpeapplication.h>
20 20#include <opie/oapplicationfactory.h>
21#include <stdlib.h>
22#include <time.h>
23 21
24#include "buzzword.h" 22#include "buzzword.h"
25 23
26int main(int argc, char **argv) 24OPIE_EXPORT_APP( OApplicationFactory<BuzzWord> )
27{
28 srand(time(0));
29
30 QPEApplication a( argc, argv );
31 BuzzWord *top = new BuzzWord;
32 a.showMainWidget(top);
33
34 return a.exec();
35}
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,11 +1,11 @@
1Package: opie-buzzword 1Package: opie-buzzword
2Files: bin/buzzword apps/Games/buzzword.desktop pics/buzzword/buzzword.png share/buzzword/buzzwords 2Files: plugins/application/libbuzzword.so* bin/buzzword apps/Games/buzzword.desktop pics/buzzword/buzzword.png share/buzzword/buzzwords
3Version: 1.1-$SUB_VERSION 3Version: 1.1-$SUB_VERSION
4Depends: task-opie-minimal 4Depends: task-opie-minimal
5Priority: optional 5Priority: optional
6Section: opie/games 6Section: opie/games
7Maintainer: Martin Imobersteg <imm@gmx.ch> 7Maintainer: Martin Imobersteg <imm@gmx.ch>
8Architecture: arm 8Architecture: arm
9License: GPL 9License: GPL
10Description: BuzzWord 10Description: BuzzWord
11 A BuzzWord Bingo for Qtopia. 11 A BuzzWord Bingo for Qtopia.
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,11 +1,11 @@
1Package: opie-fifteen 1Package: opie-fifteen
2Files: bin/fifteen apps/Games/fifteen.desktop pics/fifteen 2Files: plugins/application/libfifteen.so* bin/fifteen apps/Games/fifteen.desktop pics/fifteen
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Martin Imobersteg <imm@gmx.ch> 5Maintainer: Martin Imobersteg <imm@gmx.ch>
6Architecture: arm 6Architecture: arm
7Arch: iPAQ 7Arch: iPAQ
8Depends: task-opie-minimal 8Depends: task-opie-minimal
9Description: Fifteen pieces game 9Description: Fifteen pieces game
10 A game for the Opie environment. 10 A game for the Opie environment.
11Version: $QPE_VERSION$EXTRAVERSION 11Version: $QPE_VERSION$EXTRAVERSION
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,19 +1,19 @@
1 DESTDIR = $(OPIEDIR)/bin 1 CONFIG = qt warn_on release quick-app
2 TEMPLATE= app
3 CONFIG = qt warn_on release
4 HEADERS = amigo.h \ 2 HEADERS = amigo.h \
5 go.h \ 3 go.h \
6 goplayutils.h \ 4 goplayutils.h \
7 gowidget.h 5 gowidget.h
8 SOURCES = amigo.c \ 6 SOURCES = amigo.c \
9 goplayer.c \ 7 goplayer.c \
10 goplayutils.c \ 8 goplayutils.c \
11 killable.c \ 9 killable.c \
12 gowidget.cpp \ 10 gowidget.cpp \
13 main.cpp 11 main.cpp
14INCLUDEPATH += $(OPIEDIR)/include 12INCLUDEPATH += $(OPIEDIR)/include
15 DEPENDPATH+= $(OPIEDIR)/include 13 DEPENDPATH+= $(OPIEDIR)/include
16LIBS += -lqpe 14LIBS += -lqpe
17 TARGET = go 15 TARGET = go
18 16
17
18
19include ( $(OPIEDIR)/include.pro ) 19include ( $(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
@@ -1,247 +1,247 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "gowidget.h" 21#include "gowidget.h"
22 22
23#include <qpe/config.h> 23#include <qpe/config.h>
24#include <qpe/resource.h> 24#include <qpe/resource.h>
25 25
26#include <qpainter.h> 26#include <qpainter.h>
27#include <qpixmap.h> 27#include <qpixmap.h>
28#include <qpe/qpetoolbar.h> 28#include <qpe/qpetoolbar.h>
29#include <qmenubar.h> 29#include <qmenubar.h>
30#include <qpopupmenu.h> 30#include <qpopupmenu.h>
31#include <qaction.h> 31#include <qaction.h>
32#include <qapplication.h> //processEvents() 32#include <qapplication.h> //processEvents()
33#include <qlabel.h> 33#include <qlabel.h>
34 34
35//#include <stdio.h> 35//#include <stdio.h>
36 36
37#include "amigo.h" 37#include "amigo.h"
38#include "goplayutils.h" 38#include "goplayutils.h"
39 39
40static const enum bVal computer_color = BLACK; 40static const enum bVal computer_color = BLACK;
41 41
42static int current_handicap = 1; 42static int current_handicap = 1;
43 43
44static QBrush *goBrush; 44static QBrush *goBrush;
45//static QImage *newBlackStone; 45//static QImage *newBlackStone;
46//static QImage *blackStone; 46//static QImage *blackStone;
47//static QImage *whiteStone; 47//static QImage *whiteStone;
48static QPixmap *newBlackStone; 48static QPixmap *newBlackStone;
49static QPixmap *blackStone; 49static QPixmap *blackStone;
50static QPixmap *whiteStone; 50static QPixmap *whiteStone;
51 51
52static bool smallStones = FALSE; 52static bool smallStones = FALSE;
53 53
54GoMainWidget::GoMainWidget( QWidget *parent, const char* name) : 54GoMainWidget::GoMainWidget( QWidget *parent, const char* name, WFlags fl) :
55 QMainWindow( parent, name ) 55 QMainWindow( parent, name, fl )
56{ 56{
57 setToolBarsMovable( FALSE ); 57 setToolBarsMovable( FALSE );
58 GoWidget *go = new GoWidget(this); 58 GoWidget *go = new GoWidget(this);
59 59
60 setCentralWidget(go); 60 setCentralWidget(go);
61 toolbar = new QToolBar(this); 61 toolbar = new QToolBar(this);
62 toolbar->setHorizontalStretchable( TRUE ); 62 toolbar->setHorizontalStretchable( TRUE );
63 addToolBar(toolbar); 63 addToolBar(toolbar);
64 64
65 QMenuBar *mb = new QMenuBar( toolbar ); 65 QMenuBar *mb = new QMenuBar( toolbar );
66 mb->setMargin(0); 66 mb->setMargin(0);
67 QPopupMenu *file = new QPopupMenu( this ); 67 QPopupMenu *file = new QPopupMenu( this );
68 68
69 QAction *a = new QAction( tr( "New Game" ), QString::null, 0, this, 0 ); 69 QAction *a = new QAction( tr( "New Game" ), QString::null, 0, this, 0 );
70 connect( a, SIGNAL( activated() ), go, SLOT( newGame() ) ); 70 connect( a, SIGNAL( activated() ), go, SLOT( newGame() ) );
71 a->addTo( file ); 71 a->addTo( file );
72 72
73 a = new QAction( tr( "Pass" ), Resource::loadPixmap( "pass" ), QString::null, 0, this, 0 ); 73 a = new QAction( tr( "Pass" ), Resource::loadPixmap( "pass" ), QString::null, 0, this, 0 );
74 connect( a, SIGNAL( activated() ), go, SLOT( pass() ) ); 74 connect( a, SIGNAL( activated() ), go, SLOT( pass() ) );
75 a->addTo( file ); 75 a->addTo( file );
76 a->addTo( toolbar ); 76 a->addTo( toolbar );
77 77
78 78
79 a = new QAction( tr( "Resign" ), Resource::loadPixmap( "reset" ), QString::null, 0, this, 0 ); 79 a = new QAction( tr( "Resign" ), Resource::loadPixmap( "reset" ), QString::null, 0, this, 0 );
80 connect( a, SIGNAL( activated() ), go, SLOT( resign() ) ); 80 connect( a, SIGNAL( activated() ), go, SLOT( resign() ) );
81 a->addTo( file ); 81 a->addTo( file );
82 82
83 a = new QAction( tr( "Two player option" ), QString::null, 0, this, 0 ); 83 a = new QAction( tr( "Two player option" ), QString::null, 0, this, 0 );
84 a->setToggleAction( TRUE ); 84 a->setToggleAction( TRUE );
85 connect( a, SIGNAL( toggled(bool) ), go, SLOT( setTwoplayer(bool) ) ); 85 connect( a, SIGNAL( toggled(bool) ), go, SLOT( setTwoplayer(bool) ) );
86 a->addTo( file ); 86 a->addTo( file );
87 87
88 mb->insertItem( tr( "Game" ), file ); 88 mb->insertItem( tr( "Game" ), file );
89 89
90 QLabel *turnLabel = new QLabel( toolbar ); 90 QLabel *turnLabel = new QLabel( toolbar );
91 turnLabel->setBackgroundMode( PaletteButton ); 91 turnLabel->setBackgroundMode( PaletteButton );
92 connect( go, SIGNAL(showTurn(const QPixmap&)), 92 connect( go, SIGNAL(showTurn(const QPixmap&)),
93 turnLabel, SLOT(setPixmap(const QPixmap&)) ); 93 turnLabel, SLOT(setPixmap(const QPixmap&)) );
94 94
95 95
96 QLabel * scoreLabel = new QLabel( toolbar ); 96 QLabel * scoreLabel = new QLabel( toolbar );
97 scoreLabel->setBackgroundMode( PaletteButton ); 97 scoreLabel->setBackgroundMode( PaletteButton );
98 connect( go, SIGNAL(showScore(const QString&)), 98 connect( go, SIGNAL(showScore(const QString&)),
99 scoreLabel, SLOT(setText(const QString&)) ); 99 scoreLabel, SLOT(setText(const QString&)) );
100 100
101 toolbar->setStretchableWidget( scoreLabel ); 101 toolbar->setStretchableWidget( scoreLabel );
102 102
103 go->readConfig(); 103 go->readConfig();
104} 104}
105 105
106void GoMainWidget::resizeEvent( QResizeEvent * ) 106void GoMainWidget::resizeEvent( QResizeEvent * )
107{ 107{
108 //### this won't work because of the text label... 108 //### this won't work because of the text label...
109 /* 109 /*
110 if ( width() > height() ) 110 if ( width() > height() )
111 moveToolBar( toolbar, Left ); 111 moveToolBar( toolbar, Left );
112 else 112 else
113 moveToolBar( toolbar, Top ); 113 moveToolBar( toolbar, Top );
114 */ 114 */
115} 115}
116 116
117GoWidget *GoWidget::self = 0; 117GoWidget *GoWidget::self = 0;
118 118
119GoWidget::GoWidget( QWidget *parent, const char* name) : 119GoWidget::GoWidget( QWidget *parent, const char* name) :
120 QWidget( parent, name ) 120 QWidget( parent, name )
121{ 121{
122 if ( self ) 122 if ( self )
123 fatal( "Only one Go widget allowed" ); 123 fatal( "Only one Go widget allowed" );
124 self = this; 124 self = this;
125 twoplayer = FALSE; 125 twoplayer = FALSE;
126 126
127 127
128 d = bx = by = 1; 128 d = bx = by = 1;
129 129
130 QPixmap pix = Resource::loadPixmap( "go/pine" ); 130 QPixmap pix = Resource::loadPixmap( "go/pine" );
131 goBrush = new QBrush( black, pix ); 131 goBrush = new QBrush( black, pix );
132 /* 132 /*
133 QString fn = Resource::findPixmap("Go-black"); 133 QString fn = Resource::findPixmap("Go-black");
134 blackStone = new QImage( fn ); 134 blackStone = new QImage( fn );
135 fn = Resource::findPixmap("Go-black-highlight"); 135 fn = Resource::findPixmap("Go-black-highlight");
136 newBlackStone = new QImage( fn ); 136 newBlackStone = new QImage( fn );
137 fn = Resource::findPixmap("Go-white"); 137 fn = Resource::findPixmap("Go-white");
138 whiteStone = new QImage( fn ); 138 whiteStone = new QImage( fn );
139 */ 139 */
140 blackStone = new QPixmap(Resource::loadPixmap( "Go-black" )); 140 blackStone = new QPixmap(Resource::loadPixmap( "Go-black" ));
141 whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" )); 141 whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" ));
142 newBlackStone = new QPixmap(Resource::loadPixmap( "Go-black-highlight" )); 142 newBlackStone = new QPixmap(Resource::loadPixmap( "Go-black-highlight" ));
143 143
144 init(); 144 init();
145} 145}
146 146
147GoWidget::~GoWidget() 147GoWidget::~GoWidget()
148{ 148{
149 writeConfig(); 149 writeConfig();
150} 150}
151 151
152void GoWidget::writeConfig() 152void GoWidget::writeConfig()
153{ 153{
154 Config cfg("Go"); 154 Config cfg("Go");
155 cfg.setGroup("Game"); 155 cfg.setGroup("Game");
156 cfg.writeEntry("TwoPlayer", twoplayer); 156 cfg.writeEntry("TwoPlayer", twoplayer);
157 cfg.writeEntry("CurrentPlayer", currentPlayer); 157 cfg.writeEntry("CurrentPlayer", currentPlayer);
158 cfg.writeEntry("NPassed", nPassed); 158 cfg.writeEntry("NPassed", nPassed);
159 QString b; 159 QString b;
160 for (int i=0; i<19; i++) 160 for (int i=0; i<19; i++)
161 for (int j=0; j<19; j++) 161 for (int j=0; j<19; j++)
162 b += board[i][j] == BLACK ? 'B' : board[i][j] == WHITE ? 'W' : '.'; 162 b += board[i][j] == BLACK ? 'B' : board[i][j] == WHITE ? 'W' : '.';
163 cfg.writeEntry("Board", b); 163 cfg.writeEntry("Board", b);
164 cfg.writeEntry("LastX", lastX); 164 cfg.writeEntry("LastX", lastX);
165 cfg.writeEntry("LastY", lastY); 165 cfg.writeEntry("LastY", lastY);
166 extern int blackPrisoners, whitePrisoners; 166 extern int blackPrisoners, whitePrisoners;
167 cfg.writeEntry("BlackPrisoners", blackPrisoners); 167 cfg.writeEntry("BlackPrisoners", blackPrisoners);
168 cfg.writeEntry("WhitePrisoners", whitePrisoners); 168 cfg.writeEntry("WhitePrisoners", whitePrisoners);
169} 169}
170 170
171void GoWidget::readConfig() 171void GoWidget::readConfig()
172{ 172{
173 init(); 173 init();
174 Config cfg("Go"); 174 Config cfg("Go");
175 cfg.setGroup("Game"); 175 cfg.setGroup("Game");
176 twoplayer = cfg.readBoolEntry("TwoPlayer"); 176 twoplayer = cfg.readBoolEntry("TwoPlayer");
177 currentPlayer = (bVal)cfg.readNumEntry("CurrentPlayer",1); 177 currentPlayer = (bVal)cfg.readNumEntry("CurrentPlayer",1);
178 nPassed = cfg.readNumEntry("NPassed",0); 178 nPassed = cfg.readNumEntry("NPassed",0);
179 QString b = cfg.readEntry("Board"); 179 QString b = cfg.readEntry("Board");
180 if ( b.length() == 19*19 ) 180 if ( b.length() == 19*19 )
181 for (int i=0; i<19; i++) 181 for (int i=0; i<19; i++)
182 for (int j=0; j<19; j++) { 182 for (int j=0; j<19; j++) {
183 QChar ch = b[j+19*i]; 183 QChar ch = b[j+19*i];
184 if ( ch != '.' ) 184 if ( ch != '.' )
185 GoPlaceStone( ch == 'B' ? BLACK : WHITE, i, j ); 185 GoPlaceStone( ch == 'B' ? BLACK : WHITE, i, j );
186 } 186 }
187 lastX = cfg.readNumEntry("LastX"); 187 lastX = cfg.readNumEntry("LastX");
188 lastY = cfg.readNumEntry("LastY"); 188 lastY = cfg.readNumEntry("LastY");
189 extern int blackPrisoners, whitePrisoners; 189 extern int blackPrisoners, whitePrisoners;
190 blackPrisoners = cfg.readNumEntry("BlackPrisoners",0); 190 blackPrisoners = cfg.readNumEntry("BlackPrisoners",0);
191 whitePrisoners = cfg.readNumEntry("WhitePrisoners",0); 191 whitePrisoners = cfg.readNumEntry("WhitePrisoners",0);
192 reportPrisoners(blackPrisoners,whitePrisoners); 192 reportPrisoners(blackPrisoners,whitePrisoners);
193 emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone ); 193 emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone );
194} 194}
195 195
196void GoWidget::resizeEvent( QResizeEvent * ) 196void GoWidget::resizeEvent( QResizeEvent * )
197{ 197{
198 d = QMIN(width(),height())/19; 198 d = QMIN(width(),height())/19;
199 // int r = (d/2-1); 199 // int r = (d/2-1);
200 bx = (width() - 18*d)/2 ; 200 bx = (width() - 18*d)/2 ;
201 by = (height() - 18*d)/2 ; 201 by = (height() - 18*d)/2 ;
202 202
203 if ( d < 10 && !smallStones ) { 203 if ( d < 10 && !smallStones ) {
204 blackStone->convertFromImage( blackStone->convertToImage().smoothScale(8,8) ); 204 blackStone->convertFromImage( blackStone->convertToImage().smoothScale(8,8) );
205 whiteStone->convertFromImage( whiteStone->convertToImage().smoothScale(8,8) ); 205 whiteStone->convertFromImage( whiteStone->convertToImage().smoothScale(8,8) );
206 newBlackStone->convertFromImage( newBlackStone->convertToImage().smoothScale(8,8) ); 206 newBlackStone->convertFromImage( newBlackStone->convertToImage().smoothScale(8,8) );
207 207
208 smallStones = TRUE; 208 smallStones = TRUE;
209 } else if ( d >= 10 && smallStones ) { 209 } else if ( d >= 10 && smallStones ) {
210 blackStone = new QPixmap(Resource::loadPixmap( "Go-black" )); 210 blackStone = new QPixmap(Resource::loadPixmap( "Go-black" ));
211 whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" )); 211 whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" ));
212 newBlackStone = new QPixmap(Resource::loadPixmap( "Go-black-highlight" )); 212 newBlackStone = new QPixmap(Resource::loadPixmap( "Go-black-highlight" ));
213 smallStones = FALSE; 213 smallStones = FALSE;
214 } 214 }
215} 215}
216 216
217void GoWidget::init() 217void GoWidget::init()
218{ 218{
219 lastX = lastY = newX = newY = -1; 219 lastX = lastY = newX = newY = -1;
220 nPassed = 0; 220 nPassed = 0;
221 for ( int i = 0; i < 19; i++ ) 221 for ( int i = 0; i < 19; i++ )
222 for ( int j = 0; j < 19; j++ ) 222 for ( int j = 0; j < 19; j++ )
223 board[i][j]=-1; 223 board[i][j]=-1;
224 gameActive = TRUE; 224 gameActive = TRUE;
225 goRestart(current_handicap); 225 goRestart(current_handicap);
226 226
227 if ( twoplayer ) { 227 if ( twoplayer ) {
228 currentPlayer = BLACK; 228 currentPlayer = BLACK;
229 } else { 229 } else {
230 doComputerMove(); 230 doComputerMove();
231 currentPlayer = WHITE; 231 currentPlayer = WHITE;
232 } 232 }
233 emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone ); 233 emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone );
234} 234}
235 235
236void GoWidget::paintEvent( QPaintEvent *e ) 236void GoWidget::paintEvent( QPaintEvent *e )
237{ 237{
238 int i,j; 238 int i,j;
239 239
240 int r = whiteStone->width()/2; 240 int r = whiteStone->width()/2;
241 241
242 QPainter p(this); 242 QPainter p(this);
243 p.fillRect( bx - d/2, by - d/2, 19*d, 19*d, *goBrush ); 243 p.fillRect( bx - d/2, by - d/2, 19*d, 19*d, *goBrush );
244 244
245 int xMin = QMAX( x2board(e->rect().left()), 0 ); 245 int xMin = QMAX( x2board(e->rect().left()), 0 );
246 int xMax = QMIN( x2board(e->rect().right()), 18 ); 246 int xMax = QMIN( x2board(e->rect().right()), 18 );
247 int yMin = QMAX( y2board(e->rect().top()), 0 ); 247 int yMin = QMAX( y2board(e->rect().top()), 0 );
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
@@ -1,111 +1,112 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#ifndef GOWIDGET_H 21#ifndef GOWIDGET_H
22#define GOWIDGET_H 22#define GOWIDGET_H
23 23
24#include <qmainwindow.h> 24#include <qmainwindow.h>
25#include "amigo.h" 25#include "amigo.h"
26 26
27 27
28class QToolBar; 28class QToolBar;
29 29
30class GoMainWidget : public QMainWindow 30class GoMainWidget : public QMainWindow
31{ 31{
32 Q_OBJECT 32 Q_OBJECT
33public: 33public:
34 GoMainWidget( QWidget *parent=0, const char* name=0); 34 static QString appName() { return QString::fromLatin1("go"); }
35 GoMainWidget( QWidget *parent=0, const char* name=0, WFlags fl = 0);
35protected: 36protected:
36 void resizeEvent( QResizeEvent * ); 37 void resizeEvent( QResizeEvent * );
37private: 38private:
38 QToolBar *toolbar; 39 QToolBar *toolbar;
39 40
40}; 41};
41 42
42 43
43class QLabel; 44class QLabel;
44class GoWidget : public QWidget 45class GoWidget : public QWidget
45{ 46{
46 Q_OBJECT 47 Q_OBJECT
47public: 48public:
48 GoWidget( QWidget *parent=0, const char* name=0); 49 GoWidget( QWidget *parent=0, const char* name=0);
49 ~GoWidget(); 50 ~GoWidget();
50 51
51 void doMove( int x, int y ); 52 void doMove( int x, int y );
52 void doComputerMove(); 53 void doComputerMove();
53 54
54 void readConfig(); 55 void readConfig();
55 void writeConfig(); 56 void writeConfig();
56 57
57public slots: 58public slots:
58 void pass(); 59 void pass();
59 void resign(); 60 void resign();
60 void newGame(); 61 void newGame();
61 void setTwoplayer( bool ); 62 void setTwoplayer( bool );
62 void setHandicap( int ); 63 void setHandicap( int );
63signals: 64signals:
64 void showScore( const QString& ); 65 void showScore( const QString& );
65 void showTurn( const QPixmap& ); 66 void showTurn( const QPixmap& );
66 67
67protected: 68protected:
68 void paintEvent( QPaintEvent * ); 69 void paintEvent( QPaintEvent * );
69 void mousePressEvent( QMouseEvent * ); 70 void mousePressEvent( QMouseEvent * );
70 void mouseMoveEvent( QMouseEvent * ); 71 void mouseMoveEvent( QMouseEvent * );
71 void mouseReleaseEvent( QMouseEvent * ); 72 void mouseReleaseEvent( QMouseEvent * );
72 void resizeEvent( QResizeEvent * ); 73 void resizeEvent( QResizeEvent * );
73private: 74private:
74 void init(); 75 void init();
75 void removeStone(short x, short y); 76 void removeStone(short x, short y);
76 void placeStone (enum bVal c, short x, short y ); 77 void placeStone (enum bVal c, short x, short y );
77 78
78 void refresh( int x, int y ); 79 void refresh( int x, int y );
79 void showStone( int x, int y, enum bVal ); 80 void showStone( int x, int y, enum bVal );
80 void reportPrisoners(int,int); 81 void reportPrisoners(int,int);
81 82
82 inline int x2board( int x ) { return (x-bx+d/2)/d; } 83 inline int x2board( int x ) { return (x-bx+d/2)/d; }
83 inline int y2board( int y ) { return (y-by+d/2)/d; } 84 inline int y2board( int y ) { return (y-by+d/2)/d; }
84 85
85 void endGame(); 86 void endGame();
86 87
87 bool twoplayer; 88 bool twoplayer;
88 enum bVal currentPlayer; 89 enum bVal currentPlayer;
89 bool gameActive; 90 bool gameActive;
90 int nPassed; 91 int nPassed;
91 signed char board[19][19]; 92 signed char board[19][19];
92 93
93 int d; //distance between lines 94 int d; //distance between lines
94 int bx; //vertical baseline 95 int bx; //vertical baseline
95 int by; //horizontal baseline 96 int by; //horizontal baseline
96 97
97 int lastX,lastY; 98 int lastX,lastY;
98 int newX,newY; 99 int newX,newY;
99 100
100 static GoWidget *self; 101 static GoWidget *self;
101 102
102 friend void removestone(short x, short y); 103 friend void removestone(short x, short y);
103 friend voidintrPrisonerReport( short, short ); 104 friend voidintrPrisonerReport( short, short );
104 friend void placestone(enum bVal c, short x, short y ); 105 friend void placestone(enum bVal c, short x, short y );
105}; 106};
106 107
107 108
108 109
109 110
110 111
111#endif 112#endif
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
@@ -1,35 +1,28 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "gowidget.h" 21#include "gowidget.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24 24
25#include <stdio.h> 25#include <opie/oapplicationfactory.h>
26
27OPIE_EXPORT_APP( OApplicationFactory<GoMainWidget> )
26 28
27int main( int argc, char ** argv)
28{
29 QPEApplication app( argc, argv );
30
31 GoMainWidget m;
32 m.setCaption( GoWidget::tr("Go") );
33 app.showMainWidget( &m );
34 return app.exec();
35}
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 @@
1Package: opie-go 1Package: opie-go
2Files: bin/go apps/Games/go.desktop pics/go 2Files: plugins/application/libgo.so* bin/go apps/Games/go.desktop pics/go
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Opie Project <opie@handhelds.org> 5Maintainer: Warwick Allison <warwick@trolltech.com>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal 7Depends: task-opie-minimal
8Description: The game of Go 8Description: The game of Go
9 A game for the Opie environment. 9 A game for the Opie environment.
10Version: $QPE_VERSION$EXTRAVERSION 10Version: $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
@@ -1,239 +1,240 @@
1 1
2#include <qimage.h> 2#include <qimage.h>
3#include <qframe.h> 3#include <qframe.h>
4#include <qlayout.h> 4#include <qlayout.h>
5#include <qmenubar.h> 5#include <qmenubar.h>
6#include <qtoolbar.h> 6#include <qtoolbar.h>
7#include <qpe/config.h> 7#include <qpe/config.h>
8#include <qwhatsthis.h> 8#include <qwhatsthis.h>
9#include <qtoolbutton.h> 9#include <qtoolbutton.h>
10#include <qmessagebox.h> 10#include <qmessagebox.h>
11#include <qapplication.h> 11#include <qapplication.h>
12 12
13#include "kcheckers.h" 13#include "kcheckers.h"
14#include "echeckers.h" 14#include "echeckers.h"
15#include "rcheckers.h" 15#include "rcheckers.h"
16 16
17#include "pics/logo.xpm" 17#include "pics/logo.xpm"
18#include "pics/undo.xpm" 18#include "pics/undo.xpm"
19#include "pics/exit.xpm" 19#include "pics/exit.xpm"
20#include "pics/help.xpm" 20#include "pics/help.xpm"
21#include "pics/wood1.xpm" 21#include "pics/wood1.xpm"
22#include "pics/wood2.xpm" 22#include "pics/wood2.xpm"
23#include "pics/wood3.xpm" 23#include "pics/wood3.xpm"
24#include "pics/green1.xpm" 24#include "pics/green1.xpm"
25#include "pics/green2.xpm" 25#include "pics/green2.xpm"
26#include "pics/green3.xpm" 26#include "pics/green3.xpm"
27#include "pics/marble1.xpm" 27#include "pics/marble1.xpm"
28#include "pics/marble2.xpm" 28#include "pics/marble2.xpm"
29#include "pics/marble3.xpm" 29#include "pics/marble3.xpm"
30#include "pics/biglogo.xpm" 30#include "pics/biglogo.xpm"
31#include "pics/man_black.xpm" 31#include "pics/man_black.xpm"
32#include "pics/man_white.xpm" 32#include "pics/man_white.xpm"
33#include "pics/king_black.xpm" 33#include "pics/king_black.xpm"
34#include "pics/king_white.xpm" 34#include "pics/king_white.xpm"
35#include "pics/contexthelp.xpm" 35#include "pics/contexthelp.xpm"
36 36
37 37
38QString KCheckers::enNumeration="1 2 3 4 5 6 7 8 9 1011121314151617181920212223242526272829303132"; 38QString KCheckers::enNumeration="1 2 3 4 5 6 7 8 9 1011121314151617181920212223242526272829303132";
39QString KCheckers::ruNumeration="B8D8F8H8A7C7E7G7B6D6F6H6A5C5E5G5B4D4F4H4A3C3E3G3B2D2F2H2A1C1E1G1"; 39QString KCheckers::ruNumeration="B8D8F8H8A7C7E7G7B6D6F6H6A5C5E5G5B4D4F4H4A3C3E3G3B2D2F2H2A1C1E1G1";
40 40
41const int KCheckers::t[]={6,7,8,9,11,12,13,14,17,18,19,20,22,23, 41const int KCheckers::t[]={6,7,8,9,11,12,13,14,17,18,19,20,22,23,
42 24,25,28,29,30,31,33,34,35,36,39,40,41,42,44,45,46,47}; 42 24,25,28,29,30,31,33,34,35,36,39,40,41,42,44,45,46,47};
43 43
44 44
45KCheckers::KCheckers():QMainWindow(0,0,WStyle_DialogBorder) 45KCheckers::KCheckers(QWidget *p, const char* n, WFlags )
46 :QMainWindow(p,n,WStyle_DialogBorder)
46{ 47{
47 setCaption("KCheckers"); 48 setCaption(tr("KCheckers") );
48 setIcon(QPixmap(biglogo_xpm)); 49 setIcon(QPixmap(biglogo_xpm));
49 50
50 setToolBarsMovable(false); 51 setToolBarsMovable(false);
51 52
52 // Make a menubar 53 // Make a menubar
53 54
54 gameMenu=new QPopupMenu; 55 gameMenu=new QPopupMenu;
55 CHECK_PTR(gameMenu); 56 CHECK_PTR(gameMenu);
56 57
57 gameMenu->insertItem(QPixmap(logo_xpm),tr("&New"),this,SLOT(newGame()),CTRL+Key_N); 58 gameMenu->insertItem(QPixmap(logo_xpm),tr("&New"),this,SLOT(newGame()),CTRL+Key_N);
58 gameMenu->insertSeparator(); 59 gameMenu->insertSeparator();
59 undoID=gameMenu->insertItem(QPixmap(undo_xpm),tr("&Undo Move"),this,SLOT(undoMove()),CTRL+Key_Z); 60 undoID=gameMenu->insertItem(QPixmap(undo_xpm),tr("&Undo Move"),this,SLOT(undoMove()),CTRL+Key_Z);
60 gameMenu->insertSeparator(); 61 gameMenu->insertSeparator();
61 gameMenu->insertItem(QPixmap(exit_xpm),tr("&Quit"),qApp,SLOT(closeAllWindows()),CTRL+Key_Q); 62 gameMenu->insertItem(QPixmap(exit_xpm),tr("&Quit"),qApp,SLOT(closeAllWindows()),CTRL+Key_Q);
62 63
63 skillMenu=new QPopupMenu; 64 skillMenu=new QPopupMenu;
64 CHECK_PTR(skillMenu); 65 CHECK_PTR(skillMenu);
65 66
66 skillMenu->insertItem(tr("&Beginner"),this,SLOT(setSkillBeginner()),CTRL+Key_1,BEGINNER); 67 skillMenu->insertItem(tr("&Beginner"),this,SLOT(setSkillBeginner()),CTRL+Key_1,BEGINNER);
67 skillMenu->insertItem(tr("&Novice"), this,SLOT(setSkillNovice()), CTRL+Key_2,NOVICE); 68 skillMenu->insertItem(tr("&Novice"), this,SLOT(setSkillNovice()), CTRL+Key_2,NOVICE);
68 skillMenu->insertItem(tr("&Average"), this,SLOT(setSkillAverage()), CTRL+Key_3,AVERAGE); 69 skillMenu->insertItem(tr("&Average"), this,SLOT(setSkillAverage()), CTRL+Key_3,AVERAGE);
69 skillMenu->insertItem(tr("&Good"), this,SLOT(setSkillGood()), CTRL+Key_4,GOOD); 70 skillMenu->insertItem(tr("&Good"), this,SLOT(setSkillGood()), CTRL+Key_4,GOOD);
70 skillMenu->insertItem(tr("&Expert"), this,SLOT(setSkillExpert()), CTRL+Key_5,EXPERT); 71 skillMenu->insertItem(tr("&Expert"), this,SLOT(setSkillExpert()), CTRL+Key_5,EXPERT);
71 skillMenu->insertItem(tr("&Master"), this,SLOT(setSkillMaster()), CTRL+Key_6,MASTER); 72 skillMenu->insertItem(tr("&Master"), this,SLOT(setSkillMaster()), CTRL+Key_6,MASTER);
72 73
73 optionsMenu=new QPopupMenu; 74 optionsMenu=new QPopupMenu;
74 CHECK_PTR(optionsMenu); 75 CHECK_PTR(optionsMenu);
75 76
76 numID=optionsMenu->insertItem(tr("&Show Numeration"),this,SLOT(showNumeration())); 77 numID=optionsMenu->insertItem(tr("&Show Numeration"),this,SLOT(showNumeration()));
77 optionsMenu->insertSeparator(); 78 optionsMenu->insertSeparator();
78 optionsMenu->insertItem(tr("&English Rules"),this,SLOT(setRulesEnglish()),0,ENGLISH); 79 optionsMenu->insertItem(tr("&English Rules"),this,SLOT(setRulesEnglish()),0,ENGLISH);
79 optionsMenu->insertItem(tr("&Russian Rules"),this,SLOT(setRulesRussian()),0,RUSSIAN); 80 optionsMenu->insertItem(tr("&Russian Rules"),this,SLOT(setRulesRussian()),0,RUSSIAN);
80 optionsMenu->insertSeparator(); 81 optionsMenu->insertSeparator();
81 optionsMenu->insertItem(tr("&Green Board"), this,SLOT(setPatternGreen()), 0,GREEN); 82 optionsMenu->insertItem(tr("&Green Board"), this,SLOT(setPatternGreen()), 0,GREEN);
82 optionsMenu->insertItem(tr("&Marble Board"),this,SLOT(setPatternMarble()),0,MARBLE); 83 optionsMenu->insertItem(tr("&Marble Board"),this,SLOT(setPatternMarble()),0,MARBLE);
83 optionsMenu->insertItem(tr("&Wooden Board"),this,SLOT(setPatternWooden()),0,WOODEN); 84 optionsMenu->insertItem(tr("&Wooden Board"),this,SLOT(setPatternWooden()),0,WOODEN);
84 85
85 QPopupMenu* helpMenu=new QPopupMenu; 86 QPopupMenu* helpMenu=new QPopupMenu;
86 CHECK_PTR(helpMenu); 87 CHECK_PTR(helpMenu);
87 88
88 helpMenu->insertItem(QPixmap(contexthelp_xpm),tr("What's This"),this,SLOT(whatsThis()),SHIFT+Key_F1); 89 helpMenu->insertItem(QPixmap(contexthelp_xpm),tr("What's This"),this,SLOT(whatsThis()),SHIFT+Key_F1);
89 helpMenu->insertItem(QPixmap(help_xpm),tr("&Rules of Play"),this,SLOT(help()),Key_F1); 90 helpMenu->insertItem(QPixmap(help_xpm),tr("&Rules of Play"),this,SLOT(help()),Key_F1);
90 helpMenu->insertSeparator(); 91 helpMenu->insertSeparator();
91 helpMenu->insertItem(QPixmap(logo_xpm),tr("&About KCheckers"),this,SLOT(about())); 92 helpMenu->insertItem(QPixmap(logo_xpm),tr("&About KCheckers"),this,SLOT(about()));
92 helpMenu->insertItem(tr("About &Qt"),this,SLOT(aboutQt())); 93 helpMenu->insertItem(tr("About &Qt"),this,SLOT(aboutQt()));
93 94
94 QToolBar* menuToolBar=new QToolBar(this); 95 QToolBar* menuToolBar=new QToolBar(this);
95 CHECK_PTR(menuToolBar); 96 CHECK_PTR(menuToolBar);
96 QMenuBar* menuBar=new QMenuBar(menuToolBar); 97 QMenuBar* menuBar=new QMenuBar(menuToolBar);
97 CHECK_PTR(menuBar); 98 CHECK_PTR(menuBar);
98 99
99 menuBar->insertItem(tr("&Game"), gameMenu); 100 menuBar->insertItem(tr("&Game"), gameMenu);
100 menuBar->insertItem(tr("&Skill"), skillMenu); 101 menuBar->insertItem(tr("&Skill"), skillMenu);
101 menuBar->insertItem(tr("&Options"),optionsMenu); 102 menuBar->insertItem(tr("&Options"),optionsMenu);
102 menuBar->insertItem(tr("&Help"), helpMenu); 103 menuBar->insertItem(tr("&Help"), helpMenu);
103 104
104 // Restore a settings 105 // Restore a settings
105 106
106 readConfig(); 107 readConfig();
107 108
108 skillMenu->setItemChecked(skill,true); 109 skillMenu->setItemChecked(skill,true);
109 optionsMenu->setItemChecked(rules,true); 110 optionsMenu->setItemChecked(rules,true);
110 optionsMenu->setItemChecked(numID,false); 111 optionsMenu->setItemChecked(numID,false);
111 112
112 // Make a toolbar 113 // Make a toolbar
113 114
114 QToolBar* emptyToolBar=new QToolBar(this); 115 QToolBar* emptyToolBar=new QToolBar(this);
115 emptyToolBar->setHorizontalStretchable(true); 116 emptyToolBar->setHorizontalStretchable(true);
116 117
117 QToolBar* toolBar=new QToolBar(this); 118 QToolBar* toolBar=new QToolBar(this);
118 CHECK_PTR(toolBar); 119 CHECK_PTR(toolBar);
119 120
120 QSize buttonSize(24,24); 121 QSize buttonSize(24,24);
121 122
122 QToolButton* gameButton=new QToolButton(QPixmap(logo_xpm),tr(" New Game ") ,"",this,SLOT(newGame()),toolBar); 123 QToolButton* gameButton=new QToolButton(QPixmap(logo_xpm),tr(" New Game ") ,"",this,SLOT(newGame()),toolBar);
123 CHECK_PTR(gameButton); 124 CHECK_PTR(gameButton);
124 gameButton->setMinimumSize(buttonSize); 125 gameButton->setMinimumSize(buttonSize);
125 126
126 undoButton=new QToolButton(QPixmap(undo_xpm),tr(" Undo Move "),"",this,SLOT(undoMove()),toolBar); 127 undoButton=new QToolButton(QPixmap(undo_xpm),tr(" Undo Move "),"",this,SLOT(undoMove()),toolBar);
127 CHECK_PTR(undoButton); 128 CHECK_PTR(undoButton);
128 undoButton->setMinimumSize(buttonSize); 129 undoButton->setMinimumSize(buttonSize);
129 130
130 QToolButton* helpButton=new QToolButton(QPixmap(help_xpm),tr(" Rules of Play "),"",this,SLOT(help()),toolBar); 131 QToolButton* helpButton=new QToolButton(QPixmap(help_xpm),tr(" Rules of Play "),"",this,SLOT(help()),toolBar);
131 CHECK_PTR(helpButton); 132 CHECK_PTR(helpButton);
132 helpButton->setMinimumSize(buttonSize); 133 helpButton->setMinimumSize(buttonSize);
133 134
134 // Make a checkers board 135 // Make a checkers board
135 136
136 imageMan1=new QImage(man_black_xpm); CHECK_PTR(imageMan1); 137 imageMan1=new QImage(man_black_xpm); CHECK_PTR(imageMan1);
137 imageMan2=new QImage(man_white_xpm); CHECK_PTR(imageMan2); 138 imageMan2=new QImage(man_white_xpm); CHECK_PTR(imageMan2);
138 imageKing1=new QImage(king_black_xpm); CHECK_PTR(imageKing1); 139 imageKing1=new QImage(king_black_xpm); CHECK_PTR(imageKing1);
139 imageKing2=new QImage(king_white_xpm); CHECK_PTR(imageKing2); 140 imageKing2=new QImage(king_white_xpm); CHECK_PTR(imageKing2);
140 141
141 imageWood1=new QImage(wood1_xpm); CHECK_PTR(imageWood1); 142 imageWood1=new QImage(wood1_xpm); CHECK_PTR(imageWood1);
142 imageWood2=new QImage(wood2_xpm); CHECK_PTR(imageWood2); 143 imageWood2=new QImage(wood2_xpm); CHECK_PTR(imageWood2);
143 imageWood3=new QImage(wood3_xpm); CHECK_PTR(imageWood3); 144 imageWood3=new QImage(wood3_xpm); CHECK_PTR(imageWood3);
144 imageGreen1=new QImage(green1_xpm); CHECK_PTR(imageGreen1); 145 imageGreen1=new QImage(green1_xpm); CHECK_PTR(imageGreen1);
145 imageGreen2=new QImage(green2_xpm); CHECK_PTR(imageGreen2); 146 imageGreen2=new QImage(green2_xpm); CHECK_PTR(imageGreen2);
146 imageGreen3=new QImage(green3_xpm); CHECK_PTR(imageGreen3); 147 imageGreen3=new QImage(green3_xpm); CHECK_PTR(imageGreen3);
147 imageMarble1=new QImage(marble1_xpm); CHECK_PTR(imageMarble1); 148 imageMarble1=new QImage(marble1_xpm); CHECK_PTR(imageMarble1);
148 imageMarble2=new QImage(marble2_xpm); CHECK_PTR(imageMarble2); 149 imageMarble2=new QImage(marble2_xpm); CHECK_PTR(imageMarble2);
149 imageMarble3=new QImage(marble3_xpm); CHECK_PTR(imageMarble3); 150 imageMarble3=new QImage(marble3_xpm); CHECK_PTR(imageMarble3);
150 151
151 QWidget* centralWidget=new QWidget(this); 152 QWidget* centralWidget=new QWidget(this);
152 setCentralWidget(centralWidget); 153 setCentralWidget(centralWidget);
153 154
154 QFrame* frame=new QFrame(centralWidget); 155 QFrame* frame=new QFrame(centralWidget);
155 CHECK_PTR(frame); 156 CHECK_PTR(frame);
156 frame->setFrameStyle(QFrame::Box|QFrame::Plain); 157 frame->setFrameStyle(QFrame::Box|QFrame::Plain);
157 frame->setFixedSize(SIZE*8+2,SIZE*8+2); 158 frame->setFixedSize(SIZE*8+2,SIZE*8+2);
158 159
159 statusLabel = new QLabel(centralWidget); 160 statusLabel = new QLabel(centralWidget);
160 statusLabel->setAlignment(Qt::AlignHCenter); 161 statusLabel->setAlignment(Qt::AlignHCenter);
161 162
162 QVBoxLayout* vlayout=new QVBoxLayout(centralWidget); 163 QVBoxLayout* vlayout=new QVBoxLayout(centralWidget);
163 164
164 vlayout->addStretch(); 165 vlayout->addStretch();
165 vlayout->addWidget(frame); 166 vlayout->addWidget(frame);
166 vlayout->addStretch(); 167 vlayout->addStretch();
167 vlayout->addWidget(statusLabel); 168 vlayout->addWidget(statusLabel);
168 vlayout->addStretch(); 169 vlayout->addStretch();
169 170
170 for(int i=0;i<64;i++) 171 for(int i=0;i<64;i++)
171 { 172 {
172 field[i]=new Field(frame,i); 173 field[i]=new Field(frame,i);
173 CHECK_PTR(field[i]); 174 CHECK_PTR(field[i]);
174 } 175 }
175 176
176 QGridLayout* grid=new QGridLayout(frame,8,8,1,0); 177 QGridLayout* grid=new QGridLayout(frame,8,8,1,0);
177 CHECK_PTR(grid); 178 CHECK_PTR(grid);
178 179
179 for(int i=0;i<4;i++) 180 for(int i=0;i<4;i++)
180 { 181 {
181 for(int k=0;k<4;k++) 182 for(int k=0;k<4;k++)
182 { 183 {
183 grid->addWidget(field[i*8+k+32],i*2, k*2 ); 184 grid->addWidget(field[i*8+k+32],i*2, k*2 );
184 grid->addWidget(field[i*8+k ],i*2, k*2+1); 185 grid->addWidget(field[i*8+k ],i*2, k*2+1);
185 grid->addWidget(field[i*8+k+4 ],i*2+1,k*2 ); 186 grid->addWidget(field[i*8+k+4 ],i*2+1,k*2 );
186 grid->addWidget(field[i*8+k+36],i*2+1,k*2+1); 187 grid->addWidget(field[i*8+k+36],i*2+1,k*2+1);
187 } 188 }
188 } 189 }
189 190
190 for(int i=0;i<32;i++) 191 for(int i=0;i<32;i++)
191 connect(field[i],SIGNAL(click(int)),this,SLOT(click(int))); 192 connect(field[i],SIGNAL(click(int)),this,SLOT(click(int)));
192 193
193 selected=false; 194 selected=false;
194 195
195 setPattern(pattern); 196 setPattern(pattern);
196 197
197 QWhatsThis::add(frame,"A checkers board"); 198 QWhatsThis::add(frame,"A checkers board");
198 199
199 userFirst=false; 200 userFirst=false;
200 201
201 game=NULL; 202 game=NULL;
202 newGame(); 203 newGame();
203} 204}
204 205
205 206
206void KCheckers::readConfig() 207void KCheckers::readConfig()
207{ 208{
208 Config config("KCheckers"); 209 Config config("KCheckers");
209 config.setGroup("KCheckers"); 210 config.setGroup("KCheckers");
210 QString entry; 211 QString entry;
211 212
212 entry=config.readEntry("skill","novice"); 213 entry=config.readEntry("skill","novice");
213 if(entry=="beginner") skill=BEGINNER; 214 if(entry=="beginner") skill=BEGINNER;
214 else if(entry=="average") skill=AVERAGE; 215 else if(entry=="average") skill=AVERAGE;
215 else if(entry=="good") skill=GOOD; 216 else if(entry=="good") skill=GOOD;
216 else if(entry=="expert") skill=EXPERT; 217 else if(entry=="expert") skill=EXPERT;
217 else if(entry=="master") skill=MASTER; 218 else if(entry=="master") skill=MASTER;
218 else skill=NOVICE; 219 else skill=NOVICE;
219 220
220 entry=config.readEntry("rules","english"); 221 entry=config.readEntry("rules","english");
221 if(entry=="russian") rules=RUSSIAN; 222 if(entry=="russian") rules=RUSSIAN;
222 else rules=ENGLISH; 223 else rules=ENGLISH;
223 224
224 entry=config.readEntry("theme","wooden"); 225 entry=config.readEntry("theme","wooden");
225 if(entry=="green") pattern=GREEN; 226 if(entry=="green") pattern=GREEN;
226 else if(entry=="marble") pattern=MARBLE; 227 else if(entry=="marble") pattern=MARBLE;
227 else pattern=WOODEN; 228 else pattern=WOODEN;
228} 229}
229 230
230 231
231void KCheckers::closeEvent(QCloseEvent* event) 232void KCheckers::closeEvent(QCloseEvent* event)
232{ 233{
233 Config config("KCheckers"); 234 Config config("KCheckers");
234 config.setGroup("KCheckers"); 235 config.setGroup("KCheckers");
235 QString entry; 236 QString entry;
236 237
237 if(skill==BEGINNER) entry="beginner"; 238 if(skill==BEGINNER) entry="beginner";
238 if(skill==NOVICE) entry="novice"; 239 if(skill==NOVICE) entry="novice";
239 if(skill==AVERAGE) entry="average"; 240 if(skill==AVERAGE) entry="average";
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
@@ -1,125 +1,126 @@
1 1
2#ifndef KCHECKERS_H 2#ifndef KCHECKERS_H
3#define KCHECKERS_H 3#define KCHECKERS_H
4 4
5#include <qmainwindow.h> 5#include <qmainwindow.h>
6#include <qlabel.h> 6#include <qlabel.h>
7 7
8#include "field.h" 8#include "field.h"
9#include "checkers.h" 9#include "checkers.h"
10 10
11#define WOODEN 1 11#define WOODEN 1
12#define GREEN 2 12#define GREEN 2
13#define MARBLE 3 13#define MARBLE 3
14 14
15#define ENGLISH 11 15#define ENGLISH 11
16#define RUSSIAN 12 16#define RUSSIAN 12
17 17
18#define BEGINNER 2 18#define BEGINNER 2
19#define NOVICE 4 19#define NOVICE 4
20#define AVERAGE 6 20#define AVERAGE 6
21#define GOOD 7 21#define GOOD 7
22#define EXPERT 8 22#define EXPERT 8
23#define MASTER 9 23#define MASTER 9
24 24
25class QToolButton; 25class QToolButton;
26 26
27 27
28class KCheckers:public QMainWindow 28class KCheckers:public QMainWindow
29{ 29{
30 Q_OBJECT 30 Q_OBJECT
31 public: 31 public:
32 KCheckers(); 32 static QString appName() { return QString::fromLatin1("kcheckers"); }
33 KCheckers(QWidget *parent, const char* name, WFlags fl);
33 34
34 protected: 35 protected:
35 void closeEvent(QCloseEvent*); 36 void closeEvent(QCloseEvent*);
36 37
37 private slots: 38 private slots:
38 39
39 void help(); 40 void help();
40 void about(); 41 void about();
41 void aboutQt(); 42 void aboutQt();
42 void newGame(); 43 void newGame();
43 void undoMove(); 44 void undoMove();
44 void click(int); 45 void click(int);
45 void showNumeration(); 46 void showNumeration();
46 47
47 void setSkillBeginner() {setSkill(BEGINNER);}; 48 void setSkillBeginner() {setSkill(BEGINNER);};
48 void setSkillNovice() {setSkill(NOVICE);}; 49 void setSkillNovice() {setSkill(NOVICE);};
49 void setSkillAverage() {setSkill(AVERAGE);}; 50 void setSkillAverage() {setSkill(AVERAGE);};
50 void setSkillGood() {setSkill(GOOD);}; 51 void setSkillGood() {setSkill(GOOD);};
51 void setSkillExpert() {setSkill(EXPERT);}; 52 void setSkillExpert() {setSkill(EXPERT);};
52 void setSkillMaster() {setSkill(MASTER);}; 53 void setSkillMaster() {setSkill(MASTER);};
53 54
54 void setPatternWooden() {setPattern(WOODEN);}; 55 void setPatternWooden() {setPattern(WOODEN);};
55 void setPatternGreen() {setPattern(GREEN);}; 56 void setPatternGreen() {setPattern(GREEN);};
56 void setPatternMarble() {setPattern(MARBLE);}; 57 void setPatternMarble() {setPattern(MARBLE);};
57 58
58 void setRulesEnglish() {setRules(ENGLISH);}; 59 void setRulesEnglish() {setRules(ENGLISH);};
59 void setRulesRussian() {setRules(RUSSIAN);}; 60 void setRulesRussian() {setRules(RUSSIAN);};
60 61
61 private: 62 private:
62 63
63 void compGo(); 64 void compGo();
64 bool userGo(int); 65 bool userGo(int);
65 66
66 void drawBoard(int); 67 void drawBoard(int);
67 void drawNumeration(); 68 void drawNumeration();
68 void colorChange(); 69 void colorChange();
69 void unselect(); 70 void unselect();
70 void readConfig(); 71 void readConfig();
71 72
72 void setSkill(int); 73 void setSkill(int);
73 void setRules(int); 74 void setRules(int);
74 void setPattern(int); 75 void setPattern(int);
75 76
76 int from; // Selected by user 77 int from; // Selected by user
77 int skill; 78 int skill;
78 int rules; 79 int rules;
79 int pattern; 80 int pattern;
80 81
81 int numID; // Show Numeration 82 int numID; // Show Numeration
82 int undoID; // Undo Move 83 int undoID; // Undo Move
83 int undoBoard[32]; 84 int undoBoard[32];
84 85
85 bool gameOver; 86 bool gameOver;
86 bool selected; 87 bool selected;
87 bool userFirst; 88 bool userFirst;
88 89
89 Field* field[64]; // Fields of board 90 Field* field[64]; // Fields of board
90 91
91 QImage* imagePat1; // Patterns 92 QImage* imagePat1; // Patterns
92 QImage* imagePat2; 93 QImage* imagePat2;
93 QImage* imageFrame; // Frame of selected field 94 QImage* imageFrame; // Frame of selected field
94 95
95 QImage* imageWood1; 96 QImage* imageWood1;
96 QImage* imageWood2; 97 QImage* imageWood2;
97 QImage* imageWood3; 98 QImage* imageWood3;
98 QImage* imageGreen1; 99 QImage* imageGreen1;
99 QImage* imageGreen2; 100 QImage* imageGreen2;
100 QImage* imageGreen3; 101 QImage* imageGreen3;
101 QImage* imageMarble1; 102 QImage* imageMarble1;
102 QImage* imageMarble2; 103 QImage* imageMarble2;
103 QImage* imageMarble3; 104 QImage* imageMarble3;
104 105
105 QImage* imageMan1; 106 QImage* imageMan1;
106 QImage* imageMan2; 107 QImage* imageMan2;
107 QImage* imageKing1; 108 QImage* imageKing1;
108 QImage* imageKing2; 109 QImage* imageKing2;
109 110
110 Checkers* game; 111 Checkers* game;
111 QPopupMenu* gameMenu; 112 QPopupMenu* gameMenu;
112 QPopupMenu* skillMenu; 113 QPopupMenu* skillMenu;
113 QPopupMenu* optionsMenu; 114 QPopupMenu* optionsMenu;
114 QToolButton* undoButton; 115 QToolButton* undoButton;
115 QLabel* statusLabel; 116 QLabel* statusLabel;
116 117
117 static QString enNumeration; 118 static QString enNumeration;
118 static QString ruNumeration; 119 static QString ruNumeration;
119 120
120 static const int t[32]; // Translate table 121 static const int t[32]; // Translate table
121 122
122}; 123};
123 124
124#endif 125#endif
125 126
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,20 +1,19 @@
1 TEMPLATE= app 1 CONFIG = qt warn_on release quick-app
2 CONFIG = qt warn_on release
3 HEADERS = checkers.h \ 2 HEADERS = checkers.h \
4 echeckers.h \ 3 echeckers.h \
5 field.h \ 4 field.h \
6 kcheckers.h \ 5 kcheckers.h \
7 rcheckers.h 6 rcheckers.h
8 SOURCES = checkers.cpp \ 7 SOURCES = checkers.cpp \
9 echeckers.cpp \ 8 echeckers.cpp \
10 field.cpp \ 9 field.cpp \
11 kcheckers.cpp \ 10 kcheckers.cpp \
12 main.cpp \ 11 main.cpp \
13 rcheckers.cpp 12 rcheckers.cpp
14 INTERFACES= 13 INTERFACES=
15 INCLUDEPATH+= $(OPIEDIR)/include 14 INCLUDEPATH+= $(OPIEDIR)/include
16 LIBS += -lqpe 15 LIBS += -lqpe
17 DESTDIR = $(OPIEDIR)/bin
18 TARGET = kcheckers 16 TARGET = kcheckers
19 17
18
20include ( $(OPIEDIR)/include.pro ) 19include ( $(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 @@
1 1
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include <qfont.h> 3#include <qfont.h>
4 4
5#include "kcheckers.h" 5#include "kcheckers.h"
6#include <opie/oapplicationfactory.h>
6 7
8OPIE_EXPORT_APP( OApplicationFactory<KCheckers> )
7 9
8int main(int argc, char *argv[])
9{
10 QPEApplication app(argc,argv);
11
12 KCheckers kcheckers;
13 app.setMainWidget(&kcheckers);
14 kcheckers.showMaximized();
15
16 return app.exec();
17}
18 10
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,10 +1,10 @@
1Package: opie-kcheckers 1Package: opie-kcheckers
2Files: bin/kcheckers apps/Games/kcheckers.desktop pics/kcheckers 2Files: plugins/application/libkcheckers.so* bin/kcheckers apps/Games/kcheckers.desktop pics/kcheckers
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: leseb <prudhomme@laposte.net> 5Maintainer: leseb <prudhomme@laposte.net>
6Architecture: arm 6Architecture: arm
7Version: 0.3-$SUB_VERSION 7Version: 0.3-$SUB_VERSION
8Depends: task-opie-minimal 8Depends: task-opie-minimal
9Description: The game of Checkers 9Description: The game of Checkers
10 A game for the Opie environment. 10 A game for the Opie environment.
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,35 +1,35 @@
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**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "mindbreaker.h" 21#include "mindbreaker.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qtopia/qpeapplication.h>
24 24
25int main( int argc, char **argv ) 25int main( int argc, char **argv )
26{ 26{
27 QPEApplication a( argc, argv ); 27 QPEApplication a( argc, 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 );
32 a.showMainWidget(&w); 32 a.showMainWidget(&w);
33 33
34 return a.exec(); 34 return a.exec();
35} 35}
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,818 +1,957 @@
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**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "mindbreaker.h" 21#include "mindbreaker.h"
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
26#include <qpainter.h> 28#include <qpainter.h>
27#include <qpixmap.h> 29#include <qpixmap.h>
28#include <qpe/qpetoolbar.h>
29#include <qtoolbutton.h> 30#include <qtoolbutton.h>
30#include <qpushbutton.h> 31#include <qpushbutton.h>
31#include <qmessagebox.h> 32#include <qmessagebox.h>
32#include <qlabel.h> 33#include <qlabel.h>
33#include <qstyle.h> 34#include <qlayout.h>
35#include <qtimer.h>
34 36
35#include <stdlib.h> 37#include <stdlib.h>
36#include <sys/time.h> 38#include <sys/time.h>
37#include <unistd.h> 39#include <unistd.h>
38 40
39static int pegRTTI = 3393393; 41static 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, */
42class Peg : public QCanvasRectangle 102class Peg : public QCanvasRectangle
43{ 103{
44public: 104public:
45 Peg(QCanvas *canvas, int type, int go = -1, int pos = -1); 105 Peg(QCanvas *canvas, int type, int go = -1, int pos = -1);
46 int rtti() const {return pegRTTI; } 106 int rtti() const {return pegRTTI; }
47 void advance(int phase); 107 void advance(int phase);
48 108
49 bool hit( const QPoint &) const; 109 bool hit( const QPoint &) const;
50 110
51/* a placed peg is one that has been set down on the board correctly and 111/* a placed peg is one that has been set down on the board correctly and
52 should not be moved, only copied */ 112 should not be moved, only copied */
53 bool placed() const; 113 bool placed() const;
54 void setPlaced(bool); 114 void setPlaced(bool);
55 115
56 int pegGo() const; 116 int pegGo() const;
57 int pegPos() const; 117 int pegPos() const;
58 void setPegPos(int); 118 void setPegPos(int);
59 119
60 int type() const; 120 int type() const;
61 121
62 static void buildImages(); 122 static void buildImages();
63 static QImage imageForType(int t); 123 static QImage imageForType(int t);
64 124
65 static int eggLevel; 125 static int eggLevel;
66 126
67protected: 127protected:
68 void drawShape(QPainter &); 128 void drawShape(QPainter &);
69private: 129private:
70 static QVector<QImage> normalPegs; 130 static QVector<QImage> normalPegs;
71 static QVector<QImage> specialPegs; 131 static QVector<QImage> specialPegs;
72 132
73 bool isplaced; 133 bool isplaced;
74 int pegtype; 134 int pegtype;
75 int peg_go; 135 int peg_go;
76 int peg_pos; 136 int peg_pos;
77 137
78 int aniStep; 138 int aniStep;
79}; 139};
80
81int Peg::eggLevel = 0; 140int Peg::eggLevel = 0;
82QVector<QImage> Peg::normalPegs; 141QVector<QImage> Peg::normalPegs;
83QVector<QImage> Peg::specialPegs; 142QVector<QImage> Peg::specialPegs;
84 143
85void Peg::buildImages() 144void Peg::buildImages()
86{ 145{
87
88 QImage pegs = Resource::loadImage("mindbreaker/pegs"); 146 QImage pegs = Resource::loadImage("mindbreaker/pegs");
89 int x = 0; 147 int x = 0;
90 int y = 0; 148 int y = 0;
91 int i; 149 int i;
92 eggLevel = 0; 150 eggLevel = 0;
93 normalPegs.resize(10); 151 normalPegs.resize(10);
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;
97 } 156 }
98 specialPegs.resize(5); 157 specialPegs.resize(5);
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;
102 } 162 }
103 163
104 QImage image = Resource::loadImage("mindbreaker/mindbreaker"); 164 QImage image = Resource::loadImage("mindbreaker/mindbreaker");
105 /* copy from master image to functional images */ 165 /* copy from master image to functional images */
106 x = 0; 166 x = 0;
107 y = panel_height; 167 y = panel_height;
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;
111 y += title_height; 173 y += title_height;
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;
115 179
116 x = 6 * peg_size; 180 x = 6 * peg_size;
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}
123 189
124QImage Peg::imageForType(int t) 190QImage Peg::imageForType(int t)
125{ 191{
126 if (eggLevel > t ) { 192 if (eggLevel > t ) {
127 if( t < 5) { 193 if( t < 5) {
128 return *specialPegs[t]; 194 return *specialPegs[t];
129 } else { 195 } else {
130 return *normalPegs[rand() % 6]; 196 return *normalPegs[rand() % 6];
131 } 197 }
132 } 198 }
133 return *normalPegs[t]; 199 return *normalPegs[t];
134} 200}
135 201
136Peg::Peg(QCanvas *canvas , int t, int g, int p) 202Peg::Peg(QCanvas *canvas , int t, int g, int p)
137 : QCanvasRectangle(canvas) 203 : QCanvasRectangle(canvas)
138{ 204{
139 setSize(normalPegs[t]->width(), normalPegs[t]->height() ); 205 setSize(normalPegs[t]->width(), normalPegs[t]->height() );
140 pegtype = t; 206 pegtype = t;
141 isplaced = FALSE; 207 isplaced = FALSE;
142 peg_pos = p; 208 peg_pos = p;
143 peg_go = g; 209 peg_go = g;
144 aniStep = rand() % 6; 210 aniStep = rand() % 6;
145 setAnimated(TRUE); 211 setAnimated(TRUE);
146} 212}
147 213
148void Peg::advance(int phase) { 214void Peg::advance(int phase) {
149 if (phase == 0) 215 if (phase == 0)
150 aniStep = (++aniStep) % 6; 216 aniStep = (++aniStep) % 6;
151 else { 217 else {
152 hide(); 218 hide();
153 show(); 219 show();
154 } 220 }
155} 221}
156 222
157void Peg::drawShape(QPainter &p ) 223void Peg::drawShape(QPainter &p )
158{ 224{
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}
164 230
165bool Peg::hit( const QPoint &p ) const 231bool Peg::hit( const QPoint &p ) const
166{ 232{
167 int ix = p.x() - int(x()); 233 int ix = p.x() - int(x());
168 int iy = p.y() - int(y()); 234 int iy = p.y() - int(y());
169 if (!normalPegs[pegtype]->valid(ix, iy)) 235 if (!normalPegs[pegtype]->valid(ix, iy))
170 return FALSE; 236 return FALSE;
171 QRgb pixel = normalPegs[pegtype]->pixel(ix, iy); 237 QRgb pixel = normalPegs[pegtype]->pixel(ix, iy);
172 return (qAlpha(pixel ) != 0); 238 return (qAlpha(pixel ) != 0);
173} 239}
174 240
175inline bool Peg::placed() const 241inline bool Peg::placed() const
176{ 242{
177 return isplaced; 243 return isplaced;
178} 244}
179 245
180inline int Peg::pegGo() const 246inline int Peg::pegGo() const
181{ 247{
182 return peg_go; 248 return peg_go;
183} 249}
184 250
185inline int Peg::pegPos() const 251inline int Peg::pegPos() const
186{ 252{
187 return peg_pos; 253 return peg_pos;
188} 254}
189 255
190inline void Peg::setPegPos(int p) 256inline void Peg::setPegPos(int p)
191{ 257{
192 peg_pos = p; 258 peg_pos = p;
193} 259}
194 260
195inline void Peg::setPlaced(bool p) 261inline void Peg::setPlaced(bool p)
196{ 262{
197 isplaced = p; 263 isplaced = p;
198} 264}
199 265
200inline int Peg::type() const 266inline int Peg::type() const
201{ 267{
202 return pegtype; 268 return pegtype;
203} 269}
204 270
205/* Load the main image, copy from it the pegs, the board, and the answer image 271/* Load the main image, copy from it the pegs, the board, and the answer image
206 * and use these to create the tray, answer and board 272 * and use these to create the tray, answer and board
207 */ 273 */
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 );
214 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);
290
215 setToolBarsMovable( FALSE ); 291 setToolBarsMovable( FALSE );
216 292
217 QToolBar *tb = new QToolBar(this); 293 QToolBar *tb = new QToolBar(this);
218 tb->setHorizontalStretchable( TRUE ); 294 tb->setHorizontalStretchable( TRUE );
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
224 score = new QToolButton(tb); 300 score = new QToolButton(tb);
225 score->setText(""); 301 score->setText("");
226 score->setMaximumHeight(20); 302 score->setMaximumHeight(20);
227 score->setUsesTextLabel(TRUE); 303 score->setUsesTextLabel(TRUE);
228 tb->setStretchableWidget(score); 304 tb->setStretchableWidget(score);
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}
237 315
238void MindBreaker::setScore(int turns, int games) 316void MindBreaker::setScore(int turns, int games)
239{ 317{
240 double average; 318 double average;
241 double total_turns = turns; 319 double total_turns = turns;
242 double total_games = games; 320 double total_games = games;
243 321
244 if(total_games > 0) 322 if(total_games > 0)
245 average = total_turns / total_games; 323 average = total_turns / total_games;
246 else 324 else
247 average = 0.0; 325 average = 0.0;
248 326
249 score->setText(tr("win avg: %1 turns (%2 games)").arg(average).arg(games)); 327 score->setText(tr("win avg: %1 turns (%2 games)").arg(average).arg(games));
250} 328}
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;
259 349
260 current_go = 0; 350 current_go = 0;
261 gettimeofday(&tv, 0); 351 gettimeofday(&tv, 0);
262
263 srand(tv.tv_usec); 352 srand(tv.tv_usec);
264 353
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);
290 c.setGroup("Board"); 368 c.setGroup("Board");
291 game_over = FALSE; 369 game_over = FALSE;
370 int i;
292 if (c.readNumEntry("Answer0") < 0) { 371 if (c.readNumEntry("Answer0") < 0) {
293 for (i = 0; i < 4; i++) { 372 for (i = 0; i < 4; i++) {
294 answer[i] = rand() % 6; 373 answer[i] = rand() % 6;
295 current_guess[i] = 6; 374 current_guess[i] = 6;
296 } 375 }
297 total_turns = 0; 376 total_turns = 0;
298 total_games = 0; 377 total_games = 0;
299 } else { 378 } else {
300 int j; 379 int j;
301 c.setGroup("Score"); 380 c.setGroup("Score");
302 total_turns = c.readNumEntry("Turns"); 381 total_turns = c.readNumEntry("Turns");
303 total_games = c.readNumEntry("Games"); 382 total_games = c.readNumEntry("Games");
304 if(total_turns < 0) 383 if(total_turns < 0)
305 total_turns = 0; 384 total_turns = 0;
306 if(total_games < 0) 385 if(total_games < 0)
307 total_games = 0; 386 total_games = 0;
308 387
309 388
310 checkScores(); 389 checkScores();
311 c.setGroup("Board"); 390 c.setGroup("Board");
312 for(i = 0; i < 4; i++) 391 for(i = 0; i < 4; i++)
313 answer[i] = c.readNumEntry(QString("Answer%1").arg(i)); 392 answer[i] = c.readNumEntry(QString("Answer%1").arg(i));
314 /* read, and parse past guesses */ 393 /* read, and parse past guesses */
315 current_go = 0; 394 current_go = 0;
316 for(j=0; j < 9; j++) { 395 for(j=0; j < 9; j++) {
317 current_guess[0] = c.readNumEntry(QString("Go%1p0").arg(j)); 396 current_guess[0] = c.readNumEntry(QString("Go%1p0").arg(j));
318 if (current_guess[0] < 0) 397 if (current_guess[0] < 0)
319 break; 398 break;
320 placeGuessPeg(0, current_guess[0]); 399 placeGuessPeg(0, current_guess[0]);
321 current_guess[1] = c.readNumEntry(QString("Go%1p1").arg(j)); 400 current_guess[1] = c.readNumEntry(QString("Go%1p1").arg(j));
322 placeGuessPeg(1, current_guess[1]); 401 placeGuessPeg(1, current_guess[1]);
323 current_guess[2] = c.readNumEntry(QString("Go%1p2").arg(j)); 402 current_guess[2] = c.readNumEntry(QString("Go%1p2").arg(j));
324 placeGuessPeg(2, current_guess[2]); 403 placeGuessPeg(2, current_guess[2]);
325 current_guess[3] = c.readNumEntry(QString("Go%1p3").arg(j)); 404 current_guess[3] = c.readNumEntry(QString("Go%1p3").arg(j));
326 placeGuessPeg(3, current_guess[3]); 405 placeGuessPeg(3, current_guess[3]);
327 checkGuess(); 406 checkGuess();
328 } 407 }
329 for(i = 0; i < 4; i++) { 408 for(i = 0; i < 4; i++) {
330 current_guess[i] = c.readNumEntry(QString("CurrentGo%1").arg(i)); 409 current_guess[i] = c.readNumEntry(QString("CurrentGo%1").arg(i));
331 if (current_guess[i] != 6) 410 if (current_guess[i] != 6)
332 placeGuessPeg(i, current_guess[i]); 411 placeGuessPeg(i, current_guess[i]);
333 } 412 }
334 } 413 }
335
336 /* draw initial screen */
337 drawBackground();
338 canvas()->update();
339} 414}
340 415
341MindBreakerBoard::~MindBreakerBoard() 416MindBreakerBoard::~MindBreakerBoard()
342{ 417{
343 int i, j; 418 int i;
344 if (game_over) { 419 if (game_over) {
345 current_go = 0; 420 current_go = 0;
346 /* clear the answer, clear the guess */ 421 /* clear the answer, clear the guess */
347 for (i = 0; i < 4; i++) { 422 for (i = 0; i < 4; i++) {
348 answer[i] = rand() % 6; 423 answer[i] = rand() % 6;
349 current_guess[i] = 6; 424 current_guess[i] = 6;
350 } 425 }
351 } 426 }
352 427 writeConfig();
428}
429
430void MindBreakerBoard::writeConfig()
431{
353 Config c("MindBreaker", Config::User); 432 Config c("MindBreaker", Config::User);
354 c.setGroup("Board"); 433 c.setGroup("Board");
355 c.clearGroup(); 434 c.clearGroup();
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
366 c.setGroup("Score"); 446 c.setGroup("Score");
367 /* write the score */ 447 /* write the score */
368 448
369 c.writeEntry("Turns", total_turns); 449 c.writeEntry("Turns", total_turns);
370 c.writeEntry("Games", total_games); 450 c.writeEntry("Games", total_games);
371} 451}
372 452
373void MindBreakerBoard::getScore(int *a, int *b) 453void MindBreakerBoard::getScore(int *a, int *b)
374{ 454{
375 *a = total_turns; 455 *a = total_turns;
376 *b = total_games; 456 *b = total_games;
377 return; 457 return;
378} 458}
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
386 Peg *peg = new Peg(canvas(), pegId, current_go, pos); 530 Peg *peg = new Peg(canvas(), pegId, current_go, pos);
387 peg->setPegPos(pos); 531 peg->setPegPos(pos);
388 peg->setPlaced(TRUE); 532 peg->setPlaced(TRUE);
389 peg->setX(x); 533 peg->setX(x);
390 peg->setY(y); 534 peg->setY(y);
391 peg->setZ(2); 535 peg->setZ(2);
392 peg->show(); 536 peg->show();
393} 537}
394 538
395void MindBreakerBoard::drawBackground() 539void MindBreakerBoard::drawBackground()
396{ 540{
397 int i, j, x, y, x_gap, y_gap; 541 int i, j, x, y, x_gap, y_gap;
398 QPixmap background = QPixmap(canvas()->width(), canvas()->height()); 542 QPixmap background = QPixmap(canvas()->width(), canvas()->height());
399 543
400 QPainter painter(&background); 544 QPainter painter(&background);
401 545
402 painter.fillRect(0, 0, canvas()->width(), canvas()->height(), QColor(0,0,0)); 546 painter.fillRect(0, 0, canvas()->width(), canvas()->height(), QColor(0,0,0));
403 /* very first thing is to draw the bins, as everything else needs 547 /* very first thing is to draw the bins, as everything else needs
404 * to be drawn over them */ 548 * to be drawn over them */
405 549
406 QPen pen(QColor(85, 45, 27), 4); 550 QPen pen(QColor(85, 45, 27), 4);
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;
410 if (x_gap < 1) 554 if (x_gap < 1)
411 x_gap = 1; 555 x_gap = 1;
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;
416 if (y_gap < 1) 560 if (y_gap < 1)
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
421 for (i = 0; i < 6; i++) { 565 for (i = 0; i < 6; i++) {
422 for (j = 0; j < 10; j++) { 566 for (j = 0; j < 10; j++) {
423 int rx = x + (rand() % x_gap); 567 int rx = x + (rand() % x_gap);
424 int ry = y + (rand() % y_gap); 568 int ry = y + (rand() % y_gap);
425 painter.drawImage(rx,ry, Peg::imageForType(i)); 569 painter.drawImage(rx,ry, Peg::imageForType(i));
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;
435 579
436 for (i = 0; i < 6; i++) { 580 for (i = 0; i < 6; i++) {
437 painter.drawRect(x, y, x_gap, y_gap); 581 painter.drawRect(x, y, x_gap, y_gap);
438 y += y_gap; 582 y += y_gap;
439 } 583 }
440 584
441 x = 0; 585 x = 0;
442 y = 0; 586 y = 0;
443 587
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 */
447 for (i = 0; i < 9; i ++) { 591 for (i = 0; i < 9; i ++) {
448 painter.drawImage(x, y, panelImage); 592 painter.drawImage(x, y, panelImage);
449 y += panel_height; 593 y += adjusted_panel_height;
450 } 594 }
451 595
452 painter.flush(); 596 painter.flush();
453 canvas()->setBackgroundPixmap(background); 597 canvas()->setBackgroundPixmap(background);
454} 598}
455 599
456void MindBreakerBoard::checkGuess() 600void MindBreakerBoard::checkGuess()
457{ 601{
458 int i,j; 602 int i,j;
459 int num_white = 0; 603 int num_white = 0;
460 int num_black = 0; 604 int num_black = 0;
461 int copy_answer[4]; 605 int copy_answer[4];
462 int copy_guess[4]; 606 int copy_guess[4];
463 607
464 for(i = 0; i < 4; i++) { 608 for(i = 0; i < 4; i++) {
465 copy_answer[i] = answer[i]; 609 copy_answer[i] = answer[i];
466 copy_guess[i] = current_guess[i]; 610 copy_guess[i] = current_guess[i];
467 if (current_guess[i] == 6) 611 if (current_guess[i] == 6)
468 return; 612 return;
469 if (answer[i] == current_guess[i]) { 613 if (answer[i] == current_guess[i]) {
470 num_black++; 614 num_black++;
471 copy_answer[i] = 6; 615 copy_answer[i] = 6;
472 copy_guess[i] = 7; 616 copy_guess[i] = 7;
473 } 617 }
474 } 618 }
475 619
476 /* now sure that user has completed a 'guess' */ 620 /* now sure that user has completed a 'guess' */
477 for (i = 0; i < 4; i++) { 621 for (i = 0; i < 4; i++) {
478 if (copy_guess[i] == 7) 622 if (copy_guess[i] == 7)
479 continue; // already marked for a black 623 continue; // already marked for a black
480 for (j = 0; j < 4; j++) { 624 for (j = 0; j < 4; j++) {
481 if(copy_guess[i] == copy_answer[j]) { 625 if(copy_guess[i] == copy_answer[j]) {
482 copy_answer[j] = 6; 626 copy_answer[j] = 6;
483 num_white++; 627 num_white++;
484 break; 628 break;
485 } 629 }
486 } 630 }
487 } 631 }
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
492 if (num_black == 4) 636 if (num_black == 4)
493 game_over = TRUE; 637 game_over = TRUE;
494 638
495 while(num_black > 0) { 639 while(num_black > 0) {
496 Peg *p = new Peg(canvas(), 7); 640 Peg *p = new Peg(canvas(), 7);
497 p->setPlaced(TRUE); 641 p->setPlaced(TRUE);
498 p->setX(x); 642 p->setX(x);
499 p->setY(y); 643 p->setY(y);
500 p->setZ(1); 644 p->setZ(1);
501 p->show(); 645 p->show();
502 num_black--; 646 num_black--;
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 }
510 } 654 }
511 while(num_white > 0){ 655 while(num_white > 0){
512 Peg *p = new Peg(canvas(), 6); 656 Peg *p = new Peg(canvas(), 6);
513 p->setPlaced(TRUE); 657 p->setPlaced(TRUE);
514 p->setX(x); 658 p->setX(x);
515 p->setY(y); 659 p->setY(y);
516 p->setZ(1); 660 p->setZ(1);
517 p->show(); 661 p->show();
518 num_white--; 662 num_white--;
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 }
526 } 670 }
527 /* move to next go */ 671 /* move to next go */
528 for(i = 0; i < 4; i++) { 672 for(i = 0; i < 4; i++) {
529 past_guesses[4*current_go+i] = current_guess[i]; 673 past_guesses[4*current_go+i] = current_guess[i];
530 current_guess[i] = 6; 674 current_guess[i] = 6;
531 } 675 }
532 676
533 current_go++; 677 current_go++;
534 if((current_go > 8) || game_over) { 678 if((current_go > 8) || game_over) {
535 total_games++; 679 total_games++;
536 if(!game_over) 680 if(!game_over)
537 total_turns += 10; 681 total_turns += 10;
538 else 682 else
539 total_turns += current_go; 683 total_turns += current_go;
540 684
541 emit scoreChanged(total_turns, total_games); 685 emit scoreChanged(total_turns, total_games);
542 Peg *p = new Peg(canvas(), 9); 686 Peg *p = new Peg(canvas(), 9);
543 game_over = TRUE; 687 game_over = TRUE;
544 p->setPlaced(TRUE); 688 p->setPlaced(TRUE);
545 p->setX(0); 689 p->setX(0);
546 p->setY(0); 690 p->setY(0);
547 p->setZ(0); 691 p->setZ(0);
548 p->show(); 692 p->show();
549 693
550 for (i = 0; i < 4; i++) { 694 for (i = 0; i < 4; i++) {
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);
555 p->show(); 699 p->show();
556 } 700 }
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 }
560 canvas()->update(); 704 canvas()->update();
561} 705}
562 706
563void MindBreakerBoard::clear() 707void MindBreakerBoard::clear()
564{ 708{
565 if(!game_over) { 709 if(!game_over) {
566 total_games++; 710 total_games++;
567 total_turns += 10; 711 total_turns += 10;
568 emit scoreChanged(total_turns, total_games); 712 emit scoreChanged(total_turns, total_games);
569 } 713 }
570 int i; 714 int i;
571 /* reset the game board */ 715 /* reset the game board */
572 game_over = FALSE; 716 game_over = FALSE;
573 /* clear the answer, clear the guess */ 717 /* clear the answer, clear the guess */
574 for (i = 0; i < 4; i++) { 718 for (i = 0; i < 4; i++) {
575 answer[i] = rand() % 6; 719 answer[i] = rand() % 6;
576 current_guess[i] = 6; 720 current_guess[i] = 6;
577 } 721 }
578 current_go = 0; 722 current_go = 0;
579 723
580 QCanvasItemList list = canvas()->allItems(); 724 QCanvasItemList list = canvas()->allItems();
581 QCanvasItemList::Iterator it = list.begin(); 725 QCanvasItemList::Iterator it = list.begin();
582 for (; it != list.end(); ++it) { 726 for (; it != list.end(); ++it) {
583 if (*it == current_highlight) 727 if (*it == current_highlight)
584 continue; 728 continue;
585 if (*it) 729 if (*it)
586 delete *it; 730 delete *it;
587 } 731 }
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();
591 drawBackground(); 735 drawBackground();
592 canvas()->update(); 736 canvas()->update();
593} 737}
594 738
595void MindBreakerBoard::resetScore() 739void MindBreakerBoard::resetScore()
596{ 740{
597 /* are u sure */ 741 /* are u sure */
598 742
599 if (QMessageBox::information(this, tr( "Reset Statistics" ), 743 if (QMessageBox::information(this, tr( "Reset Statistics" ),
600 tr( "Reset the win ratio?" ), 744 tr( "Reset the win ratio?" ),
601 tr( "OK" ), tr( "Cancel" ) ) == 0) { 745 tr( "OK" ), tr( "Cancel" ) ) == 0) {
602 total_turns = 0; 746 total_turns = 0;
603 total_games = 0; 747 total_games = 0;
604 Peg::eggLevel = 0; 748 Peg::eggLevel = 0;
605 drawBackground(); 749 drawBackground();
606 canvas()->update(); 750 canvas()->update();
607 emit scoreChanged(total_turns, total_games); 751 emit scoreChanged(total_turns, total_games);
608 } 752 }
609} 753}
610 754
611/* EVENTS */ 755/* EVENTS */
612 756
613void MindBreakerBoard::contentsMousePressEvent(QMouseEvent *e) 757void 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;
616 null_press = FALSE; 767 null_press = FALSE;
617 /* ok, first work out if it is one of the bins that 768 /* ok, first work out if it is one of the bins that
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
625 /* make new peg... set it moving */ 776 /* make new peg... set it moving */
626 moving_pos = e->pos(); 777 moving_pos = e->pos();
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);
631 moving->show(); 782 moving->show();
632 canvas()->update(); 783 canvas()->update();
633 return; 784 return;
634 } 785 }
635 786
636 QCanvasItemList l = canvas()->collisions(e->pos()); 787 QCanvasItemList l = canvas()->collisions(e->pos());
637 for (QCanvasItemList::Iterator it=l.begin(); it !=l.end(); ++it) { 788 for (QCanvasItemList::Iterator it=l.begin(); it !=l.end(); ++it) {
638 if ( (*it)->rtti() == pegRTTI ) { 789 if ( (*it)->rtti() == pegRTTI ) {
639 Peg *item = (Peg *)(*it); 790 Peg *item = (Peg *)(*it);
640 if (!item->hit(e->pos())) 791 if (!item->hit(e->pos()))
641 continue; 792 continue;
642 if (item->type() > 5) { 793 if (item->type() > 5) {
643 null_press = TRUE; 794 null_press = TRUE;
644 null_point = e->pos(); 795 null_point = e->pos();
645 continue; /* not a color peg */ 796 continue; /* not a color peg */
646 } 797 }
647 if (item->placed()) { 798 if (item->placed()) {
648 /* copy */ 799 /* copy */
649 if(item->pegGo() == -1) 800 if(item->pegGo() == -1)
650 return; 801 return;
651 if(item->pegGo() == current_go) { 802 if(item->pegGo() == current_go) {
652 copy_press = TRUE; 803 copy_press = TRUE;
653 copy_peg = item; 804 copy_peg = item;
654 } 805 }
655 moving = new Peg(canvas(), 806 moving = new Peg(canvas(),
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);
660 moving->show(); 811 moving->show();
661 moving_pos = QPoint(e->x(), e->y()); 812 moving_pos = QPoint(e->x(), e->y());
662 canvas()->update(); 813 canvas()->update();
663 return; 814 return;
664 } 815 }
665 moving = (Peg *)*it; 816 moving = (Peg *)*it;
666 moving_pos = e->pos(); 817 moving_pos = e->pos();
667 canvas()->update(); 818 canvas()->update();
668 return; 819 return;
669 } 820 }
670 } 821 }
671 null_press = TRUE; 822 null_press = TRUE;
672 null_point = e->pos(); 823 null_point = e->pos();
673 moving = 0; 824 moving = 0;
674} 825}
675 826
676void MindBreakerBoard::contentsMouseMoveEvent(QMouseEvent* e) 827void MindBreakerBoard::contentsMouseMoveEvent(QMouseEvent* e)
677{ 828{
678 if (moving ) { 829 if (moving ) {
679 moving->moveBy(e->pos().x() - moving_pos.x(), 830 moving->moveBy(e->pos().x() - moving_pos.x(),
680 e->pos().y() - moving_pos.y()); 831 e->pos().y() - moving_pos.y());
681 moving_pos = e->pos(); 832 moving_pos = e->pos();
682 canvas()->update(); 833 canvas()->update();
683 return; 834 return;
684 } 835 }
685} 836}
686 837
687void MindBreakerBoard::contentsMouseReleaseEvent(QMouseEvent* e) 838void MindBreakerBoard::contentsMouseReleaseEvent(QMouseEvent* e)
688{ 839{
689 /* time to put down the peg */ 840 /* time to put down the peg */
690 if(moving) { 841 if(moving) {
691 if(copy_press) { 842 if(copy_press) {
692 /* check if collided with original. if so, delete both */ 843 /* check if collided with original. if so, delete both */
693 copy_press = FALSE; 844 copy_press = FALSE;
694 QCanvasItemList l = canvas()->collisions(e->pos()); 845 QCanvasItemList l = canvas()->collisions(e->pos());
695 for (QCanvasItemList::Iterator it=l.begin(); it !=l.end(); ++it) { 846 for (QCanvasItemList::Iterator it=l.begin(); it !=l.end(); ++it) {
696 if (*it == copy_peg) 847 if (*it == copy_peg)
697 copy_press = TRUE; 848 copy_press = TRUE;
698 } 849 }
699 if (copy_press) { 850 if (copy_press) {
700 current_guess[copy_peg->pegPos()] = 6; 851 current_guess[copy_peg->pegPos()] = 6;
701 delete copy_peg; 852 delete copy_peg;
702 delete moving; 853 delete moving;
703 copy_press = FALSE; 854 copy_press = FALSE;
704 moving = 0; 855 moving = 0;
705 copy_peg = 0; 856 copy_peg = 0;
706 canvas()->update(); 857 canvas()->update();
707 return; 858 return;
708 } 859 }
709 } 860 }
710 861
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;
714 moving = 0; 865 moving = 0;
715 canvas()->update(); 866 canvas()->update();
716 return; 867 return;
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;
720 moving = 0; 871 moving = 0;
721 canvas()->update(); 872 canvas()->update();
722 return; 873 return;
723 } 874 }
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;
728 if (e->x() > x_bar) 879 if (e->x() > x_bar)
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
738 if (e->x() > x_bar) { 889 if (e->x() > x_bar) {
739 /* invalid x */ 890 /* invalid x */
740 delete moving; 891 delete moving;
741 moving = 0; 892 moving = 0;
742 canvas()->update(); 893 canvas()->update();
743 return; 894 return;
744 } 895 }
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);
750 moving->setX(x); 901 moving->setX(x);
751 moving->setY(y); 902 moving->setY(y);
752 moving->setZ(2); 903 moving->setZ(2);
753 904
754 /* remove all other pegs from this position */ 905 /* remove all other pegs from this position */
755 QCanvasItemList l = canvas()->collisions(QPoint(x,y)); 906 QCanvasItemList l = canvas()->collisions(QPoint(x,y));
756 for (QCanvasItemList::Iterator it=l.begin(); it !=l.end(); ++it) { 907 for (QCanvasItemList::Iterator it=l.begin(); it !=l.end(); ++it) {
757 if ( (*it)->rtti() == pegRTTI ) { 908 if ( (*it)->rtti() == pegRTTI ) {
758 Peg *item = (Peg *)(*it); 909 Peg *item = (Peg *)(*it);
759 if ((item != moving) && (item != current_highlight)) 910 if ((item != moving) && (item != current_highlight))
760 delete item; 911 delete item;
761 } 912 }
762 } 913 }
763 current_guess[pos] = ((Peg *)moving)->type(); 914 current_guess[pos] = ((Peg *)moving)->type();
764 915
765 ((Peg *)moving)->setPlaced(true); 916 ((Peg *)moving)->setPlaced(true);
766 canvas()->update(); 917 canvas()->update();
767 return; 918 return;
768 } 919 }
769 moving = 0; 920 moving = 0;
770 null_point -= e->pos(); 921 null_point -= e->pos();
771 if(null_point.manhattanLength() < 6) { 922 if(null_point.manhattanLength() < 6) {
772 if (game_over) 923 if (game_over)
773 clear(); 924 clear();
774 else 925 else
775 checkGuess(); 926 checkGuess();
776 } 927 }
777} 928}
778 929
779void MindBreakerBoard::resizeEvent(QResizeEvent *e) 930void 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}
796 935
797 936
798/* Easter egg function... beat the clock */ 937/* Easter egg function... beat the clock */
799void MindBreakerBoard::checkScores() 938void MindBreakerBoard::checkScores()
800{ 939{
801 double games = total_games; 940 double games = total_games;
802 double turns = total_turns; 941 double turns = total_turns;
803 double g = games / 10.0; 942 double g = games / 10.0;
804 Peg::eggLevel = 0; 943 Peg::eggLevel = 0;
805 944
806 double break_even = 5.0; 945 double break_even = 5.0;
807 if (g < 1.0) 946 if (g < 1.0)
808 return; 947 return;
809 double avg = turns / games; 948 double avg = turns / games;
810 g--; 949 g--;
811 while (break_even >= 0.0) { 950 while (break_even >= 0.0) {
812 if (avg >= (break_even + g)) 951 if (avg >= (break_even + g))
813 return; 952 return;
814 // score a peg. 953 // score a peg.
815 break_even -= 1.0; 954 break_even -= 1.0;
816 Peg::eggLevel = int(5.0 - break_even); 955 Peg::eggLevel = int(5.0 - break_even);
817 } 956 }
818} 957}
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,122 +1,139 @@
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**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#ifndef MINDBREAKER_H 21#ifndef MINDBREAKER_H
22#define MINDBREAKER_H 22#define MINDBREAKER_H
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qmainwindow.h> 25#include <qmainwindow.h>
26#include <qimage.h> 26#include <qimage.h>
27#include <qvector.h> 27#include <qvector.h>
28#include <qcanvas.h> 28#include <qcanvas.h>
29#include <qlabel.h> 29#include <qlabel.h>
30 30
31static const int panel_height = 26; 31static const int panel_height = 26;
32static const int panel_width = 180; 32static const int panel_width = 180;
33 33
34static const int title_height = 25; 34static const int title_height = 25;
35static const int title_width = 180; 35static const int title_width = 180;
36 36
37static const int bin_margin = 10; 37static const int bin_margin = 10;
38static const int peg_size = 20; 38static const int peg_size = 20;
39static const int answerpeg_size = 13; 39static const int answerpeg_size = 13;
40 40
41static const int first_peg_x_diff = 21; 41static const int first_peg_x_diff = 21;
42static const int first_peg_y_diff = ((panel_height - peg_size) >> 1); 42static const int first_peg_y_diff = ((panel_height - peg_size) >> 1);
43static const int peg_spacing = 30; 43static const int peg_spacing = 30;
44 44
45static const int answerpegx = 152; 45static const int answerpegx = 152;
46static const int answerpegy = 2; 46static const int answerpegy = 2;
47static const int answerpeg_diff = 9; 47static const int answerpeg_diff = 9;
48 48
49static const int board_height = (title_height + (panel_height * 9)); 49static const int board_height = (title_height + (panel_height * 9));
50static const int board_width = (panel_width + (bin_margin * 2) + peg_size); 50static const int board_width = (panel_width + (bin_margin * 2) + peg_size);
51 51
52class Peg; 52class Peg;
53class QToolButton; 53class QToolButton;
54class QTimer;
54 55
55class MindBreakerBoard : public QCanvasView // QWidget 56class MindBreakerBoard : public QCanvasView // QWidget
56{ 57{
57 Q_OBJECT 58 Q_OBJECT
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();
61 62
62 void getScore(int *, int *); 63 void getScore(int *, int *);
64
65 void resizeEvent(QResizeEvent*);
66 void fixSize();
67
63signals: 68signals:
64 void scoreChanged(int, int); 69 void scoreChanged(int, int);
65 70
66public slots: 71public slots:
67 void clear(); 72 void clear();
68 void resetScore(); 73 void resetScore();
69 74
75private slots:
76 void doFixSize();
77
70protected: 78protected:
71 void contentsMousePressEvent(QMouseEvent *); 79 void contentsMousePressEvent(QMouseEvent *);
72 void contentsMouseMoveEvent(QMouseEvent *); 80 void contentsMouseMoveEvent(QMouseEvent *);
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();
78 void checkGuess(); 90 void checkGuess();
79 void checkScores(); 91 void checkScores();
80 void placeGuessPeg(int pos, int pegId); 92 void placeGuessPeg(int pos, int pegId);
81 93
82 QImage panelImage; 94 QImage panelImage;
83 QImage titleImage; 95 QImage titleImage;
84 96
85 Peg *moving; 97 Peg *moving;
86 Peg *current_highlight; 98 Peg *current_highlight;
87 QPoint moving_pos; 99 QPoint moving_pos;
88 100
89 // the game stuff 101 // the game stuff
90 int answer[4]; 102 int answer[4];
91 int current_guess[4]; 103 int current_guess[4];
92 int past_guesses[4*9]; 104 int past_guesses[4*9];
93 int current_go; 105 int current_go;
94 106
95 int null_press; 107 int null_press;
96 QPoint null_point; 108 QPoint null_point;
97 bool copy_press; 109 bool copy_press;
98 Peg *copy_peg; 110 Peg *copy_peg;
99 bool game_over; 111 bool game_over;
100 112
101 int total_turns; 113 int total_turns;
102 int total_games; 114 int total_games;
115
116 QTimer *widthTimer;
103}; 117};
104 118
105class MindBreaker : public QMainWindow // QWidget 119class MindBreaker : public QMainWindow // QWidget
106{ 120{
107 Q_OBJECT 121 Q_OBJECT
108public: 122public:
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:
112 void setScore(int, int); 126 void setScore(int, int);
113 127
128protected:
129 void resizeEvent( QResizeEvent * );
130
114private: 131private:
115 QCanvas canvas; 132 QCanvas canvas;
116 MindBreakerBoard *board; 133 MindBreakerBoard *board;
117 QToolButton *score; 134 QToolButton *score;
118 135
119}; 136};
120 137
121 138
122#endif 139#endif
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 @@
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
5 SOURCES = main.cpp \ 3 SOURCES = main.cpp \
6 mindbreaker.cpp 4 mindbreaker.cpp
7TARGET = mindbreaker 5TARGET = mindbreaker
8INCLUDEPATH += $(OPIEDIR)/include 6INCLUDEPATH += $(OPIEDIR)/include
9DEPENDPATH += $(OPIEDIR)/include 7DEPENDPATH += $(OPIEDIR)/include
10LIBS += -lqpe 8LIBS += -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,10 +1,10 @@
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
4Section: opie/games 4Section: opie/games
5Maintainer: Martin Imobersteg <imm@gmx.ch> 5Maintainer: Martin Imobersteg <imm@gmx.ch>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal 7Depends: task-opie-minimal
8Description: Game: crack the coloured code 8Description: Game: crack the coloured code
9 A game for the Opie environment. 9 A game for the Opie environment.
10Version: $QPE_VERSION$EXTRAVERSION 10Version: $QPE_VERSION$EXTRAVERSION
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
@@ -1,34 +1,27 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "minesweep.h" 21#include "minesweep.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <opie/oapplicationfactory.h>
24 25
25int main( int argc, char** argv ) 26OPIE_EXPORT_APP( OApplicationFactory<MineSweep> )
26{
27 QPEApplication a( argc, argv );
28 27
29 MineSweep ms;
30 QPEApplication::setInputMethodHint( &ms, QPEApplication::AlwaysOff );
31 a.showMainWidget( &ms );
32
33 return a.exec();
34}
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
@@ -164,385 +164,385 @@ void Mine::setState( MineState s )
164} 164}
165 165
166void Mine::setHint( int h ) 166void Mine::setHint( int h )
167{ 167{
168 hint = h; 168 hint = h;
169} 169}
170 170
171void Mine::paletteChange() 171void Mine::paletteChange()
172{ 172{
173 delete knownField; 173 delete knownField;
174 knownField = 0; 174 knownField = 0;
175 delete unknownField; 175 delete unknownField;
176 unknownField = 0; 176 unknownField = 0;
177 delete mine_pix; 177 delete mine_pix;
178 mine_pix = 0; 178 mine_pix = 0;
179 delete flag_pix; 179 delete flag_pix;
180 flag_pix = 0; 180 flag_pix = 0;
181} 181}
182 182
183void Mine::paint( QPainter* p, const QColorGroup &cg, const QRect& cr ) 183void Mine::paint( QPainter* p, const QColorGroup &cg, const QRect& cr )
184{ 184{
185 int x = cr.x(); 185 int x = cr.x();
186 int y = cr.y(); 186 int y = cr.y();
187 if ( !knownField ) { 187 if ( !knownField ) {
188 knownField = new QPixmap( cr.width(), cr.height() ); 188 knownField = new QPixmap( cr.width(), cr.height() );
189 QPainter pp( knownField ); 189 QPainter pp( knownField );
190 QBrush br( cg.button().dark(115) ); 190 QBrush br( cg.button().dark(115) );
191 qDrawWinButton( &pp, cr, cg, TRUE, &br ); 191 qDrawWinButton( &pp, cr, cg, TRUE, &br );
192 } 192 }
193 193
194 const int pmmarg=cr.width()/5; 194 const int pmmarg=cr.width()/5;
195 195
196 if ( !unknownField ) { 196 if ( !unknownField ) {
197 unknownField = new QPixmap( cr.width(), cr.height() ); 197 unknownField = new QPixmap( cr.width(), cr.height() );
198 QPainter pp( unknownField ); 198 QPainter pp( unknownField );
199 QBrush br( cg.button() ); 199 QBrush br( cg.button() );
200 qDrawWinButton( &pp, cr, cg, FALSE, &br ); 200 qDrawWinButton( &pp, cr, cg, FALSE, &br );
201 } 201 }
202 202
203 if ( !flag_pix ) { 203 if ( !flag_pix ) {
204 flag_pix = new QPixmap( cr.width()-pmmarg*2, cr.height()-pmmarg*2 ); 204 flag_pix = new QPixmap( cr.width()-pmmarg*2, cr.height()-pmmarg*2 );
205 flag_pix->convertFromImage( QImage(pix_flag).smoothScale(cr.width()-pmmarg*2, cr.height()-pmmarg*2) ); 205 flag_pix->convertFromImage( QImage(pix_flag).smoothScale(cr.width()-pmmarg*2, cr.height()-pmmarg*2) );
206 } 206 }
207 207
208 if ( !mine_pix ) { 208 if ( !mine_pix ) {
209 mine_pix = new QPixmap( cr.width()-pmmarg*2, cr.height()-pmmarg*2 ); 209 mine_pix = new QPixmap( cr.width()-pmmarg*2, cr.height()-pmmarg*2 );
210 mine_pix->convertFromImage( QImage(pix_mine).smoothScale(cr.width()-pmmarg*2, cr.height()-pmmarg*2) ); 210 mine_pix->convertFromImage( QImage(pix_mine).smoothScale(cr.width()-pmmarg*2, cr.height()-pmmarg*2) );
211 } 211 }
212 212
213 p->save(); 213 p->save();
214 214
215 switch(st) { 215 switch(st) {
216 case Hidden: 216 case Hidden:
217 p->drawPixmap( x, y, *unknownField ); 217 p->drawPixmap( x, y, *unknownField );
218 break; 218 break;
219 case Empty: 219 case Empty:
220 p->drawPixmap( x, y, *knownField ); 220 p->drawPixmap( x, y, *knownField );
221 if ( hint > 0 ) { 221 if ( hint > 0 ) {
222 switch( hint ) { 222 switch( hint ) {
223 case 1: 223 case 1:
224 p->setPen( blue ); 224 p->setPen( blue );
225 break; 225 break;
226 case 2: 226 case 2:
227 p->setPen( green.dark() ); 227 p->setPen( green.dark() );
228 break; 228 break;
229 case 3: 229 case 3:
230 p->setPen( red ); 230 p->setPen( red );
231 break; 231 break;
232 case 4: 232 case 4:
233 p->setPen( darkYellow.dark() ); 233 p->setPen( darkYellow.dark() );
234 break; 234 break;
235 case 5: 235 case 5:
236 p->setPen( darkMagenta ); 236 p->setPen( darkMagenta );
237 break; 237 break;
238 case 6: 238 case 6:
239 p->setPen( darkRed ); 239 p->setPen( darkRed );
240 break; 240 break;
241 default: 241 default:
242 p->setPen( black ); 242 p->setPen( black );
243 break; 243 break;
244 } 244 }
245 p->drawText( cr, AlignHCenter | AlignVCenter, QString::number( hint ) ); 245 p->drawText( cr, AlignHCenter | AlignVCenter, QString::number( hint ) );
246 } 246 }
247 break; 247 break;
248 case Mined: 248 case Mined:
249 p->drawPixmap( x, y, *knownField ); 249 p->drawPixmap( x, y, *knownField );
250 p->drawPixmap( x+pmmarg, y+pmmarg, *mine_pix ); 250 p->drawPixmap( x+pmmarg, y+pmmarg, *mine_pix );
251 break; 251 break;
252 case Exploded: 252 case Exploded:
253 p->drawPixmap( x, y, *knownField ); 253 p->drawPixmap( x, y, *knownField );
254 p->drawPixmap( x+pmmarg, y+pmmarg, *mine_pix ); 254 p->drawPixmap( x+pmmarg, y+pmmarg, *mine_pix );
255 p->setPen( red ); 255 p->setPen( red );
256 p->drawText( cr, AlignHCenter | AlignVCenter, "X" ); 256 p->drawText( cr, AlignHCenter | AlignVCenter, "X" );
257 break; 257 break;
258 case Flagged: 258 case Flagged:
259 p->drawPixmap( x, y, *unknownField ); 259 p->drawPixmap( x, y, *unknownField );
260 p->drawPixmap( x+pmmarg, y+pmmarg, *flag_pix ); 260 p->drawPixmap( x+pmmarg, y+pmmarg, *flag_pix );
261 break; 261 break;
262#ifdef MARK_UNSURE 262#ifdef MARK_UNSURE
263 case Unsure: 263 case Unsure:
264 p->drawPixmap( x, y, *unknownField ); 264 p->drawPixmap( x, y, *unknownField );
265 p->drawText( cr, AlignHCenter | AlignVCenter, "?" ); 265 p->drawText( cr, AlignHCenter | AlignVCenter, "?" );
266 break; 266 break;
267#endif 267#endif
268 case Wrong: 268 case Wrong:
269 p->drawPixmap( x, y, *unknownField ); 269 p->drawPixmap( x, y, *unknownField );
270 p->drawPixmap( x+pmmarg, y+pmmarg, *flag_pix ); 270 p->drawPixmap( x+pmmarg, y+pmmarg, *flag_pix );
271 p->setPen( red ); 271 p->setPen( red );
272 p->drawText( cr, AlignHCenter | AlignVCenter, "X" ); 272 p->drawText( cr, AlignHCenter | AlignVCenter, "X" );
273 break; 273 break;
274 } 274 }
275 275
276 p->restore(); 276 p->restore();
277} 277}
278 278
279/* 279/*
280 MineField implementation 280 MineField implementation
281*/ 281*/
282 282
283MineField::MineField( QWidget* parent, const char* name ) 283MineField::MineField( QWidget* parent, const char* name )
284: QScrollView( parent, name ) 284: QScrollView( parent, name )
285{ 285{
286 setState( GameOver ); 286 setState( GameOver );
287 287
288 setSizePolicy( QSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum ) ); 288 setSizePolicy( QSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum ) );
289 289
290 setFocusPolicy( QWidget::NoFocus ); 290 setFocusPolicy( QWidget::NoFocus );
291 291
292 holdTimer = new QTimer( this ); 292 holdTimer = new QTimer( this );
293 connect( holdTimer, SIGNAL( timeout() ), this, SLOT( held() ) ); 293 connect( holdTimer, SIGNAL( timeout() ), this, SLOT( held() ) );
294 294
295 flagAction = NoAction; 295 flagAction = NoAction;
296 ignoreClick = FALSE; 296 ignoreClick = FALSE;
297 currRow = currCol = -1; 297 currRow = currCol = -1;
298 minecount=0; 298 minecount=0;
299 mineguess=0; 299 mineguess=0;
300 nonminecount=0; 300 nonminecount=0;
301 cellSize = -1; 301 cellSize = -1;
302 mines = 0; 302 mines = 0;
303} 303}
304 304
305MineField::~MineField() 305MineField::~MineField()
306{ 306{
307 int i; 307 int i;
308 if ( mines ) 308 if ( mines )
309 { 309 {
310 for ( i = 0; i < numCols*numRows; i++ ) 310 for ( i = 0; i < numCols*numRows; i++ )
311 { 311 {
312 delete mines[i]; 312 delete mines[i];
313 } 313 }
314 delete[] mines; 314 delete[] mines;
315 } 315 }
316} 316}
317 317
318void MineField::setState( State st ) 318void MineField::setState( State st )
319{ 319{
320 stat = st; 320 stat = st;
321} 321}
322 322
323void MineField::setup( int level ) 323void MineField::setup( int level )
324{ 324{
325 lev = level; 325 lev = level;
326 setState( Waiting ); 326 setState( Waiting );
327 //viewport()->setUpdatesEnabled( FALSE ); 327 //viewport()->setUpdatesEnabled( FALSE );
328 328
329 int i; 329 int i;
330 if ( mines ) 330 if ( mines )
331 { 331 {
332 for ( i = 0; i < numCols*numRows; i++ ) 332 for ( i = 0; i < numCols*numRows; i++ )
333 { 333 {
334 delete mines[i]; 334 delete mines[i];
335 } 335 }
336 delete[] mines; 336 delete[] mines;
337 } 337 }
338 338
339 switch( lev ) { 339 switch( lev ) {
340 case 1: 340 case 1:
341 numRows = 9 ; 341 numRows = 9 ;
342 numCols = 9 ; 342 numCols = 9 ;
343 minecount = 12; 343 minecount = 12;
344 break; 344 break;
345 case 2: 345 case 2:
346 numRows = 16; 346 numRows = 16;
347 numCols = 16; 347 numCols = 16;
348 minecount = 45; 348 minecount = 45;
349 break; 349 break;
350 case 3: 350 case 3:
351 numCols = 18; 351 numCols = 18;
352 numRows = 18; 352 numRows = 18;
353 minecount = 66 ; 353 minecount = 66 ;
354 break; 354 break;
355 } 355 }
356 mines = new (Mine*)[numRows*numCols]; 356 mines = new Mine*[numRows*numCols];
357 for ( i = 0; i < numCols*numRows; i++ ) 357 for ( i = 0; i < numCols*numRows; i++ )
358 mines[i] = new Mine( this ); 358 mines[i] = new Mine( this );
359 359
360 360
361 nonminecount = numRows*numCols - minecount; 361 nonminecount = numRows*numCols - minecount;
362 mineguess = minecount; 362 mineguess = minecount;
363 emit mineCount( mineguess ); 363 emit mineCount( mineguess );
364 Mine::paletteChange(); 364 Mine::paletteChange();
365 365
366 if ( availableRect.isValid() ) 366 if ( availableRect.isValid() )
367 setCellSize(findCellSize()); 367 setCellSize(findCellSize());
368 // viewport()->setUpdatesEnabled( TRUE ); 368 // viewport()->setUpdatesEnabled( TRUE );
369 //viewport()->repaint( TRUE ); 369 //viewport()->repaint( TRUE );
370 updateContents( 0, 0, numCols*cellSize, numRows*cellSize ); 370 updateContents( 0, 0, numCols*cellSize, numRows*cellSize );
371 updateGeometry(); 371 updateGeometry();
372} 372}
373 373
374void MineField::drawContents( QPainter * p, int clipx, int clipy, int clipw, int cliph ) 374void MineField::drawContents( QPainter * p, int clipx, int clipy, int clipw, int cliph )
375{ 375{
376 int c1 = clipx / cellSize; 376 int c1 = clipx / cellSize;
377 int c2 = ( clipx + clipw - 1 ) / cellSize; 377 int c2 = ( clipx + clipw - 1 ) / cellSize;
378 int r1 = clipy / cellSize; 378 int r1 = clipy / cellSize;
379 int r2 = ( clipy + cliph - 1 ) / cellSize; 379 int r2 = ( clipy + cliph - 1 ) / cellSize;
380 380
381 for ( int c = c1; c <= c2 ; c++ ) { 381 for ( int c = c1; c <= c2 ; c++ ) {
382 for ( int r = r1; r <= r2 ; r++ ) { 382 for ( int r = r1; r <= r2 ; r++ ) {
383 int x = c * cellSize; 383 int x = c * cellSize;
384 int y = r * cellSize; 384 int y = r * cellSize;
385 Mine *m = mine( r, c ); 385 Mine *m = mine( r, c );
386 if ( m ) 386 if ( m )
387 m->paint( p, colorGroup(), QRect(x, y, cellSize, cellSize ) ); 387 m->paint( p, colorGroup(), QRect(x, y, cellSize, cellSize ) );
388 } 388 }
389 } 389 }
390} 390}
391 391
392 392
393// Chicken and egg problem: We need to know how big the parent is 393// Chicken and egg problem: We need to know how big the parent is
394// before we can decide how big to make the table. 394// before we can decide how big to make the table.
395 395
396void MineField::setAvailableRect( const QRect &r ) 396void MineField::setAvailableRect( const QRect &r )
397{ 397{
398 availableRect = r; 398 availableRect = r;
399 int newCellSize = findCellSize(); 399 int newCellSize = findCellSize();
400 if ( newCellSize != cellSize ) { 400 if ( newCellSize != cellSize ) {
401 viewport()->setUpdatesEnabled( FALSE ); 401 viewport()->setUpdatesEnabled( FALSE );
402 setCellSize( newCellSize ); 402 setCellSize( newCellSize );
403 viewport()->setUpdatesEnabled( TRUE ); 403 viewport()->setUpdatesEnabled( TRUE );
404 viewport()->repaint( TRUE ); 404 viewport()->repaint( TRUE );
405 } 405 }
406} 406}
407 407
408int MineField::findCellSize() 408int MineField::findCellSize()
409{ 409{
410 int w = availableRect.width() - 1; 410 int w = availableRect.width() - 1;
411 int h = availableRect.height() - 1; 411 int h = availableRect.height() - 1;
412 int cellsize; 412 int cellsize;
413 413
414 cellsize = QMIN( w/numCols, h/numRows ); 414 cellsize = QMIN( w/numCols, h/numRows );
415 cellsize = QMIN( QMAX( cellsize, minGrid ), maxGrid ); 415 cellsize = QMIN( QMAX( cellsize, minGrid ), maxGrid );
416 return cellsize; 416 return cellsize;
417} 417}
418 418
419 419
420void MineField::setCellSize( int cellsize ) 420void MineField::setCellSize( int cellsize )
421{ 421{
422 cellSize = cellsize; 422 cellSize = cellsize;
423 423
424 int w = availableRect.width(); 424 int w = availableRect.width();
425 int h = availableRect.height(); 425 int h = availableRect.height();
426 426
427 int w2 = cellsize*numCols; 427 int w2 = cellsize*numCols;
428 int h2 = cellsize*numRows; 428 int h2 = cellsize*numRows;
429 429
430 resizeContents( w2, h2 ); 430 resizeContents( w2, h2 );
431 431
432 int b = 5; 432 int b = 5;
433 433
434 setGeometry( availableRect.x() + (w-w2)/2, availableRect.y() + (h-h2)/2, 434 setGeometry( availableRect.x() + (w-w2)/2, availableRect.y() + (h-h2)/2,
435 w2+b, h2+b ); 435 w2+b, h2+b );
436 // QMIN(w,w2+b), QMIN(h,h2+b) ); 436 // QMIN(w,w2+b), QMIN(h,h2+b) );
437} 437}
438 438
439 439
440void MineField::placeMines() 440void MineField::placeMines()
441{ 441{
442 int mines = minecount; 442 int mines = minecount;
443 while ( mines ) { 443 while ( mines ) {
444 int col = int((double(rand()) / double(RAND_MAX)) * numCols); 444 int col = int((double(rand()) / double(RAND_MAX)) * numCols);
445 int row = int((double(rand()) / double(RAND_MAX)) * numRows); 445 int row = int((double(rand()) / double(RAND_MAX)) * numRows);
446 446
447 Mine* m = mine( row, col ); 447 Mine* m = mine( row, col );
448 448
449 if ( m && !m->isMined() && m->state() == Mine::Hidden ) { 449 if ( m && !m->isMined() && m->state() == Mine::Hidden ) {
450 m->setMined( TRUE ); 450 m->setMined( TRUE );
451 mines--; 451 mines--;
452 } 452 }
453 } 453 }
454} 454}
455 455
456 456
457void MineField::updateCell( int r, int c ) 457void MineField::updateCell( int r, int c )
458{ 458{
459 updateContents( c*cellSize, r*cellSize, cellSize, cellSize ); 459 updateContents( c*cellSize, r*cellSize, cellSize, cellSize );
460} 460}
461 461
462 462
463void MineField::contentsMousePressEvent( QMouseEvent* e ) 463void MineField::contentsMousePressEvent( QMouseEvent* e )
464{ 464{
465 int c = e->pos().x() / cellSize; 465 int c = e->pos().x() / cellSize;
466 int r = e->pos().y() / cellSize; 466 int r = e->pos().y() / cellSize;
467 if ( onBoard( r, c ) ) 467 if ( onBoard( r, c ) )
468 cellPressed( r, c ); 468 cellPressed( r, c );
469 else 469 else
470 currCol = currRow = -1; 470 currCol = currRow = -1;
471} 471}
472 472
473void MineField::contentsMouseReleaseEvent( QMouseEvent* e ) 473void MineField::contentsMouseReleaseEvent( QMouseEvent* e )
474{ 474{
475 int c = e->pos().x() / cellSize; 475 int c = e->pos().x() / cellSize;
476 int r = e->pos().y() / cellSize; 476 int r = e->pos().y() / cellSize;
477 if ( onBoard( r, c ) && c == currCol && r == currRow ) 477 if ( onBoard( r, c ) && c == currCol && r == currRow )
478 cellClicked( r, c ); 478 cellClicked( r, c );
479 479
480 480
481 if ( flagAction == FlagNext ) { 481 if ( flagAction == FlagNext ) {
482 flagAction = NoAction; 482 flagAction = NoAction;
483 } 483 }
484} 484}
485 485
486 486
487 487
488/* 488/*
489 state == Waiting means no "hold" 489 state == Waiting means no "hold"
490 490
491 491
492*/ 492*/
493void MineField::cellPressed( int row, int col ) 493void MineField::cellPressed( int row, int col )
494{ 494{
495 if ( state() == GameOver ) 495 if ( state() == GameOver )
496 return; 496 return;
497 currRow = row; 497 currRow = row;
498 currCol = col; 498 currCol = col;
499 if ( state() == Playing ) 499 if ( state() == Playing )
500 holdTimer->start( 150, TRUE ); 500 holdTimer->start( 150, TRUE );
501} 501}
502 502
503void MineField::held() 503void MineField::held()
504{ 504{
505 flagAction = FlagNext; 505 flagAction = FlagNext;
506 updateMine( currRow, currCol ); 506 updateMine( currRow, currCol );
507 ignoreClick = TRUE; 507 ignoreClick = TRUE;
508} 508}
509 509
510 510
511 511
512 512
513void MineField::keyPressEvent( QKeyEvent* e ) 513void MineField::keyPressEvent( QKeyEvent* e )
514{ 514{
515#if defined(Q_WS_QWS) || defined(_WS_QWS_) 515#if defined(Q_WS_QWS) || defined(_WS_QWS_)
516 flagAction = ( e->key() == Key_Up ) ? FlagOn : NoAction; 516 flagAction = ( e->key() == Key_Up ) ? FlagOn : NoAction;
517#else 517#else
518 flagAction = ( ( e->state() & ShiftButton ) == ShiftButton ) ? FlagOn : NoAction; 518 flagAction = ( ( e->state() & ShiftButton ) == ShiftButton ) ? FlagOn : NoAction;
519#endif 519#endif
520} 520}
521 521
522void MineField::keyReleaseEvent( QKeyEvent* ) 522void MineField::keyReleaseEvent( QKeyEvent* )
523{ 523{
524 flagAction = NoAction; 524 flagAction = NoAction;
525} 525}
526 526
527int MineField::getHint( int row, int col ) 527int MineField::getHint( int row, int col )
528{ 528{
529 int hint = 0; 529 int hint = 0;
530 for ( int c = col-1; c <= col+1; c++ ) 530 for ( int c = col-1; c <= col+1; c++ )
531 for ( int r = row-1; r <= row+1; r++ ) { 531 for ( int r = row-1; r <= row+1; r++ ) {
532 Mine* m = mine( r, c ); 532 Mine* m = mine( r, c );
533 if ( m && m->isMined() ) 533 if ( m && m->isMined() )
534 hint++; 534 hint++;
535 } 535 }
536 536
537 return hint; 537 return hint;
538} 538}
539 539
540void MineField::setHint( int row, int col ) 540void MineField::setHint( int row, int col )
541{ 541{
542 Mine *m = mine( row, col ); 542 Mine *m = mine( row, col );
543 if ( !m ) 543 if ( !m )
544 return; 544 return;
545 545
546 int hint = getHint( row, col ); 546 int hint = getHint( row, col );
547 547
548 if ( !hint ) { 548 if ( !hint ) {
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
@@ -1,405 +1,407 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "minesweep.h" 21#include "minesweep.h"
22#include "minefield.h" 22#include "minefield.h"
23 23
24#include <qpe/qpeapplication.h>
24#include <qpe/resource.h> 25#include <qpe/resource.h>
25#include <qpe/config.h> 26#include <qpe/config.h>
26 27
27#include <qpe/qpetoolbar.h> 28#include <qpe/qpetoolbar.h>
28#include <qmenubar.h> 29#include <qmenubar.h>
29#include <qpopupmenu.h> 30#include <qpopupmenu.h>
30#include <qpushbutton.h> 31#include <qpushbutton.h>
31#include <qlcdnumber.h> 32#include <qlcdnumber.h>
32#include <qmessagebox.h> 33#include <qmessagebox.h>
33#include <qtimer.h> 34#include <qtimer.h>
34#include <qpalette.h> 35#include <qpalette.h>
35#include <qapplication.h> 36#include <qapplication.h>
36#include <qlayout.h> 37#include <qlayout.h>
37#include <qlabel.h> 38#include <qlabel.h>
38 39
39#include <stdlib.h> 40#include <stdlib.h>
40#include <time.h> 41#include <time.h>
41 42
42 43
43 44
44 45
45static const char *pix_new[]={ 46static const char *pix_new[]={
46"20 20 3 1", 47"20 20 3 1",
47" c None", 48" c None",
48"# c #00FF00", 49"# c #00FF00",
49". c #000000", 50". c #000000",
50" ", 51" ",
51" ...... ", 52" ...... ",
52" ..######.. ", 53" ..######.. ",
53" .##########. ", 54" .##########. ",
54" .############. ", 55" .############. ",
55" .##############. ", 56" .##############. ",
56" .##############. ", 57" .##############. ",
57" .################. ", 58" .################. ",
58" .################. ", 59" .################. ",
59" .################. ", 60" .################. ",
60" .################. ", 61" .################. ",
61" .################. ", 62" .################. ",
62" .################. ", 63" .################. ",
63" .##############. ", 64" .##############. ",
64" .##############. ", 65" .##############. ",
65" .############. ", 66" .############. ",
66" .##########. ", 67" .##########. ",
67" ..######.. ", 68" ..######.. ",
68" ...... ", 69" ...... ",
69" "}; 70" "};
70 71
71 72
72/* XPM */ 73/* XPM */
73static const char * happy_xpm[] = { 74static const char * happy_xpm[] = {
74"20 20 3 1", 75"20 20 3 1",
75 " c None", 76 " c None",
76 ".c #ffff3f ", 77 ".c #ffff3f ",
77 "#c #000000", 78 "#c #000000",
78" ", 79" ",
79" ###### ", 80" ###### ",
80" ##......## ", 81" ##......## ",
81" #..........# ", 82" #..........# ",
82" #............# ", 83" #............# ",
83" #..............# ", 84" #..............# ",
84" #..............# ", 85" #..............# ",
85" #....##....##....# ", 86" #....##....##....# ",
86" #....##....##....# ", 87" #....##....##....# ",
87" #................# ", 88" #................# ",
88" #................# ", 89" #................# ",
89" #................# ", 90" #................# ",
90" #...#........#...# ", 91" #...#........#...# ",
91" #.##........##.# ", 92" #.##........##.# ",
92" #...########...# ", 93" #...########...# ",
93" #...######...# ", 94" #...######...# ",
94" #..........# ", 95" #..........# ",
95" ##......## ", 96" ##......## ",
96" ###### ", 97" ###### ",
97" "}; 98" "};
98 99
99 100
100/* XPM */ 101/* XPM */
101static const char * worried_xpm[] = { 102static const char * worried_xpm[] = {
102"20 20 3 1", 103"20 20 3 1",
103 " c None", 104 " c None",
104 ".c #ffff3f", 105 ".c #ffff3f",
105 "#c #000000", 106 "#c #000000",
106" ", 107" ",
107" ###### ", 108" ###### ",
108" ##......## ", 109" ##......## ",
109" #..........# ", 110" #..........# ",
110" #............# ", 111" #............# ",
111" #..............# ", 112" #..............# ",
112" #..............# ", 113" #..............# ",
113" #....##....##....# ", 114" #....##....##....# ",
114" #....##....##....# ", 115" #....##....##....# ",
115" #................# ", 116" #................# ",
116" #................# ", 117" #................# ",
117" #................# ", 118" #................# ",
118" #................# ", 119" #................# ",
119" #....######....# ", 120" #....######....# ",
120" #..............# ", 121" #..............# ",
121" #............# ", 122" #............# ",
122" #..........# ", 123" #..........# ",
123" ##......## ", 124" ##......## ",
124" ###### ", 125" ###### ",
125" "}; 126" "};
126 127
127 128
128/* XPM */ 129/* XPM */
129static const char * dead_xpm[] = { 130static const char * dead_xpm[] = {
130"20 20 3 1", 131"20 20 3 1",
131 " c None", 132 " c None",
132 ".c #ffff3f", 133 ".c #ffff3f",
133 "#c #000000", 134 "#c #000000",
134" ", 135" ",
135" ###### ", 136" ###### ",
136" ##......## ", 137" ##......## ",
137" #..........# ", 138" #..........# ",
138" #............# ", 139" #............# ",
139" #..............# ", 140" #..............# ",
140" #..#.#...#.#...# ", 141" #..#.#...#.#...# ",
141" #....#.....#.....# ", 142" #....#.....#.....# ",
142" #...#.#...#.#....# ", 143" #...#.#...#.#....# ",
143" #................# ", 144" #................# ",
144" #................# ", 145" #................# ",
145" #................# ", 146" #................# ",
146" #......####......# ", 147" #......####......# ",
147" #....# #....# ", 148" #....# #....# ",
148" #...#......#...# ", 149" #...#......#...# ",
149" #............# ", 150" #............# ",
150" #..........# ", 151" #..........# ",
151" ##......## ", 152" ##......## ",
152" ###### ", 153" ###### ",
153" "}; 154" "};
154 155
155 156
156class ResultIndicator : private QLabel 157class ResultIndicator : private QLabel
157{ 158{
158public: 159public:
159 static void showResult( QWidget *ref, bool won ); 160 static void showResult( QWidget *ref, bool won );
160private: 161private:
161 ResultIndicator( QWidget *parent, const char *name, WFlags f) 162 ResultIndicator( QWidget *parent, const char *name, WFlags f)
162 :QLabel( parent, name, f ) {} 163 :QLabel( parent, name, f ) {}
163 164
164 void timerEvent( QTimerEvent *); 165 void timerEvent( QTimerEvent *);
165 void center(); 166 void center();
166 bool twoStage; 167 bool twoStage;
167 int timerId; 168 int timerId;
168}; 169};
169 170
170void ResultIndicator::showResult( QWidget *ref, bool won ) 171void ResultIndicator::showResult( QWidget *ref, bool won )
171{ 172{
172 ResultIndicator *r = new ResultIndicator( ref, 0, WStyle_Customize | WStyle_Tool | WType_TopLevel ); 173 ResultIndicator *r = new ResultIndicator( ref, 0, WStyle_Customize | WStyle_Tool | WType_TopLevel );
173 174
174 r->setAlignment( AlignCenter ); 175 r->setAlignment( AlignCenter );
175 r->setFrameStyle( Sunken|StyledPanel ); 176 r->setFrameStyle( Sunken|StyledPanel );
176 if ( won ) { 177 if ( won ) {
177 r->setText( MineSweep::tr("You won!") ); 178 r->setText( MineSweep::tr("You won!") );
178 r->center(); 179 r->center();
179 r->show(); 180 r->show();
180 r->twoStage = FALSE; 181 r->twoStage = FALSE;
181 r->timerId = r->startTimer(1500); 182 r->timerId = r->startTimer(1500);
182 } else { 183 } else {
183 QPalette p( red ); 184 QPalette p( red );
184 r->setPalette( p ); 185 r->setPalette( p );
185 r->setText( MineSweep::tr("You exploded!") ); 186 r->setText( MineSweep::tr("You exploded!") );
186 r->resize( ref->size() ); 187 r->resize( ref->size() );
187 r->move( ref->mapToGlobal(QPoint(0,0)) ); 188 r->move( ref->mapToGlobal(QPoint(0,0)) );
188 r->show(); 189 r->show();
189 r->twoStage = TRUE; 190 r->twoStage = TRUE;
190 r->timerId =r->startTimer(200); 191 r->timerId =r->startTimer(200);
191 } 192 }
192} 193}
193 194
194void ResultIndicator::center() 195void ResultIndicator::center()
195{ 196{
196 QWidget *w = parentWidget(); 197 QWidget *w = parentWidget();
197 198
198 QPoint pp = w->mapToGlobal( QPoint(0,0) ); 199 QPoint pp = w->mapToGlobal( QPoint(0,0) );
199 QSize s = sizeHint()*3; 200 QSize s = sizeHint()*3;
200 pp = QPoint( pp.x() + w->width()/2 - s.width()/2, 201 pp = QPoint( pp.x() + w->width()/2 - s.width()/2,
201 pp.y() + w->height()/ 2 - s.height()/2 ); 202 pp.y() + w->height()/ 2 - s.height()/2 );
202 203
203 setGeometry( QRect(pp, s) ); 204 setGeometry( QRect(pp, s) );
204 205
205} 206}
206 207
207void ResultIndicator::timerEvent( QTimerEvent *te ) 208void ResultIndicator::timerEvent( QTimerEvent *te )
208{ 209{
209 if ( te->timerId() != timerId ) 210 if ( te->timerId() != timerId )
210 return; 211 return;
211 killTimer( timerId ); 212 killTimer( timerId );
212 if ( twoStage ) { 213 if ( twoStage ) {
213 center(); 214 center();
214 twoStage = FALSE; 215 twoStage = FALSE;
215 timerId = startTimer( 1000 ); 216 timerId = startTimer( 1000 );
216 } else { 217 } else {
217 delete this; 218 delete this;
218 } 219 }
219} 220}
220 221
221 222
222class MineFrame : public QFrame 223class MineFrame : public QFrame
223{ 224{
224public: 225public:
225 MineFrame( QWidget *parent, const char *name = 0 ) 226 MineFrame( QWidget *parent, const char *name = 0 )
226 :QFrame( parent, name ) {} 227 :QFrame( parent, name ) {}
227 void setField( MineField *f ) { field = f; } 228 void setField( MineField *f ) { field = f; }
228protected: 229protected:
229 void resizeEvent( QResizeEvent *e ) { 230 void resizeEvent( QResizeEvent *e ) {
230 field->setAvailableRect( contentsRect()); 231 field->setAvailableRect( contentsRect());
231 QFrame::resizeEvent(e); 232 QFrame::resizeEvent(e);
232 } 233 }
233private: 234private:
234 MineField *field; 235 MineField *field;
235}; 236};
236 237
237 238
238 239
239MineSweep::MineSweep( QWidget* parent, const char* name, WFlags f ) 240MineSweep::MineSweep( QWidget* parent, const char* name, WFlags f )
240: QMainWindow( parent, name, f ) 241: QMainWindow( parent, name, f )
241{ 242{
243 QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff );
242 srand(::time(0)); 244 srand(::time(0));
243 setCaption( tr("Mine Hunt") ); 245 setCaption( tr("Mine Hunt") );
244 setIcon( Resource::loadPixmap( "minesweep_icon" ) ); 246 setIcon( Resource::loadPixmap( "minesweep_icon" ) );
245 247
246 QToolBar *toolBar = new QToolBar( this ); 248 QToolBar *toolBar = new QToolBar( this );
247 toolBar->setHorizontalStretchable( TRUE ); 249 toolBar->setHorizontalStretchable( TRUE );
248 250
249 QMenuBar *menuBar = new QMenuBar( toolBar ); 251 QMenuBar *menuBar = new QMenuBar( toolBar );
250 252
251 QPopupMenu *gameMenu = new QPopupMenu( this ); 253 QPopupMenu *gameMenu = new QPopupMenu( this );
252 gameMenu->insertItem( tr("Beginner"), this, SLOT( beginner() ) ); 254 gameMenu->insertItem( tr("Beginner"), this, SLOT( beginner() ) );
253 gameMenu->insertItem( tr("Advanced"), this, SLOT( advanced() ) ); 255 gameMenu->insertItem( tr("Advanced"), this, SLOT( advanced() ) );
254 gameMenu->insertItem( tr("Expert"), this, SLOT( expert() ) ); 256 gameMenu->insertItem( tr("Expert"), this, SLOT( expert() ) );
255 257
256 menuBar->insertItem( tr("Game"), gameMenu ); 258 menuBar->insertItem( tr("Game"), gameMenu );
257 259
258 guessLCD = new QLCDNumber( toolBar ); 260 guessLCD = new QLCDNumber( toolBar );
259 toolBar->setStretchableWidget( guessLCD ); 261 toolBar->setStretchableWidget( guessLCD );
260 262
261 QPalette lcdPal( red ); 263 QPalette lcdPal( red );
262 lcdPal.setColor( QColorGroup::Background, QApplication::palette().active().background() ); 264 lcdPal.setColor( QColorGroup::Background, QApplication::palette().active().background() );
263 lcdPal.setColor( QColorGroup::Button, QApplication::palette().active().button() ); 265 lcdPal.setColor( QColorGroup::Button, QApplication::palette().active().button() );
264 266
265// guessLCD->setPalette( lcdPal ); 267// guessLCD->setPalette( lcdPal );
266 guessLCD->setSegmentStyle( QLCDNumber::Flat ); 268 guessLCD->setSegmentStyle( QLCDNumber::Flat );
267 guessLCD->setFrameStyle( QFrame::NoFrame ); 269 guessLCD->setFrameStyle( QFrame::NoFrame );
268 guessLCD->setNumDigits( 2 ); 270 guessLCD->setNumDigits( 2 );
269 guessLCD->setBackgroundMode( PaletteButton ); 271 guessLCD->setBackgroundMode( PaletteButton );
270 newGameButton = new QPushButton( toolBar ); 272 newGameButton = new QPushButton( toolBar );
271 newGameButton->setPixmap( QPixmap( pix_new ) ); 273 newGameButton->setPixmap( QPixmap( pix_new ) );
272 newGameButton->setFocusPolicy(QWidget::NoFocus); 274 newGameButton->setFocusPolicy(QWidget::NoFocus);
273 connect( newGameButton, SIGNAL(clicked()), this, SLOT(newGame()) ); 275 connect( newGameButton, SIGNAL(clicked()), this, SLOT(newGame()) );
274 276
275 timeLCD = new QLCDNumber( toolBar ); 277 timeLCD = new QLCDNumber( toolBar );
276// timeLCD->setPalette( lcdPal ); 278// timeLCD->setPalette( lcdPal );
277 timeLCD->setSegmentStyle( QLCDNumber::Flat ); 279 timeLCD->setSegmentStyle( QLCDNumber::Flat );
278 timeLCD->setFrameStyle( QFrame::NoFrame ); 280 timeLCD->setFrameStyle( QFrame::NoFrame );
279 timeLCD->setNumDigits( 5 ); // "mm:ss" 281 timeLCD->setNumDigits( 5 ); // "mm:ss"
280 timeLCD->setBackgroundMode( PaletteButton ); 282 timeLCD->setBackgroundMode( PaletteButton );
281 283
282 setToolBarsMovable ( FALSE ); 284 setToolBarsMovable ( FALSE );
283 285
284 addToolBar( toolBar ); 286 addToolBar( toolBar );
285 287
286 MineFrame *mainframe = new MineFrame( this ); 288 MineFrame *mainframe = new MineFrame( this );
287 mainframe->setFrameShape( QFrame::Box ); 289 mainframe->setFrameShape( QFrame::Box );
288 mainframe->setFrameShadow( QFrame::Raised ); 290 mainframe->setFrameShadow( QFrame::Raised );
289 291
290 mainframe->setLineWidth(2); 292 mainframe->setLineWidth(2);
291 293
292 field = new MineField( mainframe ); 294 field = new MineField( mainframe );
293 mainframe->setField( field ); 295 mainframe->setField( field );
294 QFont fnt = field->font(); 296 QFont fnt = field->font();
295 fnt.setBold( TRUE ); 297 fnt.setBold( TRUE );
296 field->setFont( QFont( fnt ) ); 298 field->setFont( QFont( fnt ) );
297 field->setFocus(); 299 field->setFocus();
298 setCentralWidget( mainframe ); 300 setCentralWidget( mainframe );
299 301
300 connect( field, SIGNAL( gameOver( bool ) ), this, SLOT( gameOver( bool ) ) ); 302 connect( field, SIGNAL( gameOver( bool ) ), this, SLOT( gameOver( bool ) ) );
301 connect( field, SIGNAL( mineCount( int ) ), this, SLOT( setCounter( int ) ) ); 303 connect( field, SIGNAL( mineCount( int ) ), this, SLOT( setCounter( int ) ) );
302 connect( field, SIGNAL( gameStarted()), this, SLOT( startPlaying() ) ); 304 connect( field, SIGNAL( gameStarted()), this, SLOT( startPlaying() ) );
303 305
304 timer = new QTimer( this ); 306 timer = new QTimer( this );
305 307
306 connect( timer, SIGNAL( timeout() ), this, SLOT( updateTime() ) ); 308 connect( timer, SIGNAL( timeout() ), this, SLOT( updateTime() ) );
307 309
308 readConfig(); 310 readConfig();
309} 311}
310 312
311MineSweep::~MineSweep() 313MineSweep::~MineSweep()
312{ 314{
313 writeConfig(); 315 writeConfig();
314} 316}
315 317
316void MineSweep::gameOver( bool won ) 318void MineSweep::gameOver( bool won )
317{ 319{
318 field->showMines(); 320 field->showMines();
319 if ( won ) { 321 if ( won ) {
320 newGameButton->setPixmap( QPixmap( happy_xpm ) ); 322 newGameButton->setPixmap( QPixmap( happy_xpm ) );
321 } else { 323 } else {
322 newGameButton->setPixmap( QPixmap( dead_xpm ) ); 324 newGameButton->setPixmap( QPixmap( dead_xpm ) );
323 } 325 }
324 ResultIndicator::showResult( this, won ); 326 ResultIndicator::showResult( this, won );
325 timer->stop(); 327 timer->stop();
326} 328}
327 329
328void MineSweep::newGame() 330void MineSweep::newGame()
329{ 331{
330 newGame(field->level()); 332 newGame(field->level());
331} 333}
332 334
333void MineSweep::newGame(int level) 335void MineSweep::newGame(int level)
334{ 336{
335 timeLCD->display( "0:00" ); 337 timeLCD->display( "0:00" );
336 field->setup( level ); 338 field->setup( level );
337 newGameButton->setPixmap( QPixmap( pix_new ) ); 339 newGameButton->setPixmap( QPixmap( pix_new ) );
338 timer->stop(); 340 timer->stop();
339} 341}
340 342
341void MineSweep::startPlaying() 343void MineSweep::startPlaying()
342{ 344{
343 newGameButton->setPixmap( QPixmap( worried_xpm ) ); 345 newGameButton->setPixmap( QPixmap( worried_xpm ) );
344 starttime = QDateTime::currentDateTime(); 346 starttime = QDateTime::currentDateTime();
345 timer->start( 1000 ); 347 timer->start( 1000 );
346} 348}
347 349
348void MineSweep::beginner() 350void MineSweep::beginner()
349{ 351{
350 newGame(1); 352 newGame(1);
351} 353}
352 354
353void MineSweep::advanced() 355void MineSweep::advanced()
354{ 356{
355 newGame(2); 357 newGame(2);
356} 358}
357 359
358void MineSweep::expert() 360void MineSweep::expert()
359{ 361{
360 newGame(3); 362 newGame(3);
361} 363}
362 364
363void MineSweep::setCounter( int c ) 365void MineSweep::setCounter( int c )
364{ 366{
365 if ( !guessLCD ) 367 if ( !guessLCD )
366 return; 368 return;
367 369
368 guessLCD->display( c ); 370 guessLCD->display( c );
369} 371}
370 372
371void MineSweep::updateTime() 373void MineSweep::updateTime()
372{ 374{
373 if ( !timeLCD ) 375 if ( !timeLCD )
374 return; 376 return;
375 377
376 int s = starttime.secsTo(QDateTime::currentDateTime()); 378 int s = starttime.secsTo(QDateTime::currentDateTime());
377 if ( s/60 > 99 ) 379 if ( s/60 > 99 )
378 timeLCD->display( "-----" ); 380 timeLCD->display( "-----" );
379 else 381 else
380 timeLCD->display( QString().sprintf("%2d:%02d",s/60,s%60) ); 382 timeLCD->display( QString().sprintf("%2d:%02d",s/60,s%60) );
381} 383}
382 384
383void MineSweep::writeConfig() const 385void MineSweep::writeConfig() const
384{ 386{
385 Config cfg("MineSweep"); 387 Config cfg("MineSweep");
386 cfg.setGroup("Panel"); 388 cfg.setGroup("Panel");
387 cfg.writeEntry("Time", 389 cfg.writeEntry("Time",
388 timer->isActive() ? starttime.secsTo(QDateTime::currentDateTime()) : -1); 390 timer->isActive() ? starttime.secsTo(QDateTime::currentDateTime()) : -1);
389 field->writeConfig(cfg); 391 field->writeConfig(cfg);
390} 392}
391 393
392void MineSweep::readConfig() 394void MineSweep::readConfig()
393{ 395{
394 Config cfg("MineSweep"); 396 Config cfg("MineSweep");
395 field->readConfig(cfg); 397 field->readConfig(cfg);
396 cfg.setGroup("Panel"); 398 cfg.setGroup("Panel");
397 int s = cfg.readNumEntry("Time",-1); 399 int s = cfg.readNumEntry("Time",-1);
398 if ( s<0 ) { 400 if ( s<0 ) {
399 newGame(); 401 newGame();
400 } else { 402 } else {
401 startPlaying(); 403 startPlaying();
402 starttime = QDateTime::currentDateTime().addSecs(-s); 404 starttime = QDateTime::currentDateTime().addSecs(-s);
403 updateTime(); 405 updateTime();
404 } 406 }
405} 407}
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
@@ -1,67 +1,68 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef MINESWEEP_H 20#ifndef MINESWEEP_H
21#define MINESWEEP_H 21#define MINESWEEP_H
22 22
23#include <qmainwindow.h> 23#include <qmainwindow.h>
24#include <qdatetime.h> 24#include <qdatetime.h>
25 25
26class MineField; 26class MineField;
27class QLCDNumber; 27class QLCDNumber;
28class QPushButton; 28class QPushButton;
29 29
30class MineSweep : public QMainWindow 30class MineSweep : public QMainWindow
31{ 31{
32 Q_OBJECT 32 Q_OBJECT
33public: 33public:
34 static QString appName() { return QString::fromLatin1("minesweep"); }
34 MineSweep( QWidget* parent = 0, const char* name = 0, WFlags f = 0 ); 35 MineSweep( QWidget* parent = 0, const char* name = 0, WFlags f = 0 );
35 ~MineSweep(); 36 ~MineSweep();
36 37
37public slots: 38public slots:
38 void gameOver( bool won ); 39 void gameOver( bool won );
39 void newGame(); 40 void newGame();
40 41
41protected slots: 42protected slots:
42 void setCounter( int ); 43 void setCounter( int );
43 void updateTime(); 44 void updateTime();
44 45
45 void beginner(); 46 void beginner();
46 void advanced(); 47 void advanced();
47 void expert(); 48 void expert();
48 49
49private slots: 50private slots:
50 void startPlaying(); 51 void startPlaying();
51 52
52private: 53private:
53 void readConfig(); 54 void readConfig();
54 void writeConfig() const; 55 void writeConfig() const;
55 56
56 void newGame(int); 57 void newGame(int);
57 MineField* field; 58 MineField* field;
58 QLCDNumber* guessLCD; 59 QLCDNumber* guessLCD;
59 QLCDNumber* timeLCD; 60 QLCDNumber* timeLCD;
60 QPushButton* newGameButton; 61 QPushButton* newGameButton;
61 62
62 QDateTime starttime; 63 QDateTime starttime;
63 QTimer* timer; 64 QTimer* timer;
64}; 65};
65 66
66#endif // MINESWEEP_H 67#endif // MINESWEEP_H
67 68
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 @@
1 TEMPLATE= app 1 CONFIG = qt warn_on release quick-app
2 CONFIG = qt warn_on release 2 HEADERS = minefield.h \
3 DESTDIR = $(OPIEDIR)/bin 3 minesweep.h
4 HEADERS = minefield.h \ 4 SOURCES = main.cpp \
5 minesweep.h 5 minefield.cpp \
6 SOURCES = main.cpp \ 6 minesweep.cpp
7 minefield.cpp \ 7INCLUDEPATH += $(OPIEDIR)/include
8 minesweep.cpp 8 DEPENDPATH+= $(OPIEDIR)/include
9INCLUDEPATH += $(OPIEDIR)/include 9LIBS += -lqpe
10 DEPENDPATH+= $(OPIEDIR)/include 10 INTERFACES=
11LIBS += -lqpe 11 TARGET = minesweep
12 INTERFACES= 12
13 TARGET = minesweep 13include ( $(OPIEDIR)/include.pro )
14
15include ( $(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,10 +1,10 @@
1Package: opie-minesweep 1Package: opie-minesweep
2Files: bin/minesweep apps/Games/minesweep.desktop pics/minesweep 2Files: plugins/application/libminesweep.so* bin/minesweep apps/Games/minesweep.desktop pics/minesweep
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Martin Imobersteg <imm@gmx.ch> 5Maintainer: Martin Imobersteg <imm@gmx.ch>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal 7Depends: task-opie-minimal
8Description: Game: find the mines 8Description: Game: find the mines
9 A game for the Opie environment. 9 A game for the Opie environment.
10Version: $QPE_VERSION$EXTRAVERSION 10Version: $QPE_VERSION$EXTRAVERSION
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
@@ -1,247 +1,250 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "interface.h" 21#include "interface.h"
22#include "man.h" 22#include "man.h"
23 23
24#include <qpe/resource.h> 24#include <qpe/resource.h>
25#include <qpe/qpeapplication.h>
25 26
26#include <qlabel.h> 27#include <qlabel.h>
27#include <qmessagebox.h> 28#include <qmessagebox.h>
28#include <qapplication.h> 29#include <qapplication.h>
29#include <qstyle.h> 30#include <qstyle.h>
30#include <qpe/qpetoolbar.h> 31#include <qpe/qpetoolbar.h>
31#include <qtoolbutton.h> 32#include <qtoolbutton.h>
32 33
33ParaShoot::ParaShoot(QWidget* parent, const char* name, WFlags f) : 34ParaShoot::ParaShoot(QWidget* parent, const char* name, WFlags f) :
34 QMainWindow(parent,name,f), 35 QMainWindow(parent,name,f),
35 canvas(232, 258), 36 canvas(232, 258),
36 fanfare("level_up"), 37 fanfare("level_up"),
37 score(0) 38 score(0)
38{ 39{
40 QPEApplication::grabKeyboard();
41 QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff );
39 canvas.setAdvancePeriod(80); 42 canvas.setAdvancePeriod(80);
40 QPixmap bg = Resource::loadPixmap("parashoot/sky"); 43 QPixmap bg = Resource::loadPixmap("parashoot/sky");
41 canvas.setBackgroundPixmap(bg); 44 canvas.setBackgroundPixmap(bg);
42 45
43 pb = new QCanvasView(&canvas, this); 46 pb = new QCanvasView(&canvas, this);
44 pb->setFocus(); 47 pb->setFocus();
45 48
46 setToolBarsMovable( FALSE ); 49 setToolBarsMovable( FALSE );
47 50
48 QToolBar* toolbar = new QToolBar(this); 51 QToolBar* toolbar = new QToolBar(this);
49 toolbar->setHorizontalStretchable( TRUE ); 52 toolbar->setHorizontalStretchable( TRUE );
50 53
51 setCaption( tr("ParaShoot") ); 54 setCaption( tr("ParaShoot") );
52 QPixmap newicon = Resource::loadPixmap("parashoot/manicon"); 55 QPixmap newicon = Resource::loadPixmap("parashoot/manicon");
53 setIcon(newicon); 56 setIcon(newicon);
54 new QToolButton(newicon, tr("New Game"), 0, 57 new QToolButton(newicon, tr("New Game"), 0,
55 this, SLOT(newGame()), toolbar, "New Game"); 58 this, SLOT(newGame()), toolbar, "New Game");
56 59
57 levelscore = new QLabel(toolbar); 60 levelscore = new QLabel(toolbar);
58 levelscore->setBackgroundMode( PaletteButton ); 61 levelscore->setBackgroundMode( PaletteButton );
59 levelscore->setAlignment( AlignRight | AlignVCenter | ExpandTabs ); 62 levelscore->setAlignment( AlignRight | AlignVCenter | ExpandTabs );
60 toolbar->setStretchableWidget( levelscore ); 63 toolbar->setStretchableWidget( levelscore );
61 showScore(0,0); 64 showScore(0,0);
62 65
63 setCentralWidget(pb); 66 setCentralWidget(pb);
64 67
65 autoDropTimer = new QTimer(this); 68 autoDropTimer = new QTimer(this);
66 connect (autoDropTimer, SIGNAL(timeout()), this, SLOT(play()) ); 69 connect (autoDropTimer, SIGNAL(timeout()), this, SLOT(play()) );
67 70
68 pauseTimer = new QTimer(this); 71 pauseTimer = new QTimer(this);
69 connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) ); 72 connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) );
70 73
71 setFocusPolicy(StrongFocus); 74 setFocusPolicy(StrongFocus);
72 75
73 newGame(); 76 newGame();
74} 77}
75 78
76 79
77void ParaShoot::resizeEvent(QResizeEvent *) 80void ParaShoot::resizeEvent(QResizeEvent *)
78{ 81{
79 QSize s = centralWidget()->size(); 82 QSize s = centralWidget()->size();
80 int fw = style().defaultFrameWidth(); 83 int fw = style().defaultFrameWidth();
81 canvas.resize( s.width() - fw - 2, s.height() - fw - 2); 84 canvas.resize( s.width() - fw - 2, s.height() - fw - 2);
82} 85}
83 86
84 87
85void ParaShoot::showScore( int score, int level ) 88void ParaShoot::showScore( int score, int level )
86{ 89{
87 levelscore->setText(tr(" Level: %1 Score: %2 ").arg(score).arg(level) ); 90 levelscore->setText(tr(" Level: %1 Score: %2 ").arg(score).arg(level) );
88} 91}
89 92
90 93
91void ParaShoot::newGame() 94void ParaShoot::newGame()
92{ 95{
93 clear(); 96 clear();
94 if (pauseTimer->isActive()) 97 if (pauseTimer->isActive())
95 pauseTimer->stop(); 98 pauseTimer->stop();
96 clear(); 99 clear();
97 Man::setManCount(0); 100 Man::setManCount(0);
98 score = 0; 101 score = 0;
99 Bullet::setShotCount(0); 102 Bullet::setShotCount(0);
100 Bullet::setNobullets(0); 103 Bullet::setNobullets(0);
101 nomen = 2; 104 nomen = 2;
102 Bullet::setLimit(nomen); 105 Bullet::setLimit(nomen);
103 level = 0; 106 level = 0;
104 updatespeed = 80; 107 updatespeed = 80;
105 showScore(0,0); 108 showScore(0,0);
106 gamestopped = false; 109 gamestopped = false;
107 Helicopter::deleteAll(); 110 Helicopter::deleteAll();
108 waitover = true; 111 waitover = true;
109 base = new Base(&canvas); 112 base = new Base(&canvas);
110 cannon = new Cannon(&canvas); 113 cannon = new Cannon(&canvas);
111 connect( cannon, SIGNAL(score(int)), this, SLOT(increaseScore(int))); 114 connect( cannon, SIGNAL(score(int)), this, SLOT(increaseScore(int)));
112 autoDropTimer->start(100); 115 autoDropTimer->start(100);
113} 116}
114 117
115 118
116void ParaShoot::clear() 119void ParaShoot::clear()
117{ 120{
118 autoDropTimer->stop(); 121 autoDropTimer->stop();
119// QCanvasItem* item; 122// QCanvasItem* item;
120 QCanvasItemList l = canvas.allItems(); 123 QCanvasItemList l = canvas.allItems();
121 for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) { 124 for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) {
122 delete *it; 125 delete *it;
123 } 126 }
124} 127}
125 128
126void ParaShoot::gameOver() 129void ParaShoot::gameOver()
127{ 130{
128 QCanvasItem* item; 131 QCanvasItem* item;
129 QCanvasItemList l = canvas.allItems(); 132 QCanvasItemList l = canvas.allItems();
130 for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) { 133 for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) {
131 item = *it; 134 item = *it;
132 if ((item->rtti()==1500) || (item->rtti()==1600) || item->rtti()==1900) 135 if ((item->rtti()==1500) || (item->rtti()==1600) || item->rtti()==1900)
133 item->setAnimated(false); 136 item->setAnimated(false);
134 } 137 }
135 autoDropTimer->stop(); 138 autoDropTimer->stop();
136 Helicopter::silenceAll(); 139 Helicopter::silenceAll();
137 140
138 int shots = Bullet::getShotCount(); 141 int shots = Bullet::getShotCount();
139 142
140 int shotsFired = cannon->shotsFired(); 143 int shotsFired = cannon->shotsFired();
141 if ( shotsFired == 0 ) 144 if ( shotsFired == 0 )
142 shotsFired = 1; 145 shotsFired = 1;
143 QCanvasText* gameover = new QCanvasText( 146 QCanvasText* gameover = new QCanvasText(
144 tr( " GAME OVER!\n" 147 tr( " GAME OVER!\n"
145 " Your Score: %1\n" 148 " Your Score: %1\n"
146 " Parachuters Killed: %2\n" 149 " Parachuters Killed: %2\n"
147 " Accuracy: %3% " ).arg(score).arg(shots).arg(shots * 100 / shotsFired ), 150 " Accuracy: %3% " ).arg(score).arg(shots).arg(shots * 100 / shotsFired ),
148 &canvas); 151 &canvas);
149 gameover->setColor(red); 152 gameover->setColor(red);
150 gameover->setFont( QFont("times", 18, QFont::Bold) ); 153 gameover->setFont( QFont("times", 18, QFont::Bold) );
151 gameover->move(canvas.width()/2 -110, canvas.height()/2 -50); 154 gameover->move(canvas.width()/2 -110, canvas.height()/2 -50);
152 gameover->setZ(500); 155 gameover->setZ(500);
153 gameover->show(); 156 gameover->show();
154 gamestopped = true; 157 gamestopped = true;
155 waitover = false; 158 waitover = false;
156 pauseTimer->start(3000); 159 pauseTimer->start(3000);
157} 160}
158 161
159void ParaShoot::wait() 162void ParaShoot::wait()
160{ 163{
161 waitover = true; 164 waitover = true;
162 pauseTimer->stop(); 165 pauseTimer->stop();
163} 166}
164 167
165void ParaShoot::play() 168void ParaShoot::play()
166{ 169{
167 if (Man::getManCount() < nomen ) { 170 if (Man::getManCount() < nomen ) {
168 new Man(&canvas); 171 new Man(&canvas);
169 } 172 }
170 if (Base::baseDestroyed()) { 173 if (Base::baseDestroyed()) {
171 gameOver(); 174 gameOver();
172 return; 175 return;
173 } 176 }
174} 177}
175 178
176void ParaShoot::increaseScore(int x) 179void ParaShoot::increaseScore(int x)
177{ 180{
178 score += x; 181 score += x;
179 if ( score / 150 != (score-x) / 150 ) 182 if ( score / 150 != (score-x) / 150 )
180 levelUp(); 183 levelUp();
181 showScore(level,score); 184 showScore(level,score);
182} 185}
183 186
184void ParaShoot::levelUp() 187void ParaShoot::levelUp()
185{ 188{
186 level++; 189 level++;
187 int stage = level % 3; 190 int stage = level % 3;
188 switch(stage) { 191 switch(stage) {
189 case 0: 192 case 0:
190 nomen++; 193 nomen++;
191 Bullet::setLimit(nomen); 194 Bullet::setLimit(nomen);
192 fanfare.play(); 195 fanfare.play();
193 break; 196 break;
194 case 1: 197 case 1:
195 new Helicopter(&canvas); 198 new Helicopter(&canvas);
196 break; 199 break;
197 case 2: 200 case 2:
198 moveFaster(); 201 moveFaster();
199 fanfare.play(); 202 fanfare.play();
200 break; 203 break;
201 default: return; 204 default: return;
202 } 205 }
203} 206}
204 207
205void ParaShoot::moveFaster() 208void ParaShoot::moveFaster()
206{ 209{
207 if (updatespeed > 50) 210 if (updatespeed > 50)
208 updatespeed = updatespeed-5; 211 updatespeed = updatespeed-5;
209 else 212 else
210 updatespeed = updatespeed-3; 213 updatespeed = updatespeed-3;
211 canvas.setAdvancePeriod(updatespeed); 214 canvas.setAdvancePeriod(updatespeed);
212} 215}
213 216
214void ParaShoot::keyPressEvent(QKeyEvent* event) 217void ParaShoot::keyPressEvent(QKeyEvent* event)
215{ 218{
216 if (gamestopped) { 219 if (gamestopped) {
217 if (waitover) 220 if (waitover)
218 newGame(); 221 newGame();
219 else 222 else
220 return; 223 return;
221 } else { 224 } else {
222 switch(event->key()) { 225 switch(event->key()) {
223 case Key_Up: 226 case Key_Up:
224 case Key_F1: 227 case Key_F1:
225 case Key_F9: 228 case Key_F9:
226 case Key_Space: 229 case Key_Space:
227 cannon->shoot(); 230 cannon->shoot();
228 break; 231 break;
229 case Key_Left: 232 case Key_Left:
230 cannon->pointCannon(Cannon::Left); 233 cannon->pointCannon(Cannon::Left);
231 lastcannonkey=Key_Left; 234 lastcannonkey=Key_Left;
232 break; 235 break;
233 case Key_Right: 236 case Key_Right:
234 cannon->pointCannon(Cannon::Right); 237 cannon->pointCannon(Cannon::Right);
235 lastcannonkey=Key_Right; 238 lastcannonkey=Key_Right;
236 break; 239 break;
237 default: 240 default:
238 return; 241 return;
239 } 242 }
240 } 243 }
241} 244}
242 245
243void ParaShoot::keyReleaseEvent(QKeyEvent* event) 246void ParaShoot::keyReleaseEvent(QKeyEvent* event)
244{ 247{
245 if ( lastcannonkey == event->key() ) 248 if ( lastcannonkey == event->key() )
246 cannon->pointCannon(Cannon::NoDir); 249 cannon->pointCannon(Cannon::NoDir);
247} 250}
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
@@ -1,79 +1,80 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "cannon.h" 21#include "cannon.h"
22#include "base.h" 22#include "base.h"
23#include "helicopter.h" 23#include "helicopter.h"
24 24
25#include <qpe/sound.h> 25#include <qpe/sound.h>
26 26
27#include <qmainwindow.h> 27#include <qmainwindow.h>
28#include <qtimer.h> 28#include <qtimer.h>
29#include <qlabel.h> 29#include <qlabel.h>
30 30
31class QCanvas; 31class QCanvas;
32class Helicopter; 32class Helicopter;
33 33
34//enum Direction{ 34//enum Direction{
35// left, right, up, down }; 35// left, right, up, down };
36 36
37class ParaShoot : public QMainWindow { 37class ParaShoot : public QMainWindow {
38 Q_OBJECT 38 Q_OBJECT
39 39
40public: 40public:
41 static QString appName() { return QString::fromLatin1("parashoot"); }
41 ParaShoot(QWidget* parent=0, const char* name=0, WFlags f=0); 42 ParaShoot(QWidget* parent=0, const char* name=0, WFlags f=0);
42 43
43 void clear(); 44 void clear();
44 void gameOver(); 45 void gameOver();
45 int mancount; 46 int mancount;
46 void levelUp(); 47 void levelUp();
47 void moveFaster(); 48 void moveFaster();
48 49
49protected: 50protected:
50 virtual void keyPressEvent(QKeyEvent*); 51 virtual void keyPressEvent(QKeyEvent*);
51 virtual void keyReleaseEvent(QKeyEvent*); 52 virtual void keyReleaseEvent(QKeyEvent*);
52 virtual void resizeEvent(QResizeEvent *e); 53 virtual void resizeEvent(QResizeEvent *e);
53 54
54private slots: 55private slots:
55 void increaseScore(int); 56 void increaseScore(int);
56 void newGame(); 57 void newGame();
57 void play(); 58 void play();
58 void wait(); 59 void wait();
59 60
60private: 61private:
61 void showScore( int score, int level ); 62 void showScore( int score, int level );
62 QCanvasView* pb; 63 QCanvasView* pb;
63 QCanvas canvas; 64 QCanvas canvas;
64 Cannon* cannon; 65 Cannon* cannon;
65 Base* base; 66 Base* base;
66 QCanvasText* gameover; 67 QCanvasText* gameover;
67 QLabel* levelscore; 68 QLabel* levelscore;
68 int nomen; 69 int nomen;
69 int level; 70 int level;
70 int oldscore; 71 int oldscore;
71 int updatespeed; 72 int updatespeed;
72 QTimer* autoDropTimer; 73 QTimer* autoDropTimer;
73 QTimer* pauseTimer; 74 QTimer* pauseTimer;
74 bool gamestopped; 75 bool gamestopped;
75 bool waitover; 76 bool waitover;
76 Sound fanfare; 77 Sound fanfare;
77 int score; 78 int score;
78 int lastcannonkey; 79 int lastcannonkey;
79}; 80};
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
@@ -1,36 +1,27 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "interface.h" 21#include "interface.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <opie/oapplicationfactory.h>
24 25
25int main(int argc, char **argv) 26OPIE_EXPORT_APP( OApplicationFactory<ParaShoot> )
26{
27 QPEApplication app(argc,argv);
28 27
29 QPEApplication::grabKeyboard();
30
31 ParaShoot m;
32 QPEApplication::setInputMethodHint( &m, QPEApplication::AlwaysOff );
33 app.showMainWidget(&m);
34
35 return app.exec();
36}
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,10 +1,10 @@
1Package: opie-parashoot 1Package: opie-parashoot
2Files: bin/parashoot apps/Games/parashoot.desktop pics/parashoot 2Files: plugins/application/libparashoot.so* bin/parashoot apps/Games/parashoot.desktop pics/parashoot
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Martin Imobersteg <imm@gmx.ch> 5Maintainer: Martin Imobersteg <imm@gmx.ch>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal 7Depends: task-opie-minimal
8Description: Game: shoot the parachutists 8Description: Game: shoot the parachutists
9 A game for the Opie environment. 9 A game for the Opie environment.
10Version: $QPE_VERSION$EXTRAVERSION 10Version: $QPE_VERSION$EXTRAVERSION
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 @@
1 TEMPLATE= app 1 CONFIG += qt warn_on release quick-app
2 CONFIG += qt warn_on release
3 DESTDIR = $(OPIEDIR)/bin
4 HEADERS = interface.h man.h cannon.h base.h bullet.h helicopter.h 2 HEADERS = interface.h man.h cannon.h base.h bullet.h helicopter.h
5 SOURCES = main.cpp interface.cpp man.cpp cannon.cpp base.cpp bullet.cpp helicopter.cpp 3 SOURCES = main.cpp interface.cpp man.cpp cannon.cpp base.cpp bullet.cpp helicopter.cpp
6 TARGET = parashoot 4 TARGET = parashoot
7INCLUDEPATH += $(OPIEDIR)/include 5INCLUDEPATH += $(OPIEDIR)/include
8 DEPENDPATH+= $(OPIEDIR)/include 6 DEPENDPATH+= $(OPIEDIR)/include
9LIBS += -lqpe 7LIBS += -lqpe
10 8
9
10
11include ( $(OPIEDIR)/include.pro ) 11include ( $(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
@@ -1,36 +1,27 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "toplevel.h" 21#include "toplevel.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <opie/oapplicationfactory.h>
24 25
25int main( int argc, char *argv[] )
26{
27 QPEApplication app( argc, argv );
28
29 QPEApplication::grabKeyboard();
30
31 KAstTopLevel *mainWidget = new KAstTopLevel();
32 app.showMainWidget( mainWidget );
33
34 app.exec();
35}
36 26
27OPIE_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,10 +1,10 @@
1Package: opie-qasteroids 1Package: opie-qasteroids
2Files: bin/qasteroids apps/Games/qasteroids.desktop pics/qasteroids/* 2Files: plugins/application/libqasteroids.so* bin/qasteroids apps/Games/qasteroids.desktop pics/qasteroids/*
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Martin Jones <mjones@trolltech.com> 5Maintainer: Martin Jones <mjones@trolltech.com>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal 7Depends: task-opie-minimal
8Description: Game: shoot the asteroids 8Description: Game: shoot the asteroids
9 A game for the Opie environment. 9 A game for the Opie environment.
10Version: $QPE_VERSION$EXTRAVERSION 10Version: $QPE_VERSION$EXTRAVERSION
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 @@
1 TEMPLATE= app 1 CONFIG += qt warn_on release quick-app
2 CONFIG += qt warn_on release
3 DESTDIR = $(OPIEDIR)/bin
4 HEADERS = ledmeter.h sprites.h toplevel.h view.h 2 HEADERS = ledmeter.h sprites.h toplevel.h view.h
5 SOURCES = ledmeter.cpp toplevel.cpp view.cpp main.cpp 3 SOURCES = ledmeter.cpp toplevel.cpp view.cpp main.cpp
6 TARGET = qasteroids 4 TARGET = qasteroids
7INCLUDEPATH += $(OPIEDIR)/include 5INCLUDEPATH += $(OPIEDIR)/include
8 DEPENDPATH+= $(OPIEDIR)/include 6 DEPENDPATH+= $(OPIEDIR)/include
9LIBS += -lqpe 7LIBS += -lqpe
10 8
9
10
11include ( $(OPIEDIR)/include.pro ) 11include ( $(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
@@ -1,532 +1,535 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************//* 19**********************************************************************//*
20 * KAsteroids - Copyright (c) Martin R. Jones 1997 20 * KAsteroids - Copyright (c) Martin R. Jones 1997
21 * 21 *
22 * Part of the KDE project 22 * Part of the KDE project
23 */ 23 */
24 //--- toplevel.cpp --- 24 //--- toplevel.cpp ---
25 25
26#include "toplevel.h" 26#include "toplevel.h"
27#include "ledmeter.h" 27#include "ledmeter.h"
28 28
29#include <qpe/qpeapplication.h> 29#include <qpe/qpeapplication.h>
30#include <qpe/resource.h> 30#include <qpe/resource.h>
31 31
32#include <qaccel.h> 32#include <qaccel.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qlcdnumber.h> 35#include <qlcdnumber.h>
36#include <qpushbutton.h> 36#include <qpushbutton.h>
37 37
38#include <sys/utsname.h> 38#include <sys/utsname.h>
39 39
40 40
41 #define SB_SCORE1 41 #define SB_SCORE1
42 #define SB_LEVEL2 42 #define SB_LEVEL2
43 #define SB_SHIPS3 43 #define SB_SHIPS3
44 44
45struct SLevel 45struct SLevel
46{ 46{
47 int nrocks; 47 int nrocks;
48 double rockSpeed; 48 double rockSpeed;
49}; 49};
50 50
51 #define MAX_LEVELS16 51 #define MAX_LEVELS16
52 52
53SLevel levels[MAX_LEVELS] = 53SLevel levels[MAX_LEVELS] =
54{ 54{
55 { 1, 0.4 }, 55 { 1, 0.4 },
56 { 1, 0.6 }, 56 { 1, 0.6 },
57 { 2, 0.5 }, 57 { 2, 0.5 },
58 { 2, 0.7 }, 58 { 2, 0.7 },
59 { 2, 0.8 }, 59 { 2, 0.8 },
60 { 3, 0.6 }, 60 { 3, 0.6 },
61 { 3, 0.7 }, 61 { 3, 0.7 },
62 { 3, 0.8 }, 62 { 3, 0.8 },
63 { 4, 0.6 }, 63 { 4, 0.6 },
64 { 4, 0.7 }, 64 { 4, 0.7 },
65 { 4, 0.8 }, 65 { 4, 0.8 },
66 { 5, 0.7 }, 66 { 5, 0.7 },
67 { 5, 0.8 }, 67 { 5, 0.8 },
68 { 5, 0.9 }, 68 { 5, 0.9 },
69 { 5, 1.0 } 69 { 5, 1.0 }
70}; 70};
71 71
72const char *soundEvents[] = 72const char *soundEvents[] =
73{ 73{
74 "ShipDestroyed", 74 "ShipDestroyed",
75 "RockDestroyed", 75 "RockDestroyed",
76 0 76 0
77}; 77};
78 78
79const char *soundDefaults[] = 79const char *soundDefaults[] =
80{ 80{
81 "Explosion.wav", 81 "Explosion.wav",
82 "ploop.wav", 82 "ploop.wav",
83 0 83 0
84}; 84};
85 85
86 86
87KAstTopLevel::KAstTopLevel( QWidget *parent, const char *_name ) 87KAstTopLevel::KAstTopLevel( QWidget *parent, const char *_name, WFlags fl )
88 : QMainWindow( parent, _name ) 88 : QMainWindow( parent, _name, fl )
89{ 89{
90 setCaption( tr("Asteroids") ); 90 setCaption( tr("Asteroids") );
91
92 QPEApplication::grabKeyboard();
93
91 QWidget *border = new QWidget( this ); 94 QWidget *border = new QWidget( this );
92 border->setBackgroundColor( black ); 95 border->setBackgroundColor( black );
93 setCentralWidget( border ); 96 setCentralWidget( border );
94 97
95 QVBoxLayout *borderLayout = new QVBoxLayout( border ); 98 QVBoxLayout *borderLayout = new QVBoxLayout( border );
96 99
97 QWidget *mainWin = new QWidget( border ); 100 QWidget *mainWin = new QWidget( border );
98 borderLayout->addWidget( mainWin, 2, AlignHCenter ); 101 borderLayout->addWidget( mainWin, 2, AlignHCenter );
99 102
100 view = new KAsteroidsView( mainWin ); 103 view = new KAsteroidsView( mainWin );
101 connect( view, SIGNAL( shipKilled() ), SLOT( slotShipKilled() ) ); 104 connect( view, SIGNAL( shipKilled() ), SLOT( slotShipKilled() ) );
102 connect( view, SIGNAL( rockHit(int) ), SLOT( slotRockHit(int) ) ); 105 connect( view, SIGNAL( rockHit(int) ), SLOT( slotRockHit(int) ) );
103 connect( view, SIGNAL( rocksRemoved() ), SLOT( slotRocksRemoved() ) ); 106 connect( view, SIGNAL( rocksRemoved() ), SLOT( slotRocksRemoved() ) );
104 connect( view, SIGNAL( updateVitals() ), SLOT( slotUpdateVitals() ) ); 107 connect( view, SIGNAL( updateVitals() ), SLOT( slotUpdateVitals() ) );
105 108
106 QVBoxLayout *vb = new QVBoxLayout( mainWin ); 109 QVBoxLayout *vb = new QVBoxLayout( mainWin );
107 QHBoxLayout *hb = new QHBoxLayout; 110 QHBoxLayout *hb = new QHBoxLayout;
108 QHBoxLayout *hbd = new QHBoxLayout; 111 QHBoxLayout *hbd = new QHBoxLayout;
109 vb->addLayout( hb ); 112 vb->addLayout( hb );
110 113
111 QFont labelFont( "helvetica", 12 ); 114 QFont labelFont( "helvetica", 12 );
112 QColorGroup grp( darkGreen, black, QColor( 128, 128, 128 ), 115 QColorGroup grp( darkGreen, black, QColor( 128, 128, 128 ),
113 QColor( 64, 64, 64 ), black, darkGreen, black ); 116 QColor( 64, 64, 64 ), black, darkGreen, black );
114 QPalette pal( grp, grp, grp ); 117 QPalette pal( grp, grp, grp );
115 118
116 mainWin->setPalette( pal ); 119 mainWin->setPalette( pal );
117 120
118 QLabel *label; 121 QLabel *label;
119 label = new QLabel( tr("Score"), mainWin ); 122 label = new QLabel( tr("Score"), mainWin );
120 label->setFont( labelFont ); 123 label->setFont( labelFont );
121 label->setPalette( pal ); 124 label->setPalette( pal );
122// label->setFixedWidth( label->sizeHint().width() ); 125// label->setFixedWidth( label->sizeHint().width() );
123 hb->addWidget( label ); 126 hb->addWidget( label );
124 127
125 scoreLCD = new QLCDNumber( 5, mainWin ); 128 scoreLCD = new QLCDNumber( 5, mainWin );
126 scoreLCD->setFrameStyle( QFrame::NoFrame ); 129 scoreLCD->setFrameStyle( QFrame::NoFrame );
127 scoreLCD->setSegmentStyle( QLCDNumber::Flat ); 130 scoreLCD->setSegmentStyle( QLCDNumber::Flat );
128 scoreLCD->setFixedHeight( 16 ); 131 scoreLCD->setFixedHeight( 16 );
129 scoreLCD->setPalette( pal ); 132 scoreLCD->setPalette( pal );
130 hb->addWidget( scoreLCD ); 133 hb->addWidget( scoreLCD );
131 hb->addStretch( 1 ); 134 hb->addStretch( 1 );
132 135
133 label = new QLabel( tr("Level"), mainWin ); 136 label = new QLabel( tr("Level"), mainWin );
134 label->setFont( labelFont ); 137 label->setFont( labelFont );
135 label->setPalette( pal ); 138 label->setPalette( pal );
136// label->setFixedWidth( label->sizeHint().width() ); 139// label->setFixedWidth( label->sizeHint().width() );
137 hb->addWidget( label ); 140 hb->addWidget( label );
138 141
139 levelLCD = new QLCDNumber( 2, mainWin ); 142 levelLCD = new QLCDNumber( 2, mainWin );
140 levelLCD->setFrameStyle( QFrame::NoFrame ); 143 levelLCD->setFrameStyle( QFrame::NoFrame );
141 levelLCD->setSegmentStyle( QLCDNumber::Flat ); 144 levelLCD->setSegmentStyle( QLCDNumber::Flat );
142 levelLCD->setFixedHeight( 16 ); 145 levelLCD->setFixedHeight( 16 );
143 levelLCD->setPalette( pal ); 146 levelLCD->setPalette( pal );
144 hb->addWidget( levelLCD ); 147 hb->addWidget( levelLCD );
145 hb->addStretch( 1 ); 148 hb->addStretch( 1 );
146 149
147 label = new QLabel( tr("Ships"), mainWin ); 150 label = new QLabel( tr("Ships"), mainWin );
148 label->setFont( labelFont ); 151 label->setFont( labelFont );
149// label->setFixedWidth( label->sizeHint().width() ); 152// label->setFixedWidth( label->sizeHint().width() );
150 label->setPalette( pal ); 153 label->setPalette( pal );
151 hb->addWidget( label ); 154 hb->addWidget( label );
152 155
153 shipsLCD = new QLCDNumber( 1, mainWin ); 156 shipsLCD = new QLCDNumber( 1, mainWin );
154 shipsLCD->setFrameStyle( QFrame::NoFrame ); 157 shipsLCD->setFrameStyle( QFrame::NoFrame );
155 shipsLCD->setSegmentStyle( QLCDNumber::Flat ); 158 shipsLCD->setSegmentStyle( QLCDNumber::Flat );
156 shipsLCD->setFixedHeight( 16 ); 159 shipsLCD->setFixedHeight( 16 );
157 shipsLCD->setPalette( pal ); 160 shipsLCD->setPalette( pal );
158 hb->addWidget( shipsLCD ); 161 hb->addWidget( shipsLCD );
159 162
160// hb->addStrut( 14 ); 163// hb->addStrut( 14 );
161 164
162 vb->addWidget( view, 10 ); 165 vb->addWidget( view, 10 );
163 166
164// -- bottom layout: 167// -- bottom layout:
165 vb->addLayout( hbd ); 168 vb->addLayout( hbd );
166 169
167 QFont smallFont( "helvetica", 12 ); 170 QFont smallFont( "helvetica", 12 );
168 hbd->addSpacing( 5 ); 171 hbd->addSpacing( 5 );
169 172
170/* 173/*
171 label = new QLabel( tr( "T" ), mainWin ); 174 label = new QLabel( tr( "T" ), mainWin );
172 label->setFont( smallFont ); 175 label->setFont( smallFont );
173 label->setFixedWidth( label->sizeHint().width() ); 176 label->setFixedWidth( label->sizeHint().width() );
174 label->setPalette( pal ); 177 label->setPalette( pal );
175 hbd->addWidget( label ); 178 hbd->addWidget( label );
176 179
177 teleportsLCD = new QLCDNumber( 1, mainWin ); 180 teleportsLCD = new QLCDNumber( 1, mainWin );
178 teleportsLCD->setFrameStyle( QFrame::NoFrame ); 181 teleportsLCD->setFrameStyle( QFrame::NoFrame );
179 teleportsLCD->setSegmentStyle( QLCDNumber::Flat ); 182 teleportsLCD->setSegmentStyle( QLCDNumber::Flat );
180 teleportsLCD->setPalette( pal ); 183 teleportsLCD->setPalette( pal );
181 teleportsLCD->setFixedHeight( 18 ); 184 teleportsLCD->setFixedHeight( 18 );
182 hbd->addWidget( teleportsLCD ); 185 hbd->addWidget( teleportsLCD );
183 186
184 hbd->addSpacing( 10 ); 187 hbd->addSpacing( 10 );
185*/ 188*/
186 label = new QLabel( mainWin ); 189 label = new QLabel( mainWin );
187 label->setPixmap( Resource::loadPixmap("qasteroids/powerups/brake.png") ); 190 label->setPixmap( Resource::loadPixmap("qasteroids/powerups/brake.png") );
188 label->setFixedWidth( 16 ); 191 label->setFixedWidth( 16 );
189 label->setPalette( pal ); 192 label->setPalette( pal );
190 hbd->addWidget( label ); 193 hbd->addWidget( label );
191 194
192 brakesLCD = new QLCDNumber( 1, mainWin ); 195 brakesLCD = new QLCDNumber( 1, mainWin );
193 brakesLCD->setFrameStyle( QFrame::NoFrame ); 196 brakesLCD->setFrameStyle( QFrame::NoFrame );
194 brakesLCD->setSegmentStyle( QLCDNumber::Flat ); 197 brakesLCD->setSegmentStyle( QLCDNumber::Flat );
195 brakesLCD->setPalette( pal ); 198 brakesLCD->setPalette( pal );
196 brakesLCD->setFixedHeight( 16 ); 199 brakesLCD->setFixedHeight( 16 );
197 hbd->addWidget( brakesLCD ); 200 hbd->addWidget( brakesLCD );
198 201
199 hbd->addSpacing( 5 ); 202 hbd->addSpacing( 5 );
200 203
201 label = new QLabel( mainWin ); 204 label = new QLabel( mainWin );
202 label->setPixmap( Resource::loadPixmap("qasteroids/powerups/shield.png") ); 205 label->setPixmap( Resource::loadPixmap("qasteroids/powerups/shield.png") );
203 label->setFixedWidth( 16 ); 206 label->setFixedWidth( 16 );
204 label->setPalette( pal ); 207 label->setPalette( pal );
205 hbd->addWidget( label ); 208 hbd->addWidget( label );
206 209
207 shieldLCD = new QLCDNumber( 1, mainWin ); 210 shieldLCD = new QLCDNumber( 1, mainWin );
208 shieldLCD->setFrameStyle( QFrame::NoFrame ); 211 shieldLCD->setFrameStyle( QFrame::NoFrame );
209 shieldLCD->setSegmentStyle( QLCDNumber::Flat ); 212 shieldLCD->setSegmentStyle( QLCDNumber::Flat );
210 shieldLCD->setPalette( pal ); 213 shieldLCD->setPalette( pal );
211 shieldLCD->setFixedHeight( 16 ); 214 shieldLCD->setFixedHeight( 16 );
212 hbd->addWidget( shieldLCD ); 215 hbd->addWidget( shieldLCD );
213 216
214 hbd->addSpacing( 5 ); 217 hbd->addSpacing( 5 );
215 218
216 label = new QLabel( mainWin ); 219 label = new QLabel( mainWin );
217 label->setPixmap( Resource::loadPixmap("qasteroids/powerups/shoot.png") ); 220 label->setPixmap( Resource::loadPixmap("qasteroids/powerups/shoot.png") );
218 label->setFixedWidth( 16 ); 221 label->setFixedWidth( 16 );
219 label->setPalette( pal ); 222 label->setPalette( pal );
220 hbd->addWidget( label ); 223 hbd->addWidget( label );
221 224
222 shootLCD = new QLCDNumber( 1, mainWin ); 225 shootLCD = new QLCDNumber( 1, mainWin );
223 shootLCD->setFrameStyle( QFrame::NoFrame ); 226 shootLCD->setFrameStyle( QFrame::NoFrame );
224 shootLCD->setSegmentStyle( QLCDNumber::Flat ); 227 shootLCD->setSegmentStyle( QLCDNumber::Flat );
225 shootLCD->setPalette( pal ); 228 shootLCD->setPalette( pal );
226 shootLCD->setFixedHeight( 16 ); 229 shootLCD->setFixedHeight( 16 );
227 hbd->addWidget( shootLCD ); 230 hbd->addWidget( shootLCD );
228 231
229 hbd->addStretch( 1 ); 232 hbd->addStretch( 1 );
230 233
231 label = new QLabel( tr( "Fuel" ), mainWin ); 234 label = new QLabel( tr( "Fuel" ), mainWin );
232 label->setFont( smallFont ); 235 label->setFont( smallFont );
233 label->setFixedWidth( label->sizeHint().width() + 5 ); 236 label->setFixedWidth( label->sizeHint().width() + 5 );
234 label->setPalette( pal ); 237 label->setPalette( pal );
235 hbd->addWidget( label ); 238 hbd->addWidget( label );
236 239
237 powerMeter = new KALedMeter( mainWin ); 240 powerMeter = new KALedMeter( mainWin );
238 powerMeter->setFrameStyle( QFrame::Box | QFrame::Plain ); 241 powerMeter->setFrameStyle( QFrame::Box | QFrame::Plain );
239 powerMeter->setRange( MAX_POWER_LEVEL ); 242 powerMeter->setRange( MAX_POWER_LEVEL );
240 powerMeter->addColorRange( 10, darkRed ); 243 powerMeter->addColorRange( 10, darkRed );
241 powerMeter->addColorRange( 20, QColor(160, 96, 0) ); 244 powerMeter->addColorRange( 20, QColor(160, 96, 0) );
242 powerMeter->addColorRange( 70, darkGreen ); 245 powerMeter->addColorRange( 70, darkGreen );
243 powerMeter->setCount( 15 ); 246 powerMeter->setCount( 15 );
244 powerMeter->setPalette( pal ); 247 powerMeter->setPalette( pal );
245 powerMeter->setFixedSize( 60, 12 ); 248 powerMeter->setFixedSize( 60, 12 );
246 hbd->addWidget( powerMeter ); 249 hbd->addWidget( powerMeter );
247 250
248 shipsRemain = 3; 251 shipsRemain = 3;
249 showHiscores = FALSE; 252 showHiscores = FALSE;
250 253
251 actions.insert( Qt::Key_Up, Thrust ); 254 actions.insert( Qt::Key_Up, Thrust );
252 actions.insert( Qt::Key_Left, RotateLeft ); 255 actions.insert( Qt::Key_Left, RotateLeft );
253 actions.insert( Qt::Key_Right, RotateRight ); 256 actions.insert( Qt::Key_Right, RotateRight );
254 actions.insert( Qt::Key_Enter, Shoot ); 257 actions.insert( Qt::Key_Enter, Shoot );
255 actions.insert( Qt::Key_Z, Teleport ); 258 actions.insert( Qt::Key_Z, Teleport );
256 actions.insert( Qt::Key_Down, Brake ); 259 actions.insert( Qt::Key_Down, Brake );
257 actions.insert( Qt::Key_P, Pause ); 260 actions.insert( Qt::Key_P, Pause );
258 261
259 262
260 struct utsname name; /* check for embedix kernel running on the zaurus, if 263 struct utsname name; /* check for embedix kernel running on the zaurus, if
261 lineo change string, this break 264 lineo change string, this break
262 */ 265 */
263 if (uname(&name) != -1) { 266 if (uname(&name) != -1) {
264 QString release=name.release; 267 QString release=name.release;
265 if(release.find("embedix",0,TRUE) !=-1) { 268 if(release.find("embedix",0,TRUE) !=-1) {
266 actions.insert( Key_F12, Launch ); 269 actions.insert( Key_F12, Launch );
267 actions.insert( Key_F11, Shield ); 270 actions.insert( Key_F11, Shield );
268 actions.insert( Key_F9, NewGame ); 271 actions.insert( Key_F9, NewGame );
269 } else { 272 } else {
270 // ipaq 273 // ipaq
271 actions.insert( Key_F12, Shoot ); 274 actions.insert( Key_F12, Shoot );
272 actions.insert( Key_F11, Shield ); 275 actions.insert( Key_F11, Shield );
273 actions.insert( Key_F10, Launch ); 276 actions.insert( Key_F10, Launch );
274 actions.insert( Key_F9, NewGame ); 277 actions.insert( Key_F9, NewGame );
275 } 278 }
276 } 279 }
277 280
278// actions.insert( Qt::Key_S, Shield ); 281// actions.insert( Qt::Key_S, Shield );
279// actions.insert( Qt::Key_X, Brake ); 282// actions.insert( Qt::Key_X, Brake );
280// actions.insert( Qt::Key_L, Launch ); 283// actions.insert( Qt::Key_L, Launch );
281 actions.insert( Qt::Key_Space, Shoot ); 284 actions.insert( Qt::Key_Space, Shoot );
282 285
283 view->showText( tr( "Press Calendar to start playing" ), yellow ); 286 view->showText( tr( "Press Calendar to start playing" ), yellow );
284 287
285 setFocusPolicy( StrongFocus ); 288 setFocusPolicy( StrongFocus );
286 289
287 slotNewGame(); 290 slotNewGame();
288} 291}
289 292
290KAstTopLevel::~KAstTopLevel() 293KAstTopLevel::~KAstTopLevel()
291{ 294{
292} 295}
293 296
294void KAstTopLevel::playSound( const char * ) 297void KAstTopLevel::playSound( const char * )
295{ 298{
296} 299}
297 300
298void KAstTopLevel::keyPressEvent( QKeyEvent *event ) 301void KAstTopLevel::keyPressEvent( QKeyEvent *event )
299{ 302{
300 if ( event->isAutoRepeat() || !actions.contains( event->key() ) ) 303 if ( event->isAutoRepeat() || !actions.contains( event->key() ) )
301 { 304 {
302 event->ignore(); 305 event->ignore();
303 return; 306 return;
304 } 307 }
305 308
306 Action a = actions[ event->key() ]; 309 Action a = actions[ event->key() ];
307 310
308 switch ( a ) 311 switch ( a )
309 { 312 {
310 case RotateLeft: 313 case RotateLeft:
311 view->rotateLeft( TRUE ); 314 view->rotateLeft( TRUE );
312 break; 315 break;
313 316
314 case RotateRight: 317 case RotateRight:
315 view->rotateRight( TRUE ); 318 view->rotateRight( TRUE );
316 break; 319 break;
317 320
318 case Thrust: 321 case Thrust:
319 view->thrust( TRUE ); 322 view->thrust( TRUE );
320 break; 323 break;
321 324
322 case Shoot: 325 case Shoot:
323 view->shoot( TRUE ); 326 view->shoot( TRUE );
324 break; 327 break;
325 328
326 case Shield: 329 case Shield:
327 view->setShield( TRUE ); 330 view->setShield( TRUE );
328 break; 331 break;
329 332
330 case Teleport: 333 case Teleport:
331 view->teleport( TRUE ); 334 view->teleport( TRUE );
332 break; 335 break;
333 336
334 case Brake: 337 case Brake:
335 view->brake( TRUE ); 338 view->brake( TRUE );
336 break; 339 break;
337 340
338 default: 341 default:
339 event->ignore(); 342 event->ignore();
340 return; 343 return;
341 } 344 }
342 event->accept(); 345 event->accept();
343} 346}
344 347
345void KAstTopLevel::keyReleaseEvent( QKeyEvent *event ) 348void KAstTopLevel::keyReleaseEvent( QKeyEvent *event )
346{ 349{
347 if ( event->isAutoRepeat() || !actions.contains( event->key() ) ) 350 if ( event->isAutoRepeat() || !actions.contains( event->key() ) )
348 { 351 {
349 event->ignore(); 352 event->ignore();
350 return; 353 return;
351 } 354 }
352 355
353 Action a = actions[ event->key() ]; 356 Action a = actions[ event->key() ];
354 357
355 switch ( a ) 358 switch ( a )
356 { 359 {
357 case RotateLeft: 360 case RotateLeft:
358 view->rotateLeft( FALSE ); 361 view->rotateLeft( FALSE );
359 break; 362 break;
360 363
361 case RotateRight: 364 case RotateRight:
362 view->rotateRight( FALSE ); 365 view->rotateRight( FALSE );
363 break; 366 break;
364 367
365 case Thrust: 368 case Thrust:
366 view->thrust( FALSE ); 369 view->thrust( FALSE );
367 break; 370 break;
368 371
369 case Shoot: 372 case Shoot:
370 view->shoot( FALSE ); 373 view->shoot( FALSE );
371 break; 374 break;
372 375
373 case Brake: 376 case Brake:
374 view->brake( FALSE ); 377 view->brake( FALSE );
375 break; 378 break;
376 379
377 case Shield: 380 case Shield:
378 view->setShield( FALSE ); 381 view->setShield( FALSE );
379 break; 382 break;
380 383
381 case Teleport: 384 case Teleport:
382 view->teleport( FALSE ); 385 view->teleport( FALSE );
383 break; 386 break;
384 387
385 case Launch: 388 case Launch:
386 if ( waitShip ) 389 if ( waitShip )
387 { 390 {
388 view->newShip(); 391 view->newShip();
389 waitShip = FALSE; 392 waitShip = FALSE;
390 view->hideText(); 393 view->hideText();
391 } 394 }
392 else 395 else
393 { 396 {
394 event->ignore(); 397 event->ignore();
395 return; 398 return;
396 } 399 }
397 break; 400 break;
398 401
399 case NewGame: 402 case NewGame:
400 slotNewGame(); 403 slotNewGame();
401 break; 404 break;
402/* 405/*
403 case Pause: 406 case Pause:
404 { 407 {
405 view->pause( TRUE ); 408 view->pause( TRUE );
406 QMessageBox::information( this, 409 QMessageBox::information( this,
407 tr("KAsteroids is paused"), 410 tr("KAsteroids is paused"),
408 tr("Paused") ); 411 tr("Paused") );
409 view->pause( FALSE ); 412 view->pause( FALSE );
410 } 413 }
411 break; 414 break;
412*/ 415*/
413 default: 416 default:
414 event->ignore(); 417 event->ignore();
415 return; 418 return;
416 } 419 }
417 420
418 event->accept(); 421 event->accept();
419} 422}
420 423
421void KAstTopLevel::showEvent( QShowEvent *e ) 424void KAstTopLevel::showEvent( QShowEvent *e )
422{ 425{
423 QMainWindow::showEvent( e ); 426 QMainWindow::showEvent( e );
424 view->pause( FALSE ); 427 view->pause( FALSE );
425 setFocus(); 428 setFocus();
426} 429}
427 430
428void KAstTopLevel::hideEvent( QHideEvent *e ) 431void KAstTopLevel::hideEvent( QHideEvent *e )
429{ 432{
430 QMainWindow::hideEvent( e ); 433 QMainWindow::hideEvent( e );
431 view->pause( TRUE ); 434 view->pause( TRUE );
432} 435}
433 436
434void KAstTopLevel::focusInEvent( QFocusEvent * ) 437void KAstTopLevel::focusInEvent( QFocusEvent * )
435{ 438{
436 view->pause( FALSE ); 439 view->pause( FALSE );
437 setFocus(); 440 setFocus();
438} 441}
439 442
440void KAstTopLevel::focusOutEvent( QFocusEvent * ) 443void KAstTopLevel::focusOutEvent( QFocusEvent * )
441{ 444{
442 view->pause( TRUE ); 445 view->pause( TRUE );
443} 446}
444 447
445void KAstTopLevel::slotNewGame() 448void KAstTopLevel::slotNewGame()
446{ 449{
447 shipsRemain = 3; 450 shipsRemain = 3;
448 score = 0; 451 score = 0;
449 scoreLCD->display( 0 ); 452 scoreLCD->display( 0 );
450 level = 0; 453 level = 0;
451 levelLCD->display( level+1 ); 454 levelLCD->display( level+1 );
452 shipsLCD->display( shipsRemain-1 ); 455 shipsLCD->display( shipsRemain-1 );
453 view->newGame(); 456 view->newGame();
454 view->setRockSpeed( levels[0].rockSpeed ); 457 view->setRockSpeed( levels[0].rockSpeed );
455 view->addRocks( levels[0].nrocks ); 458 view->addRocks( levels[0].nrocks );
456 view->newShip(); 459 view->newShip();
457 waitShip = FALSE; 460 waitShip = FALSE;
458 view->hideText(); 461 view->hideText();
459 isPaused = FALSE; 462 isPaused = FALSE;
460} 463}
461 464
462void KAstTopLevel::slotShipKilled() 465void KAstTopLevel::slotShipKilled()
463{ 466{
464 shipsRemain--; 467 shipsRemain--;
465 shipsLCD->display( shipsRemain-1 ); 468 shipsLCD->display( shipsRemain-1 );
466 469
467 playSound( "ShipDestroyed" ); 470 playSound( "ShipDestroyed" );
468 471
469 if ( shipsRemain > 0 ) 472 if ( shipsRemain > 0 )
470 { 473 {
471 waitShip = TRUE; 474 waitShip = TRUE;
472 view->showText( tr( "Ship Destroyed.\nPress Contacts/Home key."), yellow ); 475 view->showText( tr( "Ship Destroyed.\nPress Contacts/Home key."), yellow );
473 } 476 }
474 else 477 else
475 { 478 {
476 view->endGame(); 479 view->endGame();
477 doStats(); 480 doStats();
478 } 481 }
479} 482}
480 483
481void KAstTopLevel::slotRockHit( int size ) 484void KAstTopLevel::slotRockHit( int size )
482{ 485{
483 switch ( size ) 486 switch ( size )
484 { 487 {
485 case 0: 488 case 0:
486 score += 10; 489 score += 10;
487 break; 490 break;
488 491
489 case 1: 492 case 1:
490 score += 20; 493 score += 20;
491 break; 494 break;
492 495
493 default: 496 default:
494 score += 40; 497 score += 40;
495 } 498 }
496 499
497 playSound( "RockDestroyed" ); 500 playSound( "RockDestroyed" );
498 501
499 scoreLCD->display( score ); 502 scoreLCD->display( score );
500} 503}
501 504
502void KAstTopLevel::slotRocksRemoved() 505void KAstTopLevel::slotRocksRemoved()
503{ 506{
504 level++; 507 level++;
505 508
506 if ( level >= MAX_LEVELS ) 509 if ( level >= MAX_LEVELS )
507 level = MAX_LEVELS - 1; 510 level = MAX_LEVELS - 1;
508 511
509 view->setRockSpeed( levels[level-1].rockSpeed ); 512 view->setRockSpeed( levels[level-1].rockSpeed );
510 view->addRocks( levels[level-1].nrocks ); 513 view->addRocks( levels[level-1].nrocks );
511 514
512 levelLCD->display( level+1 ); 515 levelLCD->display( level+1 );
513} 516}
514 517
515void KAstTopLevel::doStats() 518void KAstTopLevel::doStats()
516{ 519{
517 QString r( "0.00" ); 520 QString r( "0.00" );
518 if ( view->shots() ) 521 if ( view->shots() )
519 r = QString::number( (double)view->hits() / view->shots() * 100.0, 522 r = QString::number( (double)view->hits() / view->shots() * 100.0,
520 'g', 2 ); 523 'g', 2 );
521 524
522 view->showText( tr( "Game Over.\nPress Calendar for a new game." ), yellow, FALSE ); 525 view->showText( tr( "Game Over.\nPress Calendar for a new game." ), yellow, FALSE );
523} 526}
524 527
525void KAstTopLevel::slotUpdateVitals() 528void KAstTopLevel::slotUpdateVitals()
526{ 529{
527 brakesLCD->display( view->brakeCount() ); 530 brakesLCD->display( view->brakeCount() );
528 shieldLCD->display( view->shieldCount() ); 531 shieldLCD->display( view->shieldCount() );
529 shootLCD->display( view->shootCount() ); 532 shootLCD->display( view->shootCount() );
530// teleportsLCD->display( view->teleportCount() ); 533// teleportsLCD->display( view->teleportCount() );
531 powerMeter->setValue( view->power() ); 534 powerMeter->setValue( view->power() );
532} 535}
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
@@ -1,99 +1,101 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************//* 19**********************************************************************//*
20 * KAsteroids - Copyright (c) Martin R. Jones 1997 20 * KAsteroids - Copyright (c) Martin R. Jones 1997
21 * 21 *
22 * Part of the KDE project 22 * Part of the KDE project
23 */ 23 */
24 24
25#ifndef __KAST_TOPLEVEL_H__ 25#ifndef __KAST_TOPLEVEL_H__
26#define __KAST_TOPLEVEL_H__ 26#define __KAST_TOPLEVEL_H__
27 27
28#include <qmainwindow.h> 28#include <qmainwindow.h>
29#include <qdict.h> 29#include <qdict.h>
30#include <qmap.h> 30#include <qmap.h>
31 31
32#include "view.h" 32#include "view.h"
33 33
34 34
35class KALedMeter; 35class KALedMeter;
36class QLCDNumber; 36class QLCDNumber;
37 37
38class KAstTopLevel : public QMainWindow 38class KAstTopLevel : public QMainWindow
39{ 39{
40 Q_OBJECT 40 Q_OBJECT
41public: 41public:
42 KAstTopLevel( QWidget *parent=0, const char *name=0 ); 42 KAstTopLevel( QWidget *parent=0, const char *name=0, WFlags fl = 0 );
43 virtual ~KAstTopLevel(); 43 virtual ~KAstTopLevel();
44 static QString appName() { return QString::fromLatin1("qasteroids"); }
45
44 46
45private: 47private:
46 void playSound( const char *snd ); 48 void playSound( const char *snd );
47 void readSoundMapping(); 49 void readSoundMapping();
48 void doStats(); 50 void doStats();
49 51
50protected: 52protected:
51 virtual void showEvent( QShowEvent * ); 53 virtual void showEvent( QShowEvent * );
52 virtual void hideEvent( QHideEvent * ); 54 virtual void hideEvent( QHideEvent * );
53 virtual void keyPressEvent( QKeyEvent *event ); 55 virtual void keyPressEvent( QKeyEvent *event );
54 virtual void keyReleaseEvent( QKeyEvent *event ); 56 virtual void keyReleaseEvent( QKeyEvent *event );
55 virtual void focusInEvent( QFocusEvent *event ); 57 virtual void focusInEvent( QFocusEvent *event );
56 virtual void focusOutEvent( QFocusEvent *event ); 58 virtual void focusOutEvent( QFocusEvent *event );
57 59
58private slots: 60private slots:
59 void slotNewGame(); 61 void slotNewGame();
60 62
61 void slotShipKilled(); 63 void slotShipKilled();
62 void slotRockHit( int size ); 64 void slotRockHit( int size );
63 void slotRocksRemoved(); 65 void slotRocksRemoved();
64 66
65 void slotUpdateVitals(); 67 void slotUpdateVitals();
66 68
67private: 69private:
68 KAsteroidsView *view; 70 KAsteroidsView *view;
69 QLCDNumber *scoreLCD; 71 QLCDNumber *scoreLCD;
70 QLCDNumber *levelLCD; 72 QLCDNumber *levelLCD;
71 QLCDNumber *shipsLCD; 73 QLCDNumber *shipsLCD;
72 74
73 QLCDNumber *teleportsLCD; 75 QLCDNumber *teleportsLCD;
74// QLCDNumber *bombsLCD; 76// QLCDNumber *bombsLCD;
75 QLCDNumber *brakesLCD; 77 QLCDNumber *brakesLCD;
76 QLCDNumber *shieldLCD; 78 QLCDNumber *shieldLCD;
77 QLCDNumber *shootLCD; 79 QLCDNumber *shootLCD;
78 KALedMeter *powerMeter; 80 KALedMeter *powerMeter;
79 81
80 bool sound; 82 bool sound;
81 QDict<QString> soundDict; 83 QDict<QString> soundDict;
82 84
83 // waiting for user to press Enter to launch a ship 85 // waiting for user to press Enter to launch a ship
84 bool waitShip; 86 bool waitShip;
85 bool isPaused; 87 bool isPaused;
86 88
87 int shipsRemain; 89 int shipsRemain;
88 int score; 90 int score;
89 int level; 91 int level;
90 bool showHiscores; 92 bool showHiscores;
91 93
92 enum Action { Launch, Thrust, RotateLeft, RotateRight, Shoot, Teleport, 94 enum Action { Launch, Thrust, RotateLeft, RotateRight, Shoot, Teleport,
93 Brake, Shield, Pause, NewGame }; 95 Brake, Shield, Pause, NewGame };
94 96
95 QMap<int,Action> actions; 97 QMap<int,Action> actions;
96}; 98};
97 99
98#endif 100#endif
99 101
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
@@ -1,221 +1,223 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "interface.h" 21#include "interface.h"
22 22
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24#include <qpe/qpeapplication.h>
24 25
25#include <qpe/qpetoolbar.h> 26#include <qpe/qpetoolbar.h>
26#include <qtoolbutton.h> 27#include <qtoolbutton.h>
27#include <qstyle.h> 28#include <qstyle.h>
28#include <qapplication.h> 29#include <qapplication.h>
29#include <qmessagebox.h> 30#include <qmessagebox.h>
30 31
31SnakeGame::SnakeGame(QWidget* parent, const char* name, WFlags f) : 32SnakeGame::SnakeGame(QWidget* parent, const char* name, WFlags f) :
32 QMainWindow(parent,name,f), 33 QMainWindow(parent,name,f),
33 canvas(232, 258) 34 canvas(232, 258)
34{ 35{
35 setCaption( tr("Snake") ); 36 setCaption( tr("Snake") );
37 QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff );
36 QPixmap bg = Resource::loadPixmap("snake/grass"); 38 QPixmap bg = Resource::loadPixmap("snake/grass");
37 canvas.setBackgroundPixmap(bg); 39 canvas.setBackgroundPixmap(bg);
38 canvas.setUpdatePeriod(100); 40 canvas.setUpdatePeriod(100);
39 snake = 0; 41 snake = 0;
40 42
41 cv = new QCanvasView(&canvas, this); 43 cv = new QCanvasView(&canvas, this);
42 44
43 pauseTimer = new QTimer(this); 45 pauseTimer = new QTimer(this);
44 connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) ); 46 connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) );
45 47
46 setToolBarsMovable( FALSE ); 48 setToolBarsMovable( FALSE );
47 49
48 QToolBar* toolbar = new QToolBar( this); 50 QToolBar* toolbar = new QToolBar( this);
49 toolbar->setHorizontalStretchable( TRUE ); 51 toolbar->setHorizontalStretchable( TRUE );
50 52
51 QPixmap newicon = Resource::loadPixmap("ksnake"); 53 QPixmap newicon = Resource::loadPixmap("ksnake");
52 setIcon(newicon); 54 setIcon(newicon);
53 (void)new QToolButton(newicon, tr("New Game"), 0, 55 (void)new QToolButton(newicon, tr("New Game"), 0,
54 this, SLOT(newGame()), toolbar, "New Game"); 56 this, SLOT(newGame()), toolbar, "New Game");
55 57
56 scorelabel = new QLabel(toolbar); 58 scorelabel = new QLabel(toolbar);
57 showScore(0); 59 showScore(0);
58 scorelabel->setBackgroundMode( PaletteButton ); 60 scorelabel->setBackgroundMode( PaletteButton );
59 scorelabel->setAlignment( AlignRight | AlignVCenter | ExpandTabs ); 61 scorelabel->setAlignment( AlignRight | AlignVCenter | ExpandTabs );
60 toolbar->setStretchableWidget( scorelabel ); 62 toolbar->setStretchableWidget( scorelabel );
61 63
62 setFocusPolicy(StrongFocus); 64 setFocusPolicy(StrongFocus);
63 65
64 setCentralWidget(cv); 66 setCentralWidget(cv);
65 67
66 QTimer::singleShot( 16, this, SLOT(welcomescreen()) ); 68 QTimer::singleShot( 16, this, SLOT(welcomescreen()) );
67 gamestopped = true; 69 gamestopped = true;
68 waitover = true; 70 waitover = true;
69} 71}
70 72
71SnakeGame::~SnakeGame() 73SnakeGame::~SnakeGame()
72{ 74{
73 delete snake; 75 delete snake;
74} 76}
75 77
76void SnakeGame::resizeEvent(QResizeEvent *) 78void SnakeGame::resizeEvent(QResizeEvent *)
77{ 79{
78 QSize s = centralWidget()->size(); 80 QSize s = centralWidget()->size();
79 int fw = style().defaultFrameWidth(); 81 int fw = style().defaultFrameWidth();
80 canvas.resize( s.width() - fw - 2, s.height() - fw - 2); 82 canvas.resize( s.width() - fw - 2, s.height() - fw - 2);
81} 83}
82 84
83void SnakeGame::welcomescreen() 85void SnakeGame::welcomescreen()
84{ 86{
85 QCanvasText* title = new QCanvasText(tr("SNAKE!"), &canvas); 87 QCanvasText* title = new QCanvasText(tr("SNAKE!"), &canvas);
86 title->setColor(yellow); 88 title->setColor(yellow);
87 title->setFont( QFont("times", 18, QFont::Bold) ); 89 title->setFont( QFont("times", 18, QFont::Bold) );
88 int w = title->boundingRect().width(); 90 int w = title->boundingRect().width();
89 title->move(canvas.width()/2 -w/2, canvas.height()/2-110); 91 title->move(canvas.width()/2 -w/2, canvas.height()/2-110);
90 title->show(); 92 title->show();
91 QCanvasPixmapArray* titlearray = new QCanvasPixmapArray(Resource::findPixmap("snake/title")); 93 QCanvasPixmapArray* titlearray = new QCanvasPixmapArray(Resource::findPixmap("snake/title"));
92 QCanvasSprite* titlepic = new QCanvasSprite(titlearray, &canvas); 94 QCanvasSprite* titlepic = new QCanvasSprite(titlearray, &canvas);
93 titlepic->move(canvas.width()/2 - 33, canvas.height()/2-85); 95 titlepic->move(canvas.width()/2 - 33, canvas.height()/2-85);
94 titlepic->show(); 96 titlepic->show();
95 QCanvasText* instr = new QCanvasText(tr("Use the arrow keys to guide the\n" 97 QCanvasText* instr = new QCanvasText(tr("Use the arrow keys to guide the\n"
96 "snake to eat the mouse. You must not\n" 98 "snake to eat the mouse. You must not\n"
97 "crash into the walls, edges or its tail."), 99 "crash into the walls, edges or its tail."),
98 &canvas); 100 &canvas);
99 w = instr->boundingRect().width(); 101 w = instr->boundingRect().width();
100 instr->move(canvas.width()/2-w/2, canvas.height()/2-20); 102 instr->move(canvas.width()/2-w/2, canvas.height()/2-20);
101 instr->setColor(white); 103 instr->setColor(white);
102 instr->show(); 104 instr->show();
103 QCanvasText* cont = new QCanvasText(tr("Press any key to start"), &canvas); 105 QCanvasText* cont = new QCanvasText(tr("Press any key to start"), &canvas);
104 w = cont->boundingRect().width(); 106 w = cont->boundingRect().width();
105 cont->move(canvas.width()/2-w/2, canvas.height()-20); 107 cont->move(canvas.width()/2-w/2, canvas.height()-20);
106 cont->setColor(yellow); 108 cont->setColor(yellow);
107 cont->show(); 109 cont->show();
108 110
109} 111}
110 112
111void SnakeGame::newGame() 113void SnakeGame::newGame()
112{ 114{
113 clear(); 115 clear();
114 snake = new Snake(&canvas); 116 snake = new Snake(&canvas);
115 connect(snake, SIGNAL(dead()), this, SLOT(gameOver()) ); 117 connect(snake, SIGNAL(dead()), this, SLOT(gameOver()) );
116 connect(snake, SIGNAL(targethit()), this, SLOT(levelUp()) ); 118 connect(snake, SIGNAL(targethit()), this, SLOT(levelUp()) );
117 connect(snake, SIGNAL(scorechanged()), this, SLOT(scoreInc()) ); 119 connect(snake, SIGNAL(scorechanged()), this, SLOT(scoreInc()) );
118 connect(this, SIGNAL(moveFaster()), snake, SLOT(increaseSpeed()) ); 120 connect(this, SIGNAL(moveFaster()), snake, SLOT(increaseSpeed()) );
119 last = 0; 121 last = 0;
120 targetamount = 1; 122 targetamount = 1;
121 notargets = 1; 123 notargets = 1;
122 level = 1; 124 level = 1;
123 stage = 1; 125 stage = 1;
124 showScore(0); 126 showScore(0);
125 gamestopped = false; 127 gamestopped = false;
126 waitover = true; 128 waitover = true;
127 int y = canvas.height()-50; 129 int y = canvas.height()-50;
128 (void)new Obstacle(&canvas, 32); 130 (void)new Obstacle(&canvas, 32);
129 (void)new Obstacle(&canvas, y); 131 (void)new Obstacle(&canvas, y);
130 createTargets(); 132 createTargets();
131} 133}
132 134
133 135
134void SnakeGame::showScore(int score) 136void SnakeGame::showScore(int score)
135{ 137{
136 scorelabel->setText(tr(" Score : %1 ").arg(score) ); 138 scorelabel->setText(tr(" Score : %1 ").arg(score) );
137} 139}
138 140
139 141
140void SnakeGame::scoreInc() 142void SnakeGame::scoreInc()
141{ 143{
142 showScore( snake->getScore() ); 144 showScore( snake->getScore() );
143} 145}
144 146
145void SnakeGame::levelUp() 147void SnakeGame::levelUp()
146{ 148{
147 notargets--; 149 notargets--;
148 if (notargets == 0) { 150 if (notargets == 0) {
149 stage++; 151 stage++;
150 if (stage == 3) { 152 if (stage == 3) {
151 level++; 153 level++;
152 emit moveFaster(); 154 emit moveFaster();
153 targetamount++; 155 targetamount++;
154 stage = 0; 156 stage = 0;
155 } 157 }
156 createTargets(); 158 createTargets();
157 } 159 }
158} 160}
159 161
160void SnakeGame::createTargets() 162void SnakeGame::createTargets()
161{ 163{
162 for (int i = 0; i < targetamount; i++) 164 for (int i = 0; i < targetamount; i++)
163 (void)new Target(&canvas); 165 (void)new Target(&canvas);
164 notargets = targetamount; 166 notargets = targetamount;
165} 167}
166 168
167void SnakeGame::clear() 169void SnakeGame::clear()
168{ 170{
169 delete snake; 171 delete snake;
170 snake = 0; 172 snake = 0;
171 QCanvasItemList l = canvas.allItems(); 173 QCanvasItemList l = canvas.allItems();
172 for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) { 174 for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) {
173 delete *it; 175 delete *it;
174 } 176 }
175} 177}
176 178
177void SnakeGame::gameOver() 179void SnakeGame::gameOver()
178{ 180{
179 int score = snake->getScore(); 181 int score = snake->getScore();
180 QString scoreoutput=""; 182 QString scoreoutput="";
181 scoreoutput.setNum(score); 183 scoreoutput.setNum(score);
182 QCanvasText* gameover = new QCanvasText(tr("GAME OVER!\n Your Score: %1").arg( scoreoutput), &canvas); 184 QCanvasText* gameover = new QCanvasText(tr("GAME OVER!\n Your Score: %1").arg( scoreoutput), &canvas);
183 185
184 gameover->setZ(100); 186 gameover->setZ(100);
185 gameover->setColor(yellow); 187 gameover->setColor(yellow);
186 gameover->setFont( QFont("times", 18, QFont::Bold) ); 188 gameover->setFont( QFont("times", 18, QFont::Bold) );
187 int w = gameover->boundingRect().width(); 189 int w = gameover->boundingRect().width();
188 gameover->move(canvas.width()/2 -w/2, canvas.height()/2 -50); 190 gameover->move(canvas.width()/2 -w/2, canvas.height()/2 -50);
189 gameover->show(); 191 gameover->show();
190 gamestopped = true; 192 gamestopped = true;
191 waitover = false; 193 waitover = false;
192 pauseTimer->start(1500); 194 pauseTimer->start(1500);
193} 195}
194 196
195void SnakeGame::wait() 197void SnakeGame::wait()
196{ 198{
197 waitover = true; 199 waitover = true;
198 pauseTimer->stop(); 200 pauseTimer->stop();
199 QCanvasText* cont = new QCanvasText(tr("Press any key to begin a new game."), 201 QCanvasText* cont = new QCanvasText(tr("Press any key to begin a new game."),
200 &canvas); 202 &canvas);
201 cont->setZ(100); 203 cont->setZ(100);
202 cont->setColor(white); 204 cont->setColor(white);
203 int w = cont->boundingRect().width(); 205 int w = cont->boundingRect().width();
204 cont->move(canvas.width()/2 -w/2, canvas.height()/2); 206 cont->move(canvas.width()/2 -w/2, canvas.height()/2);
205 cont->show(); 207 cont->show();
206} 208}
207 209
208void SnakeGame::keyPressEvent(QKeyEvent* event) 210void SnakeGame::keyPressEvent(QKeyEvent* event)
209{ 211{
210 if (gamestopped) { 212 if (gamestopped) {
211 if (waitover) 213 if (waitover)
212 newGame(); 214 newGame();
213 else 215 else
214 return; 216 return;
215 } 217 }
216 else { 218 else {
217 int newkey = event->key(); 219 int newkey = event->key();
218 snake->go(newkey); 220 snake->go(newkey);
219 } 221 }
220} 222}
221 223
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
@@ -1,69 +1,72 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qmainwindow.h> 20#include <qmainwindow.h>
21#include <qpe/qpeapplication.h>
21#include <qcanvas.h> 22#include <qcanvas.h>
22#include <qlabel.h> 23#include <qlabel.h>
23 24
24#include "snake.h" 25#include "snake.h"
25#include "target.h" 26#include "target.h"
26#include "obstacle.h" 27#include "obstacle.h"
27 28
28// class QCanvas; 29// class QCanvas;
29 30
30class SnakeGame : public QMainWindow { 31class SnakeGame : public QMainWindow {
31 Q_OBJECT 32 Q_OBJECT
32 33
33public: 34public:
34 SnakeGame(QWidget* parent=0, const char* name=0, WFlags f=0); 35 SnakeGame(QWidget* parent=0, const char* name=0, WFlags f=0);
35 ~SnakeGame(); 36 ~SnakeGame();
36 37
37 void clear(); 38 void clear();
38 void createTargets(); 39 void createTargets();
39 40
41 static QString appName() { return QString::fromLatin1("snake"); }
42
40protected: 43protected:
41 virtual void keyPressEvent(QKeyEvent*); 44 virtual void keyPressEvent(QKeyEvent*);
42 virtual void resizeEvent(QResizeEvent *e); 45 virtual void resizeEvent(QResizeEvent *e);
43 46
44signals: 47signals:
45 void moveFaster(); 48 void moveFaster();
46 49
47private slots: 50private slots:
48 void newGame(); 51 void newGame();
49 void gameOver(); 52 void gameOver();
50 void wait(); 53 void wait();
51 void levelUp(); 54 void levelUp();
52 void scoreInc(); 55 void scoreInc();
53 void welcomescreen(); 56 void welcomescreen();
54 57
55private: 58private:
56 void showScore(int); 59 void showScore(int);
57 QCanvasView* cv; 60 QCanvasView* cv;
58 QLabel* scorelabel; 61 QLabel* scorelabel;
59 QCanvas canvas; 62 QCanvas canvas;
60 QTimer* pauseTimer; 63 QTimer* pauseTimer;
61 Snake* snake; 64 Snake* snake;
62 int last; 65 int last;
63 int level; 66 int level;
64 int stage; 67 int stage;
65 int targetamount; 68 int targetamount;
66 int notargets; 69 int notargets;
67 bool waitover; 70 bool waitover;
68 bool gamestopped; 71 bool gamestopped;
69}; 72};
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
@@ -1,35 +1,29 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "interface.h" 21#include "interface.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <opie/oapplicationfactory.h>
25
24 26
27OPIE_EXPORT_APP( OApplicationFactory<SnakeGame> )
25 28
26int main(int argc, char **argv)
27{
28 QPEApplication app(argc,argv);
29 29
30 SnakeGame* m = new SnakeGame;
31 QPEApplication::setInputMethodHint( m, QPEApplication::AlwaysOff );
32 app.showMainWidget(m);
33
34 return app.exec();
35}
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,10 +1,10 @@
1Package: opie-snake 1Package: opie-snake
2Files: bin/snake apps/Games/snake.desktop pics/snake 2Files: plugins/application/libsnake.so* bin/snake apps/Games/snake.desktop pics/snake
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Martin Imobersteg <imm@gmx.ch> 5Maintainer: Martin Imobersteg <imm@gmx.ch>
6Architecture: arm 6Architecture: arm
7Depends: task-opie-minimal 7Depends: task-opie-minimal
8Description: Game: control the snake 8Description: Game: control the snake
9 A game for the Opie environment. 9 A game for the Opie environment.
10Version: $QPE_VERSION$EXTRAVERSION 10Version: $QPE_VERSION$EXTRAVERSION
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 @@
1 TEMPLATE= app 1 CONFIG += qt warn_on release quick-app
2 CONFIG += qt warn_on release
3 DESTDIR = $(OPIEDIR)/bin
4 HEADERS = snake.h target.h obstacle.h interface.h codes.h 2 HEADERS = snake.h target.h obstacle.h interface.h codes.h
5 SOURCES = snake.cpp target.cpp obstacle.cpp interface.cpp main.cpp 3 SOURCES = snake.cpp target.cpp obstacle.cpp interface.cpp main.cpp
6 TARGET = snake 4 TARGET = snake
7INCLUDEPATH += $(OPIEDIR)/include 5INCLUDEPATH += $(OPIEDIR)/include
8 DEPENDPATH+= $(OPIEDIR)/include 6 DEPENDPATH+= $(OPIEDIR)/include
9LIBS += -lqpe 7LIBS += -lqpe
10 8
9
11include ( $(OPIEDIR)/include.pro ) 10include ( $(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
@@ -1,314 +1,315 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "canvascardwindow.h" 21#include "canvascardwindow.h"
22#include "patiencecardgame.h" 22#include "patiencecardgame.h"
23#include "freecellcardgame.h" 23#include "freecellcardgame.h"
24#include "chicanecardgame.h" 24#include "chicanecardgame.h"
25#include "harpcardgame.h" 25#include "harpcardgame.h"
26#include "teeclubcardgame.h" 26#include "teeclubcardgame.h"
27 27
28#include <qpe/resource.h> 28#include <qpe/resource.h>
29 29
30#include <qmainwindow.h> 30#include <qmainwindow.h>
31#include <qpopupmenu.h> 31#include <qpopupmenu.h>
32#include <qstyle.h> 32#include <qstyle.h>
33 33
34 34
35CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) : 35CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) :
36 QMainWindow(parent, name, f), canvas(230, 260), snapOn(TRUE), cardBack(4), gameType(0), 36 QMainWindow(parent, name, f), canvas(230, 260), snapOn(TRUE), cardBack(4), gameType(0),
37 cardGame(NULL) 37 cardGame(NULL)
38{ 38{
39 setIcon( Resource::loadPixmap( "cards" ) ); 39 setIcon( Resource::loadPixmap( "cards" ) );
40 setCaption(tr("Patience"));
40 41
41 // Create Playing Area for Games 42 // Create Playing Area for Games
42 if ( QPixmap::defaultDepth() < 12 ) { 43 if ( QPixmap::defaultDepth() < 12 ) {
43// canvas.setBackgroundColor(QColor(0x51, 0x74, 0x6B)); 44// canvas.setBackgroundColor(QColor(0x51, 0x74, 0x6B));
44// canvas.setBackgroundColor(QColor(0x20, 0xb0, 0x50)); 45// canvas.setBackgroundColor(QColor(0x20, 0xb0, 0x50));
45 canvas.setBackgroundColor(QColor(0x08, 0x98, 0x2D)); 46 canvas.setBackgroundColor(QColor(0x08, 0x98, 0x2D));
46 } else { 47 } else {
47 QPixmap bg; 48 QPixmap bg;
48 bg.convertFromImage( Resource::loadImage( "table_pattern" ), ThresholdDither ); 49 bg.convertFromImage( Resource::loadImage( "table_pattern" ), ThresholdDither );
49 canvas.setBackgroundPixmap(bg); 50 canvas.setBackgroundPixmap(bg);
50 } 51 }
51 52
52#if defined( QT_QWS_CASSIOPEIA ) 53#if defined( QT_QWS_CASSIOPEIA )
53 canvas.setAdvancePeriod(70); 54 canvas.setAdvancePeriod(70);
54#else 55#else
55 canvas.setAdvancePeriod(30); 56 canvas.setAdvancePeriod(30);
56#endif 57#endif
57 58
58 59
59#ifdef _PATIENCE_USE_ACCELS_ 60#ifdef _PATIENCE_USE_ACCELS_
60 QMenuBar* menu = menuBar(); 61 QMenuBar* menu = menuBar();
61 62
62 QPopupMenu* file = new QPopupMenu; 63 QPopupMenu* file = new QPopupMenu;
63 file->insertItem(tr("Patience"), this, SLOT(initPatience()), CTRL+Key_F); 64 file->insertItem(tr("Patience"), this, SLOT(initPatience()), CTRL+Key_F);
64 file->insertItem(tr("Freecell"), this, SLOT(initFreecell()), CTRL+Key_F); 65 file->insertItem(tr("Freecell"), this, SLOT(initFreecell()), CTRL+Key_F);
65 file->insertItem(tr("Chicane"), this, SLOT(initChicane()), CTRL+Key_F); 66 file->insertItem(tr("Chicane"), this, SLOT(initChicane()), CTRL+Key_F);
66 file->insertItem(tr("Harp"), this, SLOT(initHarp()), CTRL+Key_F); 67 file->insertItem(tr("Harp"), this, SLOT(initHarp()), CTRL+Key_F);
67 file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub()), CTRL+Key_F); 68 file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub()), CTRL+Key_F);
68 menu->insertItem(tr("&Game"), file); 69 menu->insertItem(tr("&Game"), file);
69 70
70 menu->insertSeparator(); 71 menu->insertSeparator();
71 72
72 settings = new QPopupMenu; 73 settings = new QPopupMenu;
73 settings->insertItem(tr("&Change card backs"), this, SLOT(changeCardBacks()), Key_F2); 74 settings->insertItem(tr("&Change card backs"), this, SLOT(changeCardBacks()), Key_F2);
74 snap_id = settings->insertItem(tr("&Snap to position"), this, SLOT(snapToggle()), Key_F3); 75 snap_id = settings->insertItem(tr("&Snap to position"), this, SLOT(snapToggle()), Key_F3);
75 settings->setCheckable(TRUE); 76 settings->setCheckable(TRUE);
76 menu->insertItem(tr("&Settings"),settings); 77 menu->insertItem(tr("&Settings"),settings);
77 78
78 menu->insertSeparator(); 79 menu->insertSeparator();
79 80
80 QPopupMenu* help = new QPopupMenu; 81 QPopupMenu* help = new QPopupMenu;
81 help->insertItem(tr("&About"), this, SLOT(help()), Key_F1); 82 help->insertItem(tr("&About"), this, SLOT(help()), Key_F1);
82 help->setItemChecked(dbf_id, TRUE); 83 help->setItemChecked(dbf_id, TRUE);
83 menu->insertItem(tr("&Help"),help); 84 menu->insertItem(tr("&Help"),help);
84#else 85#else
85 QMenuBar* menu = menuBar(); 86 QMenuBar* menu = menuBar();
86 87
87 QPopupMenu* file = new QPopupMenu; 88 QPopupMenu* file = new QPopupMenu;
88 file->insertItem(tr("Patience"), this, SLOT(initPatience())); 89 file->insertItem(tr("Patience"), this, SLOT(initPatience()));
89 file->insertItem(tr("Freecell"), this, SLOT(initFreecell())); 90 file->insertItem(tr("Freecell"), this, SLOT(initFreecell()));
90 file->insertItem(tr("Chicane"), this, SLOT(initChicane())); 91 file->insertItem(tr("Chicane"), this, SLOT(initChicane()));
91 file->insertItem(tr("Harp"), this, SLOT(initHarp())); 92 file->insertItem(tr("Harp"), this, SLOT(initHarp()));
92 file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub())); 93 file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub()));
93 menu->insertItem(tr("Play"), file); 94 menu->insertItem(tr("Play"), file);
94 95
95 menu->insertSeparator(); 96 menu->insertSeparator();
96 97
97 settings = new QPopupMenu; 98 settings = new QPopupMenu;
98 settings->setCheckable(TRUE); 99 settings->setCheckable(TRUE);
99 settings->insertItem(tr("Change card backs"), this, SLOT(changeCardBacks())); 100 settings->insertItem(tr("Change card backs"), this, SLOT(changeCardBacks()));
100 snap_id = settings->insertItem(tr("Snap to position"), this, SLOT(snapToggle())); 101 snap_id = settings->insertItem(tr("Snap to position"), this, SLOT(snapToggle()));
101 QString m; 102 QString m;
102 103
103 drawId = settings->insertItem(tr("Turn one card"), this, SLOT(drawnToggle())); 104 drawId = settings->insertItem(tr("Turn one card"), this, SLOT(drawnToggle()));
104 menu->insertItem(tr("Settings"),settings); 105 menu->insertItem(tr("Settings"),settings);
105 settings->setCheckable(TRUE); 106 settings->setCheckable(TRUE);
106 107
107#endif 108#endif
108 109
109 menu->show(); 110 menu->show();
110 111
111 Config cfg( "Patience" ); 112 Config cfg( "Patience" );
112 cfg.setGroup( "GlobalSettings" ); 113 cfg.setGroup( "GlobalSettings" );
113 snapOn = cfg.readBoolEntry( "SnapOn", TRUE); 114 snapOn = cfg.readBoolEntry( "SnapOn", TRUE);
114 settings->setItemChecked(snap_id, snapOn); 115 settings->setItemChecked(snap_id, snapOn);
115 116
116 gameType = cfg.readNumEntry( "GameType", -1 ); 117 gameType = cfg.readNumEntry( "GameType", -1 );
117 drawThree = cfg.readBoolEntry( "DrawThree", FALSE); 118 drawThree = cfg.readBoolEntry( "DrawThree", FALSE);
118 if ( gameType == 0 ) { 119 if ( gameType == 0 ) {
119 cardGame = new PatienceCardGame( &canvas, snapOn, this ); 120 cardGame = new PatienceCardGame( &canvas, snapOn, this );
120 cardGame->setNumberToDraw(drawThree ? 3 : 1); 121 cardGame->setNumberToDraw(drawThree ? 3 : 1);
121 122
122 setCaption(tr("Patience")); 123 setCaption(tr("Patience"));
123 setCentralWidget(cardGame); 124 setCentralWidget(cardGame);
124 cardGame->readConfig( cfg ); 125 cardGame->readConfig( cfg );
125 setCardBacks(); 126 setCardBacks();
126 } else if ( gameType == 1 ) { 127 } else if ( gameType == 1 ) {
127 cardGame = new FreecellCardGame( &canvas, snapOn, this ); 128 cardGame = new FreecellCardGame( &canvas, snapOn, this );
128 setCaption(tr("Freecell")); 129 setCaption(tr("Freecell"));
129 setCentralWidget(cardGame); 130 setCentralWidget(cardGame);
130 //cardGame->newGame(); // Until we know how to handle reading freecell config 131 //cardGame->newGame(); // Until we know how to handle reading freecell config
131 cardGame->readConfig( cfg ); 132 cardGame->readConfig( cfg );
132 setCardBacks(); 133 setCardBacks();
133 } else if ( gameType == 2 ) { 134 } else if ( gameType == 2 ) {
134 cardGame = new ChicaneCardGame( &canvas, snapOn, this ); 135 cardGame = new ChicaneCardGame( &canvas, snapOn, this );
135 cardGame->setNumberToDraw(1); 136 cardGame->setNumberToDraw(1);
136 setCaption(tr("Chicane")); 137 setCaption(tr("Chicane"));
137 setCentralWidget(cardGame); 138 setCentralWidget(cardGame);
138 cardGame->readConfig( cfg ); 139 cardGame->readConfig( cfg );
139 setCardBacks(); 140 setCardBacks();
140 } else if ( gameType == 3 ) { 141 } else if ( gameType == 3 ) {
141 cardGame = new HarpCardGame( &canvas, snapOn, this ); 142 cardGame = new HarpCardGame( &canvas, snapOn, this );
142 cardGame->setNumberToDraw(1); 143 cardGame->setNumberToDraw(1);
143 setCaption(tr("Harp")); 144 setCaption(tr("Harp"));
144 setCentralWidget(cardGame); 145 setCentralWidget(cardGame);
145 cardGame->readConfig( cfg ); 146 cardGame->readConfig( cfg );
146 setCardBacks(); 147 setCardBacks();
147 } else if ( gameType == 4 ) { 148 } else if ( gameType == 4 ) {
148 cardGame = new TeeclubCardGame( &canvas, snapOn, this ); 149 cardGame = new TeeclubCardGame( &canvas, snapOn, this );
149 cardGame->setNumberToDraw(1); 150 cardGame->setNumberToDraw(1);
150 setCaption(tr("Teeclub")); 151 setCaption(tr("Teeclub"));
151 setCentralWidget(cardGame); 152 setCentralWidget(cardGame);
152 cardGame->readConfig( cfg ); 153 cardGame->readConfig( cfg );
153 setCardBacks(); 154 setCardBacks();
154 } else { 155 } else {
155 // Probably there isn't a config file or it is broken 156 // Probably there isn't a config file or it is broken
156 // Start a new game 157 // Start a new game
157 initPatience(); 158 initPatience();
158 } 159 }
159 160
160 updateDraw(); 161 updateDraw();
161} 162}
162 163
163 164
164CanvasCardWindow::~CanvasCardWindow() 165CanvasCardWindow::~CanvasCardWindow()
165{ 166{
166 if (cardGame) { 167 if (cardGame) {
167 Config cfg("Patience"); 168 Config cfg("Patience");
168 cfg.setGroup( "GlobalSettings" ); 169 cfg.setGroup( "GlobalSettings" );
169 cfg.writeEntry( "GameType", gameType ); 170 cfg.writeEntry( "GameType", gameType );
170 cfg.writeEntry( "SnapOn", snapOn ); 171 cfg.writeEntry( "SnapOn", snapOn );
171 cfg.writeEntry( "DrawThree", drawThree); 172 cfg.writeEntry( "DrawThree", drawThree);
172 cfg.write(); 173 cfg.write();
173 cardGame->writeConfig( cfg ); 174 cardGame->writeConfig( cfg );
174 delete cardGame; 175 delete cardGame;
175 } 176 }
176} 177}
177 178
178 179
179void CanvasCardWindow::resizeEvent(QResizeEvent *) 180void CanvasCardWindow::resizeEvent(QResizeEvent *)
180{ 181{
181 QSize s = centralWidget()->size(); 182 QSize s = centralWidget()->size();
182 int fw = style().defaultFrameWidth(); 183 int fw = style().defaultFrameWidth();
183 canvas.resize( s.width() - fw - 2, s.height() - fw - 2); 184 canvas.resize( s.width() - fw - 2, s.height() - fw - 2);
184} 185}
185 186
186 187
187void CanvasCardWindow::initPatience() 188void CanvasCardWindow::initPatience()
188{ 189{
189 // Create New Game 190 // Create New Game
190 if ( cardGame ) 191 if ( cardGame )
191 delete cardGame; 192 delete cardGame;
192 cardGame = new PatienceCardGame( &canvas, snapOn, this ); 193 cardGame = new PatienceCardGame( &canvas, snapOn, this );
193 cardGame->setNumberToDraw(drawThree ? 3 : 1); 194 cardGame->setNumberToDraw(drawThree ? 3 : 1);
194 gameType = 0; 195 gameType = 0;
195 setCaption(tr("Patience")); 196 setCaption(tr("Patience"));
196 setCentralWidget(cardGame); 197 setCentralWidget(cardGame);
197 cardGame->newGame(); 198 cardGame->newGame();
198 setCardBacks(); 199 setCardBacks();
199 updateDraw(); 200 updateDraw();
200} 201}
201 202
202 203
203void CanvasCardWindow::initFreecell() 204void CanvasCardWindow::initFreecell()
204{ 205{
205 // Create New Game 206 // Create New Game
206 if ( cardGame ) { 207 if ( cardGame ) {
207 delete cardGame; 208 delete cardGame;
208 } 209 }
209 cardGame = new FreecellCardGame( &canvas, snapOn, this ); 210 cardGame = new FreecellCardGame( &canvas, snapOn, this );
210 gameType = 1; 211 gameType = 1;
211 setCaption(tr("Freecell")); 212 setCaption(tr("Freecell"));
212 setCentralWidget(cardGame); 213 setCentralWidget(cardGame);
213 cardGame->newGame(); 214 cardGame->newGame();
214 setCardBacks(); 215 setCardBacks();
215} 216}
216 217
217 218
218void CanvasCardWindow::initChicane() 219void CanvasCardWindow::initChicane()
219{ 220{
220 // Create New Game 221 // Create New Game
221 if ( cardGame ) { 222 if ( cardGame ) {
222 delete cardGame; 223 delete cardGame;
223 } 224 }
224 cardGame = new ChicaneCardGame( &canvas, snapOn, this ); 225 cardGame = new ChicaneCardGame( &canvas, snapOn, this );
225 cardGame->setNumberToDraw(1); 226 cardGame->setNumberToDraw(1);
226 gameType = 2; 227 gameType = 2;
227 setCaption(tr("Chicane")); 228 setCaption(tr("Chicane"));
228 setCentralWidget(cardGame); 229 setCentralWidget(cardGame);
229 cardGame->newGame(); 230 cardGame->newGame();
230 setCardBacks(); 231 setCardBacks();
231} 232}
232 233
233void CanvasCardWindow::initHarp() 234void CanvasCardWindow::initHarp()
234{ 235{
235 // Create New Game 236 // Create New Game
236 if ( cardGame ) { 237 if ( cardGame ) {
237 delete cardGame; 238 delete cardGame;
238 } 239 }
239 cardGame = new HarpCardGame( &canvas, snapOn, this ); 240 cardGame = new HarpCardGame( &canvas, snapOn, this );
240 cardGame->setNumberToDraw(1); 241 cardGame->setNumberToDraw(1);
241 gameType = 3; 242 gameType = 3;
242 setCaption(tr("Harp")); 243 setCaption(tr("Harp"));
243 setCentralWidget(cardGame); 244 setCentralWidget(cardGame);
244 cardGame->newGame(); 245 cardGame->newGame();
245 setCardBacks(); 246 setCardBacks();
246} 247}
247 248
248 249
249void CanvasCardWindow::initTeeclub() 250void CanvasCardWindow::initTeeclub()
250{ 251{
251 // Create New Game 252 // Create New Game
252 if ( cardGame ) { 253 if ( cardGame ) {
253 delete cardGame; 254 delete cardGame;
254 } 255 }
255 cardGame = new TeeclubCardGame( &canvas, snapOn, this ); 256 cardGame = new TeeclubCardGame( &canvas, snapOn, this );
256 cardGame->setNumberToDraw(1); 257 cardGame->setNumberToDraw(1);
257 gameType = 4; 258 gameType = 4;
258 setCaption(tr("Teeclub")); 259 setCaption(tr("Teeclub"));
259 setCentralWidget(cardGame); 260 setCentralWidget(cardGame);
260 cardGame->newGame(); 261 cardGame->newGame();
261 setCardBacks(); 262 setCardBacks();
262} 263}
263 264
264 265
265void CanvasCardWindow::snapToggle() 266void CanvasCardWindow::snapToggle()
266{ 267{
267 snapOn = !snapOn; 268 snapOn = !snapOn;
268 settings->setItemChecked(snap_id, snapOn); 269 settings->setItemChecked(snap_id, snapOn);
269 cardGame->toggleSnap(); 270 cardGame->toggleSnap();
270} 271}
271 272
272 273
273void CanvasCardWindow::drawnToggle() 274void CanvasCardWindow::drawnToggle()
274{ 275{
275 drawThree=!drawThree; 276 drawThree=!drawThree;
276 Config cfg( "Patience" ); 277 Config cfg( "Patience" );
277 cfg.setGroup( "GlobalSettings" ); 278 cfg.setGroup( "GlobalSettings" );
278 cardGame->toggleCardsDrawn(); 279 cardGame->toggleCardsDrawn();
279 updateDraw(); 280 updateDraw();
280 cfg.writeEntry( "DrawThree", drawThree); 281 cfg.writeEntry( "DrawThree", drawThree);
281 cfg.write(); 282 cfg.write();
282} 283}
283 284
284void CanvasCardWindow::updateDraw() { 285void CanvasCardWindow::updateDraw() {
285 if(cardGame->cardsDrawn() == 3){ 286 if(cardGame->cardsDrawn() == 3){
286 settings->changeItem(drawId, tr("Turn one card")); 287 settings->changeItem(drawId, tr("Turn one card"));
287 } else { 288 } else {
288 settings->changeItem(drawId, tr("Turn three cards")); 289 settings->changeItem(drawId, tr("Turn three cards"));
289 } 290 }
290} 291}
291 292
292 293
293void CanvasCardWindow::setCardBacks() 294void CanvasCardWindow::setCardBacks()
294{ 295{
295 QCanvasItemList l = canvas.allItems(); 296 QCanvasItemList l = canvas.allItems();
296 297
297 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) { 298 for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) {
298 if ( (*it)->rtti() == canvasCardId ) 299 if ( (*it)->rtti() == canvasCardId )
299 ((CanvasCard *)(*it))->setCardBack( cardBack ); 300 ((CanvasCard *)(*it))->setCardBack( cardBack );
300 } 301 }
301} 302}
302 303
303 304
304void CanvasCardWindow::changeCardBacks() 305void CanvasCardWindow::changeCardBacks()
305{ 306{
306 cardBack++; 307 cardBack++;
307 308
308 if (cardBack == 5) 309 if (cardBack == 5)
309 cardBack = 0; 310 cardBack = 0;
310 311
311 setCardBacks(); 312 setCardBacks();
312} 313}
313 314
314 315
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
@@ -1,73 +1,74 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef CANVAS_CARD_WINDOW_H 20#ifndef CANVAS_CARD_WINDOW_H
21#define CANVAS_CARD_WINDOW_H 21#define CANVAS_CARD_WINDOW_H
22 22
23 23
24#include <qmainwindow.h> 24#include <qmainwindow.h>
25#include <qcanvas.h> 25#include <qcanvas.h>
26 26
27 27
28class CanvasCardGame; 28class CanvasCardGame;
29class QPopupMenu; 29class QPopupMenu;
30 30
31 31
32class CanvasCardWindow : public QMainWindow { 32class CanvasCardWindow : public QMainWindow {
33 Q_OBJECT 33 Q_OBJECT
34 34
35public: 35public:
36 static QString appName() { return QString::fromLatin1("patience"); }
36 CanvasCardWindow(QWidget* parent=0, const char* name=0, WFlags f=0); 37 CanvasCardWindow(QWidget* parent=0, const char* name=0, WFlags f=0);
37 virtual ~CanvasCardWindow(); 38 virtual ~CanvasCardWindow();
38 39
39public slots: 40public slots:
40 void setCardBacks(); 41 void setCardBacks();
41 void changeCardBacks(); 42 void changeCardBacks();
42 void snapToggle(); 43 void snapToggle();
43 void drawnToggle(); 44 void drawnToggle();
44 45
45private slots: 46private slots:
46 void initFreecell(); 47 void initFreecell();
47 void initPatience(); 48 void initPatience();
48 void initChicane(); 49 void initChicane();
49 void initHarp(); 50 void initHarp();
50 void initTeeclub(); 51 void initTeeclub();
51 52
52protected: 53protected:
53 virtual void resizeEvent(QResizeEvent *e); 54 virtual void resizeEvent(QResizeEvent *e);
54 55
55 void updateDraw(); 56 void updateDraw();
56private: 57private:
57 QCanvas canvas; 58 QCanvas canvas;
58 bool snapOn; 59 bool snapOn;
59 bool drawThree; 60 bool drawThree;
60 int drawId; 61 int drawId;
61 int cardBack; 62 int cardBack;
62 int gameType; 63 int gameType;
63 CanvasCardGame *cardGame; 64 CanvasCardGame *cardGame;
64 65
65 QPopupMenu* options; 66 QPopupMenu* options;
66 QPopupMenu* settings; 67 QPopupMenu* settings;
67 int dbf_id; 68 int dbf_id;
68 int snap_id; 69 int snap_id;
69}; 70};
70 71
71 72
72#endif 73#endif
73 74
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
@@ -1,91 +1,91 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <stdlib.h> 20#include <stdlib.h>
21#include <time.h> 21#include <time.h>
22#include "card.h" 22#include "card.h"
23#include "carddeck.h" 23#include "carddeck.h"
24 24
25 25
26CardDeck::CardDeck(int jokers, int numOfDecks) : numberOfJokers(jokers), numberOfDecks(numOfDecks), deckCreated(FALSE) 26CardDeck::CardDeck(int jokers, int numOfDecks) : numberOfJokers(jokers), numberOfDecks(numOfDecks), deckCreated(FALSE)
27{ 27{
28 cards = new (Card *)[getNumberOfCards()]; 28 cards = new Card *[getNumberOfCards()];
29} 29}
30 30
31 31
32CardDeck::~CardDeck() 32CardDeck::~CardDeck()
33{ 33{
34 for (int i = 0; i < getNumberOfCards(); i++) 34 for (int i = 0; i < getNumberOfCards(); i++)
35 delete cards[i]; 35 delete cards[i];
36 delete cards; 36 delete cards;
37} 37}
38 38
39 39
40void CardDeck::createDeck() 40void CardDeck::createDeck()
41{ 41{
42 if (!deckCreated) { 42 if (!deckCreated) {
43 for (int j = 0; j < getNumberOfDecks(); j++) { 43 for (int j = 0; j < getNumberOfDecks(); j++) {
44 for (int i = 0; i < 52; i++) { 44 for (int i = 0; i < 52; i++) {
45 cards[i+j*52] = newCard( (eValue)((i % 13) + 1), (eSuit)((i / 13) + 1), FALSE); 45 cards[i+j*52] = newCard( (eValue)((i % 13) + 1), (eSuit)((i / 13) + 1), FALSE);
46 cards[i+j*52]->setDeckNumber(j); 46 cards[i+j*52]->setDeckNumber(j);
47 } 47 }
48 } 48 }
49 for (int i = 0; i < getNumberOfJokers(); i++) 49 for (int i = 0; i < getNumberOfJokers(); i++)
50 cards[52*getNumberOfDecks() + i] = newCard( jokerVal, jokerSuit, FALSE); 50 cards[52*getNumberOfDecks() + i] = newCard( jokerVal, jokerSuit, FALSE);
51 deckCreated = TRUE; 51 deckCreated = TRUE;
52 } 52 }
53} 53}
54 54
55 55
56void CardDeck::shuffle() 56void CardDeck::shuffle()
57{ 57{
58 srand(time(NULL)); 58 srand(time(NULL));
59 for (int i = 0; i < getNumberOfCards(); i++) { 59 for (int i = 0; i < getNumberOfCards(); i++) {
60 int index = rand() % getNumberOfCards(); 60 int index = rand() % getNumberOfCards();
61 Card *tmpCard = cards[i]; 61 Card *tmpCard = cards[i];
62 cards[i] = cards[index]; 62 cards[i] = cards[index];
63 cards[index] = tmpCard; 63 cards[index] = tmpCard;
64 } 64 }
65} 65}
66 66
67 67
68int CardDeck::getNumberOfCards() 68int CardDeck::getNumberOfCards()
69{ 69{
70 return 52*getNumberOfDecks() + getNumberOfJokers(); 70 return 52*getNumberOfDecks() + getNumberOfJokers();
71} 71}
72 72
73 73
74int CardDeck::getNumberOfDecks() 74int CardDeck::getNumberOfDecks()
75{ 75{
76 return numberOfDecks; 76 return numberOfDecks;
77} 77}
78 78
79 79
80int CardDeck::getNumberOfJokers() 80int CardDeck::getNumberOfJokers()
81{ 81{
82 return numberOfJokers; 82 return numberOfJokers;
83} 83}
84 84
85 85
86Card *CardDeck::newCard( eValue v, eSuit s, bool f) 86Card *CardDeck::newCard( eValue v, eSuit s, bool f)
87{ 87{
88 return new Card(v, s, f); 88 return new Card(v, s, f);
89} 89}
90 90
91 91
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
@@ -1,36 +1,26 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "canvascardwindow.h" 21#include "canvascardwindow.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <opie/oapplicationfactory.h>
24 25
25 26OPIE_EXPORT_APP( OApplicationFactory<CanvasCardWindow> ) \ No newline at end of file
26int main( int argc, char ** argv )
27{
28 QPEApplication a( argc, argv );
29
30 CanvasCardWindow m;
31 m.setCaption( CanvasCardWindow::tr("Patience") );
32 a.showMainWidget( &m );
33
34 return a.exec();
35}
36
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,21 +1,20 @@
1TEMPLATE = app
2 1
3CONFIG += qt warn_on release 2CONFIG += qt warn_on release quick-app
4DESTDIR = $(OPIEDIR)/bin
5 3
6HEADERS = canvascard.h canvasshapes.h cardgame.h cardgamelayout.h cardpile.h card.h carddeck.h \ 4HEADERS = canvascard.h canvasshapes.h cardgame.h cardgamelayout.h cardpile.h card.h carddeck.h \
7 canvascardgame.h freecellcardgame.h chicanecardgame.h harpcardgame.h teeclubcardgame.h \ 5 canvascardgame.h freecellcardgame.h chicanecardgame.h harpcardgame.h teeclubcardgame.h \
8 patiencecardgame.h canvascardwindow.h 6 patiencecardgame.h canvascardwindow.h
9 7
10SOURCES = canvascard.cpp canvasshapes.cpp cardgame.cpp cardgamelayout.cpp \ 8SOURCES = canvascard.cpp canvasshapes.cpp cardgame.cpp cardgamelayout.cpp \
11 cardpile.cpp card.cpp carddeck.cpp canvascardgame.cpp freecellcardgame.cpp \ 9 cardpile.cpp card.cpp carddeck.cpp canvascardgame.cpp freecellcardgame.cpp \
12 chicanecardgame.cpp harpcardgame.cpp teeclubcardgame.cpp \ 10 chicanecardgame.cpp harpcardgame.cpp teeclubcardgame.cpp \
13 patiencecardgame.cpp canvascardwindow.cpp main.cpp 11 patiencecardgame.cpp canvascardwindow.cpp main.cpp
14 12
15TARGET = patience 13TARGET = patience
16 14
17INCLUDEPATH += $(OPIEDIR)/include 15INCLUDEPATH += $(OPIEDIR)/include
18DEPENDPATH += $(OPIEDIR)/include 16DEPENDPATH += $(OPIEDIR)/include
19LIBS += -lqpe 17LIBS += -lqpe
20 18
19
21include ( $(OPIEDIR)/include.pro ) 20include ( $(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
@@ -1,33 +1,28 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "qtetrix.h" 21#include "qtetrix.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24 24
25int main( int argc, char **argv ) 25#include <opie/oapplicationfactory.h>
26{
27 QPEApplication a(argc,argv);
28 26
29 QTetrix *tetrix = new QTetrix; 27OPIE_EXPORT_APP( OApplicationFactory<QTetrix> )
30 a.showMainWidget(tetrix);
31 28
32 return a.exec();
33}
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,11 +1,11 @@
1Package: opie-tetrix 1Package: opie-tetrix
2Files: bin/tetrix apps/Games/tetrix.desktop pics/tetrix/* 2Files: plugins/application/libtetrix.so* bin/tetrix apps/Games/tetrix.desktop pics/tetrix/*
3Priority: optional 3Priority: optional
4Section: opie/games 4Section: opie/games
5Maintainer: Martin Imobersteg <imm@gmx.ch> 5Maintainer: Martin Imobersteg <imm@gmx.ch>
6Architecture: arm 6Architecture: arm
7Arch: iPAQ 7Arch: iPAQ
8Depends: task-opie-minimal 8Depends: task-opie-minimal
9Description: Game: control falling blocks 9Description: Game: control falling blocks
10 A game for the Opie environment. 10 A game for the Opie environment.
11Version: $QPE_VERSION$EXTRAVERSION 11Version: $QPE_VERSION$EXTRAVERSION
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
@@ -1,76 +1,77 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef QTETRIX_H 20#ifndef QTETRIX_H
21#define QTETRIX_H 21#define QTETRIX_H
22 22
23#include "qtetrixb.h" 23#include "qtetrixb.h"
24#include <qframe.h> 24#include <qframe.h>
25#include <qlcdnumber.h> 25#include <qlcdnumber.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qpainter.h> 27#include <qpainter.h>
28#include <qmainwindow.h> 28#include <qmainwindow.h>
29 29
30class QLabel; 30class QLabel;
31 31
32class ShowNextPiece : public QFrame 32class ShowNextPiece : public QFrame
33{ 33{
34 Q_OBJECT 34 Q_OBJECT
35 friend class QTetrix; 35 friend class QTetrix;
36public: 36public:
37 ShowNextPiece( QWidget *parent=0, const char *name=0 ); 37 ShowNextPiece( QWidget *parent=0, const char *name=0 );
38public slots: 38public slots:
39 void drawNextSquare( int x, int y,QColor *color ); 39 void drawNextSquare( int x, int y,QColor *color );
40signals: 40signals:
41 void update(); 41 void update();
42private: 42private:
43 void paintEvent( QPaintEvent * ); 43 void paintEvent( QPaintEvent * );
44 void resizeEvent( QResizeEvent * ); 44 void resizeEvent( QResizeEvent * );
45 45
46 int blockWidth,blockHeight; 46 int blockWidth,blockHeight;
47 int xOffset,yOffset; 47 int xOffset,yOffset;
48}; 48};
49 49
50 50
51class QTetrix : public QMainWindow 51class QTetrix : public QMainWindow
52{ 52{
53 Q_OBJECT 53 Q_OBJECT
54public: 54public:
55 static QString appName() { return QString::fromLatin1("tetrix"); }
55 QTetrix( QWidget *parent=0, const char *name=0, WFlags f=0 ); 56 QTetrix( QWidget *parent=0, const char *name=0, WFlags f=0 );
56 void startGame() { board->startGame(); } 57 void startGame() { board->startGame(); }
57 58
58public slots: 59public slots:
59 void gameOver(); 60 void gameOver();
60 void quit(); 61 void quit();
61private: 62private:
62 void keyPressEvent( QKeyEvent *e ) { board->keyPressEvent(e); } 63 void keyPressEvent( QKeyEvent *e ) { board->keyPressEvent(e); }
63 64
64 QTetrixBoard *board; 65 QTetrixBoard *board;
65 ShowNextPiece *showNext; 66 ShowNextPiece *showNext;
66 QLabel *showScore; 67 QLabel *showScore;
67 QLabel *showLevel; 68 QLabel *showLevel;
68 QLabel *showLines; 69 QLabel *showLines;
69}; 70};
70 71
71 72
72void drawTetrixButton( QPainter *, int x, int y, int w, int h, 73void drawTetrixButton( QPainter *, int x, int y, int w, int h,
73 const QColor *color ); 74 const QColor *color );
74 75
75 76
76#endif 77#endif
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,21 +1,22 @@
1 TEMPLATE= app 1 CONFIG = qt warn_on release quick-app
2 CONFIG = qt warn_on release
3 DESTDIR = $(OPIEDIR)/bin
4 HEADERS = gtetrix.h \ 2 HEADERS = gtetrix.h \
5 qtetrix.h \ 3 qtetrix.h \
6 qtetrixb.h \ 4 qtetrixb.h \
7 tpiece.h \ 5 tpiece.h \
8 ohighscoredlg.h 6 ohighscoredlg.h
9 SOURCES = main.cpp \ 7 SOURCES = main.cpp \
10 gtetrix.cpp \ 8 gtetrix.cpp \
11 qtetrix.cpp \ 9 qtetrix.cpp \
12 qtetrixb.cpp \ 10 qtetrixb.cpp \
13 tpiece.cpp \ 11 tpiece.cpp \
14 ohighscoredlg.cpp 12 ohighscoredlg.cpp
15INCLUDEPATH += $(OPIEDIR)/include 13INCLUDEPATH += $(OPIEDIR)/include
16 DEPENDPATH+= $(OPIEDIR)/include 14 DEPENDPATH+= $(OPIEDIR)/include
17LIBS += -lqpe -lstdc++ 15LIBS += -lqpe -lstdc++
18 INTERFACES= 16 INTERFACES=
19 TARGET = tetrix 17 TARGET = tetrix
20 18
19
20
21
21include ( $(OPIEDIR)/include.pro ) 22include ( $(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
@@ -1,34 +1,28 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "wordgame.h" 21#include "wordgame.h"
22 22
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <opie/oapplicationfactory.h>
24 25
25int main( int argc, char ** argv )
26{
27 QPEApplication a( argc, argv );
28 26
29 WordGame mw; 27OPIE_EXPORT_APP( OApplicationFactory<WordGame> )
30 //QPEApplication::setInputMethodHint( &mw, QPEApplication::AlwaysOff );
31 a.showMainWidget(&mw);
32 28
33 return a.exec();
34}
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
@@ -120,261 +120,262 @@ protected:
120 120
121private: 121private:
122 Tile t; 122 Tile t;
123 bool big; 123 bool big;
124 State s; 124 State s;
125}; 125};
126 126
127class Rack : public QCanvasView { 127class Rack : public QCanvasView {
128public: 128public:
129 Rack(int ntiles, QWidget* parent); 129 Rack(int ntiles, QWidget* parent);
130 ~Rack(); 130 ~Rack();
131 131
132 void readConfig(Config&); 132 void readConfig(Config&);
133 void writeConfig(Config&); 133 void writeConfig(Config&);
134 134
135 bool isFull() const { return count()==max(); } 135 bool isFull() const { return count()==max(); }
136 int max() const { return item.count(); } 136 int max() const { return item.count(); }
137 int count() const { return n; } 137 int count() const { return n; }
138 void addTile(const Tile& t); 138 void addTile(const Tile& t);
139 Tile tile(int i) const { return item[i]->tile(); } 139 Tile tile(int i) const { return item[i]->tile(); }
140 const Tile* tileRef(int i) const { return &item[i]->tile(); } 140 const Tile* tileRef(int i) const { return &item[i]->tile(); }
141 void remove(int i); 141 void remove(int i);
142 void remove(Tile); 142 void remove(Tile);
143 bool arrangeTiles(const Tile** s, int sn); 143 bool arrangeTiles(const Tile** s, int sn);
144 void setBlanks(const Tile*); 144 void setBlanks(const Tile*);
145 145
146 void setPlayerName(const QString& name) { nm = name; } 146 void setPlayerName(const QString& name) { nm = name; }
147 QString playerName() const { return nm; } 147 QString playerName() const { return nm; }
148 void setComputerization(int level) { cpu=level; } 148 void setComputerization(int level) { cpu=level; }
149 bool computerized() const { return cpu>0; } 149 bool computerized() const { return cpu>0; }
150 150
151 QSize sizeHint() const; 151 QSize sizeHint() const;
152 152
153protected: 153protected:
154 void resizeEvent(QResizeEvent*e); 154 void resizeEvent(QResizeEvent*e);
155 void contentsMousePressEvent(QMouseEvent*); 155 void contentsMousePressEvent(QMouseEvent*);
156 void contentsMouseMoveEvent(QMouseEvent*); 156 void contentsMouseMoveEvent(QMouseEvent*);
157 void contentsMouseReleaseEvent(QMouseEvent*); 157 void contentsMouseReleaseEvent(QMouseEvent*);
158 158
159private: 159private:
160 void clear(); 160 void clear();
161 void layoutTiles(); 161 void layoutTiles();
162 int n; 162 int n;
163 QArray<TileItem*> item; 163 QArray<TileItem*> item;
164 int dragging_adj; 164 int dragging_adj;
165 QPoint dragstart; 165 QPoint dragstart;
166 QCanvasItem* dragging; 166 QCanvasItem* dragging;
167 QString nm; 167 QString nm;
168 int cpu; 168 int cpu;
169}; 169};
170 170
171class Board : public QCanvasView { 171class Board : public QCanvasView {
172 Q_OBJECT 172 Q_OBJECT
173public: 173public:
174 Board(QPixmap bgshapes, int w, int h, QWidget* parent); 174 Board(QPixmap bgshapes, int w, int h, QWidget* parent);
175 ~Board(); 175 ~Board();
176 176
177 void readConfig(Config&); 177 void readConfig(Config&);
178 void writeConfig(Config&); 178 void writeConfig(Config&);
179 179
180 int xTiles() const { return canvas()->tilesHorizontally(); } 180 int xTiles() const { return canvas()->tilesHorizontally(); }
181 int yTiles() const { return canvas()->tilesVertically(); } 181 int yTiles() const { return canvas()->tilesVertically(); }
182 182
183 bool contains(const QPoint& p) const 183 bool contains(const QPoint& p) const
184 { return p.x() >= 0 && p.y() >= 0 184 { return p.x() >= 0 && p.y() >= 0
185 && p.x() < canvas()->tilesHorizontally() 185 && p.x() < canvas()->tilesHorizontally()
186 && p.y() < canvas()->tilesVertically(); } 186 && p.y() < canvas()->tilesVertically(); }
187 const Tile* tile(const QPoint& p) const 187 const Tile* tile(const QPoint& p) const
188 { TileItem* it=item(p); return it ? &it->tile() : 0; } 188 { TileItem* it=item(p); return it ? &it->tile() : 0; }
189 189
190 void setRules(const QString& shapes, const int* effects); 190 void setRules(const QString& shapes, const int* effects);
191 191
192 void clear(); 192 void clear();
193 void unsetTile(const QPoint& p); 193 void unsetTile(const QPoint& p);
194 void setTile(const QPoint& p, const Tile& t); 194 void setTile(const QPoint& p, const Tile& t);
195 195
196 void setTileState(const QPoint& p, TileItem::State s) 196 void setTileState(const QPoint& p, TileItem::State s)
197 { 197 {
198 TileItem* it=item(p); 198 TileItem* it=item(p);
199 if (it) it->setState(s); 199 if (it) it->setState(s);
200 } 200 }
201 201
202 void setCurrentRack(Rack*); 202 void setCurrentRack(Rack*);
203 void resetRack(); 203 void resetRack();
204 void finalizeTurn(); 204 void finalizeTurn();
205 void showTurn(); 205 void showTurn();
206 void scoreTurn(const QPoint& at, int n, const QPoint& d); 206 void scoreTurn(const QPoint& at, int n, const QPoint& d);
207 bool checkTurn(); 207 bool checkTurn();
208 int score(QPoint at, const Tile** tiles, int n, 208 int score(QPoint at, const Tile** tiles, int n,
209 const Tile* blankvalue, 209 const Tile* blankvalue,
210 const QPoint& d, bool ignoredict, QStringList* words) const; 210 const QPoint& d, bool ignoredict, QStringList* words) const;
211 int bonussedValue(const QPoint& at, int base, int& all_mult) const; 211 int bonussedValue(const QPoint& at, int base, int& all_mult) const;
212 bool isStart(const QPoint& at) const; 212 bool isStart(const QPoint& at) const;
213 213
214 int turnScore() const { return turn_score; } 214 int turnScore() const { return turn_score; }
215 215
216 QSize sizeHint() const; 216 QSize sizeHint() const;
217 217
218signals: 218signals:
219 void temporaryScore(int); 219 void temporaryScore(int);
220 220
221protected: 221protected:
222 void contentsMousePressEvent(QMouseEvent*); 222 void contentsMousePressEvent(QMouseEvent*);
223 void contentsMouseMoveEvent(QMouseEvent*); 223 void contentsMouseMoveEvent(QMouseEvent*);
224 void contentsMouseReleaseEvent(QMouseEvent*); 224 void contentsMouseReleaseEvent(QMouseEvent*);
225 225
226private: 226private:
227 int idx(const QPoint& p) const 227 int idx(const QPoint& p) const
228 { return p.x()+p.y()*canvas()->tilesHorizontally(); } 228 { return p.x()+p.y()*canvas()->tilesHorizontally(); }
229 TileItem*& item(const QPoint& p) const 229 TileItem*& item(const QPoint& p) const
230 { return grid[idx(p)]; } 230 { return grid[idx(p)]; }
231 TileItem **grid; 231 TileItem **grid;
232 QString rule_shape; 232 QString rule_shape;
233 const int* rule_effect; 233 const int* rule_effect;
234 int rack_tiles_bonus; 234 int rack_tiles_bonus;
235 Rack* current_rack; 235 Rack* current_rack;
236 QPoint boardPos(const QPoint&) const; 236 QPoint boardPos(const QPoint&) const;
237 QPoint dragstart; 237 QPoint dragstart;
238 QPoint shown_at; 238 QPoint shown_at;
239 int shown_n; 239 int shown_n;
240 QPoint shown_step; 240 QPoint shown_step;
241 void unshowTurn(); 241 void unshowTurn();
242 int turn_score; 242 int turn_score;
243}; 243};
244 244
245class ComputerPlayer 245class ComputerPlayer
246{ 246{
247 Board* board; 247 Board* board;
248 Rack* rack; 248 Rack* rack;
249 249
250 bool across; 250 bool across;
251 int dict; 251 int dict;
252 QPoint current; 252 QPoint current;
253 253
254 const Tile** best; 254 const Tile** best;
255 int best_n; 255 int best_n;
256 Tile* best_blankvalues; 256 Tile* best_blankvalues;
257 int best_blused; 257 int best_blused;
258 int best_score; 258 int best_score;
259 QPoint best_dir; 259 QPoint best_dir;
260 QPoint best_start; 260 QPoint best_start;
261 261
262public: 262public:
263 ComputerPlayer(Board* b, Rack* r); 263 ComputerPlayer(Board* b, Rack* r);
264 ~ComputerPlayer(); 264 ~ComputerPlayer();
265 265
266 bool step(); 266 bool step();
267 267
268private: 268private:
269 void findBest(QPoint at, const QPoint& d, const QDawg::Node* node, ulong used, uchar *nletter, const Tile** tiles, int n, Tile* blankvalues, int blused); 269 void findBest(QPoint at, const QPoint& d, const QDawg::Node* node, ulong used, uchar *nletter, const Tile** tiles, int n, Tile* blankvalues, int blused);
270 void noteChoice(const Tile** tiles, int n, const QPoint& d, const Tile* blankvalues, int blused); 270 void noteChoice(const Tile** tiles, int n, const QPoint& d, const Tile* blankvalues, int blused);
271}; 271};
272 272
273class ScoreInfo : public QLabel { 273class ScoreInfo : public QLabel {
274 Q_OBJECT 274 Q_OBJECT
275public: 275public:
276 ScoreInfo( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 276 ScoreInfo( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
277 ~ScoreInfo(); 277 ~ScoreInfo();
278 278
279 void init(const QStringList&); 279 void init(const QStringList&);
280 void addScore(int player, int change); 280 void addScore(int player, int change);
281 int playerScore(int player) const { return score[player]; } 281 int playerScore(int player) const { return score[player]; }
282 void setShowWinner(bool); 282 void setShowWinner(bool);
283 void setBoldOne(int); 283 void setBoldOne(int);
284 284
285 void readConfig(Config&); 285 void readConfig(Config&);
286 void writeConfig(Config&); 286 void writeConfig(Config&);
287 287
288protected: 288protected:
289 QSize sizeHint() const; 289 QSize sizeHint() const;
290 290
291public slots: 291public slots:
292 void showTemporaryScore(int amount); 292 void showTemporaryScore(int amount);
293 293
294private slots: 294private slots:
295 void showScores(); 295 void showScores();
296 296
297private: 297private:
298 QStringList names; 298 QStringList names;
299 int *score; 299 int *score;
300 QTimer* msgtimer; 300 QTimer* msgtimer;
301 bool showwinner; 301 bool showwinner;
302 int boldone; 302 int boldone;
303}; 303};
304 304
305class NewGame; 305class NewGame;
306 306
307class WordGame : public QMainWindow { 307class WordGame : public QMainWindow {
308 Q_OBJECT 308 Q_OBJECT
309public: 309public:
310 WordGame( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 310 WordGame( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
311 ~WordGame(); 311 ~WordGame();
312 static QString appName() { return QString::fromLatin1("wordgame"); }
312 313
313private slots: 314private slots:
314 void endTurn(); 315 void endTurn();
315 void resetTurn(); 316 void resetTurn();
316 void passTurn(); 317 void passTurn();
317 void think(); 318 void think();
318 void endGame(); 319 void endGame();
319 void startGame(); 320 void startGame();
320 321
321private: 322private:
322 void writeConfig(); 323 void writeConfig();
323 void readConfig(); 324 void readConfig();
324 325
325 void startGame(const QStringList& pnames); 326 void startGame(const QStringList& pnames);
326 bool mayEndGame(); 327 bool mayEndGame();
327 void openGameSelector(const QStringList& initnames); 328 void openGameSelector(const QStringList& initnames);
328 bool loadRules(const QString& filename); 329 bool loadRules(const QString& filename);
329 void addPlayer(const QString& name); 330 void addPlayer(const QString& name);
330 void addPlayer(const QString& name, int cpu); 331 void addPlayer(const QString& name, int cpu);
331 void nextPlayer(); 332 void nextPlayer();
332 bool refillRack(int i); 333 bool refillRack(int i);
333 void readyRack(int i); 334 void readyRack(int i);
334 Rack* rack(int i) const; 335 Rack* rack(int i) const;
335 336
336 QWidgetStack *racks; 337 QWidgetStack *racks;
337 QToolBar* toolbar; 338 QToolBar* toolbar;
338 QWidget *vbox; 339 QWidget *vbox;
339 Board *board; 340 Board *board;
340 Bag *bag; 341 Bag *bag;
341 ScoreInfo *scoreinfo; 342 ScoreInfo *scoreinfo;
342 QToolButton *done; 343 QToolButton *done;
343 QToolButton *reset; 344 QToolButton *reset;
344 QTimer* aiheart; 345 QTimer* aiheart;
345 ComputerPlayer *cpu; 346 ComputerPlayer *cpu;
346 int player; 347 int player;
347 int nplayers; 348 int nplayers;
348 QStringList namelist; 349 QStringList namelist;
349 bool gameover; 350 bool gameover;
350 QString rules; 351 QString rules;
351 NewGame* newgame; 352 NewGame* newgame;
352}; 353};
353 354
354class NewGame : public NewGameBase { 355class NewGame : public NewGameBase {
355 Q_OBJECT 356 Q_OBJECT
356public: 357public:
357 NewGame(QWidget* parent); 358 NewGame(QWidget* parent);
358 QStringList ruleslist; 359 QStringList ruleslist;
359 360
360public slots: 361public slots:
361 void updateRuleSets(); 362 void updateRuleSets();
362}; 363};
363 364
364class Rules : public RulesBase { 365class Rules : public RulesBase {
365 Q_OBJECT 366 Q_OBJECT
366 367
367public: 368public:
368 Rules(QWidget* parent); 369 Rules(QWidget* parent);
369 370
370signals: 371signals:
371 void rulesChanged(); 372 void rulesChanged();
372 373
373public slots: 374public slots:
374 void editRules(); 375 void editRules();
375 376
376private: 377private:
377 void deleteRuleSet(); 378 void deleteRuleSet();
378}; 379};
379 380
380#endif // WORDGAME_H 381#endif // WORDGAME_H
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 @@
1 TEMPLATE= app 1 CONFIG = qt warn_on release quick-app
2 CONFIG = qt warn_on release
3 DESTDIR = $(OPIEDIR)/bin
4 HEADERS = wordgame.h 2 HEADERS = wordgame.h
5 SOURCES = main.cpp \ 3 SOURCES = main.cpp \
6 wordgame.cpp 4 wordgame.cpp
7 INTERFACES= newgamebase.ui rulesbase.ui 5 INTERFACES= newgamebase.ui rulesbase.ui
8 TARGET = wordgame 6 TARGET = wordgame
9INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
10 DEPENDPATH+= $(OPIEDIR)/include 8 DEPENDPATH+= $(OPIEDIR)/include
11LIBS += -lqpe 9LIBS += -lqpe
12 10
11
13include ( $(OPIEDIR)/include.pro ) 12include ( $(OPIEDIR)/include.pro )