00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef GOWIDGET_H
00022 #define GOWIDGET_H
00023
00024 #include <qmainwindow.h>
00025 #include "amigo.h"
00026
00027
00028 class QToolBar;
00029
00030 class GoMainWidget : public QMainWindow
00031 {
00032 Q_OBJECT
00033 public:
00034 static QString appName() { return QString::fromLatin1("go"); }
00035 GoMainWidget( QWidget *parent=0, const char* name=0, WFlags fl = 0);
00036 protected:
00037 void resizeEvent( QResizeEvent * );
00038 private:
00039 QToolBar *toolbar;
00040
00041 };
00042
00043
00044 class QLabel;
00045 class GoWidget : public QWidget
00046 {
00047 Q_OBJECT
00048 public:
00049 GoWidget( QWidget *parent=0, const char* name=0);
00050 ~GoWidget();
00051
00052 void doMove( int x, int y );
00053 void doComputerMove();
00054
00055 void readConfig();
00056 void writeConfig();
00057
00058 public slots:
00059 void pass();
00060 void resign();
00061 void newGame();
00062 void setTwoplayer( bool );
00063 void setHandicap( int );
00064 signals:
00065 void showScore( const QString& );
00066 void showTurn( const QPixmap& );
00067
00068 protected:
00069 void paintEvent( QPaintEvent * );
00070 void mousePressEvent( QMouseEvent * );
00071 void mouseMoveEvent( QMouseEvent * );
00072 void mouseReleaseEvent( QMouseEvent * );
00073 void resizeEvent( QResizeEvent * );
00074 private:
00075 void init();
00076 void removeStone(short x, short y);
00077 void placeStone (enum bVal c, short x, short y );
00078
00079 void refresh( int x, int y );
00080 void showStone( int x, int y, enum bVal );
00081 void reportPrisoners(int,int);
00082
00083 inline int x2board( int x ) { return (x-bx+d/2)/d; }
00084 inline int y2board( int y ) { return (y-by+d/2)/d; }
00085
00086 void endGame();
00087
00088 bool twoplayer;
00089 enum bVal currentPlayer;
00090 bool gameActive;
00091 int nPassed;
00092 signed char board[19][19];
00093
00094 int d;
00095 int bx;
00096 int by;
00097
00098 int lastX,lastY;
00099 int newX,newY;
00100
00101 static GoWidget *self;
00102
00103 friend void removestone(short x, short y);
00104 friend void intrPrisonerReport( short, short );
00105 friend void placestone(enum bVal c, short x, short y );
00106 };
00107
00108
00109
00110
00111
00112 #endif