~ubuntu-branches/ubuntu/maverick/qgo/maverick

« back to all changes in this revision

Viewing changes to src/qgo_interface.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin A. Godisch
  • Date: 2005-01-01 23:07:10 UTC
  • Revision ID: james.westby@ubuntu.com-20050101230710-fhng6yidm47xlb2i
Tags: upstream-1.0.0-r2
ImportĀ upstreamĀ versionĀ 1.0.0-r2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*
 
3
 *   qgo_interface.h
 
4
 */
 
5
 
 
6
#ifndef QGO_INTERFACE_H
 
7
#define QGO_INTERFACE_H
 
8
 
 
9
#undef SHOW_INTERNAL_TIME
 
10
#undef SHOW_MOVES_DLG
 
11
 
 
12
#include "tables.h"
 
13
#include "defines.h"
 
14
#include "globals.h"
 
15
#include "gs_globals.h"
 
16
#include "misc.h"
 
17
#include "setting.h"
 
18
#include <qobject.h>
 
19
#include <qstring.h>
 
20
#include <qtimer.h>
 
21
#include <qptrlist.h>
 
22
 
 
23
// from qGo:
 
24
#include "qgo.h"
 
25
#include "mainwindow.h"
 
26
//#include "qgoclient_interface.h"
 
27
 
 
28
 
 
29
//-----------
 
30
 
 
31
class Game;
 
32
 
 
33
//-----------
 
34
 
 
35
class GameInfo
 
36
{
 
37
public:
 
38
        GameInfo() {};
 
39
        ~GameInfo() {};
 
40
        // 15 Game 43 I: xxxx (4 223 16) vs yyyy (5 59 13)
 
41
        // 15 144(B): B12
 
42
        QString nr;
 
43
        QString type;
 
44
        QString wname;
 
45
        QString wprisoners;
 
46
        QString wtime;
 
47
        QString wstones;
 
48
        QString bname;
 
49
        QString bprisoners;
 
50
        QString btime;
 
51
        QString bstones;
 
52
        QString mv_col; // T..Time, B..Black, W..White, I..Init
 
53
        QString mv_nr;
 
54
        QString mv_pt;
 
55
};
 
56
 
 
57
//-----------
 
58
 
 
59
class qGoBoard : public QObject, public Misc<QString>
 
60
{
 
61
        Q_OBJECT
 
62
 
 
63
public:
 
64
        qGoBoard(qGoIF*, qGo*);
 
65
        ~qGoBoard();
 
66
        int get_id() const { return id; }
 
67
        void set_id(int i) { id = i; gd.gameNumber = i; }
 
68
        GameData get_gameData() { return gd; }
 
69
        void set_title(const QString&);
 
70
        bool get_haveTitle() { return haveTitle; }
 
71
        void set_komi(const QString&);
 
72
        void set_freegame(bool);
 
73
        bool get_havegd() { return have_gameData; }
 
74
        bool get_sentmovescmd() { return sent_movescmd; }
 
75
        void set_sentmovescmd(bool m) { sent_movescmd = m; }
 
76
        bool get_adj() { return adjourned; }
 
77
        QString get_bplayer() { return gd.playerBlack; }
 
78
        QString get_wplayer() { return gd.playerWhite; }
 
79
        void set_adj(bool a) { adjourned = a; }
 
80
        void set_game(Game *g);
 
81
 
 
82
        void set_Mode(int);
 
83
        GameMode get_Mode() { return gameMode; }
 
84
        void set_move(StoneColor, QString, QString);
 
85
        void send_kibitz(const QString);
 
86
        MainWindow *get_win() { return win; }
 
87
        void initGame() { win->getBoard()->initGame(&gd); }
 
88
        void setGameData() {win->getBoard()->setGameData(&gd); }
 
89
        void setMode() { win->getBoard()->setMode(gameMode); }
 
90
        void setTimerInfo(const QString&, const QString&, const QString&, const QString&);
 
91
        void timerEvent(QTimerEvent*);
 
92
        QString secToTime(int);
 
93
        void set_stopTimer();
 
94
        void set_runTimer();
 
95
        void set_gamePaused(bool p) { game_paused = p; }
 
96
        int get_boardsize() { return gd.size; }
 
97
        int get_mvcount() { return mv_counter; }
 
98
        void set_myColorIsBlack(bool b);
 
99
        bool get_myColorIsBlack() { return myColorIsBlack; }
 
100
        void set_requests(const QString &handicap, const QString &komi, assessType);
 
101
        void check_requests();
 
102
        QString get_reqKomi() { return req_komi; }
 
103
        QString get_currentKomi() { return QString::number(gd.komi); }
 
104
        void dec_mv_counter() { mv_counter--; }
 
105
        int get_mv_counter() { return mv_counter; }
 
106
        bool get_requests_set() { return requests_set; }
 
107
        qGo* get_qgo() { return qgo; }
 
108
        void set_gsName(GSName g) { gsName = g; }
 
109
        void addtime_b(int m);
 
110
        void addtime_w(int m);
 
111
        void set_myName(const QString &n) { myName = n; }
 
112
        void clearObserverList() { win->getListView_observers()->clear(); }
 
113
        void playComputer(StoneColor);
 
114
 
 
115
        // teaching features
 
116
        bool        ExtendedTeachingGame;
 
117
        bool        IamTeacher;
 
118
        bool        IamPupil;
 
119
        bool        havePupil;
 
120
        bool        haveControls;
 
121
        QString     ttOpponent;
 
122
        bool        mark_set;
 
123
        int         mark_counter;
 
124
 
 
125
signals:
 
126
        // to qGoIF
 
127
//      void signal_closeevent(int);
 
128
        void signal_sendcommand(const QString&, bool);
 
129
        void signal_2passes(const QString&, const QString&);
 
130
  
 
131
public slots:
 
132
        // MainWindow
 
133
        void slot_closeevent();
 
134
        void slot_sendcomment(const QString&);
 
135
 
 
136
        // Board
 
137
        void slot_addStone(enum StoneColor, int, int);
 
138
        void slot_stoneComputer(enum StoneColor, int, int);    
 
139
        void slot_PassComputer(StoneColor c) ;                 
 
140
        void slot_UndoComputer(StoneColor c) ;                 
 
141
        void slot_DoneComputer() ;                 
 
142
        void slot_doPass();
 
143
        void slot_doResign();
 
144
        void slot_doUndo();
 
145
        void slot_doAdjourn();
 
146
        void slot_doDone();
 
147
        void slot_doRefresh();
 
148
 
 
149
        // normaltools
 
150
        void slot_addtimePauseW();
 
151
        void slot_addtimePauseB();
 
152
 
 
153
        // teachtools
 
154
        void slot_ttOpponentSelected(const QString&);
 
155
        void slot_ttControls(bool);
 
156
        void slot_ttMark(bool);
 
157
 
 
158
private:
 
159
        bool        timer_running;
 
160
        bool            game_paused;
 
161
        bool        have_gameData;
 
162
        bool        sent_movescmd;
 
163
        bool        adjourned;
 
164
        bool        myColorIsBlack;
 
165
        bool        haveTitle;
 
166
        GameMode    gameMode;
 
167
        GameData    gd;
 
168
        int         id;
 
169
        MainWindow  *win;
 
170
        qGo         *qgo;
 
171
        int         mv_counter;
 
172
        int             stated_mv_count ;
 
173
        bool                sound;
 
174
        int         bt_i, wt_i;
 
175
        QString     bt, wt;
 
176
        QString     b_stones, w_stones;
 
177
        QString     req_handicap;
 
178
        QString     req_komi;
 
179
        assessType  req_free;
 
180
        bool                requests_set;
 
181
        GSName      gsName;
 
182
        QString     myName;
 
183
  int         BY_timer;
 
184
 
 
185
#ifdef SHOW_INTERNAL_TIME
 
186
        int chk_b, chk_w;
 
187
#endif
 
188
};
 
189
 
 
190
//-----------
 
191
 
 
192
class qGoIF : public QObject
 
193
{
 
194
        Q_OBJECT
 
195
 
 
196
public:
 
197
        qGoIF(QWidget*);
 
198
        ~qGoIF();
 
199
        bool set_observe(QString);
 
200
        void set_initIF();
 
201
        void set_myName(const QString &n) { myName = n; }
 
202
        qGo  *get_qgo() { return qgo; };
 
203
        void set_gsName(GSName n) { gsName = n; }
 
204
        void set_localboard(QString file=0);
 
205
        void set_localgame();
 
206
        void openPreferences(int tab=-1);
 
207
        QWidget *get_parent() { return parent; }
 
208
 
 
209
signals:
 
210
        void signal_sendcommand(const QString&, bool);
 
211
        void signal_addToObservationList(int);
 
212
 
 
213
public slots:
 
214
        // parser/mainwindow
 
215
        void slot_move(GameInfo*);
 
216
        void slot_move(Game*);
 
217
        void slot_computer_game(QNewGameDlg*);
 
218
        void slot_kibitz(int, const QString&, const QString&);
 
219
        void slot_title(const QString&);
 
220
        void slot_komi(const QString&, const QString&, bool);
 
221
        void slot_freegame(bool);
 
222
        void slot_matchcreate(const QString&, const QString&);
 
223
        void slot_removestones(const QString&, const QString&);
 
224
        void slot_undo(const QString&, const QString&);
 
225
        void slot_result(const QString&, const QString&, bool, const QString&);
 
226
        void slot_matchsettings(const QString&, const QString&, const QString&, assessType);
 
227
        void slot_requestDialog(const QString&, const QString&, const QString&, const QString&);
 
228
        void slot_timeAdded(int, bool);
 
229
 
 
230
        // qGoBoard
 
231
//      void slot_closeevent(int) {};
 
232
        void slot_closeevent();
 
233
        void slot_sendcommand(const QString&, bool);
 
234
 
 
235
protected:
 
236
        bool parse_move(int src, GameInfo* gi=0, Game* g=0, QString txt=0);
 
237
 
 
238
private:
 
239
        qGo     *qgo;
 
240
        QWidget *parent;
 
241
        // actual pointer, for speedup reason
 
242
        qGoBoard *qgobrd;
 
243
        QString  myName;
 
244
        QList<qGoBoard> *boardlist;
 
245
        GSName   gsName;
 
246
        int      localBoardCounter;
 
247
//      int      lockObserveCmd;
 
248
};
 
249
 
 
250
#endif
 
251