author | mickeyl <mickeyl> | 2003-11-03 23:05:29 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-11-03 23:05:29 (UTC) |
commit | 8046118c7d4def83ef1a70628870b5ebad0534a4 (patch) (unidiff) | |
tree | 21f03403f1f4d42d72eace822511e084580a8772 | |
parent | 7f34e7b45108c353e0a2575153904ce655cb1896 (diff) | |
download | opie-8046118c7d4def83ef1a70628870b5ebad0534a4.zip opie-8046118c7d4def83ef1a70628870b5ebad0534a4.tar.gz opie-8046118c7d4def83ef1a70628870b5ebad0534a4.tar.bz2 |
noncore/games/tictac now fully merged
-rw-r--r-- | noncore/games/tictac/main.cpp | 6 | ||||
-rw-r--r-- | noncore/games/tictac/tictac.cpp | 7 | ||||
-rw-r--r-- | noncore/games/tictac/tictac.h | 7 | ||||
-rw-r--r-- | noncore/games/tictac/tictac.pro | 9 |
4 files changed, 12 insertions, 17 deletions
diff --git a/noncore/games/tictac/main.cpp b/noncore/games/tictac/main.cpp index 0185b8c..cfff683 100644 --- a/noncore/games/tictac/main.cpp +++ b/noncore/games/tictac/main.cpp | |||
@@ -1,19 +1,13 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | <<<<<<< main.cpp | ||
3 | ** $Id$ | ||
4 | ======= | ||
5 | ** $Id$ | ||
6 | >>>>>>> 1.1.8.1.2.1 | ||
7 | ** | ||
8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. |
9 | ** | 3 | ** |
10 | ** 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 |
11 | ** program may be used, distributed and modified without limitation. | 5 | ** program may be used, distributed and modified without limitation. |
12 | ** | 6 | ** |
13 | *****************************************************************************/ | 7 | *****************************************************************************/ |
14 | 8 | ||
15 | #include <qpe/qpeapplication.h> | 9 | #include <qpe/qpeapplication.h> |
16 | #include <opie/oapplicationfactory.h> | 10 | #include <opie/oapplicationfactory.h> |
17 | #include "tictac.h" | 11 | #include "tictac.h" |
18 | 12 | ||
19 | OPIE_EXPORT_APP( OApplicationFactory<TicTacToe> ) | 13 | OPIE_EXPORT_APP( OApplicationFactory<TicTacToe> ) |
diff --git a/noncore/games/tictac/tictac.cpp b/noncore/games/tictac/tictac.cpp index 3d727ac..4954ba4 100644 --- a/noncore/games/tictac/tictac.cpp +++ b/noncore/games/tictac/tictac.cpp | |||
@@ -1,26 +1,26 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | 2 | ** tictac.cpp,v 1.3.8.1 2003/08/29 06:50:40 harlekin Exp |
3 | ** | 3 | ** |
4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | 4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. |
5 | ** | 5 | ** |
6 | ** This file is part of an example program for Qt. This example | 6 | ** This file is part of an example program for Qt. This example |
7 | ** program may be used, distributed and modified without limitation. | 7 | ** program may be used, distributed and modified without limitation. |
8 | ** | 8 | ** |
9 | *****************************************************************************/ | 9 | *****************************************************************************/ |
10 | 10 | ||
11 | #include "tictac.h" | 11 | #include "tictac.h" |
12 | #include <qpe/qpeapplication.h> | 12 | #include <qpe/qpeapplication.h> |
13 | #include <qpainter.h> | 13 | #include <qpainter.h> |
14 | #include <qdrawutil.h> | 14 | #include <qdrawutil.h> |
15 | #include <qcombobox.h> | 15 | #include <qcombobox.h> |
16 | #include <qcheckbox.h> | 16 | #include <qcheckbox.h> |
17 | #include <qlabel.h> | 17 | #include <qlabel.h> |
18 | #include <qlayout.h> | 18 | #include <qlayout.h> |
19 | #include <stdlib.h> // rand() function | 19 | #include <stdlib.h> // rand() function |
20 | #include <qdatetime.h> // seed for rand() | 20 | #include <qdatetime.h> // seed for rand() |
21 | #include <qstringlist.h> //needed for proper internationalization | 21 | #include <qstringlist.h> //needed for proper internationalization |
22 | 22 | ||
23 | 23 | ||
24 | //*************************************************************************** | 24 | //*************************************************************************** |
25 | //* TicTacButton member functions | 25 | //* TicTacButton member functions |
26 | //*************************************************************************** | 26 | //*************************************************************************** |
@@ -267,54 +267,55 @@ void TicTacGameBoard::computerMove() | |||
267 | a[stopHuman] = TicTacButton::Cross; | 267 | a[stopHuman] = TicTacButton::Cross; |
268 | else if ( i == numButtons ) { // tried all alternatives | 268 | else if ( i == numButtons ) { // tried all alternatives |
269 | if ( altc > 0 ) // set random piece | 269 | if ( altc > 0 ) // set random piece |
270 | a[altv[rand()%(altc--)]] = TicTacButton::Cross; | 270 | a[altv[rand()%(altc--)]] = TicTacButton::Cross; |
271 | if ( altc == 0 ) { // no more blanks | 271 | if ( altc == 0 ) { // no more blanks |
272 | st = NobodyWon; | 272 | st = NobodyWon; |
273 | emit finished(); | 273 | emit finished(); |
274 | } | 274 | } |
275 | } | 275 | } |
276 | *btArray = a; // update model | 276 | *btArray = a; // update model |
277 | updateButtons(); // update buttons | 277 | updateButtons(); // update buttons |
278 | delete[] altv; | 278 | delete[] altv; |
279 | } | 279 | } |
280 | 280 | ||
281 | 281 | ||
282 | //*************************************************************************** | 282 | //*************************************************************************** |
283 | //* TicTacToe member functions | 283 | //* TicTacToe member functions |
284 | //*************************************************************************** | 284 | //*************************************************************************** |
285 | 285 | ||
286 | // -------------------------------------------------------------------------- | 286 | // -------------------------------------------------------------------------- |
287 | // Creates a game widget with a game board and two push buttons, and connects | 287 | // Creates a game widget with a game board and two push buttons, and connects |
288 | // signals of child widgets to slots. | 288 | // signals of child widgets to slots. |
289 | // | 289 | // |
290 | 290 | ||
291 | TicTacToe::TicTacToe( int boardSize, QWidget *parent, const char *name ) | 291 | TicTacToe::TicTacToe( QWidget *parent, const char *name, WFlags fl ) |
292 | : QWidget( parent, name ) | 292 | : QWidget( parent, name, fl ) |
293 | { | 293 | { |
294 | QVBoxLayout * l = new QVBoxLayout( this, 6 ); | 294 | QVBoxLayout * l = new QVBoxLayout( this, 6 ); |
295 | 295 | ||
296 | // Create a message label | 296 | // Create a message label |
297 | boardSize = 3; | ||
297 | 298 | ||
298 | message = new QLabel( this ); | 299 | message = new QLabel( this ); |
299 | message->setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); | 300 | message->setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); |
300 | message->setAlignment( AlignCenter ); | 301 | message->setAlignment( AlignCenter ); |
301 | l->addWidget( message ); | 302 | l->addWidget( message ); |
302 | 303 | ||
303 | // Create the game board and connect the signal finished() to this | 304 | // Create the game board and connect the signal finished() to this |
304 | // gameOver() slot | 305 | // gameOver() slot |
305 | 306 | ||
306 | board = new TicTacGameBoard( boardSize, this ); | 307 | board = new TicTacGameBoard( boardSize, this ); |
307 | connect( board, SIGNAL(finished()), SLOT(gameOver()) ); | 308 | connect( board, SIGNAL(finished()), SLOT(gameOver()) ); |
308 | l->addWidget( board ); | 309 | l->addWidget( board ); |
309 | 310 | ||
310 | // Create a horizontal frame line | 311 | // Create a horizontal frame line |
311 | 312 | ||
312 | QFrame *line = new QFrame( this ); | 313 | QFrame *line = new QFrame( this ); |
313 | line->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | 314 | line->setFrameStyle( QFrame::HLine | QFrame::Sunken ); |
314 | l->addWidget( line ); | 315 | l->addWidget( line ); |
315 | 316 | ||
316 | // Create the combo box for deciding who should start, and | 317 | // Create the combo box for deciding who should start, and |
317 | // connect its clicked() signals to the buttonClicked() slot | 318 | // connect its clicked() signals to the buttonClicked() slot |
318 | 319 | ||
319 | whoStarts = new QComboBox( this ); | 320 | whoStarts = new QComboBox( this ); |
320 | whoStarts->insertItem( tr( "Computer starts" ) ); | 321 | whoStarts->insertItem( tr( "Computer starts" ) ); |
diff --git a/noncore/games/tictac/tictac.h b/noncore/games/tictac/tictac.h index ec6c79c..bb0b485 100644 --- a/noncore/games/tictac/tictac.h +++ b/noncore/games/tictac/tictac.h | |||
@@ -1,26 +1,26 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | 2 | ** tictac.h,v 1.1.10.1 2003/08/29 06:50:40 harlekin Exp |
3 | ** | 3 | ** |
4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | 4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. |
5 | ** | 5 | ** |
6 | ** This file is part of an example program for Qt. This example | 6 | ** This file is part of an example program for Qt. This example |
7 | ** program may be used, distributed and modified without limitation. | 7 | ** program may be used, distributed and modified without limitation. |
8 | ** | 8 | ** |
9 | *****************************************************************************/ | 9 | *****************************************************************************/ |
10 | 10 | ||
11 | #ifndef TICTAC_H | 11 | #ifndef TICTAC_H |
12 | #define TICTAC_H | 12 | #define TICTAC_H |
13 | 13 | ||
14 | 14 | ||
15 | #include <qpushbutton.h> | 15 | #include <qpushbutton.h> |
16 | #include <qvector.h> | 16 | #include <qvector.h> |
17 | 17 | ||
18 | class QComboBox; | 18 | class QComboBox; |
19 | class QLabel; | 19 | class QLabel; |
20 | 20 | ||
21 | 21 | ||
22 | // -------------------------------------------------------------------------- | 22 | // -------------------------------------------------------------------------- |
23 | // TicTacButton implements a single tic-tac-toe button | 23 | // TicTacButton implements a single tic-tac-toe button |
24 | // | 24 | // |
25 | 25 | ||
26 | class TicTacButton : public QPushButton | 26 | class TicTacButton : public QPushButton |
@@ -70,39 +70,42 @@ private slots: | |||
70 | voidbuttonClicked(); | 70 | voidbuttonClicked(); |
71 | private: | 71 | private: |
72 | void setState( State state ) { st = state; } | 72 | void setState( State state ) { st = state; } |
73 | voidupdateButtons(); | 73 | voidupdateButtons(); |
74 | int checkBoard( TicTacArray * ); | 74 | int checkBoard( TicTacArray * ); |
75 | void computerMove(); | 75 | void computerMove(); |
76 | Statest; | 76 | Statest; |
77 | int nBoard; | 77 | int nBoard; |
78 | boolcomp_starts; | 78 | boolcomp_starts; |
79 | TicTacArray *btArray; | 79 | TicTacArray *btArray; |
80 | TicTacButtons *buttons; | 80 | TicTacButtons *buttons; |
81 | }; | 81 | }; |
82 | 82 | ||
83 | 83 | ||
84 | // -------------------------------------------------------------------------- | 84 | // -------------------------------------------------------------------------- |
85 | // TicTacToe implements the complete game. | 85 | // TicTacToe implements the complete game. |
86 | // TicTacToe is a composite widget that contains a TicTacGameBoard and | 86 | // TicTacToe is a composite widget that contains a TicTacGameBoard and |
87 | // two push buttons for starting the game and quitting. | 87 | // two push buttons for starting the game and quitting. |
88 | // | 88 | // |
89 | 89 | ||
90 | class TicTacToe : public QWidget | 90 | class TicTacToe : public QWidget |
91 | { | 91 | { |
92 | Q_OBJECT | 92 | Q_OBJECT |
93 | public: | 93 | public: |
94 | TicTacToe( int boardSize=3, QWidget *parent=0, const char *name=0 ); | 94 | TicTacToe( QWidget *parent=0, const char *name=0, WFlags fl = 0 ); |
95 | static QString appName() { return QString::fromLatin1("tictac"); } | ||
96 | |||
95 | private slots: | 97 | private slots: |
96 | voidnewGameClicked(); | 98 | voidnewGameClicked(); |
97 | voidgameOver(); | 99 | voidgameOver(); |
98 | private: | 100 | private: |
99 | voidnewState(); | 101 | voidnewState(); |
100 | QComboBox*whoStarts; | 102 | QComboBox*whoStarts; |
101 | QPushButton *newGame; | 103 | QPushButton *newGame; |
102 | QPushButton *quit; | 104 | QPushButton *quit; |
103 | QLabel*message; | 105 | QLabel*message; |
104 | TicTacGameBoard *board; | 106 | TicTacGameBoard *board; |
107 | int boardSize; | ||
105 | }; | 108 | }; |
106 | 109 | ||
107 | 110 | ||
108 | #endif // TICTAC_H | 111 | #endif // TICTAC_H |
diff --git a/noncore/games/tictac/tictac.pro b/noncore/games/tictac/tictac.pro index eb0705e..5cbdbdc 100644 --- a/noncore/games/tictac/tictac.pro +++ b/noncore/games/tictac/tictac.pro | |||
@@ -1,32 +1,29 @@ | |||
1 | TEMPLATE = app | 1 | CONFIG += qt warn_on release quick-app |
2 | CONFIG += qt warn_on release | ||
3 | HEADERS = tictac.h | 2 | HEADERS = tictac.h |
4 | SOURCES = main.cpp \ | 3 | SOURCES = main.cpp \ |
5 | tictac.cpp | 4 | tictac.cpp |
6 | TARGET = tictac | ||
7 | INCLUDEPATH += $(OPIEDIR)/include | 5 | INCLUDEPATH += $(OPIEDIR)/include |
8 | DEPENDPATH += $(OPIEDIR)/include | 6 | DEPENDPATH += $(OPIEDIR)/include |
9 | LIBS += -lqpe | 7 | LIBS += -lqpe |
10 | DESTDIR = $(OPIEDIR)/bin | 8 | |
9 | TARGET = tictac | ||
11 | 10 | ||
12 | TRANSLATIONS = ../../../i18n/de/tictac.ts \ | 11 | TRANSLATIONS = ../../../i18n/de/tictac.ts \ |
13 | ../../../i18n/nl/tictac.ts \ | 12 | ../../../i18n/nl/tictac.ts \ |
14 | ../../../i18n/da/tictac.ts \ | 13 | ../../../i18n/da/tictac.ts \ |
15 | ../../../i18n/xx/tictac.ts \ | 14 | ../../../i18n/xx/tictac.ts \ |
16 | ../../../i18n/en/tictac.ts \ | 15 | ../../../i18n/en/tictac.ts \ |
17 | ../../../i18n/es/tictac.ts \ | 16 | ../../../i18n/es/tictac.ts \ |
18 | ../../../i18n/fr/tictac.ts \ | 17 | ../../../i18n/fr/tictac.ts \ |
19 | ../../../i18n/hu/tictac.ts \ | 18 | ../../../i18n/hu/tictac.ts \ |
20 | ../../../i18n/ja/tictac.ts \ | 19 | ../../../i18n/ja/tictac.ts \ |
21 | ../../../i18n/ko/tictac.ts \ | 20 | ../../../i18n/ko/tictac.ts \ |
22 | ../../../i18n/no/tictac.ts \ | 21 | ../../../i18n/no/tictac.ts \ |
23 | ../../../i18n/pl/tictac.ts \ | 22 | ../../../i18n/pl/tictac.ts \ |
24 | ../../../i18n/pt/tictac.ts \ | 23 | ../../../i18n/pt/tictac.ts \ |
25 | ../../../i18n/pt_BR/tictac.ts \ | 24 | ../../../i18n/pt_BR/tictac.ts \ |
26 | ../../../i18n/sl/tictac.ts \ | 25 | ../../../i18n/sl/tictac.ts \ |
27 | ../../../i18n/zh_CN/tictac.ts \ | 26 | ../../../i18n/zh_CN/tictac.ts \ |
28 | ../../../i18n/zh_TW/tictac.ts | 27 | ../../../i18n/zh_TW/tictac.ts |
29 | 28 | ||
30 | |||
31 | |||
32 | include ( $(OPIEDIR)/include.pro ) | 29 | include ( $(OPIEDIR)/include.pro ) |