summaryrefslogtreecommitdiff
path: root/noncore/games/go/gowidget.cpp
Unidiff
Diffstat (limited to 'noncore/games/go/gowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/go/gowidget.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/noncore/games/go/gowidget.cpp b/noncore/games/go/gowidget.cpp
index 8567b30..1d38c9f 100644
--- a/noncore/games/go/gowidget.cpp
+++ b/noncore/games/go/gowidget.cpp
@@ -38,7 +38,7 @@
38#include "goplayutils.h" 38#include "goplayutils.h"
39 39
40static const enum bVal computer_color = BLACK; 40static const enum bVal computer_color = BLACK;
41 41
42static int current_handicap = 1; 42static int current_handicap = 1;
43 43
44static QBrush *goBrush; 44static QBrush *goBrush;
@@ -52,7 +52,7 @@ static QPixmap *whiteStone;
52static bool smallStones = FALSE; 52static bool smallStones = FALSE;
53 53
54GoMainWidget::GoMainWidget( QWidget *parent, const char* name) : 54GoMainWidget::GoMainWidget( QWidget *parent, const char* name) :
55 QMainWindow( parent, name ) 55 QMainWindow( parent, name )
56{ 56{
57 setToolBarsMovable( FALSE ); 57 setToolBarsMovable( FALSE );
58 GoWidget *go = new GoWidget(this); 58 GoWidget *go = new GoWidget(this);
@@ -74,8 +74,8 @@ GoMainWidget::GoMainWidget( QWidget *parent, const char* name) :
74 connect( a, SIGNAL( activated() ), go, SLOT( pass() ) ); 74 connect( a, SIGNAL( activated() ), go, SLOT( pass() ) );
75 a->addTo( file ); 75 a->addTo( file );
76 a->addTo( toolbar ); 76 a->addTo( toolbar );
77 77
78 78
79 a = new QAction( tr( "Resign" ), Resource::loadPixmap( "reset" ), QString::null, 0, this, 0 ); 79 a = new QAction( tr( "Resign" ), Resource::loadPixmap( "reset" ), QString::null, 0, this, 0 );
80 connect( a, SIGNAL( activated() ), go, SLOT( resign() ) ); 80 connect( a, SIGNAL( activated() ), go, SLOT( resign() ) );
81 a->addTo( file ); 81 a->addTo( file );
@@ -84,22 +84,22 @@ GoMainWidget::GoMainWidget( QWidget *parent, const char* name) :
84 a->setToggleAction( TRUE ); 84 a->setToggleAction( TRUE );
85 connect( a, SIGNAL( toggled(bool) ), go, SLOT( setTwoplayer(bool) ) ); 85 connect( a, SIGNAL( toggled(bool) ), go, SLOT( setTwoplayer(bool) ) );
86 a->addTo( file ); 86 a->addTo( file );
87 87
88 mb->insertItem( tr( "Game" ), file ); 88 mb->insertItem( tr( "Game" ), file );
89 89
90 QLabel *turnLabel = new QLabel( toolbar ); 90 QLabel *turnLabel = new QLabel( toolbar );
91 turnLabel->setBackgroundMode( PaletteButton ); 91 turnLabel->setBackgroundMode( PaletteButton );
92 connect( go, SIGNAL(showTurn(const QPixmap&)), 92 connect( go, SIGNAL(showTurn(const QPixmap&)),
93 turnLabel, SLOT(setPixmap(const QPixmap&)) ); 93 turnLabel, SLOT(setPixmap(const QPixmap&)) );
94 94
95 95
96 QLabel * scoreLabel = new QLabel( toolbar ); 96 QLabel * scoreLabel = new QLabel( toolbar );
97 scoreLabel->setBackgroundMode( PaletteButton ); 97 scoreLabel->setBackgroundMode( PaletteButton );
98 connect( go, SIGNAL(showScore(const QString&)), 98 connect( go, SIGNAL(showScore(const QString&)),
99 scoreLabel, SLOT(setText(const QString&)) ); 99 scoreLabel, SLOT(setText(const QString&)) );
100 100
101 toolbar->setStretchableWidget( scoreLabel ); 101 toolbar->setStretchableWidget( scoreLabel );
102 102
103 go->readConfig(); 103 go->readConfig();
104} 104}
105 105
@@ -117,17 +117,17 @@ void GoMainWidget::resizeEvent( QResizeEvent * )
117GoWidget *GoWidget::self = 0; 117GoWidget *GoWidget::self = 0;
118 118
119GoWidget::GoWidget( QWidget *parent, const char* name) : 119GoWidget::GoWidget( QWidget *parent, const char* name) :
120 QWidget( parent, name ) 120 QWidget( parent, name )
121{ 121{
122 if ( self ) 122 if ( self )
123 fatal( "Only one Go widget allowed" ); 123 fatal( "Only one Go widget allowed" );
124 self = this; 124 self = this;
125 twoplayer = FALSE; 125 twoplayer = FALSE;
126 126
127 127
128 d = bx = by = 1; 128 d = bx = by = 1;
129 129
130 QPixmap pix = Resource::loadPixmap( "pine" ); 130 QPixmap pix = Resource::loadPixmap( "go/pine" );
131 goBrush = new QBrush( black, pix ); 131 goBrush = new QBrush( black, pix );
132 /* 132 /*
133 QString fn = Resource::findPixmap("Go-black"); 133 QString fn = Resource::findPixmap("Go-black");
@@ -204,7 +204,7 @@ void GoWidget::resizeEvent( QResizeEvent * )
204 blackStone->convertFromImage( blackStone->convertToImage().smoothScale(8,8) ); 204 blackStone->convertFromImage( blackStone->convertToImage().smoothScale(8,8) );
205 whiteStone->convertFromImage( whiteStone->convertToImage().smoothScale(8,8) ); 205 whiteStone->convertFromImage( whiteStone->convertToImage().smoothScale(8,8) );
206 newBlackStone->convertFromImage( newBlackStone->convertToImage().smoothScale(8,8) ); 206 newBlackStone->convertFromImage( newBlackStone->convertToImage().smoothScale(8,8) );
207 207
208 smallStones = TRUE; 208 smallStones = TRUE;
209 } else if ( d >= 10 && smallStones ) { 209 } else if ( d >= 10 && smallStones ) {
210 blackStone = new QPixmap(Resource::loadPixmap( "Go-black" )); 210 blackStone = new QPixmap(Resource::loadPixmap( "Go-black" ));
@@ -238,7 +238,7 @@ void GoWidget::paintEvent( QPaintEvent *e )
238 int i,j; 238 int i,j;
239 239
240 int r = whiteStone->width()/2; 240 int r = whiteStone->width()/2;
241 241
242 QPainter p(this); 242 QPainter p(this);
243 p.fillRect( bx - d/2, by - d/2, 19*d, 19*d, *goBrush ); 243 p.fillRect( bx - d/2, by - d/2, 19*d, 19*d, *goBrush );
244 244
@@ -249,7 +249,7 @@ void GoWidget::paintEvent( QPaintEvent *e )
249 249
250 QColor pine( 255, 186, 89 ); 250 QColor pine( 255, 186, 89 );
251 p.setPen( pine.dark() ); 251 p.setPen( pine.dark() );
252 252
253 for ( i = xMin; i < xMax+1 ; i ++ ) { 253 for ( i = xMin; i < xMax+1 ; i ++ ) {
254 p.drawLine( bx+i*d, by, bx+i*d, by+18*d ); 254 p.drawLine( bx+i*d, by, bx+i*d, by+18*d );
255 } 255 }
@@ -262,11 +262,11 @@ void GoWidget::paintEvent( QPaintEvent *e )
262 for ( i = 3; i < xMax+1; i+=6 ) 262 for ( i = 3; i < xMax+1; i+=6 )
263 for ( j = 3; j < yMax+1; j+=6 ) 263 for ( j = 3; j < yMax+1; j+=6 )
264 p.drawEllipse( bx+i*d-2, by+j*d-2, 5, 5 ); 264 p.drawEllipse( bx+i*d-2, by+j*d-2, 5, 5 );
265 265
266 266
267 for ( i = xMin; i < xMax+1; i++ ) 267 for ( i = xMin; i < xMax+1; i++ )
268 for ( j = yMin; j < yMax+1; j++ ) { 268 for ( j = yMin; j < yMax+1; j++ ) {
269 if ( board[i][j] == WHITE || 269 if ( board[i][j] == WHITE ||
270 currentPlayer==WHITE && newX == i && newY == j ) 270 currentPlayer==WHITE && newX == i && newY == j )
271 p.drawPixmap( bx+i*d - r, by+j*d - r, *whiteStone ); 271 p.drawPixmap( bx+i*d - r, by+j*d - r, *whiteStone );
272 else if ( i == lastX && j == lastY ) 272 else if ( i == lastX && j == lastY )
@@ -394,7 +394,7 @@ void GoWidget::showStone( int x, int y, enum bVal c )
394 newY = y; 394 newY = y;
395 refresh(x,y); 395 refresh(x,y);
396 } 396 }
397 397
398} 398}
399 399
400void GoWidget::mouseReleaseEvent( QMouseEvent * ) 400void GoWidget::mouseReleaseEvent( QMouseEvent * )
@@ -406,7 +406,7 @@ void GoWidget::mouseReleaseEvent( QMouseEvent * )
406 406
407void GoWidget::refresh( int x, int y ) 407void GoWidget::refresh( int x, int y )
408{ 408{
409 update( bx+d*x-d/2-1, by+d*y-d/2-1, d+2, d+2 ); 409 update( bx+d*x-d/2-1, by+d*y-d/2-1, d+2, d+2 );
410} 410}
411 411
412void GoWidget::removeStone(short x, short y) 412void GoWidget::removeStone(short x, short y)