summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-03-24 18:09:38 (UTC)
committer harlekin <harlekin>2003-03-24 18:09:38 (UTC)
commitc23656023651523d37406b43fd031ace4e2de89f (patch) (unidiff)
treefd57e9985256064e57c3f93722ba8282f7e3be41
parent58f8a4fe595182abb4372ab4f990e39cf67ef08a (diff)
downloadopie-c23656023651523d37406b43fd031ace4e2de89f.zip
opie-c23656023651523d37406b43fd031ace4e2de89f.tar.gz
opie-c23656023651523d37406b43fd031ace4e2de89f.tar.bz2
pine icon now in go dir
Diffstat (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
@@ -37,9 +37,9 @@
37#include "amigo.h" 37#include "amigo.h"
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;
45//static QImage *newBlackStone; 45//static QImage *newBlackStone;
@@ -51,9 +51,9 @@ static QPixmap *whiteStone;
51 51
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);
59 59
@@ -73,34 +73,34 @@ GoMainWidget::GoMainWidget( QWidget *parent, const char* name) :
73 a = new QAction( tr( "Pass" ), Resource::loadPixmap( "pass" ), QString::null, 0, this, 0 ); 73 a = new QAction( tr( "Pass" ), Resource::loadPixmap( "pass" ), QString::null, 0, this, 0 );
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 );
82 82
83 a = new QAction( tr( "Two player option" ), QString::null, 0, this, 0 ); 83 a = new QAction( tr( "Two player option" ), QString::null, 0, this, 0 );
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
106void GoMainWidget::resizeEvent( QResizeEvent * ) 106void GoMainWidget::resizeEvent( QResizeEvent * )
@@ -116,19 +116,19 @@ void GoMainWidget::resizeEvent( QResizeEvent * )
116 116
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");
134 blackStone = new QImage( fn ); 134 blackStone = new QImage( fn );
@@ -203,9 +203,9 @@ void GoWidget::resizeEvent( QResizeEvent * )
203 if ( d < 10 && !smallStones ) { 203 if ( d < 10 && !smallStones ) {
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" ));
211 whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" )); 211 whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" ));
@@ -237,9 +237,9 @@ void GoWidget::paintEvent( QPaintEvent *e )
237{ 237{
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
245 int xMin = QMAX( x2board(e->rect().left()), 0 ); 245 int xMin = QMAX( x2board(e->rect().left()), 0 );
@@ -248,9 +248,9 @@ void GoWidget::paintEvent( QPaintEvent *e )
248 int yMax = QMIN( y2board(e->rect().bottom()), 18 ); 248 int yMax = QMIN( y2board(e->rect().bottom()), 18 );
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 }
256 for ( j = yMin; j < yMax+1 ; j ++ ) { 256 for ( j = yMin; j < yMax+1 ; j ++ ) {
@@ -261,13 +261,13 @@ void GoWidget::paintEvent( QPaintEvent *e )
261 p.setBrush( black ); 261 p.setBrush( black );
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 )
273 p.drawPixmap( bx+i*d - r, by+j*d - r, *newBlackStone ); 273 p.drawPixmap( bx+i*d - r, by+j*d - r, *newBlackStone );
@@ -393,9 +393,9 @@ void GoWidget::showStone( int x, int y, enum bVal c )
393 newX = x; 393 newX = x;
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 * )
401{ 401{
@@ -405,9 +405,9 @@ void GoWidget::mouseReleaseEvent( QMouseEvent * )
405} 405}
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)
413{ 413{