summaryrefslogtreecommitdiff
path: root/noncore/games
authorkergoth <kergoth>2002-06-07 18:53:14 (UTC)
committer kergoth <kergoth>2002-06-07 18:53:14 (UTC)
commit640d964cfdc7467f6cacb513087cd3acda2c04f0 (patch) (side-by-side diff)
tree9a784686c1795f8b1f81eb344598f3b549d43467 /noncore/games
parentdfb9c76738bb68e235114c5ad43dbd26a59b98ab (diff)
downloadopie-640d964cfdc7467f6cacb513087cd3acda2c04f0.zip
opie-640d964cfdc7467f6cacb513087cd3acda2c04f0.tar.gz
opie-640d964cfdc7467f6cacb513087cd3acda2c04f0.tar.bz2
Backing out unintentional merge from TT branch.
Diffstat (limited to 'noncore/games') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/go/gowidget.cpp15
-rw-r--r--noncore/games/minesweep/minefield.h30
-rw-r--r--noncore/games/minesweep/minesweep.cpp35
-rw-r--r--noncore/games/snake/interface.h2
-rw-r--r--noncore/games/snake/obstacle.cpp35
-rw-r--r--noncore/games/snake/obstacle.h4
-rw-r--r--noncore/games/solitaire/canvascard.cpp71
-rw-r--r--noncore/games/solitaire/canvasshapes.cpp52
-rw-r--r--noncore/games/solitaire/freecellcardgame.cpp11
-rw-r--r--noncore/games/solitaire/patiencecardgame.cpp49
-rw-r--r--noncore/games/solitaire/patiencecardgame.h7
-rw-r--r--noncore/games/wordgame/wordgame.cpp71
-rw-r--r--noncore/games/wordgame/wordgame.h6
13 files changed, 291 insertions, 97 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
@@ -46,12 +46,14 @@ static QBrush *goBrush;
//static QImage *blackStone;
//static QImage *whiteStone;
static QPixmap *newBlackStone;
static QPixmap *blackStone;
static QPixmap *whiteStone;
+static bool smallStones = FALSE;
+
GoMainWidget::GoMainWidget( QWidget *parent, const char* name) :
QMainWindow( parent, name )
{
setToolBarsMovable( FALSE );
GoWidget *go = new GoWidget(this);
@@ -194,12 +196,25 @@ void GoWidget::readConfig()
void GoWidget::resizeEvent( QResizeEvent * )
{
d = QMIN(width(),height())/19;
// int r = (d/2-1);
bx = (width() - 18*d)/2 ;
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;
+ }
}
void GoWidget::init()
{
lastX = lastY = newX = newY = -1;
nPassed = 0;
diff --git a/noncore/games/minesweep/minefield.h b/noncore/games/minesweep/minefield.h
index 4ede435..1349c35 100644
--- a/noncore/games/minesweep/minefield.h
+++ b/noncore/games/minesweep/minefield.h
@@ -17,18 +17,18 @@
** not clear to you.
**
**********************************************************************/
#ifndef MINEFIELD_H
#define MINEFIELD_H
-#include <qtable.h>
+#include <qscrollview.h>
class Mine;
class Config;
-class MineField : public QTable
+class MineField : public QScrollView
{
Q_OBJECT
public:
MineField( QWidget* parent = 0, const char* name = 0 );
~MineField();
@@ -38,50 +38,64 @@ public:
void readConfig(Config&);
void writeConfig(Config&) const;
int level() const { return lev; }
+ void setAvailableRect( const QRect & );
public slots:
void setup( int level );
void showMines();
signals:
void gameOver( bool won );
void gameStarted();
void mineCount( int );
protected:
- void paintFocus( QPainter*, const QRect& );
- void viewportMousePressEvent( QMouseEvent* );
- void viewportMouseReleaseEvent( QMouseEvent* );
+
+ void contentsMousePressEvent( QMouseEvent* );
+ void contentsMouseReleaseEvent( QMouseEvent* );
void keyPressEvent( QKeyEvent* );
void keyReleaseEvent( QKeyEvent* );
-
+ void drawContents( QPainter * p, int clipx, int clipy, int clipw, int cliph );
+
int getHint( int row, int col );
- void setHint( Mine* );
+ void setHint( int r, int c );
void updateMine( int row, int col );
void paletteChange( const QPalette & );
-
+ void updateCell( int r, int c );
+ bool onBoard( int r, int c ) const { return r >= 0 && r < numRows && c >= 0 && c < numCols; }
+ Mine *mine( int row, int col ) { return onBoard(row, col ) ? mines[row+numCols*col] : 0; }
+ const Mine *mine( int row, int col ) const { return onBoard(row, col ) ? mines[row+numCols*col] : 0; }
+
protected slots:
void cellPressed( int row, int col );
void cellClicked( int row, int col );
void held();
private:
+ int findCellSize();
+ void setCellSize( int );
+
State stat;
void MineField::setState( State st );
void MineField::placeMines();
enum FlagAction { NoAction, FlagOn, FlagNext };
FlagAction flagAction;
bool ignoreClick;
int currRow;
int currCol;
+ int numRows, numCols;
+
int minecount;
int mineguess;
int nonminecount;
int lev;
+ QRect availableRect;
+ int cellSize;
QTimer *holdTimer;
+ Mine **mines;
};
#endif // MINEFIELD_H
diff --git a/noncore/games/minesweep/minesweep.cpp b/noncore/games/minesweep/minesweep.cpp
index 6492462..c84fe53 100644
--- a/noncore/games/minesweep/minesweep.cpp
+++ b/noncore/games/minesweep/minesweep.cpp
@@ -216,31 +216,47 @@ void ResultIndicator::timerEvent( QTimerEvent *te )
} else {
delete this;
}
}
+class MineFrame : public QFrame
+{
+public:
+ MineFrame( QWidget *parent, const char *name = 0 )
+ :QFrame( parent, name ) {}
+ void setField( MineField *f ) { field = f; }
+protected:
+ void resizeEvent( QResizeEvent *e ) {
+ field->setAvailableRect( contentsRect());
+ QFrame::resizeEvent(e);
+ }
+private:
+ MineField *field;
+};
+
+
+
MineSweep::MineSweep( QWidget* parent, const char* name, WFlags f )
: QMainWindow( parent, name, f )
{
srand(::time(0));
setCaption( tr("Mine Hunt") );
setIcon( Resource::loadPixmap( "minesweep_icon" ) );
- QPEToolBar *menuToolBar = new QPEToolBar( this );
- QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar );
+ QPEToolBar *toolBar = new QPEToolBar( this );
+ toolBar->setHorizontalStretchable( TRUE );
+
+ QPEMenuBar *menuBar = new QPEMenuBar( toolBar );
QPopupMenu *gameMenu = new QPopupMenu( this );
gameMenu->insertItem( tr("Beginner"), this, SLOT( beginner() ) );
gameMenu->insertItem( tr("Advanced"), this, SLOT( advanced() ) );
gameMenu->insertItem( tr("Expert"), this, SLOT( expert() ) );
menuBar->insertItem( tr("Game"), gameMenu );
-
- QPEToolBar *toolBar = new QPEToolBar( this );
- toolBar->setHorizontalStretchable( TRUE );
guessLCD = new QLCDNumber( toolBar );
toolBar->setStretchableWidget( guessLCD );
QPalette lcdPal( red );
lcdPal.setColor( QColorGroup::Background, QApplication::palette().active().background() );
@@ -262,23 +278,22 @@ MineSweep::MineSweep( QWidget* parent, const char* name, WFlags f )
timeLCD->setFrameStyle( QFrame::NoFrame );
timeLCD->setNumDigits( 5 ); // "mm:ss"
timeLCD->setBackgroundMode( PaletteButton );
setToolBarsMovable ( FALSE );
- addToolBar( menuToolBar );
addToolBar( toolBar );
- QFrame *mainframe = new QFrame( this );
+ MineFrame *mainframe = new MineFrame( this );
mainframe->setFrameShape( QFrame::Box );
mainframe->setFrameShadow( QFrame::Raised );
- mainframe->setMargin(5);
+
mainframe->setLineWidth(2);
- QBoxLayout *box = new QVBoxLayout( mainframe );
+
field = new MineField( mainframe );
- box->addWidget( field, 0, AlignCenter );
+ mainframe->setField( field );
QFont fnt = field->font();
fnt.setBold( TRUE );
field->setFont( QFont( fnt ) );
field->setFocus();
setCentralWidget( mainframe );
diff --git a/noncore/games/snake/interface.h b/noncore/games/snake/interface.h
index 30c7f84..454d4ee 100644
--- a/noncore/games/snake/interface.h
+++ b/noncore/games/snake/interface.h
@@ -33,13 +33,12 @@ class SnakeGame : public QMainWindow {
public:
SnakeGame(QWidget* parent=0, const char* name=0, WFlags f=0);
~SnakeGame();
void clear();
void createTargets();
- void welcomescreen();
protected:
virtual void keyPressEvent(QKeyEvent*);
virtual void resizeEvent(QResizeEvent *e);
signals:
@@ -48,12 +47,13 @@ signals:
private slots:
void newGame();
void gameOver();
void wait();
void levelUp();
void scoreInc();
+ void welcomescreen();
private:
void showScore(int);
QCanvasView* cv;
QLabel* scorelabel;
QCanvas canvas;
diff --git a/noncore/games/snake/obstacle.cpp b/noncore/games/snake/obstacle.cpp
index 2d07fe7..4bdefa5 100644
--- a/noncore/games/snake/obstacle.cpp
+++ b/noncore/games/snake/obstacle.cpp
@@ -20,26 +20,45 @@
#include "obstacle.h"
#include "codes.h"
#include <qpe/resource.h>
-Obstacle::Obstacle(QCanvas* canvas, int x, int y)
- : QCanvasSprite(0, canvas)
+
+
+Obstacle::Obstacle(QCanvas* canvas, int y)
+ : QCanvasSprite(0,canvas)
{
- newObstacle(x, y);
+ newObstacle(y);
}
-void Obstacle::newObstacle(int x, int y)
+void Obstacle::newObstacle(int y)
{
- QCanvasPixmapArray* obstaclearray = new QCanvasPixmapArray(Resource::findPixmap("snake/wall.png"));
-
+ QPixmap obstaclePix( Resource::findPixmap("snake/wall.png") );
+
+ if ( obstaclePix.width() > canvas()->width()*3/5 ) {
+ int w = canvas()->width()*3/5;
+ w = w - w % 16;
+ obstaclePix.resize( w, obstaclePix.height() );
+ }
+
+ QList<QPixmap> pixl;
+ pixl.append( &obstaclePix );
+
+ QPoint nullp;
+ QList<QPoint> pl;
+ pl.append( &nullp );
+
+ QCanvasPixmapArray* obstaclearray = new QCanvasPixmapArray(pixl, pl);
setSequence(obstaclearray);
-
+
+ int x = ( canvas()->width() - obstaclePix.width() )/2;
+ x = x - x % 16;
+ y = y - y % 16;
move(x, y);
-
+ setZ( -100 );
show();
canvas()->update();
}
int Obstacle::rtti() const
{
diff --git a/noncore/games/snake/obstacle.h b/noncore/games/snake/obstacle.h
index 838917f..b3c7846 100644
--- a/noncore/games/snake/obstacle.h
+++ b/noncore/games/snake/obstacle.h
@@ -20,11 +20,11 @@
#include <qcanvas.h>
class Obstacle : public QCanvasSprite
{
public:
- Obstacle(QCanvas*, int x, int y);
+ Obstacle(QCanvas*, int y);
~Obstacle();
- void newObstacle(int x, int y);
+ void newObstacle(int y);
int rtti() const;
};
diff --git a/noncore/games/solitaire/canvascard.cpp b/noncore/games/solitaire/canvascard.cpp
index ae3c859..7c4a5ba 100644
--- a/noncore/games/solitaire/canvascard.cpp
+++ b/noncore/games/solitaire/canvascard.cpp
@@ -24,12 +24,13 @@
#include <qpe/resource.h>
#include <qpainter.h>
#include <qimage.h>
#include <qpaintdevice.h>
#include <qbitmap.h>
+#include <qgfx_qws.h> // Needed to get the device's width
#include <math.h>
#if defined( QT_QWS_CASSIOPEIA )
#define SLOW_HARDWARE
#endif
@@ -99,16 +100,23 @@ QBitmap *CanvasCard::cardsSuitsUpsideDown = NULL;
CanvasCard::CanvasCard( eValue v, eSuit s, bool f, QCanvas *canvas ) :
Card(v, s, f), QCanvasRectangle( 0, 0, 1, 1, canvas ), cardBack(1), scaleX(1.0), scaleY(1.0)
{
if ( !cardsFaces ) {
- cardsFaces = new QPixmap( Resource::loadPixmap( "cards/card_face" ) );
- cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) );
- cardsChars = new QBitmap( Resource::loadBitmap( "cards/card_chars" ) );
- cardsSuits = new QBitmap( Resource::loadBitmap( "cards/card_suits" ) );
+ if ( qt_screen->deviceWidth() < 200 ) {
+ cardsFaces = new QPixmap( Resource::loadPixmap( "cards/card_face_small" ) );
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001_small" ) );
+ cardsChars = new QBitmap( Resource::loadBitmap( "cards/card_chars_small" ) );
+ cardsSuits = new QBitmap( Resource::loadBitmap( "cards/card_suits_small" ) );
+ } else {
+ cardsFaces = new QPixmap( Resource::loadPixmap( "cards/card_face" ) );
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) );
+ cardsChars = new QBitmap( Resource::loadBitmap( "cards/card_chars" ) );
+ cardsSuits = new QBitmap( Resource::loadBitmap( "cards/card_suits" ) );
+ }
cardsCharsUpsideDown = Create180RotatedBitmap( cardsChars );
cardsSuitsUpsideDown = Create180RotatedBitmap( cardsSuits );
}
xOff = cardsFaces->width() / 2;
yOff = cardsFaces->height() / 2;
setSize( cardsFaces->width(), cardsFaces->height() );
@@ -123,23 +131,38 @@ void CanvasCard::setCardBack(int b)
cardBack = b;
if ( cardsBacks )
delete cardsBacks;
- switch (cardBack) {
- case 0:
- cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) ); break;
- case 1:
- cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0002" ) ); break;
- case 2:
- cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0003" ) ); break;
- case 3:
- cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0004" ) ); break;
- case 4:
- cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0005" ) ); break;
+ if ( qt_screen->deviceWidth() < 200 ) {
+ switch (cardBack) {
+ case 0:
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001_small" ) ); break;
+ case 1:
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0002_small" ) ); break;
+ case 2:
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0003_small" ) ); break;
+ case 3:
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0004_small" ) ); break;
+ case 4:
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0005_small" ) ); break;
+ }
+ } else {
+ switch (cardBack) {
+ case 0:
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) ); break;
+ case 1:
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0002" ) ); break;
+ case 2:
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0003" ) ); break;
+ case 3:
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0004" ) ); break;
+ case 4:
+ cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0005" ) ); break;
+ }
}
if ( !isFacing() )
redraw();
}
}
@@ -178,17 +201,25 @@ void CanvasCard::draw(QPainter &painter)
if ( isRed() == TRUE )
p->setPen( QColor( 0xFF, 0, 0 ) );
else
p->setPen( QColor( 0, 0, 0 ) );
- p->drawPixmap( ix + 0, iy + 0, *cardsFaces );
- p->drawPixmap( ix + 4, iy + 4, *cardsChars, 7*(getValue()-1), 0, 7, 7 );
- p->drawPixmap( ix + 12, iy + 4, *cardsSuits, 7*(getSuit()-1), 0, 7, 8 );
- p->drawPixmap( ix + w-4-7, iy + h-4-7, *cardsCharsUpsideDown, 7*(12-getValue()+1), 0, 7, 7 );
- p->drawPixmap( ix + w-12-7, iy + h-5-7, *cardsSuitsUpsideDown, 7*(3-getSuit()+1), 0, 7, 8 );
+ if ( qt_screen->deviceWidth() < 200 ) {
+ p->drawPixmap( ix + 0, iy + 0, *cardsFaces );
+ p->drawPixmap( ix + 3, iy + 3, *cardsChars, 5*(getValue()-1), 0, 5, 6 );
+ p->drawPixmap( ix + 11, iy + 3, *cardsSuits, 5*(getSuit()-1), 0, 5, 6 );
+ p->drawPixmap( ix + w-3-5, iy + h-3-6, *cardsCharsUpsideDown, 5*(12-getValue()+1), 0, 5, 6 );
+ p->drawPixmap( ix + w-11-5, iy + h-3-6, *cardsSuitsUpsideDown, 5*(3-getSuit()+1), 0, 5, 6 );
+ } else {
+ p->drawPixmap( ix + 0, iy + 0, *cardsFaces );
+ p->drawPixmap( ix + 4, iy + 4, *cardsChars, 7*(getValue()-1), 0, 7, 7 );
+ p->drawPixmap( ix + 12, iy + 4, *cardsSuits, 7*(getSuit()-1), 0, 7, 8 );
+ p->drawPixmap( ix + w-4-7, iy + h-4-7, *cardsCharsUpsideDown, 7*(12-getValue()+1), 0, 7, 7 );
+ p->drawPixmap( ix + w-12-7, iy + h-5-7, *cardsSuitsUpsideDown, 7*(3-getSuit()+1), 0, 7, 8 );
+ }
} else {
p->drawPixmap( ix, iy, *cardsBacks );
}
diff --git a/noncore/games/solitaire/canvasshapes.cpp b/noncore/games/solitaire/canvasshapes.cpp
index 28d0b4e..6ccd4a4 100644
--- a/noncore/games/solitaire/canvasshapes.cpp
+++ b/noncore/games/solitaire/canvasshapes.cpp
@@ -16,17 +16,18 @@
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include <qpainter.h>
#include <qcanvas.h>
+#include <qgfx_qws.h>
#include "canvasshapes.h"
CanvasRoundRect::CanvasRoundRect(int x, int y, QCanvas *canvas) :
- QCanvasRectangle( x, y, 23, 36, canvas)
+ QCanvasRectangle( x, y, ( qt_screen->deviceWidth() < 200 ) ? 20 : 23, ( qt_screen->deviceWidth() < 200 ) ? 27 : 36, canvas)
{
setZ(0);
show();
}
@@ -36,13 +37,16 @@ void CanvasRoundRect::redraw()
show();
}
void CanvasRoundRect::drawShape(QPainter &p)
{
- p.drawRoundRect( (int)x(), (int)y(), 23, 36);
+ if ( qt_screen->deviceWidth() < 200 )
+ p.drawRoundRect( (int)x() + 1, (int)y() + 1, 18, 25);
+ else
+ p.drawRoundRect( (int)x(), (int)y(), 23, 36);
}
CanvasCircleOrCross::CanvasCircleOrCross(int x, int y, QCanvas *canvas) :
QCanvasRectangle( x, y, 21, 21, canvas), circleShape(TRUE)
{
@@ -70,23 +74,41 @@ void CanvasCircleOrCross::setCross()
redraw();
}
void CanvasCircleOrCross::drawShape(QPainter &p)
{
- int x1 = (int)x(), y1 = (int)y();
- // Green circle
- if (circleShape == TRUE) {
- p.setPen( QPen( QColor(0x10, 0xE0, 0x10), 1 ) );
- p.drawEllipse( x1 - 1, y1 - 1, 21, 21);
- p.drawEllipse( x1 - 1, y1 - 0, 21, 19);
- p.drawEllipse( x1 + 0, y1 + 0, 19, 19);
- p.drawEllipse( x1 + 1, y1 + 0, 17, 19);
- p.drawEllipse( x1 + 1, y1 + 1, 17, 17);
- // Red cross
+ if ( qt_screen->deviceWidth() < 200 ) {
+ int x1 = (int)x(), y1 = (int)y();
+ // Green circle
+ if (circleShape == TRUE) {
+ p.setPen( QPen( QColor(0x10, 0xE0, 0x10), 1 ) );
+ p.drawEllipse( x1 - 1, y1 - 1, 17, 17);
+ p.drawEllipse( x1 - 1, y1 - 0, 17, 15);
+ p.drawEllipse( x1 + 0, y1 + 0, 15, 15);
+ p.drawEllipse( x1 + 1, y1 + 0, 13, 15);
+ p.drawEllipse( x1 + 1, y1 + 1, 13, 13);
+ // Red cross
+ } else {
+ p.setPen( QPen( QColor(0xE0, 0x10, 0x10), 4 ) );
+ p.drawLine( x1, y1, x1 + 14, y1 + 14);
+ p.drawLine( x1 + 14, y1, x1, y1 + 14);
+ }
} else {
- p.setPen( QPen( QColor(0xE0, 0x10, 0x10), 5 ) );
- p.drawLine( x1, y1, x1 + 20, y1 + 20);
- p.drawLine( x1 + 20, y1, x1, y1 + 20);
+ int x1 = (int)x(), y1 = (int)y();
+ // Green circle
+ if (circleShape == TRUE) {
+ p.setPen( QPen( QColor(0x10, 0xE0, 0x10), 1 ) );
+ p.drawEllipse( x1 - 1, y1 - 1, 21, 21);
+ p.drawEllipse( x1 - 1, y1 - 0, 21, 19);
+ p.drawEllipse( x1 + 0, y1 + 0, 19, 19);
+ p.drawEllipse( x1 + 1, y1 + 0, 17, 19);
+ p.drawEllipse( x1 + 1, y1 + 1, 17, 17);
+ // Red cross
+ } else {
+ p.setPen( QPen( QColor(0xE0, 0x10, 0x10), 5 ) );
+ p.drawLine( x1, y1, x1 + 20, y1 + 20);
+ p.drawLine( x1 + 20, y1, x1, y1 + 20);
+ }
}
}
diff --git a/noncore/games/solitaire/freecellcardgame.cpp b/noncore/games/solitaire/freecellcardgame.cpp
index e82afd4..98415aa 100644
--- a/noncore/games/solitaire/freecellcardgame.cpp
+++ b/noncore/games/solitaire/freecellcardgame.cpp
@@ -14,34 +14,39 @@
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
+#include <qgfx_qws.h>
#include "freecellcardgame.h"
extern int highestZ;
int numberOfFreeCells = 4;
FreecellCardGame::FreecellCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent)
{
numberOfFreeCells = 4;
highestZ = 0;
+ int spaceBetweenPiles = ( qt_screen->deviceWidth() < 200 ) ? 21 : 28;
+ int xOrigin = ( qt_screen->deviceWidth() < 200 ) ? 0 : 5;
+ int spacing = ( qt_screen->deviceWidth() < 200 ) ? 0 : 0;
+
for (int i = 0; i < 4; i++) {
- freecellPiles[i] = new FreecellFreecellPile( 5 + i * 28, 10, canvas() );
+ freecellPiles[i] = new FreecellFreecellPile( xOrigin + i * spaceBetweenPiles, 10, canvas() );
addCardPile(freecellPiles[i]);
}
for (int i = 0; i < 4; i++) {
- discardPiles[i] = new FreecellDiscardPile( 125 + i * 28, 10, canvas() );
+ discardPiles[i] = new FreecellDiscardPile( xOrigin + spacing + 6 + (i + 4) * spaceBetweenPiles, 10, canvas() );
addCardPile(discardPiles[i]);
}
for (int i = 0; i < 8; i++) {
- workingPiles[i] = new FreecellWorkingPile( 10 + i * 28, 50, canvas() );
+ workingPiles[i] = new FreecellWorkingPile( xOrigin + spacing + 2 + i * spaceBetweenPiles, 50, canvas() );
addCardPile(workingPiles[i]);
}
}
void FreecellCardGame::deal(void)
diff --git a/noncore/games/solitaire/patiencecardgame.cpp b/noncore/games/solitaire/patiencecardgame.cpp
index 5a9326a..1501d2f 100644
--- a/noncore/games/solitaire/patiencecardgame.cpp
+++ b/noncore/games/solitaire/patiencecardgame.cpp
@@ -14,36 +14,53 @@
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
+#include <qgfx_qws.h>
#include "patiencecardgame.h"
int highestZ = 0;
PatienceCardGame::PatienceCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent)
{
numberOfTimesThroughDeck = 0;
highestZ = 0;
- circleCross = new CanvasCircleOrCross( 7, 18, canvas() );
- rectangle = new CanvasRoundRect( 35, 10, canvas() );
+ if ( qt_screen->deviceWidth() < 200 ) {
+ circleCross = new CanvasCircleOrCross( 7, 16, canvas() );
+ rectangle = new CanvasRoundRect( 30, 10, canvas() );
- for (int i = 0; i < 4; i++) {
- discardPiles[i] = new PatienceDiscardPile( 110 + i * 30, 10, canvas() );
- addCardPile(discardPiles[i]);
- }
- for (int i = 0; i < 7; i++) {
- workingPiles[i] = new PatienceWorkingPile( 10 + i * 30, 50, canvas() );
- addCardPile(workingPiles[i]);
+ for (int i = 0; i < 4; i++) {
+ discardPiles[i] = new PatienceDiscardPile( 78 + i * 23, 10, canvas() );
+ addCardPile(discardPiles[i]);
+ }
+ for (int i = 0; i < 7; i++) {
+ workingPiles[i] = new PatienceWorkingPile( 5 + i * 23, 50, canvas() );
+ addCardPile(workingPiles[i]);
+ }
+ faceDownDealingPile = new PatienceFaceDownDeck( 5, 10, canvas() );
+ faceUpDealingPile = new PatienceFaceUpDeck( 30, 10, canvas() );
+ } else {
+ circleCross = new CanvasCircleOrCross( 7, 18, canvas() );
+ rectangle = new CanvasRoundRect( 35, 10, canvas() );
+
+ for (int i = 0; i < 4; i++) {
+ discardPiles[i] = new PatienceDiscardPile( 110 + i * 30, 10, canvas() );
+ addCardPile(discardPiles[i]);
+ }
+ for (int i = 0; i < 7; i++) {
+ workingPiles[i] = new PatienceWorkingPile( 10 + i * 30, 50, canvas() );
+ addCardPile(workingPiles[i]);
+ }
+ faceDownDealingPile = new PatienceFaceDownDeck( 5, 10, canvas() );
+ faceUpDealingPile = new PatienceFaceUpDeck( 35, 10, canvas() );
}
- faceDownDealingPile = new PatienceFaceDownDeck( 5, 10, canvas() );
- faceUpDealingPile = new PatienceFaceUpDeck( 35, 10, canvas() );
}
PatienceCardGame::~PatienceCardGame()
{
delete circleCross;
@@ -170,13 +187,16 @@ bool PatienceCardGame::mousePressCard( Card *card, QPoint p )
// Added Code
faceDownDealingPile->removeCard(item);
faceUpDealingPile->addCardToTop(item);
item->setCardPile( faceUpDealingPile );
- item->flipTo( 35, (int)item->y() );
+ if ( qt_screen->deviceWidth() < 200 )
+ item->flipTo( 30, (int)item->y() );
+ else
+ item->flipTo( 35, (int)item->y() );
}
moving = NULL;
moved = FALSE;
// move two other cards if we flip three at a time
int flipped = 1;
@@ -192,13 +212,16 @@ bool PatienceCardGame::mousePressCard( Card *card, QPoint p )
// Added Code
faceDownDealingPile->removeCard(item);
faceUpDealingPile->addCardToTop(item);
item->setCardPile( faceUpDealingPile );
- item->flipTo( 35, (int)item->y(), 8 * flipped );
+ if ( qt_screen->deviceWidth() < 200 )
+ item->flipTo( 30, (int)item->y(), 8 * flipped );
+ else
+ item->flipTo( 35, (int)item->y(), 8 * flipped );
}
}
return TRUE;
}
diff --git a/noncore/games/solitaire/patiencecardgame.h b/noncore/games/solitaire/patiencecardgame.h
index c4f6c48..0d0e3d5 100644
--- a/noncore/games/solitaire/patiencecardgame.h
+++ b/noncore/games/solitaire/patiencecardgame.h
@@ -22,12 +22,13 @@
#include <qpopupmenu.h>
#include <qmainwindow.h>
#include <qintdict.h>
#include <qcanvas.h>
+#include <qgfx_qws.h>
// #include "canvascardshapes.h"
// #include "canvascard.h"
#include "canvascardgame.h"
class PatienceFaceDownDeck : public CardPile, public CanvasRoundRect
@@ -127,28 +128,30 @@ public:
setNextX( pileX );
setNextY( pileY );
return;
} else {
top = getCardPos(NULL);
if ( newTopCard->isFacing() == FALSE ) {
+ int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13;
// correct the position taking in to account the card is not
// yet flipped, but will become flipped
top = QPoint( top.x() - 1, top.y() - 3 );
newTopCard->flipTo( top.x(), top.y() );
- top = QPoint( top.x(), top.y() + 13 );
+ top = QPoint( top.x(), top.y() + offsetDown );
}
setNextX( top.x() );
setNextY( top.y() );
}
}
virtual QPoint getCardPos(Card *c) {
int x = pileX, y = pileY;
Card *card = cardOnBottom();
while ((card != c) && (card != NULL)) {
if (card->isFacing()) {
- y += 13;
+ int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13;
+ y += offsetDown;
} else {
x += 1;
y += 3;
}
card = cardInfront(card);
}
diff --git a/noncore/games/wordgame/wordgame.cpp b/noncore/games/wordgame/wordgame.cpp
index ca4352d..16d37b3 100644
--- a/noncore/games/wordgame/wordgame.cpp
+++ b/noncore/games/wordgame/wordgame.cpp
@@ -56,12 +56,19 @@
enum RuleEffects {
Multiplier=15,
MultiplyAll=64,
Start=128
};
+static int tile_smallw = 16;
+static int tile_smallh = 16;
+static int tile_bigw = 22;
+static int tile_bigh = 22;
+static int tile_stweak = -2;
+static int tile_btweak = -1;
+
static const int rack_tiles=7;
const char* sampleWGR=
"wordgame_shapes\n"
"15 15\n"
"400001040100004\n"
@@ -108,12 +115,21 @@ const char* sampleWGR=
"11 e 1\n"
"0\n";
WordGame::WordGame( QWidget* parent, const char* name, WFlags fl ) :
QMainWindow(parent, name, fl)
{
+ if ( qApp->desktop()->width() < 240 ) {
+ tile_smallw = 10;
+ tile_smallh = 10;
+ tile_bigw = 16;
+ tile_bigh = 16;
+ tile_stweak = 0;
+ tile_btweak = 0;
+ }
+
setIcon( Resource::loadPixmap( "wordgame" ) );
setCaption( tr("Word Game") );
setToolBarsMovable( FALSE );
vbox = new QVBox(this);
@@ -244,12 +260,13 @@ void WordGame::startGame()
}
void WordGame::startGame(const QStringList& playerlist)
{
toolbar->show();
racks = new QWidgetStack(vbox);
+ racks->setFixedHeight(TileItem::bigHeight()+2);
namelist.clear();
nplayers=0;
for (QStringList::ConstIterator it=playerlist.begin(); it!=playerlist.end(); ++it)
addPlayer(*it);
scoreinfo->init(namelist);
@@ -280,13 +297,12 @@ bool WordGame::loadRules(const QString &name)
int htiles,vtiles;
ts >> htiles >> vtiles;
if ( htiles < 3 || vtiles < 3 )
return FALSE;
- QPixmap bgshapes = Resource::loadPixmap(shapepixmap);
QString rule_shapes;
for (int i=0; i<vtiles; i++) {
QString line;
ts >> line;
rule_shapes += line;
}
@@ -294,12 +310,18 @@ bool WordGame::loadRules(const QString &name)
int re=0,e;
ts >> e;
while ( e && re < 10 ) {
rule_effects[re] = e;
if ( re++ < 10 ) ts >> e;
}
+
+ QImage shim = Resource::loadImage(shapepixmap);
+ shim = shim.smoothScale((re-1)*TileItem::smallWidth(),TileItem::smallHeight());
+ QPixmap bgshapes;
+ bgshapes.convertFromImage(shim);
+
rule_effects[re++] = 100; // default bonus
board = new Board(bgshapes, htiles, vtiles, vbox);
board->setRules(rule_shapes, rule_effects);
connect(board, SIGNAL(temporaryScore(int)), scoreinfo, SLOT(showTemporaryScore(int)));
bag = new Bag;
@@ -678,28 +700,28 @@ qDebug("%d,%d: %s (%d) for %d",current.x(),current.y(),st.latin1(),n,s);
best_start = current;
}
}
int TileItem::smallWidth()
{
- return 16;
+ return tile_smallw;
}
int TileItem::smallHeight()
{
- return 16;
+ return tile_smallh;
}
int TileItem::bigWidth()
{
- return 22;
+ return tile_bigw;
}
int TileItem::bigHeight()
{
- return 22;
+ return tile_bigh;
}
void TileItem::setState( State state )
{
hide();
s = state;
@@ -717,42 +739,53 @@ void TileItem::setBig(bool b)
{
big = b;
}
void TileItem::drawShape(QPainter& p)
{
- static QFont value_font("heletica",8);
- static QFont big_font("smoothtimes",17);
- static QFont small_font("smoothtimes",10);
+ static QFont *value_font=0;
+ static QFont *big_font=0;
+ static QFont *small_font=0;
+ if ( !value_font ) {
+ value_font = new QFont("helvetica",8);
+ if ( TileItem::bigWidth() < 20 ) {
+ big_font = new QFont("helvetica",12);
+ small_font = new QFont("helvetica",8);
+ } else {
+ big_font = new QFont("smoothtimes",17);
+ small_font = new QFont("smoothtimes",10);
+ }
+ }
QRect area(x(),y(),width(),height());
p.setBrush(s == Floating ? yellow/*lightGray*/ : white);
p.drawRect(area);
if ( big ) {
- p.setFont(value_font);
+ p.setFont(*value_font);
QString n = QString::number(t.value());
int w = p.fontMetrics().width('1');
int h = p.fontMetrics().height();
w *= n.length();
- QRect valuearea(x()+width()-w-2,y()+height()-h+1,w,h);
+ QRect valuearea(x()+width()-w-1,y()+height()-h,w,h);
p.drawText(valuearea,AlignCenter,n);
- p.setFont(big_font);
- area = QRect(x(),y(),width()-2,height()-1);
+ p.setFont(*big_font);
+ area = QRect(x(),y()+tile_btweak,width()-4,height()-1);
} else {
- p.setFont(small_font);
- area = QRect(x(),y()+2,width(),height()-2);
+ p.setFont(*small_font);
+ area = QRect(x()+1+tile_stweak,y()+1,width(),height()-3);
}
if ( t.value() == 0 )
p.setPen(darkGray);
p.drawText(area,AlignCenter,t.text().upper());
}
Board::Board(QPixmap bgshapes, int w, int h, QWidget* parent) :
QCanvasView(new QCanvas(bgshapes,w,h, TileItem::smallWidth(), TileItem::smallHeight()),
parent)
{
+ setFixedSize(w*TileItem::smallWidth(),h*TileItem::smallHeight());
grid = new TileItem*[w*h];
memset(grid,0,w*h*sizeof(TileItem*));
setFrameStyle(0);
setHScrollBarMode(AlwaysOff);
setVScrollBarMode(AlwaysOff);
current_rack = 0;
@@ -761,12 +794,17 @@ Board::Board(QPixmap bgshapes, int w, int h, QWidget* parent) :
Board::~Board()
{
delete canvas();
}
+QSize Board::sizeHint() const
+{
+ return QSize(canvas()->width(),canvas()->height());
+}
+
void Board::writeConfig(Config& cfg)
{
QStringList t;
int n=canvas()->tilesHorizontally()*canvas()->tilesVertically();
for (int i=0; i<n; i++)
t.append( grid[i] ? grid[i]->tile().key() : QString(".") );
@@ -1178,12 +1216,17 @@ Rack::Rack(int ntiles, QWidget* parent) : QCanvasView(
Rack::~Rack()
{
clear();
delete canvas();
}
+QSize Rack::sizeHint() const
+{
+ return QSize(-1,TileItem::bigHeight()+2);
+}
+
void Rack::clear()
{
for (int i=0; i<n; i++)
delete item[i];
n=0;
}
diff --git a/noncore/games/wordgame/wordgame.h b/noncore/games/wordgame/wordgame.h
index 0ffa56a..f73c85a 100644
--- a/noncore/games/wordgame/wordgame.h
+++ b/noncore/games/wordgame/wordgame.h
@@ -145,12 +145,14 @@ public:
void setPlayerName(const QString& name) { nm = name; }
QString playerName() const { return nm; }
void setComputerization(int level) { cpu=level; }
bool computerized() const { return cpu>0; }
+ QSize sizeHint() const;
+
protected:
void resizeEvent(QResizeEvent*e);
void contentsMousePressEvent(QMouseEvent*);
void contentsMouseMoveEvent(QMouseEvent*);
void contentsMouseReleaseEvent(QMouseEvent*);
@@ -208,12 +210,14 @@ public:
const QPoint& d, bool ignoredict, QStringList* words) const;
int bonussedValue(const QPoint& at, int base, int& all_mult) const;
bool isStart(const QPoint& at) const;
int turnScore() const { return turn_score; }
+ QSize sizeHint() const;
+
signals:
void temporaryScore(int);
protected:
void contentsMousePressEvent(QMouseEvent*);
void contentsMouseMoveEvent(QMouseEvent*);
@@ -328,13 +332,13 @@ private:
bool refillRack(int i);
void readyRack(int i);
Rack* rack(int i) const;
QWidgetStack *racks;
QToolBar* toolbar;
- QVBox *vbox;
+ QWidget *vbox;
Board *board;
Bag *bag;
ScoreInfo *scoreinfo;
QToolButton *done;
QToolButton *reset;
QTimer* aiheart;