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.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/noncore/games/go/gowidget.cpp b/noncore/games/go/gowidget.cpp
index fca9797..8567b30 100644
--- a/noncore/games/go/gowidget.cpp
+++ b/noncore/games/go/gowidget.cpp
@@ -40,24 +40,26 @@
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;
46//static QImage *blackStone; 46//static QImage *blackStone;
47//static QImage *whiteStone; 47//static QImage *whiteStone;
48static QPixmap *newBlackStone; 48static QPixmap *newBlackStone;
49static QPixmap *blackStone; 49static QPixmap *blackStone;
50static QPixmap *whiteStone; 50static QPixmap *whiteStone;
51 51
52static bool smallStones = FALSE;
53
52GoMainWidget::GoMainWidget( QWidget *parent, const char* name) : 54GoMainWidget::GoMainWidget( QWidget *parent, const char* name) :
53 QMainWindow( parent, name ) 55 QMainWindow( parent, name )
54{ 56{
55 setToolBarsMovable( FALSE ); 57 setToolBarsMovable( FALSE );
56 GoWidget *go = new GoWidget(this); 58 GoWidget *go = new GoWidget(this);
57 59
58 setCentralWidget(go); 60 setCentralWidget(go);
59 toolbar = new QPEToolBar(this); 61 toolbar = new QPEToolBar(this);
60 toolbar->setHorizontalStretchable( TRUE ); 62 toolbar->setHorizontalStretchable( TRUE );
61 addToolBar(toolbar); 63 addToolBar(toolbar);
62 64
63 QPEMenuBar *mb = new QPEMenuBar( toolbar ); 65 QPEMenuBar *mb = new QPEMenuBar( toolbar );
@@ -188,24 +190,37 @@ void GoWidget::readConfig()
188 blackPrisoners = cfg.readNumEntry("BlackPrisoners",0); 190 blackPrisoners = cfg.readNumEntry("BlackPrisoners",0);
189 whitePrisoners = cfg.readNumEntry("WhitePrisoners",0); 191 whitePrisoners = cfg.readNumEntry("WhitePrisoners",0);
190 reportPrisoners(blackPrisoners,whitePrisoners); 192 reportPrisoners(blackPrisoners,whitePrisoners);
191 emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone ); 193 emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone );
192} 194}
193 195
194void GoWidget::resizeEvent( QResizeEvent * ) 196void GoWidget::resizeEvent( QResizeEvent * )
195{ 197{
196 d = QMIN(width(),height())/19; 198 d = QMIN(width(),height())/19;
197 // int r = (d/2-1); 199 // int r = (d/2-1);
198 bx = (width() - 18*d)/2 ; 200 bx = (width() - 18*d)/2 ;
199 by = (height() - 18*d)/2 ; 201 by = (height() - 18*d)/2 ;
202
203 if ( d < 10 && !smallStones ) {
204 blackStone->convertFromImage( blackStone->convertToImage().smoothScale(8,8) );
205 whiteStone->convertFromImage( whiteStone->convertToImage().smoothScale(8,8) );
206 newBlackStone->convertFromImage( newBlackStone->convertToImage().smoothScale(8,8) );
207
208 smallStones = TRUE;
209 } else if ( d >= 10 && smallStones ) {
210 blackStone = new QPixmap(Resource::loadPixmap( "Go-black" ));
211 whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" ));
212 newBlackStone = new QPixmap(Resource::loadPixmap( "Go-black-highlight" ));
213 smallStones = FALSE;
214 }
200} 215}
201 216
202void GoWidget::init() 217void GoWidget::init()
203{ 218{
204 lastX = lastY = newX = newY = -1; 219 lastX = lastY = newX = newY = -1;
205 nPassed = 0; 220 nPassed = 0;
206 for ( int i = 0; i < 19; i++ ) 221 for ( int i = 0; i < 19; i++ )
207 for ( int j = 0; j < 19; j++ ) 222 for ( int j = 0; j < 19; j++ )
208 board[i][j]=-1; 223 board[i][j]=-1;
209 gameActive = TRUE; 224 gameActive = TRUE;
210 goRestart(current_handicap); 225 goRestart(current_handicap);
211 226