-rw-r--r-- | noncore/games/go/gowidget.h | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/noncore/games/go/gowidget.h b/noncore/games/go/gowidget.h new file mode 100644 index 0000000..94de2cc --- a/dev/null +++ b/noncore/games/go/gowidget.h | |||
@@ -0,0 +1,111 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #ifndef GOWIDGET_H | ||
22 | #define GOWIDGET_H | ||
23 | |||
24 | #include <qmainwindow.h> | ||
25 | #include "amigo.h" | ||
26 | |||
27 | |||
28 | class QToolBar; | ||
29 | |||
30 | class GoMainWidget : public QMainWindow | ||
31 | { | ||
32 | Q_OBJECT | ||
33 | public: | ||
34 | GoMainWidget( QWidget *parent=0, const char* name=0); | ||
35 | protected: | ||
36 | void resizeEvent( QResizeEvent * ); | ||
37 | private: | ||
38 | QToolBar *toolbar; | ||
39 | |||
40 | }; | ||
41 | |||
42 | |||
43 | class QLabel; | ||
44 | class GoWidget : public QWidget | ||
45 | { | ||
46 | Q_OBJECT | ||
47 | public: | ||
48 | GoWidget( QWidget *parent=0, const char* name=0); | ||
49 | ~GoWidget(); | ||
50 | |||
51 | void doMove( int x, int y ); | ||
52 | void doComputerMove(); | ||
53 | |||
54 | void readConfig(); | ||
55 | void writeConfig(); | ||
56 | |||
57 | public slots: | ||
58 | void pass(); | ||
59 | void resign(); | ||
60 | void newGame(); | ||
61 | void setTwoplayer( bool ); | ||
62 | void setHandicap( int ); | ||
63 | signals: | ||
64 | void showScore( const QString& ); | ||
65 | void showTurn( const QPixmap& ); | ||
66 | |||
67 | protected: | ||
68 | void paintEvent( QPaintEvent * ); | ||
69 | void mousePressEvent( QMouseEvent * ); | ||
70 | void mouseMoveEvent( QMouseEvent * ); | ||
71 | void mouseReleaseEvent( QMouseEvent * ); | ||
72 | void resizeEvent( QResizeEvent * ); | ||
73 | private: | ||
74 | void init(); | ||
75 | void removeStone(short x, short y); | ||
76 | void placeStone (enum bVal c, short x, short y ); | ||
77 | |||
78 | void refresh( int x, int y ); | ||
79 | void showStone( int x, int y, enum bVal ); | ||
80 | void reportPrisoners(int,int); | ||
81 | |||
82 | inline int x2board( int x ) { return (x-bx+d/2)/d; } | ||
83 | inline int y2board( int y ) { return (y-by+d/2)/d; } | ||
84 | |||
85 | void endGame(); | ||
86 | |||
87 | bool twoplayer; | ||
88 | enum bVal currentPlayer; | ||
89 | bool gameActive; | ||
90 | int nPassed; | ||
91 | signed char board[19][19]; | ||
92 | |||
93 | int d; //distance between lines | ||
94 | int bx; //vertical baseline | ||
95 | int by; //horizontal baseline | ||
96 | |||
97 | int lastX,lastY; | ||
98 | int newX,newY; | ||
99 | |||
100 | static GoWidget *self; | ||
101 | |||
102 | friend void removestone(short x, short y); | ||
103 | friend voidintrPrisonerReport( short, short ); | ||
104 | friend void placestone(enum bVal c, short x, short y ); | ||
105 | }; | ||
106 | |||
107 | |||
108 | |||
109 | |||
110 | |||
111 | #endif | ||