-rw-r--r-- | noncore/games/bounce/main.cpp | 1 | ||||
-rw-r--r-- | noncore/games/buzzword/main.cpp | 1 | ||||
-rw-r--r-- | noncore/games/fifteen/main.cpp | 1 | ||||
-rw-r--r-- | noncore/games/go/gowidget.cpp | 2 | ||||
-rw-r--r-- | noncore/games/go/main.cpp | 1 | ||||
-rw-r--r-- | noncore/games/kcheckers/main.cpp | 1 | ||||
-rw-r--r-- | noncore/games/minesweep/main.cpp | 1 | ||||
-rw-r--r-- | noncore/games/parashoot/main.cpp | 1 | ||||
-rw-r--r-- | noncore/games/qasteroids/main.cpp | 1 | ||||
-rw-r--r-- | noncore/games/snake/interface.cpp | 2 | ||||
-rw-r--r-- | noncore/games/snake/main.cpp | 1 | ||||
-rw-r--r-- | noncore/games/solitaire/main.cpp | 1 | ||||
-rw-r--r-- | noncore/games/tetrix/main.cpp | 1 | ||||
-rw-r--r-- | noncore/games/tictac/main.cpp | 1 | ||||
-rw-r--r-- | noncore/games/wordgame/main.cpp | 1 | ||||
-rw-r--r-- | noncore/games/wordgame/wordgame.cpp | 2 | ||||
-rw-r--r-- | noncore/games/zlines/main.cpp | 1 | ||||
-rw-r--r-- | noncore/games/zsame/ZSameWidget.cpp | 1 |
18 files changed, 18 insertions, 3 deletions
diff --git a/noncore/games/bounce/main.cpp b/noncore/games/bounce/main.cpp index eb8d561..bec4a86 100644 --- a/noncore/games/bounce/main.cpp +++ b/noncore/games/bounce/main.cpp | |||
@@ -1,24 +1,25 @@ | |||
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 "kbounce.h" | 19 | #include "kbounce.h" |
20 | 20 | ||
21 | #include <opie2/oapplicationfactory.h> | 21 | #include <opie2/oapplicationfactory.h> |
22 | 22 | ||
23 | using namespace Opie::Core; | ||
23 | OPIE_EXPORT_APP( OApplicationFactory<KJezzball> ) | 24 | OPIE_EXPORT_APP( OApplicationFactory<KJezzball> ) |
24 | 25 | ||
diff --git a/noncore/games/buzzword/main.cpp b/noncore/games/buzzword/main.cpp index 596cf16..a95e91a 100644 --- a/noncore/games/buzzword/main.cpp +++ b/noncore/games/buzzword/main.cpp | |||
@@ -1,23 +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 <opie2/oapplicationfactory.h> | 19 | #include <opie2/oapplicationfactory.h> |
20 | 20 | ||
21 | #include "buzzword.h" | 21 | #include "buzzword.h" |
22 | 22 | ||
23 | using namespace Opie::Core; | ||
23 | OPIE_EXPORT_APP( OApplicationFactory<BuzzWord> ) | 24 | OPIE_EXPORT_APP( OApplicationFactory<BuzzWord> ) |
diff --git a/noncore/games/fifteen/main.cpp b/noncore/games/fifteen/main.cpp index ed74a47..800a270 100644 --- a/noncore/games/fifteen/main.cpp +++ b/noncore/games/fifteen/main.cpp | |||
@@ -1,23 +1,24 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2004 Holger Freyther. All rights reserved. | 2 | ** Copyright (C) 2004 Holger Freyther. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Opie Environment. | 4 | ** This file is part of Opie 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 | **********************************************************************/ | 16 | **********************************************************************/ |
17 | 17 | ||
18 | #include "fifteen.h" | 18 | #include "fifteen.h" |
19 | 19 | ||
20 | #include <opie2/oapplicationfactory.h> | 20 | #include <opie2/oapplicationfactory.h> |
21 | 21 | ||
22 | using namespace Opie::Core; | ||
22 | OPIE_EXPORT_APP( OApplicationFactory<FifteenMainWindow> ) | 23 | OPIE_EXPORT_APP( OApplicationFactory<FifteenMainWindow> ) |
23 | 24 | ||
diff --git a/noncore/games/go/gowidget.cpp b/noncore/games/go/gowidget.cpp index 79820b1..d134540 100644 --- a/noncore/games/go/gowidget.cpp +++ b/noncore/games/go/gowidget.cpp | |||
@@ -1,460 +1,460 @@ | |||
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 <qpe/qpetoolbar.h> | 27 | #include <qtoolbar.h> |
28 | #include <qmenubar.h> | 28 | #include <qmenubar.h> |
29 | #include <qaction.h> | 29 | #include <qaction.h> |
30 | #include <qapplication.h> //processEvents() | 30 | #include <qapplication.h> //processEvents() |
31 | #include <qlabel.h> | 31 | #include <qlabel.h> |
32 | 32 | ||
33 | //#include <stdio.h> | 33 | //#include <stdio.h> |
34 | 34 | ||
35 | 35 | ||
36 | static const enum bVal computer_color = BLACK; | 36 | static const enum bVal computer_color = BLACK; |
37 | 37 | ||
38 | static int current_handicap = 1; | 38 | static int current_handicap = 1; |
39 | 39 | ||
40 | static QBrush *goBrush; | 40 | static QBrush *goBrush; |
41 | //static QImage *newBlackStone; | 41 | //static QImage *newBlackStone; |
42 | //static QImage *blackStone; | 42 | //static QImage *blackStone; |
43 | //static QImage *whiteStone; | 43 | //static QImage *whiteStone; |
44 | static QPixmap *newBlackStone; | 44 | static QPixmap *newBlackStone; |
45 | static QPixmap *blackStone; | 45 | static QPixmap *blackStone; |
46 | static QPixmap *whiteStone; | 46 | static QPixmap *whiteStone; |
47 | 47 | ||
48 | static bool smallStones = FALSE; | 48 | static bool smallStones = FALSE; |
49 | 49 | ||
50 | GoMainWidget::GoMainWidget( QWidget *parent, const char* name, WFlags fl) : | 50 | GoMainWidget::GoMainWidget( QWidget *parent, const char* name, WFlags fl) : |
51 | QMainWindow( parent, name, fl ) | 51 | QMainWindow( parent, name, fl ) |
52 | { | 52 | { |
53 | setToolBarsMovable( FALSE ); | 53 | setToolBarsMovable( FALSE ); |
54 | GoWidget *go = new GoWidget(this); | 54 | GoWidget *go = new GoWidget(this); |
55 | 55 | ||
56 | setCentralWidget(go); | 56 | setCentralWidget(go); |
57 | toolbar = new QToolBar(this); | 57 | toolbar = new QToolBar(this); |
58 | toolbar->setHorizontalStretchable( TRUE ); | 58 | toolbar->setHorizontalStretchable( TRUE ); |
59 | addToolBar(toolbar); | 59 | addToolBar(toolbar); |
60 | 60 | ||
61 | QMenuBar *mb = new QMenuBar( toolbar ); | 61 | QMenuBar *mb = new QMenuBar( toolbar ); |
62 | mb->setMargin(0); | 62 | mb->setMargin(0); |
63 | QPopupMenu *file = new QPopupMenu( this ); | 63 | QPopupMenu *file = new QPopupMenu( this ); |
64 | 64 | ||
65 | QAction *a = new QAction( tr( "New Game" ), QString::null, 0, this, 0 ); | 65 | QAction *a = new QAction( tr( "New Game" ), QString::null, 0, this, 0 ); |
66 | connect( a, SIGNAL( activated() ), go, SLOT( newGame() ) ); | 66 | connect( a, SIGNAL( activated() ), go, SLOT( newGame() ) ); |
67 | a->addTo( file ); | 67 | a->addTo( file ); |
68 | 68 | ||
69 | a = new QAction( tr( "Pass" ), Resource::loadPixmap( "pass" ), QString::null, 0, this, 0 ); | 69 | a = new QAction( tr( "Pass" ), Resource::loadPixmap( "pass" ), QString::null, 0, this, 0 ); |
70 | connect( a, SIGNAL( activated() ), go, SLOT( pass() ) ); | 70 | connect( a, SIGNAL( activated() ), go, SLOT( pass() ) ); |
71 | a->addTo( file ); | 71 | a->addTo( file ); |
72 | a->addTo( toolbar ); | 72 | a->addTo( toolbar ); |
73 | 73 | ||
74 | 74 | ||
75 | a = new QAction( tr( "Resign" ), Resource::loadPixmap( "reset" ), QString::null, 0, this, 0 ); | 75 | a = new QAction( tr( "Resign" ), Resource::loadPixmap( "reset" ), QString::null, 0, this, 0 ); |
76 | connect( a, SIGNAL( activated() ), go, SLOT( resign() ) ); | 76 | connect( a, SIGNAL( activated() ), go, SLOT( resign() ) ); |
77 | a->addTo( file ); | 77 | a->addTo( file ); |
78 | 78 | ||
79 | a = new QAction( tr( "Two player option" ), QString::null, 0, this, 0 ); | 79 | a = new QAction( tr( "Two player option" ), QString::null, 0, this, 0 ); |
80 | a->setToggleAction( TRUE ); | 80 | a->setToggleAction( TRUE ); |
81 | connect( a, SIGNAL( toggled(bool) ), go, SLOT( setTwoplayer(bool) ) ); | 81 | connect( a, SIGNAL( toggled(bool) ), go, SLOT( setTwoplayer(bool) ) ); |
82 | a->addTo( file ); | 82 | a->addTo( file ); |
83 | 83 | ||
84 | mb->insertItem( tr( "Game" ), file ); | 84 | mb->insertItem( tr( "Game" ), file ); |
85 | 85 | ||
86 | QLabel *turnLabel = new QLabel( toolbar ); | 86 | QLabel *turnLabel = new QLabel( toolbar ); |
87 | turnLabel->setBackgroundMode( PaletteButton ); | 87 | turnLabel->setBackgroundMode( PaletteButton ); |
88 | connect( go, SIGNAL(showTurn(const QPixmap&)), | 88 | connect( go, SIGNAL(showTurn(const QPixmap&)), |
89 | turnLabel, SLOT(setPixmap(const QPixmap&)) ); | 89 | turnLabel, SLOT(setPixmap(const QPixmap&)) ); |
90 | 90 | ||
91 | 91 | ||
92 | QLabel * scoreLabel = new QLabel( toolbar ); | 92 | QLabel * scoreLabel = new QLabel( toolbar ); |
93 | scoreLabel->setBackgroundMode( PaletteButton ); | 93 | scoreLabel->setBackgroundMode( PaletteButton ); |
94 | connect( go, SIGNAL(showScore(const QString&)), | 94 | connect( go, SIGNAL(showScore(const QString&)), |
95 | scoreLabel, SLOT(setText(const QString&)) ); | 95 | scoreLabel, SLOT(setText(const QString&)) ); |
96 | 96 | ||
97 | toolbar->setStretchableWidget( scoreLabel ); | 97 | toolbar->setStretchableWidget( scoreLabel ); |
98 | 98 | ||
99 | go->readConfig(); | 99 | go->readConfig(); |
100 | } | 100 | } |
101 | 101 | ||
102 | void GoMainWidget::resizeEvent( QResizeEvent * ) | 102 | void GoMainWidget::resizeEvent( QResizeEvent * ) |
103 | { | 103 | { |
104 | //### this won't work because of the text label... | 104 | //### this won't work because of the text label... |
105 | /* | 105 | /* |
106 | if ( width() > height() ) | 106 | if ( width() > height() ) |
107 | moveToolBar( toolbar, Left ); | 107 | moveToolBar( toolbar, Left ); |
108 | else | 108 | else |
109 | moveToolBar( toolbar, Top ); | 109 | moveToolBar( toolbar, Top ); |
110 | */ | 110 | */ |
111 | } | 111 | } |
112 | 112 | ||
113 | GoWidget *GoWidget::self = 0; | 113 | GoWidget *GoWidget::self = 0; |
114 | 114 | ||
115 | GoWidget::GoWidget( QWidget *parent, const char* name) : | 115 | GoWidget::GoWidget( QWidget *parent, const char* name) : |
116 | QWidget( parent, name ) | 116 | QWidget( parent, name ) |
117 | { | 117 | { |
118 | if ( self ) | 118 | if ( self ) |
119 | fatal( "Only one Go widget allowed" ); | 119 | fatal( "Only one Go widget allowed" ); |
120 | self = this; | 120 | self = this; |
121 | twoplayer = FALSE; | 121 | twoplayer = FALSE; |
122 | 122 | ||
123 | 123 | ||
124 | d = bx = by = 1; | 124 | d = bx = by = 1; |
125 | 125 | ||
126 | QPixmap pix = Resource::loadPixmap( "go/pine" ); | 126 | QPixmap pix = Resource::loadPixmap( "go/pine" ); |
127 | goBrush = new QBrush( black, pix ); | 127 | goBrush = new QBrush( black, pix ); |
128 | /* | 128 | /* |
129 | QString fn = Resource::findPixmap("Go-black"); | 129 | QString fn = Resource::findPixmap("Go-black"); |
130 | blackStone = new QImage( fn ); | 130 | blackStone = new QImage( fn ); |
131 | fn = Resource::findPixmap("Go-black-highlight"); | 131 | fn = Resource::findPixmap("Go-black-highlight"); |
132 | newBlackStone = new QImage( fn ); | 132 | newBlackStone = new QImage( fn ); |
133 | fn = Resource::findPixmap("Go-white"); | 133 | fn = Resource::findPixmap("Go-white"); |
134 | whiteStone = new QImage( fn ); | 134 | whiteStone = new QImage( fn ); |
135 | */ | 135 | */ |
136 | blackStone = new QPixmap(Resource::loadPixmap( "Go-black" )); | 136 | blackStone = new QPixmap(Resource::loadPixmap( "Go-black" )); |
137 | whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" )); | 137 | whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" )); |
138 | newBlackStone = new QPixmap(Resource::loadPixmap( "Go-black-highlight" )); | 138 | newBlackStone = new QPixmap(Resource::loadPixmap( "Go-black-highlight" )); |
139 | 139 | ||
140 | init(); | 140 | init(); |
141 | } | 141 | } |
142 | 142 | ||
143 | GoWidget::~GoWidget() | 143 | GoWidget::~GoWidget() |
144 | { | 144 | { |
145 | writeConfig(); | 145 | writeConfig(); |
146 | } | 146 | } |
147 | 147 | ||
148 | void GoWidget::writeConfig() | 148 | void GoWidget::writeConfig() |
149 | { | 149 | { |
150 | Config cfg("Go"); | 150 | Config cfg("Go"); |
151 | cfg.setGroup("Game"); | 151 | cfg.setGroup("Game"); |
152 | cfg.writeEntry("TwoPlayer", twoplayer); | 152 | cfg.writeEntry("TwoPlayer", twoplayer); |
153 | cfg.writeEntry("CurrentPlayer", currentPlayer); | 153 | cfg.writeEntry("CurrentPlayer", currentPlayer); |
154 | cfg.writeEntry("NPassed", nPassed); | 154 | cfg.writeEntry("NPassed", nPassed); |
155 | QString b; | 155 | QString b; |
156 | for (int i=0; i<19; i++) | 156 | for (int i=0; i<19; i++) |
157 | for (int j=0; j<19; j++) | 157 | for (int j=0; j<19; j++) |
158 | b += board[i][j] == BLACK ? 'B' : board[i][j] == WHITE ? 'W' : '.'; | 158 | b += board[i][j] == BLACK ? 'B' : board[i][j] == WHITE ? 'W' : '.'; |
159 | cfg.writeEntry("Board", b); | 159 | cfg.writeEntry("Board", b); |
160 | cfg.writeEntry("LastX", lastX); | 160 | cfg.writeEntry("LastX", lastX); |
161 | cfg.writeEntry("LastY", lastY); | 161 | cfg.writeEntry("LastY", lastY); |
162 | extern int blackPrisoners, whitePrisoners; | 162 | extern int blackPrisoners, whitePrisoners; |
163 | cfg.writeEntry("BlackPrisoners", blackPrisoners); | 163 | cfg.writeEntry("BlackPrisoners", blackPrisoners); |
164 | cfg.writeEntry("WhitePrisoners", whitePrisoners); | 164 | cfg.writeEntry("WhitePrisoners", whitePrisoners); |
165 | } | 165 | } |
166 | 166 | ||
167 | void GoWidget::readConfig() | 167 | void GoWidget::readConfig() |
168 | { | 168 | { |
169 | init(); | 169 | init(); |
170 | Config cfg("Go"); | 170 | Config cfg("Go"); |
171 | cfg.setGroup("Game"); | 171 | cfg.setGroup("Game"); |
172 | twoplayer = cfg.readBoolEntry("TwoPlayer"); | 172 | twoplayer = cfg.readBoolEntry("TwoPlayer"); |
173 | currentPlayer = (bVal)cfg.readNumEntry("CurrentPlayer",1); | 173 | currentPlayer = (bVal)cfg.readNumEntry("CurrentPlayer",1); |
174 | nPassed = cfg.readNumEntry("NPassed",0); | 174 | nPassed = cfg.readNumEntry("NPassed",0); |
175 | QString b = cfg.readEntry("Board"); | 175 | QString b = cfg.readEntry("Board"); |
176 | if ( b.length() == 19*19 ) | 176 | if ( b.length() == 19*19 ) |
177 | for (int i=0; i<19; i++) | 177 | for (int i=0; i<19; i++) |
178 | for (int j=0; j<19; j++) { | 178 | for (int j=0; j<19; j++) { |
179 | QChar ch = b[j+19*i]; | 179 | QChar ch = b[j+19*i]; |
180 | if ( ch != '.' ) | 180 | if ( ch != '.' ) |
181 | GoPlaceStone( ch == 'B' ? BLACK : WHITE, i, j ); | 181 | GoPlaceStone( ch == 'B' ? BLACK : WHITE, i, j ); |
182 | } | 182 | } |
183 | lastX = cfg.readNumEntry("LastX"); | 183 | lastX = cfg.readNumEntry("LastX"); |
184 | lastY = cfg.readNumEntry("LastY"); | 184 | lastY = cfg.readNumEntry("LastY"); |
185 | extern int blackPrisoners, whitePrisoners; | 185 | extern int blackPrisoners, whitePrisoners; |
186 | blackPrisoners = cfg.readNumEntry("BlackPrisoners",0); | 186 | blackPrisoners = cfg.readNumEntry("BlackPrisoners",0); |
187 | whitePrisoners = cfg.readNumEntry("WhitePrisoners",0); | 187 | whitePrisoners = cfg.readNumEntry("WhitePrisoners",0); |
188 | reportPrisoners(blackPrisoners,whitePrisoners); | 188 | reportPrisoners(blackPrisoners,whitePrisoners); |
189 | emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone ); | 189 | emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone ); |
190 | } | 190 | } |
191 | 191 | ||
192 | void GoWidget::resizeEvent( QResizeEvent * ) | 192 | void GoWidget::resizeEvent( QResizeEvent * ) |
193 | { | 193 | { |
194 | d = QMIN(width(),height())/19; | 194 | d = QMIN(width(),height())/19; |
195 | // int r = (d/2-1); | 195 | // int r = (d/2-1); |
196 | bx = (width() - 18*d)/2 ; | 196 | bx = (width() - 18*d)/2 ; |
197 | by = (height() - 18*d)/2 ; | 197 | by = (height() - 18*d)/2 ; |
198 | 198 | ||
199 | if ( d < 10 && !smallStones ) { | 199 | if ( d < 10 && !smallStones ) { |
200 | blackStone->convertFromImage( blackStone->convertToImage().smoothScale(8,8) ); | 200 | blackStone->convertFromImage( blackStone->convertToImage().smoothScale(8,8) ); |
201 | whiteStone->convertFromImage( whiteStone->convertToImage().smoothScale(8,8) ); | 201 | whiteStone->convertFromImage( whiteStone->convertToImage().smoothScale(8,8) ); |
202 | newBlackStone->convertFromImage( newBlackStone->convertToImage().smoothScale(8,8) ); | 202 | newBlackStone->convertFromImage( newBlackStone->convertToImage().smoothScale(8,8) ); |
203 | 203 | ||
204 | smallStones = TRUE; | 204 | smallStones = TRUE; |
205 | } else if ( d >= 10 && smallStones ) { | 205 | } else if ( d >= 10 && smallStones ) { |
206 | blackStone = new QPixmap(Resource::loadPixmap( "Go-black" )); | 206 | blackStone = new QPixmap(Resource::loadPixmap( "Go-black" )); |
207 | whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" )); | 207 | whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" )); |
208 | newBlackStone = new QPixmap(Resource::loadPixmap( "Go-black-highlight" )); | 208 | newBlackStone = new QPixmap(Resource::loadPixmap( "Go-black-highlight" )); |
209 | smallStones = FALSE; | 209 | smallStones = FALSE; |
210 | } | 210 | } |
211 | } | 211 | } |
212 | 212 | ||
213 | void GoWidget::init() | 213 | void GoWidget::init() |
214 | { | 214 | { |
215 | lastX = lastY = newX = newY = -1; | 215 | lastX = lastY = newX = newY = -1; |
216 | nPassed = 0; | 216 | nPassed = 0; |
217 | for ( int i = 0; i < 19; i++ ) | 217 | for ( int i = 0; i < 19; i++ ) |
218 | for ( int j = 0; j < 19; j++ ) | 218 | for ( int j = 0; j < 19; j++ ) |
219 | board[i][j]=-1; | 219 | board[i][j]=-1; |
220 | gameActive = TRUE; | 220 | gameActive = TRUE; |
221 | goRestart(current_handicap); | 221 | goRestart(current_handicap); |
222 | 222 | ||
223 | if ( twoplayer ) { | 223 | if ( twoplayer ) { |
224 | currentPlayer = BLACK; | 224 | currentPlayer = BLACK; |
225 | } else { | 225 | } else { |
226 | doComputerMove(); | 226 | doComputerMove(); |
227 | currentPlayer = WHITE; | 227 | currentPlayer = WHITE; |
228 | } | 228 | } |
229 | emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone ); | 229 | emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone ); |
230 | } | 230 | } |
231 | 231 | ||
232 | void GoWidget::paintEvent( QPaintEvent *e ) | 232 | void GoWidget::paintEvent( QPaintEvent *e ) |
233 | { | 233 | { |
234 | int i,j; | 234 | int i,j; |
235 | 235 | ||
236 | int r = whiteStone->width()/2; | 236 | int r = whiteStone->width()/2; |
237 | 237 | ||
238 | QPainter p(this); | 238 | QPainter p(this); |
239 | p.fillRect( bx - d/2, by - d/2, 19*d, 19*d, *goBrush ); | 239 | p.fillRect( bx - d/2, by - d/2, 19*d, 19*d, *goBrush ); |
240 | 240 | ||
241 | int xMin = QMAX( x2board(e->rect().left()), 0 ); | 241 | int xMin = QMAX( x2board(e->rect().left()), 0 ); |
242 | int xMax = QMIN( x2board(e->rect().right()), 18 ); | 242 | int xMax = QMIN( x2board(e->rect().right()), 18 ); |
243 | int yMin = QMAX( y2board(e->rect().top()), 0 ); | 243 | int yMin = QMAX( y2board(e->rect().top()), 0 ); |
244 | int yMax = QMIN( y2board(e->rect().bottom()), 18 ); | 244 | int yMax = QMIN( y2board(e->rect().bottom()), 18 ); |
245 | 245 | ||
246 | QColor pine( 255, 186, 89 ); | 246 | QColor pine( 255, 186, 89 ); |
247 | p.setPen( pine.dark() ); | 247 | p.setPen( pine.dark() ); |
248 | 248 | ||
249 | for ( i = xMin; i < xMax+1 ; i ++ ) { | 249 | for ( i = xMin; i < xMax+1 ; i ++ ) { |
250 | p.drawLine( bx+i*d, by, bx+i*d, by+18*d ); | 250 | p.drawLine( bx+i*d, by, bx+i*d, by+18*d ); |
251 | } | 251 | } |
252 | for ( j = yMin; j < yMax+1 ; j ++ ) { | 252 | for ( j = yMin; j < yMax+1 ; j ++ ) { |
253 | p.drawLine( bx, by+j*d, bx+18*d, by+j*d); | 253 | p.drawLine( bx, by+j*d, bx+18*d, by+j*d); |
254 | } | 254 | } |
255 | 255 | ||
256 | // dots are at (3,3), (3,9), (3,15) and so on | 256 | // dots are at (3,3), (3,9), (3,15) and so on |
257 | p.setBrush( black ); | 257 | p.setBrush( black ); |
258 | for ( i = 3; i < xMax+1; i+=6 ) | 258 | for ( i = 3; i < xMax+1; i+=6 ) |
259 | for ( j = 3; j < yMax+1; j+=6 ) | 259 | for ( j = 3; j < yMax+1; j+=6 ) |
260 | p.drawEllipse( bx+i*d-2, by+j*d-2, 5, 5 ); | 260 | p.drawEllipse( bx+i*d-2, by+j*d-2, 5, 5 ); |
261 | 261 | ||
262 | 262 | ||
263 | for ( i = xMin; i < xMax+1; i++ ) | 263 | for ( i = xMin; i < xMax+1; i++ ) |
264 | for ( j = yMin; j < yMax+1; j++ ) { | 264 | for ( j = yMin; j < yMax+1; j++ ) { |
265 | if ( board[i][j] == WHITE || | 265 | if ( board[i][j] == WHITE || |
266 | currentPlayer==WHITE && newX == i && newY == j ) | 266 | currentPlayer==WHITE && newX == i && newY == j ) |
267 | p.drawPixmap( bx+i*d - r, by+j*d - r, *whiteStone ); | 267 | p.drawPixmap( bx+i*d - r, by+j*d - r, *whiteStone ); |
268 | else if ( i == lastX && j == lastY ) | 268 | else if ( i == lastX && j == lastY ) |
269 | p.drawPixmap( bx+i*d - r, by+j*d - r, *newBlackStone ); | 269 | p.drawPixmap( bx+i*d - r, by+j*d - r, *newBlackStone ); |
270 | else if ( board[i][j] == BLACK || | 270 | else if ( board[i][j] == BLACK || |
271 | currentPlayer==BLACK && newX == i && newY == j) | 271 | currentPlayer==BLACK && newX == i && newY == j) |
272 | p.drawPixmap( bx+i*d - r, by+j*d - r, *blackStone ); | 272 | p.drawPixmap( bx+i*d - r, by+j*d - r, *blackStone ); |
273 | } | 273 | } |
274 | } | 274 | } |
275 | 275 | ||
276 | void GoWidget::doMove( int x, int y ) | 276 | void GoWidget::doMove( int x, int y ) |
277 | { | 277 | { |
278 | 278 | ||
279 | if ( !GoPlaceStone( currentPlayer, x, y ) ) { | 279 | if ( !GoPlaceStone( currentPlayer, x, y ) ) { |
280 | //printf( "Illegal move (%d,%d)\n", x, y ); | 280 | //printf( "Illegal move (%d,%d)\n", x, y ); |
281 | return; | 281 | return; |
282 | } | 282 | } |
283 | //printf( "you do (%d,%d)\n", x, y ); | 283 | //printf( "you do (%d,%d)\n", x, y ); |
284 | nPassed = 0; | 284 | nPassed = 0; |
285 | if ( twoplayer ) | 285 | if ( twoplayer ) |
286 | currentPlayer = (currentPlayer==WHITE) ? BLACK : WHITE; | 286 | currentPlayer = (currentPlayer==WHITE) ? BLACK : WHITE; |
287 | else | 287 | else |
288 | doComputerMove(); | 288 | doComputerMove(); |
289 | 289 | ||
290 | emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone ); | 290 | emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone ); |
291 | 291 | ||
292 | } | 292 | } |
293 | 293 | ||
294 | void GoWidget::pass() | 294 | void GoWidget::pass() |
295 | { | 295 | { |
296 | if ( !gameActive ) | 296 | if ( !gameActive ) |
297 | return; | 297 | return; |
298 | nPassed++; | 298 | nPassed++; |
299 | if ( nPassed >= 2 ) | 299 | if ( nPassed >= 2 ) |
300 | endGame(); | 300 | endGame(); |
301 | else if ( !twoplayer ) | 301 | else if ( !twoplayer ) |
302 | doComputerMove(); | 302 | doComputerMove(); |
303 | } | 303 | } |
304 | 304 | ||
305 | void GoWidget::resign() | 305 | void GoWidget::resign() |
306 | { | 306 | { |
307 | if ( gameActive ) | 307 | if ( gameActive ) |
308 | endGame(); | 308 | endGame(); |
309 | } | 309 | } |
310 | 310 | ||
311 | 311 | ||
312 | void GoWidget::newGame() | 312 | void GoWidget::newGame() |
313 | { | 313 | { |
314 | init(); | 314 | init(); |
315 | update(); | 315 | update(); |
316 | } | 316 | } |
317 | 317 | ||
318 | 318 | ||
319 | void GoWidget::endGame() | 319 | void GoWidget::endGame() |
320 | { | 320 | { |
321 | gameActive = FALSE; | 321 | gameActive = FALSE; |
322 | 322 | ||
323 | int w,b; | 323 | int w,b; |
324 | CountUp( &w, &b); | 324 | CountUp( &w, &b); |
325 | QString s = tr("White %1, Black %2. ").arg(w).arg(b); | 325 | QString s = tr("White %1, Black %2. ").arg(w).arg(b); |
326 | if ( w > b ) | 326 | if ( w > b ) |
327 | s += tr("White wins."); | 327 | s += tr("White wins."); |
328 | else if ( w < b ) | 328 | else if ( w < b ) |
329 | s += tr("Black wins."); | 329 | s += tr("Black wins."); |
330 | else | 330 | else |
331 | s += tr("A draw."); | 331 | s += tr("A draw."); |
332 | emit showScore( s ); | 332 | emit showScore( s ); |
333 | } | 333 | } |
334 | 334 | ||
335 | void GoWidget::doComputerMove() | 335 | void GoWidget::doComputerMove() |
336 | { | 336 | { |
337 | int ox = lastX; | 337 | int ox = lastX; |
338 | int oy = lastY; | 338 | int oy = lastY; |
339 | lastX = lastY = -1; | 339 | lastX = lastY = -1; |
340 | emit showTurn( *blackStone ); | 340 | emit showTurn( *blackStone ); |
341 | refresh( ox, oy); | 341 | refresh( ox, oy); |
342 | qApp->processEvents(); | 342 | qApp->processEvents(); |
343 | short int x,y; | 343 | short int x,y; |
344 | if ( genMove( computer_color, &x, &y ) ) { | 344 | if ( genMove( computer_color, &x, &y ) ) { |
345 | lastX = x; | 345 | lastX = x; |
346 | lastY = y; | 346 | lastY = y; |
347 | //printf( "I do (%d,%d)\n", x, y ); | 347 | //printf( "I do (%d,%d)\n", x, y ); |
348 | GoPlaceStone(computer_color,x,y); | 348 | GoPlaceStone(computer_color,x,y); |
349 | nPassed = 0; | 349 | nPassed = 0; |
350 | } else { | 350 | } else { |
351 | emit showScore( tr("I pass") ); | 351 | emit showScore( tr("I pass") ); |
352 | nPassed++; | 352 | nPassed++; |
353 | if ( nPassed >= 2 ) | 353 | if ( nPassed >= 2 ) |
354 | endGame(); | 354 | endGame(); |
355 | } | 355 | } |
356 | } | 356 | } |
357 | 357 | ||
358 | void GoWidget::mousePressEvent( QMouseEvent *me ) | 358 | void GoWidget::mousePressEvent( QMouseEvent *me ) |
359 | { | 359 | { |
360 | if ( !gameActive ) | 360 | if ( !gameActive ) |
361 | return; | 361 | return; |
362 | int x = x2board(me->x()); | 362 | int x = x2board(me->x()); |
363 | int y = y2board(me->y()); | 363 | int y = y2board(me->y()); |
364 | showStone(x,y,currentPlayer); | 364 | showStone(x,y,currentPlayer); |
365 | } | 365 | } |
366 | 366 | ||
367 | void GoWidget::mouseMoveEvent( QMouseEvent *me ) | 367 | void GoWidget::mouseMoveEvent( QMouseEvent *me ) |
368 | { | 368 | { |
369 | if ( !gameActive ) | 369 | if ( !gameActive ) |
370 | return; | 370 | return; |
371 | int x = x2board(me->x()); | 371 | int x = x2board(me->x()); |
372 | int y = y2board(me->y()); | 372 | int y = y2board(me->y()); |
373 | if ( x != newX || y != newY ) | 373 | if ( x != newX || y != newY ) |
374 | showStone(x,y,currentPlayer); | 374 | showStone(x,y,currentPlayer); |
375 | } | 375 | } |
376 | 376 | ||
377 | void GoWidget::showStone( int x, int y, enum bVal c ) | 377 | void GoWidget::showStone( int x, int y, enum bVal c ) |
378 | { | 378 | { |
379 | 379 | ||
380 | if ( newX > -1 ) { | 380 | if ( newX > -1 ) { |
381 | refresh( newX, newY ); | 381 | refresh( newX, newY ); |
382 | newY = newX = -1; | 382 | newY = newX = -1; |
383 | } | 383 | } |
384 | if ( x < 0 || x > 18 || y < 0 || y > 18 ) { | 384 | if ( x < 0 || x > 18 || y < 0 || y > 18 ) { |
385 | newX = newY = -1; | 385 | newX = newY = -1; |
386 | return; | 386 | return; |
387 | } | 387 | } |
388 | if ( board[x][y] == -1 && !Suicide( c, x, y ) ) { | 388 | if ( board[x][y] == -1 && !Suicide( c, x, y ) ) { |
389 | newX = x; | 389 | newX = x; |
390 | newY = y; | 390 | newY = y; |
391 | refresh(x,y); | 391 | refresh(x,y); |
392 | } | 392 | } |
393 | 393 | ||
394 | } | 394 | } |
395 | 395 | ||
396 | void GoWidget::mouseReleaseEvent( QMouseEvent * ) | 396 | void GoWidget::mouseReleaseEvent( QMouseEvent * ) |
397 | { | 397 | { |
398 | if ( gameActive && newX > -1 ) | 398 | if ( gameActive && newX > -1 ) |
399 | doMove( newX, newY ); | 399 | doMove( newX, newY ); |
400 | newX = newY = -1; | 400 | newX = newY = -1; |
401 | } | 401 | } |
402 | 402 | ||
403 | void GoWidget::refresh( int x, int y ) | 403 | void GoWidget::refresh( int x, int y ) |
404 | { | 404 | { |
405 | update( bx+d*x-d/2-1, by+d*y-d/2-1, d+2, d+2 ); | 405 | update( bx+d*x-d/2-1, by+d*y-d/2-1, d+2, d+2 ); |
406 | } | 406 | } |
407 | 407 | ||
408 | void GoWidget::removeStone(short x, short y) | 408 | void GoWidget::removeStone(short x, short y) |
409 | { | 409 | { |
410 | board[x][y]=-1; | 410 | board[x][y]=-1; |
411 | refresh( x, y ); | 411 | refresh( x, y ); |
412 | } | 412 | } |
413 | 413 | ||
414 | void GoWidget::placeStone (enum bVal c, short x, short y ) | 414 | void GoWidget::placeStone (enum bVal c, short x, short y ) |
415 | { | 415 | { |
416 | board[x][y]=c; | 416 | board[x][y]=c; |
417 | refresh( x, y ); | 417 | refresh( x, y ); |
418 | } | 418 | } |
419 | 419 | ||
420 | void GoWidget::reportPrisoners( int blackcnt, int whitecnt ) | 420 | void GoWidget::reportPrisoners( int blackcnt, int whitecnt ) |
421 | { | 421 | { |
422 | QString s = tr( "Prisoners: black %1, white %2" ).arg(blackcnt).arg(whitecnt); | 422 | QString s = tr( "Prisoners: black %1, white %2" ).arg(blackcnt).arg(whitecnt); |
423 | emit showScore( s ); | 423 | emit showScore( s ); |
424 | } | 424 | } |
425 | 425 | ||
426 | void GoWidget::setTwoplayer( bool b ) | 426 | void GoWidget::setTwoplayer( bool b ) |
427 | { | 427 | { |
428 | twoplayer = b; | 428 | twoplayer = b; |
429 | } | 429 | } |
430 | 430 | ||
431 | void GoWidget::setHandicap( int h ) | 431 | void GoWidget::setHandicap( int h ) |
432 | { | 432 | { |
433 | current_handicap = h; | 433 | current_handicap = h; |
434 | } | 434 | } |
435 | 435 | ||
436 | 436 | ||
437 | extern "C" { | 437 | extern "C" { |
438 | 438 | ||
439 | voidremovestone(short x, short y) | 439 | voidremovestone(short x, short y) |
440 | { | 440 | { |
441 | GoWidget::self->removeStone(x,y); | 441 | GoWidget::self->removeStone(x,y); |
442 | } | 442 | } |
443 | 443 | ||
444 | voidplacestone (enum bVal c, short x, short y ) | 444 | voidplacestone (enum bVal c, short x, short y ) |
445 | { | 445 | { |
446 | GoWidget::self->placeStone(c,x,y); | 446 | GoWidget::self->placeStone(c,x,y); |
447 | } | 447 | } |
448 | 448 | ||
449 | voidintrMoveReport(enum bVal c ,char *coord ,char *reason ) | 449 | voidintrMoveReport(enum bVal c ,char *coord ,char *reason ) |
450 | { | 450 | { |
451 | qDebug( "intrMoveReport colour %d, %s %s", c, coord, reason ); | 451 | qDebug( "intrMoveReport colour %d, %s %s", c, coord, reason ); |
452 | } | 452 | } |
453 | 453 | ||
454 | voidintrPrisonerReport( short blackcnt, short whitecnt ) | 454 | voidintrPrisonerReport( short blackcnt, short whitecnt ) |
455 | { | 455 | { |
456 | GoWidget::self->reportPrisoners(blackcnt,whitecnt); | 456 | GoWidget::self->reportPrisoners(blackcnt,whitecnt); |
457 | } | 457 | } |
458 | 458 | ||
459 | } | 459 | } |
460 | 460 | ||
diff --git a/noncore/games/go/main.cpp b/noncore/games/go/main.cpp index 46817d1..f6bb813 100644 --- a/noncore/games/go/main.cpp +++ b/noncore/games/go/main.cpp | |||
@@ -1,27 +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 | 23 | ||
24 | #include <opie2/oapplicationfactory.h> | 24 | #include <opie2/oapplicationfactory.h> |
25 | 25 | ||
26 | using namespace Opie::Core; | ||
26 | OPIE_EXPORT_APP( OApplicationFactory<GoMainWidget> ) | 27 | OPIE_EXPORT_APP( OApplicationFactory<GoMainWidget> ) |
27 | 28 | ||
diff --git a/noncore/games/kcheckers/main.cpp b/noncore/games/kcheckers/main.cpp index 79b5ac7..8c708e2 100644 --- a/noncore/games/kcheckers/main.cpp +++ b/noncore/games/kcheckers/main.cpp | |||
@@ -1,9 +1,10 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include "kcheckers.h" | 3 | #include "kcheckers.h" |
4 | 4 | ||
5 | #include <opie2/oapplicationfactory.h> | 5 | #include <opie2/oapplicationfactory.h> |
6 | 6 | ||
7 | using namespace Opie::Core; | ||
7 | OPIE_EXPORT_APP( OApplicationFactory<KCheckers> ) | 8 | OPIE_EXPORT_APP( OApplicationFactory<KCheckers> ) |
8 | 9 | ||
9 | 10 | ||
diff --git a/noncore/games/minesweep/main.cpp b/noncore/games/minesweep/main.cpp index f3070f5..629afbf 100644 --- a/noncore/games/minesweep/main.cpp +++ b/noncore/games/minesweep/main.cpp | |||
@@ -1,26 +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 <opie2/oapplicationfactory.h> | 23 | #include <opie2/oapplicationfactory.h> |
24 | 24 | ||
25 | using namespace Opie::Core; | ||
25 | OPIE_EXPORT_APP( OApplicationFactory<MineSweep> ) | 26 | OPIE_EXPORT_APP( OApplicationFactory<MineSweep> ) |
26 | 27 | ||
diff --git a/noncore/games/parashoot/main.cpp b/noncore/games/parashoot/main.cpp index 81d513d..da21c25 100644 --- a/noncore/games/parashoot/main.cpp +++ b/noncore/games/parashoot/main.cpp | |||
@@ -1,26 +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 <opie2/oapplicationfactory.h> | 23 | #include <opie2/oapplicationfactory.h> |
24 | 24 | ||
25 | using namespace Opie::Core; | ||
25 | OPIE_EXPORT_APP( OApplicationFactory<ParaShoot> ) | 26 | OPIE_EXPORT_APP( OApplicationFactory<ParaShoot> ) |
26 | 27 | ||
diff --git a/noncore/games/qasteroids/main.cpp b/noncore/games/qasteroids/main.cpp index 33e4729..6ddb238 100644 --- a/noncore/games/qasteroids/main.cpp +++ b/noncore/games/qasteroids/main.cpp | |||
@@ -1,26 +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 <opie2/oapplicationfactory.h> | 23 | #include <opie2/oapplicationfactory.h> |
24 | 24 | ||
25 | 25 | ||
26 | using namespace Opie::Core; | ||
26 | OPIE_EXPORT_APP( OApplicationFactory<KAstTopLevel> ) | 27 | OPIE_EXPORT_APP( OApplicationFactory<KAstTopLevel> ) |
diff --git a/noncore/games/snake/interface.cpp b/noncore/games/snake/interface.cpp index b5fb5bf..9d9550a 100644 --- a/noncore/games/snake/interface.cpp +++ b/noncore/games/snake/interface.cpp | |||
@@ -1,219 +1,219 @@ | |||
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 | 24 | ||
25 | #include <qpe/qpetoolbar.h> | 25 | #include <qtoolbar.h> |
26 | #include <qtoolbutton.h> | 26 | #include <qtoolbutton.h> |
27 | 27 | ||
28 | SnakeGame::SnakeGame(QWidget* parent, const char* name, WFlags f) : | 28 | SnakeGame::SnakeGame(QWidget* parent, const char* name, WFlags f) : |
29 | QMainWindow(parent,name,f), | 29 | QMainWindow(parent,name,f), |
30 | canvas(232, 258) | 30 | canvas(232, 258) |
31 | { | 31 | { |
32 | setCaption( tr("Snake") ); | 32 | setCaption( tr("Snake") ); |
33 | QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff ); | 33 | QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff ); |
34 | QPixmap bg = Resource::loadPixmap("snake/grass"); | 34 | QPixmap bg = Resource::loadPixmap("snake/grass"); |
35 | canvas.setBackgroundPixmap(bg); | 35 | canvas.setBackgroundPixmap(bg); |
36 | canvas.setUpdatePeriod(100); | 36 | canvas.setUpdatePeriod(100); |
37 | snake = 0; | 37 | snake = 0; |
38 | 38 | ||
39 | cv = new QCanvasView(&canvas, this); | 39 | cv = new QCanvasView(&canvas, this); |
40 | 40 | ||
41 | pauseTimer = new QTimer(this); | 41 | pauseTimer = new QTimer(this); |
42 | connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) ); | 42 | connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) ); |
43 | 43 | ||
44 | setToolBarsMovable( FALSE ); | 44 | setToolBarsMovable( FALSE ); |
45 | 45 | ||
46 | QToolBar* toolbar = new QToolBar( this); | 46 | QToolBar* toolbar = new QToolBar( this); |
47 | toolbar->setHorizontalStretchable( TRUE ); | 47 | toolbar->setHorizontalStretchable( TRUE ); |
48 | 48 | ||
49 | QPixmap newicon = Resource::loadPixmap("ksnake"); | 49 | QPixmap newicon = Resource::loadPixmap("ksnake"); |
50 | setIcon(newicon); | 50 | setIcon(newicon); |
51 | (void)new QToolButton(newicon, tr("New Game"), 0, | 51 | (void)new QToolButton(newicon, tr("New Game"), 0, |
52 | this, SLOT(newGame()), toolbar, "New Game"); | 52 | this, SLOT(newGame()), toolbar, "New Game"); |
53 | 53 | ||
54 | scorelabel = new QLabel(toolbar); | 54 | scorelabel = new QLabel(toolbar); |
55 | showScore(0); | 55 | showScore(0); |
56 | scorelabel->setBackgroundMode( PaletteButton ); | 56 | scorelabel->setBackgroundMode( PaletteButton ); |
57 | scorelabel->setAlignment( AlignRight | AlignVCenter | ExpandTabs ); | 57 | scorelabel->setAlignment( AlignRight | AlignVCenter | ExpandTabs ); |
58 | toolbar->setStretchableWidget( scorelabel ); | 58 | toolbar->setStretchableWidget( scorelabel ); |
59 | 59 | ||
60 | setFocusPolicy(StrongFocus); | 60 | setFocusPolicy(StrongFocus); |
61 | 61 | ||
62 | setCentralWidget(cv); | 62 | setCentralWidget(cv); |
63 | 63 | ||
64 | QTimer::singleShot( 16, this, SLOT(welcomescreen()) ); | 64 | QTimer::singleShot( 16, this, SLOT(welcomescreen()) ); |
65 | gamestopped = true; | 65 | gamestopped = true; |
66 | waitover = true; | 66 | waitover = true; |
67 | } | 67 | } |
68 | 68 | ||
69 | SnakeGame::~SnakeGame() | 69 | SnakeGame::~SnakeGame() |
70 | { | 70 | { |
71 | delete snake; | 71 | delete snake; |
72 | } | 72 | } |
73 | 73 | ||
74 | void SnakeGame::resizeEvent(QResizeEvent *) | 74 | void SnakeGame::resizeEvent(QResizeEvent *) |
75 | { | 75 | { |
76 | QSize s = centralWidget()->size(); | 76 | QSize s = centralWidget()->size(); |
77 | int fw = style().defaultFrameWidth(); | 77 | int fw = style().defaultFrameWidth(); |
78 | canvas.resize( s.width() - fw - 2, s.height() - fw - 2); | 78 | canvas.resize( s.width() - fw - 2, s.height() - fw - 2); |
79 | } | 79 | } |
80 | 80 | ||
81 | void SnakeGame::welcomescreen() | 81 | void SnakeGame::welcomescreen() |
82 | { | 82 | { |
83 | QCanvasText* title = new QCanvasText(tr("SNAKE!"), &canvas); | 83 | QCanvasText* title = new QCanvasText(tr("SNAKE!"), &canvas); |
84 | title->setColor(yellow); | 84 | title->setColor(yellow); |
85 | title->setFont( QFont("times", 18, QFont::Bold) ); | 85 | title->setFont( QFont("times", 18, QFont::Bold) ); |
86 | int w = title->boundingRect().width(); | 86 | int w = title->boundingRect().width(); |
87 | title->move(canvas.width()/2 -w/2, canvas.height()/2-110); | 87 | title->move(canvas.width()/2 -w/2, canvas.height()/2-110); |
88 | title->show(); | 88 | title->show(); |
89 | QCanvasPixmapArray* titlearray = new QCanvasPixmapArray(Resource::findPixmap("snake/title")); | 89 | QCanvasPixmapArray* titlearray = new QCanvasPixmapArray(Resource::findPixmap("snake/title")); |
90 | QCanvasSprite* titlepic = new QCanvasSprite(titlearray, &canvas); | 90 | QCanvasSprite* titlepic = new QCanvasSprite(titlearray, &canvas); |
91 | titlepic->move(canvas.width()/2 - 33, canvas.height()/2-85); | 91 | titlepic->move(canvas.width()/2 - 33, canvas.height()/2-85); |
92 | titlepic->show(); | 92 | titlepic->show(); |
93 | QCanvasText* instr = new QCanvasText(tr("Use the arrow keys to guide the\n" | 93 | QCanvasText* instr = new QCanvasText(tr("Use the arrow keys to guide the\n" |
94 | "snake to eat the mouse. You must not\n" | 94 | "snake to eat the mouse. You must not\n" |
95 | "crash into the walls, edges or its tail."), | 95 | "crash into the walls, edges or its tail."), |
96 | &canvas); | 96 | &canvas); |
97 | w = instr->boundingRect().width(); | 97 | w = instr->boundingRect().width(); |
98 | instr->move(canvas.width()/2-w/2, canvas.height()/2-20); | 98 | instr->move(canvas.width()/2-w/2, canvas.height()/2-20); |
99 | instr->setColor(white); | 99 | instr->setColor(white); |
100 | instr->show(); | 100 | instr->show(); |
101 | QCanvasText* cont = new QCanvasText(tr("Press any key to start"), &canvas); | 101 | QCanvasText* cont = new QCanvasText(tr("Press any key to start"), &canvas); |
102 | w = cont->boundingRect().width(); | 102 | w = cont->boundingRect().width(); |
103 | cont->move(canvas.width()/2-w/2, canvas.height()-20); | 103 | cont->move(canvas.width()/2-w/2, canvas.height()-20); |
104 | cont->setColor(yellow); | 104 | cont->setColor(yellow); |
105 | cont->show(); | 105 | cont->show(); |
106 | 106 | ||
107 | } | 107 | } |
108 | 108 | ||
109 | void SnakeGame::newGame() | 109 | void SnakeGame::newGame() |
110 | { | 110 | { |
111 | clear(); | 111 | clear(); |
112 | snake = new Snake(&canvas); | 112 | snake = new Snake(&canvas); |
113 | connect(snake, SIGNAL(dead()), this, SLOT(gameOver()) ); | 113 | connect(snake, SIGNAL(dead()), this, SLOT(gameOver()) ); |
114 | connect(snake, SIGNAL(targethit()), this, SLOT(levelUp()) ); | 114 | connect(snake, SIGNAL(targethit()), this, SLOT(levelUp()) ); |
115 | connect(snake, SIGNAL(scorechanged()), this, SLOT(scoreInc()) ); | 115 | connect(snake, SIGNAL(scorechanged()), this, SLOT(scoreInc()) ); |
116 | connect(this, SIGNAL(moveFaster()), snake, SLOT(increaseSpeed()) ); | 116 | connect(this, SIGNAL(moveFaster()), snake, SLOT(increaseSpeed()) ); |
117 | last = 0; | 117 | last = 0; |
118 | targetamount = 1; | 118 | targetamount = 1; |
119 | notargets = 1; | 119 | notargets = 1; |
120 | level = 1; | 120 | level = 1; |
121 | stage = 1; | 121 | stage = 1; |
122 | showScore(0); | 122 | showScore(0); |
123 | gamestopped = false; | 123 | gamestopped = false; |
124 | waitover = true; | 124 | waitover = true; |
125 | int y = canvas.height()-50; | 125 | int y = canvas.height()-50; |
126 | (void)new Obstacle(&canvas, 32); | 126 | (void)new Obstacle(&canvas, 32); |
127 | (void)new Obstacle(&canvas, y); | 127 | (void)new Obstacle(&canvas, y); |
128 | createTargets(); | 128 | createTargets(); |
129 | } | 129 | } |
130 | 130 | ||
131 | 131 | ||
132 | void SnakeGame::showScore(int score) | 132 | void SnakeGame::showScore(int score) |
133 | { | 133 | { |
134 | scorelabel->setText(tr(" Score : %1 ").arg(score) ); | 134 | scorelabel->setText(tr(" Score : %1 ").arg(score) ); |
135 | } | 135 | } |
136 | 136 | ||
137 | 137 | ||
138 | void SnakeGame::scoreInc() | 138 | void SnakeGame::scoreInc() |
139 | { | 139 | { |
140 | showScore( snake->getScore() ); | 140 | showScore( snake->getScore() ); |
141 | } | 141 | } |
142 | 142 | ||
143 | void SnakeGame::levelUp() | 143 | void SnakeGame::levelUp() |
144 | { | 144 | { |
145 | notargets--; | 145 | notargets--; |
146 | if (notargets == 0) { | 146 | if (notargets == 0) { |
147 | stage++; | 147 | stage++; |
148 | if (stage == 3) { | 148 | if (stage == 3) { |
149 | level++; | 149 | level++; |
150 | emit moveFaster(); | 150 | emit moveFaster(); |
151 | targetamount++; | 151 | targetamount++; |
152 | stage = 0; | 152 | stage = 0; |
153 | } | 153 | } |
154 | createTargets(); | 154 | createTargets(); |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | void SnakeGame::createTargets() | 158 | void SnakeGame::createTargets() |
159 | { | 159 | { |
160 | for (int i = 0; i < targetamount; i++) | 160 | for (int i = 0; i < targetamount; i++) |
161 | (void)new Target(&canvas); | 161 | (void)new Target(&canvas); |
162 | notargets = targetamount; | 162 | notargets = targetamount; |
163 | } | 163 | } |
164 | 164 | ||
165 | void SnakeGame::clear() | 165 | void SnakeGame::clear() |
166 | { | 166 | { |
167 | delete snake; | 167 | delete snake; |
168 | snake = 0; | 168 | snake = 0; |
169 | QCanvasItemList l = canvas.allItems(); | 169 | QCanvasItemList l = canvas.allItems(); |
170 | for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) { | 170 | for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) { |
171 | delete *it; | 171 | delete *it; |
172 | } | 172 | } |
173 | } | 173 | } |
174 | 174 | ||
175 | void SnakeGame::gameOver() | 175 | void SnakeGame::gameOver() |
176 | { | 176 | { |
177 | int score = snake->getScore(); | 177 | int score = snake->getScore(); |
178 | QString scoreoutput=""; | 178 | QString scoreoutput=""; |
179 | scoreoutput.setNum(score); | 179 | scoreoutput.setNum(score); |
180 | QCanvasText* gameover = new QCanvasText(tr("GAME OVER!\n Your Score: %1").arg( scoreoutput), &canvas); | 180 | QCanvasText* gameover = new QCanvasText(tr("GAME OVER!\n Your Score: %1").arg( scoreoutput), &canvas); |
181 | 181 | ||
182 | gameover->setZ(100); | 182 | gameover->setZ(100); |
183 | gameover->setColor(yellow); | 183 | gameover->setColor(yellow); |
184 | gameover->setFont( QFont("times", 18, QFont::Bold) ); | 184 | gameover->setFont( QFont("times", 18, QFont::Bold) ); |
185 | int w = gameover->boundingRect().width(); | 185 | int w = gameover->boundingRect().width(); |
186 | gameover->move(canvas.width()/2 -w/2, canvas.height()/2 -50); | 186 | gameover->move(canvas.width()/2 -w/2, canvas.height()/2 -50); |
187 | gameover->show(); | 187 | gameover->show(); |
188 | gamestopped = true; | 188 | gamestopped = true; |
189 | waitover = false; | 189 | waitover = false; |
190 | pauseTimer->start(1500); | 190 | pauseTimer->start(1500); |
191 | } | 191 | } |
192 | 192 | ||
193 | void SnakeGame::wait() | 193 | void SnakeGame::wait() |
194 | { | 194 | { |
195 | waitover = true; | 195 | waitover = true; |
196 | pauseTimer->stop(); | 196 | pauseTimer->stop(); |
197 | QCanvasText* cont = new QCanvasText(tr("Press any key to begin a new game."), | 197 | QCanvasText* cont = new QCanvasText(tr("Press any key to begin a new game."), |
198 | &canvas); | 198 | &canvas); |
199 | cont->setZ(100); | 199 | cont->setZ(100); |
200 | cont->setColor(white); | 200 | cont->setColor(white); |
201 | int w = cont->boundingRect().width(); | 201 | int w = cont->boundingRect().width(); |
202 | cont->move(canvas.width()/2 -w/2, canvas.height()/2); | 202 | cont->move(canvas.width()/2 -w/2, canvas.height()/2); |
203 | cont->show(); | 203 | cont->show(); |
204 | } | 204 | } |
205 | 205 | ||
206 | void SnakeGame::keyPressEvent(QKeyEvent* event) | 206 | void SnakeGame::keyPressEvent(QKeyEvent* event) |
207 | { | 207 | { |
208 | if (gamestopped) { | 208 | if (gamestopped) { |
209 | if (waitover) | 209 | if (waitover) |
210 | newGame(); | 210 | newGame(); |
211 | else | 211 | else |
212 | return; | 212 | return; |
213 | } | 213 | } |
214 | else { | 214 | else { |
215 | int newkey = event->key(); | 215 | int newkey = event->key(); |
216 | snake->go(newkey); | 216 | snake->go(newkey); |
217 | } | 217 | } |
218 | } | 218 | } |
219 | 219 | ||
diff --git a/noncore/games/snake/main.cpp b/noncore/games/snake/main.cpp index 44f742f..81eb9ee 100644 --- a/noncore/games/snake/main.cpp +++ b/noncore/games/snake/main.cpp | |||
@@ -1,28 +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 <opie2/oapplicationfactory.h> | 23 | #include <opie2/oapplicationfactory.h> |
24 | 24 | ||
25 | 25 | ||
26 | using namespace Opie::Core; | ||
26 | OPIE_EXPORT_APP( OApplicationFactory<SnakeGame> ) | 27 | OPIE_EXPORT_APP( OApplicationFactory<SnakeGame> ) |
27 | 28 | ||
28 | 29 | ||
diff --git a/noncore/games/solitaire/main.cpp b/noncore/games/solitaire/main.cpp index d4f6673..c8d4040 100644 --- a/noncore/games/solitaire/main.cpp +++ b/noncore/games/solitaire/main.cpp | |||
@@ -1,25 +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 <opie2/oapplicationfactory.h> | 23 | #include <opie2/oapplicationfactory.h> |
24 | 24 | ||
25 | using namespace Opie::Core; | ||
25 | OPIE_EXPORT_APP( OApplicationFactory<CanvasCardWindow> ) \ No newline at end of file | 26 | OPIE_EXPORT_APP( OApplicationFactory<CanvasCardWindow> ) \ No newline at end of file |
diff --git a/noncore/games/tetrix/main.cpp b/noncore/games/tetrix/main.cpp index 147d13d..6194bbf 100644 --- a/noncore/games/tetrix/main.cpp +++ b/noncore/games/tetrix/main.cpp | |||
@@ -1,27 +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 | 23 | ||
24 | #include <opie2/oapplicationfactory.h> | 24 | #include <opie2/oapplicationfactory.h> |
25 | 25 | ||
26 | using namespace Opie::Core; | ||
26 | OPIE_EXPORT_APP( OApplicationFactory<QTetrix> ) | 27 | OPIE_EXPORT_APP( OApplicationFactory<QTetrix> ) |
27 | 28 | ||
diff --git a/noncore/games/tictac/main.cpp b/noncore/games/tictac/main.cpp index b8193f7..f3df375 100644 --- a/noncore/games/tictac/main.cpp +++ b/noncore/games/tictac/main.cpp | |||
@@ -1,13 +1,14 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of an example program for Qt. This example | 4 | ** This file is part of an example program for Qt. This example |
5 | ** program may be used, distributed and modified without limitation. | 5 | ** program may be used, distributed and modified without limitation. |
6 | ** | 6 | ** |
7 | *****************************************************************************/ | 7 | *****************************************************************************/ |
8 | 8 | ||
9 | #include "tictac.h" | 9 | #include "tictac.h" |
10 | 10 | ||
11 | #include <opie2/oapplicationfactory.h> | 11 | #include <opie2/oapplicationfactory.h> |
12 | 12 | ||
13 | using namespace Opie::Core; | ||
13 | OPIE_EXPORT_APP( OApplicationFactory<TicTacToe> ) | 14 | OPIE_EXPORT_APP( OApplicationFactory<TicTacToe> ) |
diff --git a/noncore/games/wordgame/main.cpp b/noncore/games/wordgame/main.cpp index 7fd5f50..c388775 100644 --- a/noncore/games/wordgame/main.cpp +++ b/noncore/games/wordgame/main.cpp | |||
@@ -1,27 +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 <opie2/oapplicationfactory.h> | 23 | #include <opie2/oapplicationfactory.h> |
24 | 24 | ||
25 | 25 | ||
26 | using namespace Opie::Core; | ||
26 | OPIE_EXPORT_APP( OApplicationFactory<WordGame> ) | 27 | OPIE_EXPORT_APP( OApplicationFactory<WordGame> ) |
27 | 28 | ||
diff --git a/noncore/games/wordgame/wordgame.cpp b/noncore/games/wordgame/wordgame.cpp index 43a54f8..a80bd35 100644 --- a/noncore/games/wordgame/wordgame.cpp +++ b/noncore/games/wordgame/wordgame.cpp | |||
@@ -1,548 +1,548 @@ | |||
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 | 21 | ||
22 | #include "wordgame.h" | 22 | #include "wordgame.h" |
23 | 23 | ||
24 | #include <qpe/global.h> | 24 | #include <qpe/global.h> |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
27 | 27 | ||
28 | #include <qapplication.h> | 28 | #include <qapplication.h> |
29 | #include <qmessagebox.h> | 29 | #include <qmessagebox.h> |
30 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qtextstream.h> | 34 | #include <qtextstream.h> |
35 | #include <qtimer.h> | 35 | #include <qtimer.h> |
36 | #include <qpe/qpetoolbar.h> | 36 | #include <qtoolbar.h> |
37 | #include <qtoolbutton.h> | 37 | #include <qtoolbutton.h> |
38 | #include <qvbox.h> | 38 | #include <qvbox.h> |
39 | #include <qwidgetstack.h> | 39 | #include <qwidgetstack.h> |
40 | #include <qlayout.h> | 40 | #include <qlayout.h> |
41 | 41 | ||
42 | #include <stdlib.h> | 42 | #include <stdlib.h> |
43 | #include <unistd.h> | 43 | #include <unistd.h> |
44 | #include <pwd.h> | 44 | #include <pwd.h> |
45 | #include <sys/types.h> | 45 | #include <sys/types.h> |
46 | 46 | ||
47 | enum RuleEffects { | 47 | enum RuleEffects { |
48 | Multiplier=15, | 48 | Multiplier=15, |
49 | MultiplyAll=64, | 49 | MultiplyAll=64, |
50 | Start=128 | 50 | Start=128 |
51 | }; | 51 | }; |
52 | 52 | ||
53 | static int tile_smallw = 16; | 53 | static int tile_smallw = 16; |
54 | static int tile_smallh = 16; | 54 | static int tile_smallh = 16; |
55 | static int tile_bigw = 22; | 55 | static int tile_bigw = 22; |
56 | static int tile_bigh = 22; | 56 | static int tile_bigh = 22; |
57 | static int tile_stweak = -2; | 57 | static int tile_stweak = -2; |
58 | static int tile_btweak = -1; | 58 | static int tile_btweak = -1; |
59 | 59 | ||
60 | static const int rack_tiles=7; | 60 | static const int rack_tiles=7; |
61 | 61 | ||
62 | const char* sampleWGR= | 62 | const char* sampleWGR= |
63 | "wordgame_shapes\n" | 63 | "wordgame_shapes\n" |
64 | "15 15\n" | 64 | "15 15\n" |
65 | "400001040100004\n" | 65 | "400001040100004\n" |
66 | "030000000000030\n" | 66 | "030000000000030\n" |
67 | "002002000200200\n" | 67 | "002002000200200\n" |
68 | "000300020003000\n" | 68 | "000300020003000\n" |
69 | "000020000020000\n" | 69 | "000020000020000\n" |
70 | "102001000100201\n" | 70 | "102001000100201\n" |
71 | "000000202000000\n" | 71 | "000000202000000\n" |
72 | "400200050002004\n" | 72 | "400200050002004\n" |
73 | "000000202000000\n" | 73 | "000000202000000\n" |
74 | "102001000100201\n" | 74 | "102001000100201\n" |
75 | "000020000020000\n" | 75 | "000020000020000\n" |
76 | "000300020003000\n" | 76 | "000300020003000\n" |
77 | "002002000200200\n" | 77 | "002002000200200\n" |
78 | "030000000000030\n" | 78 | "030000000000030\n" |
79 | "400001040100004\n" | 79 | "400001040100004\n" |
80 | "1 2 3 66 67 194 100 0\n" | 80 | "1 2 3 66 67 194 100 0\n" |
81 | "1 j 8\n" | 81 | "1 j 8\n" |
82 | "1 q 7\n" | 82 | "1 q 7\n" |
83 | "1 x 6\n" | 83 | "1 x 6\n" |
84 | "1 z 6\n" | 84 | "1 z 6\n" |
85 | "1 w 4\n" | 85 | "1 w 4\n" |
86 | "1 k 4\n" | 86 | "1 k 4\n" |
87 | "1 v 3\n" | 87 | "1 v 3\n" |
88 | "1 f 3\n" | 88 | "1 f 3\n" |
89 | "2 y 3\n" | 89 | "2 y 3\n" |
90 | "2 h 2\n" | 90 | "2 h 2\n" |
91 | "2 b 2\n" | 91 | "2 b 2\n" |
92 | "2 m 2\n" | 92 | "2 m 2\n" |
93 | "3 p 2\n" | 93 | "3 p 2\n" |
94 | "3 g 2\n" | 94 | "3 g 2\n" |
95 | "3 u 2\n" | 95 | "3 u 2\n" |
96 | "4 d 2\n" | 96 | "4 d 2\n" |
97 | "4 c 2\n" | 97 | "4 c 2\n" |
98 | "5 l 1\n" | 98 | "5 l 1\n" |
99 | "5 o 1\n" | 99 | "5 o 1\n" |
100 | "7 t 1\n" | 100 | "7 t 1\n" |
101 | "7 n 1\n" | 101 | "7 n 1\n" |
102 | "7 a 1\n" | 102 | "7 a 1\n" |
103 | "7 r 1\n" | 103 | "7 r 1\n" |
104 | "8 s 1\n" | 104 | "8 s 1\n" |
105 | "8 i 1\n" | 105 | "8 i 1\n" |
106 | "11 e 1\n" | 106 | "11 e 1\n" |
107 | "0\n"; | 107 | "0\n"; |
108 | 108 | ||
109 | WordGame::WordGame( QWidget* parent, const char* name, WFlags fl ) : | 109 | WordGame::WordGame( QWidget* parent, const char* name, WFlags fl ) : |
110 | QMainWindow(parent, name, fl) | 110 | QMainWindow(parent, name, fl) |
111 | { | 111 | { |
112 | if ( qApp->desktop()->width() < 240 ) { | 112 | if ( qApp->desktop()->width() < 240 ) { |
113 | tile_smallw = 10; | 113 | tile_smallw = 10; |
114 | tile_smallh = 10; | 114 | tile_smallh = 10; |
115 | tile_bigw = 16; | 115 | tile_bigw = 16; |
116 | tile_bigh = 16; | 116 | tile_bigh = 16; |
117 | tile_stweak = 0; | 117 | tile_stweak = 0; |
118 | tile_btweak = 0; | 118 | tile_btweak = 0; |
119 | } | 119 | } |
120 | 120 | ||
121 | setIcon( Resource::loadPixmap( "wordgame/WordGame.png" ) ); | 121 | setIcon( Resource::loadPixmap( "wordgame/WordGame.png" ) ); |
122 | setCaption( tr("Word Game") ); | 122 | setCaption( tr("Word Game") ); |
123 | 123 | ||
124 | setToolBarsMovable( FALSE ); | 124 | setToolBarsMovable( FALSE ); |
125 | vbox = new QVBox(this); | 125 | vbox = new QVBox(this); |
126 | 126 | ||
127 | setCentralWidget(vbox); | 127 | setCentralWidget(vbox); |
128 | toolbar = new QToolBar(this); | 128 | toolbar = new QToolBar(this); |
129 | addToolBar(toolbar, Bottom); | 129 | addToolBar(toolbar, Bottom); |
130 | reset = new QToolButton(Resource::loadPixmap("back"), tr("Back"), "", this, SLOT(resetTurn()), toolbar); | 130 | reset = new QToolButton(Resource::loadPixmap("back"), tr("Back"), "", this, SLOT(resetTurn()), toolbar); |
131 | done = new QToolButton(Resource::loadPixmap("done"), tr("Done"), "", this, SLOT(endTurn()), toolbar); | 131 | done = new QToolButton(Resource::loadPixmap("done"), tr("Done"), "", this, SLOT(endTurn()), toolbar); |
132 | scoreinfo = new ScoreInfo(toolbar); | 132 | scoreinfo = new ScoreInfo(toolbar); |
133 | scoreinfo->setFont(QFont("Helvetica",10)); | 133 | scoreinfo->setFont(QFont("Helvetica",10)); |
134 | new QToolButton(Resource::loadPixmap("finish"), tr("Close"), "", this, SLOT(endGame()), toolbar); | 134 | new QToolButton(Resource::loadPixmap("finish"), tr("Close"), "", this, SLOT(endGame()), toolbar); |
135 | toolbar->setStretchableWidget(scoreinfo); | 135 | toolbar->setStretchableWidget(scoreinfo); |
136 | 136 | ||
137 | cpu = 0; | 137 | cpu = 0; |
138 | board = 0; | 138 | board = 0; |
139 | bag = 0; | 139 | bag = 0; |
140 | racks = 0; | 140 | racks = 0; |
141 | 141 | ||
142 | aiheart = new QTimer(this); | 142 | aiheart = new QTimer(this); |
143 | connect(aiheart, SIGNAL(timeout()), this, SLOT(think())); | 143 | connect(aiheart, SIGNAL(timeout()), this, SLOT(think())); |
144 | 144 | ||
145 | readConfig(); | 145 | readConfig(); |
146 | } | 146 | } |
147 | 147 | ||
148 | WordGame::~WordGame() | 148 | WordGame::~WordGame() |
149 | { | 149 | { |
150 | writeConfig(); | 150 | writeConfig(); |
151 | } | 151 | } |
152 | 152 | ||
153 | void WordGame::writeConfig() | 153 | void WordGame::writeConfig() |
154 | { | 154 | { |
155 | Config cfg("WordGame"); | 155 | Config cfg("WordGame"); |
156 | cfg.setGroup("Game"); | 156 | cfg.setGroup("Game"); |
157 | cfg.writeEntry("NameList",namelist,';'); | 157 | cfg.writeEntry("NameList",namelist,';'); |
158 | cfg.writeEntry("CurrentPlayer",gameover ? 0 : player+1); | 158 | cfg.writeEntry("CurrentPlayer",gameover ? 0 : player+1); |
159 | if ( !gameover ) { | 159 | if ( !gameover ) { |
160 | cfg.writeEntry("Rules",rules); | 160 | cfg.writeEntry("Rules",rules); |
161 | bag->writeConfig(cfg); | 161 | bag->writeConfig(cfg); |
162 | board->writeConfig(cfg); | 162 | board->writeConfig(cfg); |
163 | scoreinfo->writeConfig(cfg); | 163 | scoreinfo->writeConfig(cfg); |
164 | } | 164 | } |
165 | for (int p=0; p<nplayers; p++) { | 165 | for (int p=0; p<nplayers; p++) { |
166 | cfg.setGroup("Player"+QString::number(p+1)); | 166 | cfg.setGroup("Player"+QString::number(p+1)); |
167 | if ( gameover ) cfg.clearGroup(); else rack(p)->writeConfig(cfg); | 167 | if ( gameover ) cfg.clearGroup(); else rack(p)->writeConfig(cfg); |
168 | } | 168 | } |
169 | } | 169 | } |
170 | 170 | ||
171 | void WordGame::readConfig() | 171 | void WordGame::readConfig() |
172 | { | 172 | { |
173 | Config cfg("WordGame"); | 173 | Config cfg("WordGame"); |
174 | cfg.setGroup("Game"); | 174 | cfg.setGroup("Game"); |
175 | int currentplayer = cfg.readNumEntry("CurrentPlayer",0); | 175 | int currentplayer = cfg.readNumEntry("CurrentPlayer",0); |
176 | QStringList pnames = cfg.readListEntry("NameList",';'); | 176 | QStringList pnames = cfg.readListEntry("NameList",';'); |
177 | if ( currentplayer ) { | 177 | if ( currentplayer ) { |
178 | gameover = FALSE; | 178 | gameover = FALSE; |
179 | rules = cfg.readEntry("Rules"); | 179 | rules = cfg.readEntry("Rules"); |
180 | if ( rules.find("x-wordgamerules") >= 0 ) { | 180 | if ( rules.find("x-wordgamerules") >= 0 ) { |
181 | // rules files moved | 181 | // rules files moved |
182 | rules = "Sample.rules"; | 182 | rules = "Sample.rules"; |
183 | } | 183 | } |
184 | if ( loadRules(rules) ) { | 184 | if ( loadRules(rules) ) { |
185 | startGame(pnames); | 185 | startGame(pnames); |
186 | bag->readConfig(cfg); | 186 | bag->readConfig(cfg); |
187 | board->readConfig(cfg); | 187 | board->readConfig(cfg); |
188 | scoreinfo->readConfig(cfg); | 188 | scoreinfo->readConfig(cfg); |
189 | for (int p=0; p<nplayers; p++) { | 189 | for (int p=0; p<nplayers; p++) { |
190 | cfg.setGroup("Player"+QString::number(p+1)); | 190 | cfg.setGroup("Player"+QString::number(p+1)); |
191 | rack(p)->readConfig(cfg); | 191 | rack(p)->readConfig(cfg); |
192 | } | 192 | } |
193 | player=currentplayer-1; | 193 | player=currentplayer-1; |
194 | readyRack(player); | 194 | readyRack(player); |
195 | return; | 195 | return; |
196 | } | 196 | } |
197 | } | 197 | } |
198 | // fall-back | 198 | // fall-back |
199 | openGameSelector(pnames); | 199 | openGameSelector(pnames); |
200 | } | 200 | } |
201 | 201 | ||
202 | void WordGame::openGameSelector(const QStringList& initnames) | 202 | void WordGame::openGameSelector(const QStringList& initnames) |
203 | { | 203 | { |
204 | toolbar->hide(); | 204 | toolbar->hide(); |
205 | gameover = FALSE; | 205 | gameover = FALSE; |
206 | 206 | ||
207 | delete board; | 207 | delete board; |
208 | board = 0; | 208 | board = 0; |
209 | delete racks; | 209 | delete racks; |
210 | racks = 0; | 210 | racks = 0; |
211 | 211 | ||
212 | delete cpu; | 212 | delete cpu; |
213 | cpu = 0; | 213 | cpu = 0; |
214 | 214 | ||
215 | newgame = new NewGame(vbox); | 215 | newgame = new NewGame(vbox); |
216 | 216 | ||
217 | //Rules rules(this); | 217 | //Rules rules(this); |
218 | //connect(game.editrules, SIGNAL(clicked()), &rules, SLOT(editRules())); | 218 | //connect(game.editrules, SIGNAL(clicked()), &rules, SLOT(editRules())); |
219 | //connect(&rules, SIGNAL(rulesChanged()), &game, SLOT(updateRuleSets())); | 219 | //connect(&rules, SIGNAL(rulesChanged()), &game, SLOT(updateRuleSets())); |
220 | struct passwd* n = getpwuid(getuid()); | 220 | struct passwd* n = getpwuid(getuid()); |
221 | QString playername = n ? n->pw_name : ""; | 221 | QString playername = n ? n->pw_name : ""; |
222 | if ( playername.isEmpty() ) { | 222 | if ( playername.isEmpty() ) { |
223 | playername = "Player"; | 223 | playername = "Player"; |
224 | } | 224 | } |
225 | newgame->player0->changeItem(playername,0); | 225 | newgame->player0->changeItem(playername,0); |
226 | newgame->player1->setCurrentItem(1); | 226 | newgame->player1->setCurrentItem(1); |
227 | newgame->updateRuleSets(); | 227 | newgame->updateRuleSets(); |
228 | newgame->show(); | 228 | newgame->show(); |
229 | 229 | ||
230 | connect(newgame->buttonOk, SIGNAL(clicked()), this, SLOT(startGame())); | 230 | connect(newgame->buttonOk, SIGNAL(clicked()), this, SLOT(startGame())); |
231 | } | 231 | } |
232 | 232 | ||
233 | void WordGame::startGame() | 233 | void WordGame::startGame() |
234 | { | 234 | { |
235 | rules = newgame->ruleslist[newgame->rules->currentItem()]; | 235 | rules = newgame->ruleslist[newgame->rules->currentItem()]; |
236 | if ( loadRules(rules) ) { | 236 | if ( loadRules(rules) ) { |
237 | QStringList names; | 237 | QStringList names; |
238 | names.append(newgame->player0->currentText()); | 238 | names.append(newgame->player0->currentText()); |
239 | names.append(newgame->player1->currentText()); | 239 | names.append(newgame->player1->currentText()); |
240 | names.append(newgame->player2->currentText()); | 240 | names.append(newgame->player2->currentText()); |
241 | names.append(newgame->player3->currentText()); | 241 | names.append(newgame->player3->currentText()); |
242 | names.append(newgame->player4->currentText()); | 242 | names.append(newgame->player4->currentText()); |
243 | names.append(newgame->player5->currentText()); | 243 | names.append(newgame->player5->currentText()); |
244 | delete newgame; | 244 | delete newgame; |
245 | startGame(names); | 245 | startGame(names); |
246 | } else { | 246 | } else { |
247 | // error... | 247 | // error... |
248 | delete newgame; | 248 | delete newgame; |
249 | close(); | 249 | close(); |
250 | } | 250 | } |
251 | } | 251 | } |
252 | 252 | ||
253 | void WordGame::startGame(const QStringList& playerlist) | 253 | void WordGame::startGame(const QStringList& playerlist) |
254 | { | 254 | { |
255 | toolbar->show(); | 255 | toolbar->show(); |
256 | racks = new QWidgetStack(vbox); | 256 | racks = new QWidgetStack(vbox); |
257 | racks->setFixedHeight(TileItem::bigHeight()+2); | 257 | racks->setFixedHeight(TileItem::bigHeight()+2); |
258 | namelist.clear(); | 258 | namelist.clear(); |
259 | nplayers=0; | 259 | nplayers=0; |
260 | for (QStringList::ConstIterator it=playerlist.begin(); it!=playerlist.end(); ++it) | 260 | for (QStringList::ConstIterator it=playerlist.begin(); it!=playerlist.end(); ++it) |
261 | addPlayer(*it); | 261 | addPlayer(*it); |
262 | scoreinfo->init(namelist); | 262 | scoreinfo->init(namelist); |
263 | 263 | ||
264 | if ( nplayers ) { | 264 | if ( nplayers ) { |
265 | player=0; | 265 | player=0; |
266 | readyRack(player); | 266 | readyRack(player); |
267 | } | 267 | } |
268 | 268 | ||
269 | board->show(); | 269 | board->show(); |
270 | racks->show(); | 270 | racks->show(); |
271 | } | 271 | } |
272 | 272 | ||
273 | bool WordGame::loadRules(const QString &name) | 273 | bool WordGame::loadRules(const QString &name) |
274 | { | 274 | { |
275 | QString filename = Global::applicationFileName( "wordgame", name ); | 275 | QString filename = Global::applicationFileName( "wordgame", name ); |
276 | QFile file( filename ); | 276 | QFile file( filename ); |
277 | if ( !file.open( IO_ReadOnly ) ) | 277 | if ( !file.open( IO_ReadOnly ) ) |
278 | return FALSE; | 278 | return FALSE; |
279 | 279 | ||
280 | QTextStream ts( &file ); | 280 | QTextStream ts( &file ); |
281 | 281 | ||
282 | QString title = name; | 282 | QString title = name; |
283 | title.truncate( title.length() - 6 ); | 283 | title.truncate( title.length() - 6 ); |
284 | //setCaption( title ); | 284 | //setCaption( title ); |
285 | 285 | ||
286 | QString shapepixmap; | 286 | QString shapepixmap; |
287 | ts >> shapepixmap; | 287 | ts >> shapepixmap; |
288 | int htiles,vtiles; | 288 | int htiles,vtiles; |
289 | ts >> htiles >> vtiles; | 289 | ts >> htiles >> vtiles; |
290 | 290 | ||
291 | if ( htiles < 3 || vtiles < 3 ) | 291 | if ( htiles < 3 || vtiles < 3 ) |
292 | return FALSE; | 292 | return FALSE; |
293 | 293 | ||
294 | QString rule_shapes; | 294 | QString rule_shapes; |
295 | for (int i=0; i<vtiles; i++) { | 295 | for (int i=0; i<vtiles; i++) { |
296 | QString line; | 296 | QString line; |
297 | ts >> line; | 297 | ts >> line; |
298 | rule_shapes += line; | 298 | rule_shapes += line; |
299 | } | 299 | } |
300 | static int rule_effects[12]; | 300 | static int rule_effects[12]; |
301 | int re=0,e; | 301 | int re=0,e; |
302 | ts >> e; | 302 | ts >> e; |
303 | while ( e && re < 10 ) { | 303 | while ( e && re < 10 ) { |
304 | rule_effects[re] = e; | 304 | rule_effects[re] = e; |
305 | if ( re++ < 10 ) ts >> e; | 305 | if ( re++ < 10 ) ts >> e; |
306 | } | 306 | } |
307 | 307 | ||
308 | QImage shim = Resource::loadImage("wordgame/wordgame_shapes"); | 308 | QImage shim = Resource::loadImage("wordgame/wordgame_shapes"); |
309 | shim = shim.smoothScale((re-1)*TileItem::smallWidth(),TileItem::smallHeight()); | 309 | shim = shim.smoothScale((re-1)*TileItem::smallWidth(),TileItem::smallHeight()); |
310 | QPixmap bgshapes; | 310 | QPixmap bgshapes; |
311 | bgshapes.convertFromImage(shim); | 311 | bgshapes.convertFromImage(shim); |
312 | 312 | ||
313 | rule_effects[re++] = 100; // default bonus | 313 | rule_effects[re++] = 100; // default bonus |
314 | board = new Board(bgshapes, htiles, vtiles, vbox); | 314 | board = new Board(bgshapes, htiles, vtiles, vbox); |
315 | board->setRules(rule_shapes, rule_effects); | 315 | board->setRules(rule_shapes, rule_effects); |
316 | connect(board, SIGNAL(temporaryScore(int)), scoreinfo, SLOT(showTemporaryScore(int))); | 316 | connect(board, SIGNAL(temporaryScore(int)), scoreinfo, SLOT(showTemporaryScore(int))); |
317 | 317 | ||
318 | bag = new Bag; | 318 | bag = new Bag; |
319 | 319 | ||
320 | int count; | 320 | int count; |
321 | ts >> count; | 321 | ts >> count; |
322 | while ( count ) { | 322 | while ( count ) { |
323 | QString text; | 323 | QString text; |
324 | int value; | 324 | int value; |
325 | ts >> text >> value; | 325 | ts >> text >> value; |
326 | if ( text == "_" ) | 326 | if ( text == "_" ) |
327 | text = ""; | 327 | text = ""; |
328 | 328 | ||
329 | Tile t(text, value); | 329 | Tile t(text, value); |
330 | for (int n=count; n--; ) | 330 | for (int n=count; n--; ) |
331 | bag->add(t); | 331 | bag->add(t); |
332 | 332 | ||
333 | ts >> count; | 333 | ts >> count; |
334 | } | 334 | } |
335 | 335 | ||
336 | return TRUE; | 336 | return TRUE; |
337 | } | 337 | } |
338 | 338 | ||
339 | 339 | ||
340 | NewGame::NewGame(QWidget* parent) : | 340 | NewGame::NewGame(QWidget* parent) : |
341 | NewGameBase(parent) | 341 | NewGameBase(parent) |
342 | { | 342 | { |
343 | } | 343 | } |
344 | 344 | ||
345 | void NewGame::updateRuleSets() | 345 | void NewGame::updateRuleSets() |
346 | { | 346 | { |
347 | rules->clear(); | 347 | rules->clear(); |
348 | 348 | ||
349 | QString rulesDir = Global::applicationFileName( "wordgame", "" ); | 349 | QString rulesDir = Global::applicationFileName( "wordgame", "" ); |
350 | QDir dir( rulesDir, "*.rules" ); | 350 | QDir dir( rulesDir, "*.rules" ); |
351 | ruleslist = dir.entryList(); | 351 | ruleslist = dir.entryList(); |
352 | if ( ruleslist.isEmpty() ) { | 352 | if ( ruleslist.isEmpty() ) { |
353 | // Provide a sample | 353 | // Provide a sample |
354 | QFile file( rulesDir + "Sample.rules" ); | 354 | QFile file( rulesDir + "Sample.rules" ); |
355 | if ( file.open( IO_WriteOnly ) ) { | 355 | if ( file.open( IO_WriteOnly ) ) { |
356 | file.writeBlock( sampleWGR, strlen(sampleWGR) ); | 356 | file.writeBlock( sampleWGR, strlen(sampleWGR) ); |
357 | file.close(); | 357 | file.close(); |
358 | updateRuleSets(); | 358 | updateRuleSets(); |
359 | } | 359 | } |
360 | return; | 360 | return; |
361 | } | 361 | } |
362 | int newest=0; | 362 | int newest=0; |
363 | int newest_age=INT_MAX; | 363 | int newest_age=INT_MAX; |
364 | QDateTime now = QDateTime::currentDateTime(); | 364 | QDateTime now = QDateTime::currentDateTime(); |
365 | QStringList::Iterator it; | 365 | QStringList::Iterator it; |
366 | for ( it = ruleslist.begin(); it != ruleslist.end(); ++it ) { | 366 | for ( it = ruleslist.begin(); it != ruleslist.end(); ++it ) { |
367 | QFileInfo fi((*it)); | 367 | QFileInfo fi((*it)); |
368 | int age = fi.lastModified().secsTo(now); | 368 | int age = fi.lastModified().secsTo(now); |
369 | QString name = *it; | 369 | QString name = *it; |
370 | name.truncate( name.length()-6 ); // remove extension | 370 | name.truncate( name.length()-6 ); // remove extension |
371 | rules->insertItem( name ); | 371 | rules->insertItem( name ); |
372 | if ( age < newest_age ) { | 372 | if ( age < newest_age ) { |
373 | newest_age = age; | 373 | newest_age = age; |
374 | newest = rules->count()-1; | 374 | newest = rules->count()-1; |
375 | } | 375 | } |
376 | } | 376 | } |
377 | rules->setCurrentItem(newest); | 377 | rules->setCurrentItem(newest); |
378 | } | 378 | } |
379 | 379 | ||
380 | Rules::Rules(QWidget* parent) : | 380 | Rules::Rules(QWidget* parent) : |
381 | RulesBase(parent,0,TRUE) | 381 | RulesBase(parent,0,TRUE) |
382 | { | 382 | { |
383 | } | 383 | } |
384 | 384 | ||
385 | void Rules::editRules() | 385 | void Rules::editRules() |
386 | { | 386 | { |
387 | if ( exec() ) { | 387 | if ( exec() ) { |
388 | // ### create a new set of rules | 388 | // ### create a new set of rules |
389 | emit rulesChanged(); | 389 | emit rulesChanged(); |
390 | } | 390 | } |
391 | } | 391 | } |
392 | 392 | ||
393 | void Rules::deleteRuleSet() | 393 | void Rules::deleteRuleSet() |
394 | { | 394 | { |
395 | // ### delete existing rule set | 395 | // ### delete existing rule set |
396 | emit rulesChanged(); | 396 | emit rulesChanged(); |
397 | } | 397 | } |
398 | 398 | ||
399 | void WordGame::addPlayer(const QString& name) | 399 | void WordGame::addPlayer(const QString& name) |
400 | { | 400 | { |
401 | if ( !name.isEmpty() ) { | 401 | if ( !name.isEmpty() ) { |
402 | int colon = name.find(':'); | 402 | int colon = name.find(':'); |
403 | int cpu = (colon >=0 && name.left(2) == "AI") ? name.mid(2,1).toInt() : 0; | 403 | int cpu = (colon >=0 && name.left(2) == "AI") ? name.mid(2,1).toInt() : 0; |
404 | addPlayer(name,cpu); | 404 | addPlayer(name,cpu); |
405 | } | 405 | } |
406 | } | 406 | } |
407 | 407 | ||
408 | void WordGame::addPlayer(const QString& name, int cpu) | 408 | void WordGame::addPlayer(const QString& name, int cpu) |
409 | { | 409 | { |
410 | Rack* r = new Rack(rack_tiles,racks); | 410 | Rack* r = new Rack(rack_tiles,racks); |
411 | r->setPlayerName(name); | 411 | r->setPlayerName(name); |
412 | r->setComputerization(cpu); | 412 | r->setComputerization(cpu); |
413 | racks->addWidget(r, nplayers); | 413 | racks->addWidget(r, nplayers); |
414 | refillRack(nplayers); | 414 | refillRack(nplayers); |
415 | namelist.append(name); | 415 | namelist.append(name); |
416 | 416 | ||
417 | ++nplayers; | 417 | ++nplayers; |
418 | } | 418 | } |
419 | 419 | ||
420 | void WordGame::nextPlayer() | 420 | void WordGame::nextPlayer() |
421 | { | 421 | { |
422 | if ( !refillRack(player) ) { | 422 | if ( !refillRack(player) ) { |
423 | endGame(); | 423 | endGame(); |
424 | } else { | 424 | } else { |
425 | player = (player+1)%nplayers; | 425 | player = (player+1)%nplayers; |
426 | scoreinfo->setBoldOne(player); | 426 | scoreinfo->setBoldOne(player); |
427 | readyRack(player); | 427 | readyRack(player); |
428 | } | 428 | } |
429 | } | 429 | } |
430 | 430 | ||
431 | bool WordGame::mayEndGame() | 431 | bool WordGame::mayEndGame() |
432 | { | 432 | { |
433 | int out=-1; | 433 | int out=-1; |
434 | int i; | 434 | int i; |
435 | for (i=0; i<nplayers; i++) | 435 | for (i=0; i<nplayers; i++) |
436 | if ( !rack(i)->count() ) | 436 | if ( !rack(i)->count() ) |
437 | out = i; | 437 | out = i; |
438 | if ( out<0 ) { | 438 | if ( out<0 ) { |
439 | if ( QMessageBox::warning(this,tr("End game"), | 439 | if ( QMessageBox::warning(this,tr("End game"), |
440 | tr("Do you want to end the game early?"), | 440 | tr("Do you want to end the game early?"), |
441 | tr("Yes"), tr("No") )!=0 ) | 441 | tr("Yes"), tr("No") )!=0 ) |
442 | { | 442 | { |
443 | return FALSE; | 443 | return FALSE; |
444 | } | 444 | } |
445 | } | 445 | } |
446 | return TRUE; | 446 | return TRUE; |
447 | } | 447 | } |
448 | 448 | ||
449 | void WordGame::endGame() | 449 | void WordGame::endGame() |
450 | { | 450 | { |
451 | if ( gameover ) { | 451 | if ( gameover ) { |
452 | close(); | 452 | close(); |
453 | return; | 453 | return; |
454 | } | 454 | } |
455 | 455 | ||
456 | if ( !mayEndGame() ) | 456 | if ( !mayEndGame() ) |
457 | return; | 457 | return; |
458 | int out=-1; | 458 | int out=-1; |
459 | int totalleft=0; | 459 | int totalleft=0; |
460 | int i; | 460 | int i; |
461 | for (i=0; i<nplayers; i++) { | 461 | for (i=0; i<nplayers; i++) { |
462 | Rack* r = rack(i); | 462 | Rack* r = rack(i); |
463 | int c = r->count(); | 463 | int c = r->count(); |
464 | if ( c ) { | 464 | if ( c ) { |
465 | int lose=0; | 465 | int lose=0; |
466 | for ( int j=0; j<c; j++ ) | 466 | for ( int j=0; j<c; j++ ) |
467 | lose += r->tileRef(j)->value(); | 467 | lose += r->tileRef(j)->value(); |
468 | totalleft += lose; | 468 | totalleft += lose; |
469 | scoreinfo->addScore(i,-lose); | 469 | scoreinfo->addScore(i,-lose); |
470 | } else { | 470 | } else { |
471 | out = i; | 471 | out = i; |
472 | } | 472 | } |
473 | } | 473 | } |
474 | int highest=0; | 474 | int highest=0; |
475 | int winner=0; | 475 | int winner=0; |
476 | for (i=0; i<nplayers; i++) { | 476 | for (i=0; i<nplayers; i++) { |
477 | int s = scoreinfo->playerScore(i); | 477 | int s = scoreinfo->playerScore(i); |
478 | if ( s > highest ) { | 478 | if ( s > highest ) { |
479 | highest = s; | 479 | highest = s; |
480 | winner = i; | 480 | winner = i; |
481 | } | 481 | } |
482 | } | 482 | } |
483 | if ( out >= 0 ) | 483 | if ( out >= 0 ) |
484 | scoreinfo->addScore(out,totalleft); | 484 | scoreinfo->addScore(out,totalleft); |
485 | scoreinfo->setBoldOne(winner); | 485 | scoreinfo->setBoldOne(winner); |
486 | gameover = TRUE; | 486 | gameover = TRUE; |
487 | done->setEnabled(TRUE); | 487 | done->setEnabled(TRUE); |
488 | reset->setEnabled(FALSE); | 488 | reset->setEnabled(FALSE); |
489 | } | 489 | } |
490 | 490 | ||
491 | void WordGame::endTurn() | 491 | void WordGame::endTurn() |
492 | { | 492 | { |
493 | if ( gameover ) { | 493 | if ( gameover ) { |
494 | openGameSelector(namelist); | 494 | openGameSelector(namelist); |
495 | } else { | 495 | } else { |
496 | if ( board->checkTurn() ) { | 496 | if ( board->checkTurn() ) { |
497 | if ( board->turnScore() >= 0 ) { | 497 | if ( board->turnScore() >= 0 ) { |
498 | scoreinfo->addScore(player,board->turnScore()); | 498 | scoreinfo->addScore(player,board->turnScore()); |
499 | board->finalizeTurn(); | 499 | board->finalizeTurn(); |
500 | } else { | 500 | } else { |
501 | QApplication::beep(); | 501 | QApplication::beep(); |
502 | } | 502 | } |
503 | nextPlayer(); | 503 | nextPlayer(); |
504 | } | 504 | } |
505 | } | 505 | } |
506 | } | 506 | } |
507 | 507 | ||
508 | void WordGame::resetTurn() | 508 | void WordGame::resetTurn() |
509 | { | 509 | { |
510 | board->resetRack(); | 510 | board->resetRack(); |
511 | } | 511 | } |
512 | 512 | ||
513 | void WordGame::passTurn() | 513 | void WordGame::passTurn() |
514 | { | 514 | { |
515 | // ######## trade? | 515 | // ######## trade? |
516 | nextPlayer(); | 516 | nextPlayer(); |
517 | } | 517 | } |
518 | 518 | ||
519 | bool WordGame::refillRack(int i) | 519 | bool WordGame::refillRack(int i) |
520 | { | 520 | { |
521 | Rack* r = rack(i); | 521 | Rack* r = rack(i); |
522 | while ( !bag->isEmpty() && !r->isFull() ) { | 522 | while ( !bag->isEmpty() && !r->isFull() ) { |
523 | r->addTile(bag->takeRandom()); | 523 | r->addTile(bag->takeRandom()); |
524 | } | 524 | } |
525 | return r->count() != 0; | 525 | return r->count() != 0; |
526 | } | 526 | } |
527 | 527 | ||
528 | void WordGame::readyRack(int i) | 528 | void WordGame::readyRack(int i) |
529 | { | 529 | { |
530 | Rack* r = rack(i); | 530 | Rack* r = rack(i); |
531 | racks->raiseWidget(i); | 531 | racks->raiseWidget(i); |
532 | board->setCurrentRack(r); | 532 | board->setCurrentRack(r); |
533 | 533 | ||
534 | done->setEnabled( !r->computerized() ); | 534 | done->setEnabled( !r->computerized() ); |
535 | reset->setEnabled( !r->computerized() ); | 535 | reset->setEnabled( !r->computerized() ); |
536 | 536 | ||
537 | if ( r->computerized() ) { | 537 | if ( r->computerized() ) { |
538 | cpu = new ComputerPlayer(board, r); | 538 | cpu = new ComputerPlayer(board, r); |
539 | aiheart->start(0); | 539 | aiheart->start(0); |
540 | } | 540 | } |
541 | } | 541 | } |
542 | 542 | ||
543 | Rack* WordGame::rack(int i) const | 543 | Rack* WordGame::rack(int i) const |
544 | { | 544 | { |
545 | return (Rack*)racks->widget(i); | 545 | return (Rack*)racks->widget(i); |
546 | } | 546 | } |
547 | 547 | ||
548 | void WordGame::think() | 548 | void WordGame::think() |
diff --git a/noncore/games/zlines/main.cpp b/noncore/games/zlines/main.cpp index d1709e4..8d80bae 100644 --- a/noncore/games/zlines/main.cpp +++ b/noncore/games/zlines/main.cpp | |||
@@ -1,28 +1,29 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | main.cpp - description | 2 | main.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Fri May 19 2000 | 4 | begin : Fri May 19 2000 |
5 | copyright : (C) 2000 by Roman Merzlyakov | 5 | copyright : (C) 2000 by Roman Merzlyakov |
6 | email : roman@sbrf.barrt.ru | 6 | email : roman@sbrf.barrt.ru |
7 | copyright : (C) 2000 by Roman Razilov | 7 | copyright : (C) 2000 by Roman Razilov |
8 | email : Roman.Razilov@gmx.de | 8 | email : Roman.Razilov@gmx.de |
9 | ***************************************************************************/ | 9 | ***************************************************************************/ |
10 | 10 | ||
11 | /*************************************************************************** | 11 | /*************************************************************************** |
12 | * * | 12 | * * |
13 | * This program is free software; you can redistribute it and/or modify * | 13 | * This program is free software; you can redistribute it and/or modify * |
14 | * it under the terms of the GNU General Public License as published by * | 14 | * it under the terms of the GNU General Public License as published by * |
15 | * the Free Software Foundation; either version 2 of the License, or * | 15 | * the Free Software Foundation; either version 2 of the License, or * |
16 | * (at your option) any later version. * | 16 | * (at your option) any later version. * |
17 | * * | 17 | * * |
18 | ***************************************************************************/ | 18 | ***************************************************************************/ |
19 | /* | 19 | /* |
20 | * Roman Razilov 2000-05-19 debug dummmy | 20 | * Roman Razilov 2000-05-19 debug dummmy |
21 | * Roman Razilov 2000-05-21 qimgio | 21 | * Roman Razilov 2000-05-21 qimgio |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include "klines.h" | 24 | #include "klines.h" |
25 | 25 | ||
26 | #include <opie2/oapplicationfactory.h> | 26 | #include <opie2/oapplicationfactory.h> |
27 | 27 | ||
28 | using namespace Opie::Core; | ||
28 | OPIE_EXPORT_APP( OApplicationFactory<KLines> ) | 29 | OPIE_EXPORT_APP( OApplicationFactory<KLines> ) |
diff --git a/noncore/games/zsame/ZSameWidget.cpp b/noncore/games/zsame/ZSameWidget.cpp index 3c58c93..4fab0f6 100644 --- a/noncore/games/zsame/ZSameWidget.cpp +++ b/noncore/games/zsame/ZSameWidget.cpp | |||
@@ -1,243 +1,244 @@ | |||
1 | /* Yo Emacs, this is -*- C++ -*- */ | 1 | /* Yo Emacs, this is -*- C++ -*- */ |
2 | /* | 2 | /* |
3 | * ksame 0.4 - simple Game | 3 | * ksame 0.4 - simple Game |
4 | * Copyright (C) 1997,1998 Marcus Kreutzberger | 4 | * Copyright (C) 1997,1998 Marcus Kreutzberger |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or | 8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. | 9 | * (at your option) any later version. |
10 | * | 10 | * |
11 | * This program is distributed in the hope that it will be useful, | 11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. | 14 | * GNU General Public License for more details. |
15 | * | 15 | * |
16 | * You should have received a copy of the GNU General Public License | 16 | * You should have received a copy of the GNU General Public License |
17 | * along with this program; if not, write to the Free Software | 17 | * along with this program; if not, write to the Free Software |
18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <stdio.h> | 22 | #include <stdio.h> |
23 | 23 | ||
24 | #include <opie2/oapplicationfactory.h> | 24 | #include <opie2/oapplicationfactory.h> |
25 | 25 | ||
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | 27 | ||
28 | #include <qtoolbar.h> | 28 | #include <qtoolbar.h> |
29 | #include <qmenubar.h> | 29 | #include <qmenubar.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | #include <qaction.h> | 31 | #include <qaction.h> |
32 | #include <qmessagebox.h> | 32 | #include <qmessagebox.h> |
33 | 33 | ||
34 | #include <kapplication.h> | 34 | #include <kapplication.h> |
35 | 35 | ||
36 | #include "ZSameWidget.h" | 36 | #include "ZSameWidget.h" |
37 | 37 | ||
38 | static int default_colors=3; | 38 | static int default_colors=3; |
39 | 39 | ||
40 | #define i18n tr | 40 | #define i18n tr |
41 | 41 | ||
42 | 42 | ||
43 | using namespace Opie::Core; | ||
43 | OPIE_EXPORT_APP( OApplicationFactory<ZSameWidget> ) | 44 | OPIE_EXPORT_APP( OApplicationFactory<ZSameWidget> ) |
44 | 45 | ||
45 | 46 | ||
46 | 47 | ||
47 | ZSameWidget::ZSameWidget( QWidget* parent, const char* name, WFlags fl ) | 48 | ZSameWidget::ZSameWidget( QWidget* parent, const char* name, WFlags fl ) |
48 | : QMainWindow( parent, name, fl ) | 49 | : QMainWindow( parent, name, fl ) |
49 | { | 50 | { |
50 | setCaption(tr("ZSame")); | 51 | setCaption(tr("ZSame")); |
51 | 52 | ||
52 | setToolBarsMovable( false ); | 53 | setToolBarsMovable( false ); |
53 | QToolBar* con = new QToolBar( this ); | 54 | QToolBar* con = new QToolBar( this ); |
54 | con->setHorizontalStretchable( true ); | 55 | con->setHorizontalStretchable( true ); |
55 | QMenuBar* mb = new QMenuBar( con ); | 56 | QMenuBar* mb = new QMenuBar( con ); |
56 | QToolBar* tb = new QToolBar( this ); | 57 | QToolBar* tb = new QToolBar( this ); |
57 | 58 | ||
58 | QPopupMenu* fileMenu = new QPopupMenu( this ); | 59 | QPopupMenu* fileMenu = new QPopupMenu( this ); |
59 | 60 | ||
60 | QAction* a = new QAction(tr("New Game"), Resource::loadIconSet("new") , | 61 | QAction* a = new QAction(tr("New Game"), Resource::loadIconSet("new") , |
61 | QString::null, 0, this, "new_icon"); | 62 | QString::null, 0, this, "new_icon"); |
62 | a->addTo( fileMenu ); | 63 | a->addTo( fileMenu ); |
63 | a->addTo( tb ); | 64 | a->addTo( tb ); |
64 | connect(a, SIGNAL(activated()), this, SLOT(m_new())); | 65 | connect(a, SIGNAL(activated()), this, SLOT(m_new())); |
65 | 66 | ||
66 | a = new QAction(tr("Restart This Board"), Resource::loadIconSet("redo"), | 67 | a = new QAction(tr("Restart This Board"), Resource::loadIconSet("redo"), |
67 | QString::null, 0, this, "restart_board" ); | 68 | QString::null, 0, this, "restart_board" ); |
68 | a->addTo( fileMenu ); | 69 | a->addTo( fileMenu ); |
69 | connect( a, SIGNAL(activated()), this, SLOT(m_restart())); | 70 | connect( a, SIGNAL(activated()), this, SLOT(m_restart())); |
70 | restart = a; | 71 | restart = a; |
71 | 72 | ||
72 | a = new QAction( tr("Undo"), Resource::loadIconSet("undo"), | 73 | a = new QAction( tr("Undo"), Resource::loadIconSet("undo"), |
73 | QString::null, 0, this, "undo_action" ); | 74 | QString::null, 0, this, "undo_action" ); |
74 | a->addTo( fileMenu ); | 75 | a->addTo( fileMenu ); |
75 | a->addTo( tb ); | 76 | a->addTo( tb ); |
76 | connect( a, SIGNAL(activated()), this, SLOT(m_undo())); | 77 | connect( a, SIGNAL(activated()), this, SLOT(m_undo())); |
77 | 78 | ||
78 | a = new QAction(tr("Quit"), Resource::loadIconSet("quit_icon"), | 79 | a = new QAction(tr("Quit"), Resource::loadIconSet("quit_icon"), |
79 | QString::null, 0, this, "quit_action"); | 80 | QString::null, 0, this, "quit_action"); |
80 | a->addTo( fileMenu ); | 81 | a->addTo( fileMenu ); |
81 | a->addTo( tb ); | 82 | a->addTo( tb ); |
82 | connect(a, SIGNAL(activated()), this, SLOT(m_quit())); | 83 | connect(a, SIGNAL(activated()), this, SLOT(m_quit())); |
83 | 84 | ||
84 | mb->insertItem(tr("Game" ), fileMenu ); | 85 | mb->insertItem(tr("Game" ), fileMenu ); |
85 | 86 | ||
86 | int foo[2]; | 87 | int foo[2]; |
87 | desktop_widget(foo); | 88 | desktop_widget(foo); |
88 | stone = new StoneWidget(this,foo[0],foo[1]); | 89 | stone = new StoneWidget(this,foo[0],foo[1]); |
89 | 90 | ||
90 | connect( stone, SIGNAL(s_gameover()), this, SLOT(gameover())); | 91 | connect( stone, SIGNAL(s_gameover()), this, SLOT(gameover())); |
91 | 92 | ||
92 | connect( stone, SIGNAL(s_colors(int)), this, SLOT(setColors(int))); | 93 | connect( stone, SIGNAL(s_colors(int)), this, SLOT(setColors(int))); |
93 | connect( stone, SIGNAL(s_board(int)), this, SLOT(setBoard(int))); | 94 | connect( stone, SIGNAL(s_board(int)), this, SLOT(setBoard(int))); |
94 | connect( stone, SIGNAL(s_marked(int)), this, SLOT(setMarked(int))); | 95 | connect( stone, SIGNAL(s_marked(int)), this, SLOT(setMarked(int))); |
95 | connect( stone, SIGNAL(s_score(int)), this, SLOT(setScore(int))); | 96 | connect( stone, SIGNAL(s_score(int)), this, SLOT(setScore(int))); |
96 | connect( stone, SIGNAL(s_remove(int,int)), this, SLOT(stonesRemoved(int,int))); | 97 | connect( stone, SIGNAL(s_remove(int,int)), this, SLOT(stonesRemoved(int,int))); |
97 | 98 | ||
98 | connect(stone, SIGNAL(s_sizechanged()), this, SLOT(sizeChanged())); | 99 | connect(stone, SIGNAL(s_sizechanged()), this, SLOT(sizeChanged())); |
99 | 100 | ||
100 | sizeChanged(); | 101 | sizeChanged(); |
101 | setCentralWidget(stone); | 102 | setCentralWidget(stone); |
102 | 103 | ||
103 | 104 | ||
104 | setScore(0); | 105 | setScore(0); |
105 | } | 106 | } |
106 | 107 | ||
107 | ZSameWidget::~ZSameWidget() { | 108 | ZSameWidget::~ZSameWidget() { |
108 | 109 | ||
109 | } | 110 | } |
110 | 111 | ||
111 | void ZSameWidget::readProperties(Config *conf) { | 112 | void ZSameWidget::readProperties(Config *conf) { |
112 | /* | 113 | /* |
113 | Q_ASSERT(conf); | 114 | Q_ASSERT(conf); |
114 | stone->readProperties(conf); | 115 | stone->readProperties(conf); |
115 | */ | 116 | */ |
116 | } | 117 | } |
117 | 118 | ||
118 | void ZSameWidget::saveProperties(Config *conf) { | 119 | void ZSameWidget::saveProperties(Config *conf) { |
119 | /* | 120 | /* |
120 | Q_ASSERT(conf); | 121 | Q_ASSERT(conf); |
121 | stone->saveProperties(conf); | 122 | stone->saveProperties(conf); |
122 | conf->sync(); | 123 | conf->sync(); |
123 | */ | 124 | */ |
124 | } | 125 | } |
125 | 126 | ||
126 | void ZSameWidget::sizeChanged() { | 127 | void ZSameWidget::sizeChanged() { |
127 | //stone->setFixedSize(stone->sizeHint()); | 128 | //stone->setFixedSize(stone->sizeHint()); |
128 | } | 129 | } |
129 | 130 | ||
130 | void ZSameWidget::newGame(unsigned int board,int colors) { | 131 | void ZSameWidget::newGame(unsigned int board,int colors) { |
131 | while (board>=1000000) board-=1000000; | 132 | while (board>=1000000) board-=1000000; |
132 | // kdDebug() << "newgame board " << board << " colors " << colors << endl; | 133 | // kdDebug() << "newgame board " << board << " colors " << colors << endl; |
133 | stone->newGame(board,colors); | 134 | stone->newGame(board,colors); |
134 | setScore(0); | 135 | setScore(0); |
135 | } | 136 | } |
136 | 137 | ||
137 | bool ZSameWidget::confirmAbort() { | 138 | bool ZSameWidget::confirmAbort() { |
138 | return stone->isGameover() || | 139 | return stone->isGameover() || |
139 | stone->isOriginalBoard() || | 140 | stone->isOriginalBoard() || |
140 | (QMessageBox::warning(this, i18n("Resign"), i18n("<qt>Do you want to resign?</qt>"), | 141 | (QMessageBox::warning(this, i18n("Resign"), i18n("<qt>Do you want to resign?</qt>"), |
141 | QMessageBox::Yes, | 142 | QMessageBox::Yes, |
142 | QMessageBox::No|QMessageBox::Default|QMessageBox::Escape, 0) == QMessageBox::Yes ); | 143 | QMessageBox::No|QMessageBox::Default|QMessageBox::Escape, 0) == QMessageBox::Yes ); |
143 | } | 144 | } |
144 | 145 | ||
145 | void ZSameWidget::m_new() { | 146 | void ZSameWidget::m_new() { |
146 | if (confirmAbort()) | 147 | if (confirmAbort()) |
147 | newGame(_random(),default_colors); | 148 | newGame(_random(),default_colors); |
148 | 149 | ||
149 | } | 150 | } |
150 | 151 | ||
151 | void ZSameWidget::m_restart() { | 152 | void ZSameWidget::m_restart() { |
152 | if (confirmAbort()) | 153 | if (confirmAbort()) |
153 | newGame(stone->board(),default_colors); | 154 | newGame(stone->board(),default_colors); |
154 | } | 155 | } |
155 | 156 | ||
156 | void ZSameWidget::m_load() { | 157 | void ZSameWidget::m_load() { |
157 | // kdDebug() << "menu load not supported" << endl; | 158 | // kdDebug() << "menu load not supported" << endl; |
158 | } | 159 | } |
159 | 160 | ||
160 | void ZSameWidget::m_save() { | 161 | void ZSameWidget::m_save() { |
161 | // kdDebug() << "menu save not supported" << endl; | 162 | // kdDebug() << "menu save not supported" << endl; |
162 | } | 163 | } |
163 | 164 | ||
164 | void ZSameWidget::m_undo() { | 165 | void ZSameWidget::m_undo() { |
165 | //Q_ASSERT(stone); | 166 | //Q_ASSERT(stone); |
166 | stone->undo(); | 167 | stone->undo(); |
167 | } | 168 | } |
168 | 169 | ||
169 | 170 | ||
170 | void ZSameWidget::m_showhs() { | 171 | void ZSameWidget::m_showhs() { |
171 | /* Q_ASSERT(stone); | 172 | /* Q_ASSERT(stone); |
172 | stone->unmark(); | 173 | stone->unmark(); |
173 | KScoreDialog d(KScoreDialog::Name | KScoreDialog::Score, this); | 174 | KScoreDialog d(KScoreDialog::Name | KScoreDialog::Score, this); |
174 | d.addField(Board, i18n("Board"), "Board"); | 175 | d.addField(Board, i18n("Board"), "Board"); |
175 | d.exec(); | 176 | d.exec(); |
176 | */ | 177 | */ |
177 | } | 178 | } |
178 | 179 | ||
179 | void ZSameWidget::m_quit() { | 180 | void ZSameWidget::m_quit() { |
180 | // Q_ASSERT(stone); | 181 | // Q_ASSERT(stone); |
181 | stone->unmark(); | 182 | stone->unmark(); |
182 | qApp->quit(); | 183 | qApp->quit(); |
183 | // delete this; | 184 | // delete this; |
184 | } | 185 | } |
185 | 186 | ||
186 | void ZSameWidget::m_tglboard() { | 187 | void ZSameWidget::m_tglboard() { |
187 | //kdDebug() << "toggled" << endl; | 188 | //kdDebug() << "toggled" << endl; |
188 | } | 189 | } |
189 | 190 | ||
190 | 191 | ||
191 | void ZSameWidget::setColors(int colors) { | 192 | void ZSameWidget::setColors(int colors) { |
192 | //status->changeItem(i18n("%1 Colors").arg(colors),1); | 193 | //status->changeItem(i18n("%1 Colors").arg(colors),1); |
193 | } | 194 | } |
194 | 195 | ||
195 | void ZSameWidget::setBoard(int board) { | 196 | void ZSameWidget::setBoard(int board) { |
196 | //status->changeItem(i18n("Board: %1").arg(board, 6), 2); | 197 | //status->changeItem(i18n("Board: %1").arg(board, 6), 2); |
197 | } | 198 | } |
198 | 199 | ||
199 | void ZSameWidget::setMarked(int m) { | 200 | void ZSameWidget::setMarked(int m) { |
200 | // status->changeItem(i18n("Marked: %1").arg(m, 6),3); | 201 | // status->changeItem(i18n("Marked: %1").arg(m, 6),3); |
201 | } | 202 | } |
202 | 203 | ||
203 | void ZSameWidget::stonesRemoved(int,int) { | 204 | void ZSameWidget::stonesRemoved(int,int) { |
204 | //KNotifyClient::event("stones removed", | 205 | //KNotifyClient::event("stones removed", |
205 | // i18n("%1 stones removed.").arg(stone->marked())); | 206 | // i18n("%1 stones removed.").arg(stone->marked())); |
206 | } | 207 | } |
207 | 208 | ||
208 | void ZSameWidget::setScore(int score) { | 209 | void ZSameWidget::setScore(int score) { |
209 | // status->changeItem(i18n("Score: %1").arg(score, 6),4); | 210 | // status->changeItem(i18n("Score: %1").arg(score, 6),4); |
210 | // undo->setEnabled(stone->undoPossible()); | 211 | // undo->setEnabled(stone->undoPossible()); |
211 | // restart->setEnabled(!stone->isOriginalBoard()); | 212 | // restart->setEnabled(!stone->isOriginalBoard()); |
212 | } | 213 | } |
213 | 214 | ||
214 | void ZSameWidget::gameover() { | 215 | void ZSameWidget::gameover() { |
215 | // kdDebug() << "GameOver" << endl; | 216 | // kdDebug() << "GameOver" << endl; |
216 | if (stone->hasBonus()) { | 217 | if (stone->hasBonus()) { |
217 | QMessageBox::information(this,i18n("Game won"), | 218 | QMessageBox::information(this,i18n("Game won"), |
218 | i18n("<qt>You even removed the last stone, great job! " | 219 | i18n("<qt>You even removed the last stone, great job! " |
219 | "This gave you a score of %1 in total.</qt>").arg(stone->score())); | 220 | "This gave you a score of %1 in total.</qt>").arg(stone->score())); |
220 | } else { | 221 | } else { |
221 | QMessageBox::information(this,i18n("Game over"), | 222 | QMessageBox::information(this,i18n("Game over"), |
222 | i18n("<qt>There are no more removeable stones. " | 223 | i18n("<qt>There are no more removeable stones. " |
223 | "You got a score of %1 in total.</qt>").arg(stone->score())); | 224 | "You got a score of %1 in total.</qt>").arg(stone->score())); |
224 | } | 225 | } |
225 | stone->unmark(); | 226 | stone->unmark(); |
226 | } | 227 | } |
227 | 228 | ||
228 | void ZSameWidget::desktop_widget(int *f)const{ | 229 | void ZSameWidget::desktop_widget(int *f)const{ |
229 | 230 | ||
230 | QWidget* wid = QApplication::desktop(); | 231 | QWidget* wid = QApplication::desktop(); |
231 | /* width > height landscape mode */ | 232 | /* width > height landscape mode */ |
232 | if ( wid->width() > wid->height() ) { | 233 | if ( wid->width() > wid->height() ) { |
233 | f[0]=15; | 234 | f[0]=15; |
234 | f[1]=9; | 235 | f[1]=9; |
235 | } | 236 | } |
236 | /* normal */ | 237 | /* normal */ |
237 | else{ | 238 | else{ |
238 | f[0]=12; | 239 | f[0]=12; |
239 | f[1]=13; | 240 | f[1]=13; |
240 | } | 241 | } |
241 | } | 242 | } |
242 | 243 | ||
243 | 244 | ||