summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -35,13 +35,13 @@
//#include <stdio.h>
#include "amigo.h"
#include "goplayutils.h"
static const enum bVal computer_color = BLACK;
-
+
static int current_handicap = 1;
static QBrush *goBrush;
//static QImage *newBlackStone;
//static QImage *blackStone;
//static QImage *whiteStone;
@@ -49,13 +49,13 @@ static QPixmap *newBlackStone;
static QPixmap *blackStone;
static QPixmap *whiteStone;
static bool smallStones = FALSE;
GoMainWidget::GoMainWidget( QWidget *parent, const char* name) :
- QMainWindow( parent, name )
+ QMainWindow( parent, name )
{
setToolBarsMovable( FALSE );
GoWidget *go = new GoWidget(this);
setCentralWidget(go);
toolbar = new QPEToolBar(this);
@@ -71,38 +71,38 @@ GoMainWidget::GoMainWidget( QWidget *parent, const char* name) :
a->addTo( file );
a = new QAction( tr( "Pass" ), Resource::loadPixmap( "pass" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), go, SLOT( pass() ) );
a->addTo( file );
a->addTo( toolbar );
-
-
+
+
a = new QAction( tr( "Resign" ), Resource::loadPixmap( "reset" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), go, SLOT( resign() ) );
a->addTo( file );
a = new QAction( tr( "Two player option" ), QString::null, 0, this, 0 );
a->setToggleAction( TRUE );
connect( a, SIGNAL( toggled(bool) ), go, SLOT( setTwoplayer(bool) ) );
a->addTo( file );
-
+
mb->insertItem( tr( "Game" ), file );
-
+
QLabel *turnLabel = new QLabel( toolbar );
turnLabel->setBackgroundMode( PaletteButton );
- connect( go, SIGNAL(showTurn(const QPixmap&)),
+ connect( go, SIGNAL(showTurn(const QPixmap&)),
turnLabel, SLOT(setPixmap(const QPixmap&)) );
-
+
QLabel * scoreLabel = new QLabel( toolbar );
scoreLabel->setBackgroundMode( PaletteButton );
- connect( go, SIGNAL(showScore(const QString&)),
+ connect( go, SIGNAL(showScore(const QString&)),
scoreLabel, SLOT(setText(const QString&)) );
toolbar->setStretchableWidget( scoreLabel );
-
+
go->readConfig();
}
void GoMainWidget::resizeEvent( QResizeEvent * )
{
//### this won't work because of the text label...
@@ -114,23 +114,23 @@ void GoMainWidget::resizeEvent( QResizeEvent * )
*/
}
GoWidget *GoWidget::self = 0;
GoWidget::GoWidget( QWidget *parent, const char* name) :
- QWidget( parent, name )
+ QWidget( parent, name )
{
if ( self )
fatal( "Only one Go widget allowed" );
self = this;
twoplayer = FALSE;
-
+
d = bx = by = 1;
-
- QPixmap pix = Resource::loadPixmap( "pine" );
+
+ QPixmap pix = Resource::loadPixmap( "go/pine" );
goBrush = new QBrush( black, pix );
/*
QString fn = Resource::findPixmap("Go-black");
blackStone = new QImage( fn );
fn = Resource::findPixmap("Go-black-highlight");
newBlackStone = new QImage( fn );
@@ -201,13 +201,13 @@ void GoWidget::resizeEvent( QResizeEvent * )
by = (height() - 18*d)/2 ;
if ( d < 10 && !smallStones ) {
blackStone->convertFromImage( blackStone->convertToImage().smoothScale(8,8) );
whiteStone->convertFromImage( whiteStone->convertToImage().smoothScale(8,8) );
newBlackStone->convertFromImage( newBlackStone->convertToImage().smoothScale(8,8) );
-
+
smallStones = TRUE;
} else if ( d >= 10 && smallStones ) {
blackStone = new QPixmap(Resource::loadPixmap( "Go-black" ));
whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" ));
newBlackStone = new QPixmap(Resource::loadPixmap( "Go-black-highlight" ));
smallStones = FALSE;
@@ -235,41 +235,41 @@ void GoWidget::init()
void GoWidget::paintEvent( QPaintEvent *e )
{
int i,j;
int r = whiteStone->width()/2;
-
+
QPainter p(this);
p.fillRect( bx - d/2, by - d/2, 19*d, 19*d, *goBrush );
int xMin = QMAX( x2board(e->rect().left()), 0 );
int xMax = QMIN( x2board(e->rect().right()), 18 );
int yMin = QMAX( y2board(e->rect().top()), 0 );
int yMax = QMIN( y2board(e->rect().bottom()), 18 );
QColor pine( 255, 186, 89 );
p.setPen( pine.dark() );
-
+
for ( i = xMin; i < xMax+1 ; i ++ ) {
p.drawLine( bx+i*d, by, bx+i*d, by+18*d );
}
for ( j = yMin; j < yMax+1 ; j ++ ) {
p.drawLine( bx, by+j*d, bx+18*d, by+j*d);
}
// dots are at (3,3), (3,9), (3,15) and so on
p.setBrush( black );
for ( i = 3; i < xMax+1; i+=6 )
for ( j = 3; j < yMax+1; j+=6 )
p.drawEllipse( bx+i*d-2, by+j*d-2, 5, 5 );
-
-
+
+
for ( i = xMin; i < xMax+1; i++ )
for ( j = yMin; j < yMax+1; j++ ) {
- if ( board[i][j] == WHITE ||
+ if ( board[i][j] == WHITE ||
currentPlayer==WHITE && newX == i && newY == j )
p.drawPixmap( bx+i*d - r, by+j*d - r, *whiteStone );
else if ( i == lastX && j == lastY )
p.drawPixmap( bx+i*d - r, by+j*d - r, *newBlackStone );
else if ( board[i][j] == BLACK ||
currentPlayer==BLACK && newX == i && newY == j)
@@ -391,25 +391,25 @@ void GoWidget::showStone( int x, int y, enum bVal c )
}
if ( board[x][y] == -1 && !Suicide( c, x, y ) ) {
newX = x;
newY = y;
refresh(x,y);
}
-
+
}
void GoWidget::mouseReleaseEvent( QMouseEvent * )
{
if ( gameActive && newX > -1 )
doMove( newX, newY );
newX = newY = -1;
}
void GoWidget::refresh( int x, int y )
{
- update( bx+d*x-d/2-1, by+d*y-d/2-1, d+2, d+2 );
+ update( bx+d*x-d/2-1, by+d*y-d/2-1, d+2, d+2 );
}
void GoWidget::removeStone(short x, short y)
{
board[x][y]=-1;
refresh( x, y );