author | llornkcor <llornkcor> | 2002-10-26 21:48:55 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-10-26 21:48:55 (UTC) |
commit | 995821ed8070504d482212b27d9f616a4eb07a3f (patch) (side-by-side diff) | |
tree | cb3ebda16107248544d4153743aacd73d2f81c19 /noncore | |
parent | ff2c581b50252714fb4621d088cbf0961ed23f2b (diff) | |
download | opie-995821ed8070504d482212b27d9f616a4eb07a3f.zip opie-995821ed8070504d482212b27d9f616a4eb07a3f.tar.gz opie-995821ed8070504d482212b27d9f616a4eb07a3f.tar.bz2 |
now remembers how many cards to turn
-rw-r--r-- | noncore/games/solitaire/canvascardwindow.cpp | 120 | ||||
-rw-r--r-- | noncore/games/solitaire/opie-solitaire.control | 2 |
2 files changed, 66 insertions, 56 deletions
diff --git a/noncore/games/solitaire/canvascardwindow.cpp b/noncore/games/solitaire/canvascardwindow.cpp index 450b4db..e836eb2 100644 --- a/noncore/games/solitaire/canvascardwindow.cpp +++ b/noncore/games/solitaire/canvascardwindow.cpp @@ -38,17 +38,17 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) { setIcon( Resource::loadPixmap( "cards" ) ); // Create Playing Area for Games if ( QPixmap::defaultDepth() < 12 ) { // canvas.setBackgroundColor(QColor(0x51, 0x74, 0x6B)); -// canvas.setBackgroundColor(QColor(0x20, 0xb0, 0x50)); - canvas.setBackgroundColor(QColor(0x08, 0x98, 0x2D)); +// canvas.setBackgroundColor(QColor(0x20, 0xb0, 0x50)); + canvas.setBackgroundColor(QColor(0x08, 0x98, 0x2D)); } else { QPixmap bg; - bg.convertFromImage( Resource::loadImage( "table_pattern" ), ThresholdDither ); + bg.convertFromImage( Resource::loadImage( "table_pattern" ), ThresholdDither ); canvas.setBackgroundPixmap(bg); } #if defined( QT_QWS_CASSIOPEIA ) canvas.setAdvancePeriod(70); #else @@ -99,78 +99,82 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) settings->insertItem(tr("Change Card Backs"), this, SLOT(changeCardBacks())); snap_id = settings->insertItem(tr("Snap To Position"), this, SLOT(snapToggle())); QString m; drawId = settings->insertItem(tr("Turn One Card"), this, SLOT(drawnToggle())); menu->insertItem(tr("Settings"),settings); + settings->setCheckable(TRUE); #endif menu->show(); Config cfg( "Patience" ); cfg.setGroup( "GlobalSettings" ); snapOn = cfg.readBoolEntry( "SnapOn", TRUE); settings->setItemChecked(snap_id, snapOn); + gameType = cfg.readNumEntry( "GameType", -1 ); - drawThree = cfg.readBoolEntry( "DrawThree", TRUE); + drawThree = cfg.readBoolEntry( "DrawThree", FALSE); if ( gameType == 0 ) { - cardGame = new PatienceCardGame( &canvas, snapOn, this ); - cardGame->setNumberToDraw(drawThree ? 3 : 1); - setCaption(tr("Patience")); - setCentralWidget(cardGame); - cardGame->readConfig( cfg ); - setCardBacks(); + cardGame = new PatienceCardGame( &canvas, snapOn, this ); + cardGame->setNumberToDraw(drawThree ? 3 : 1); + + setCaption(tr("Patience")); + setCentralWidget(cardGame); + cardGame->readConfig( cfg ); + setCardBacks(); } else if ( gameType == 1 ) { - cardGame = new FreecellCardGame( &canvas, snapOn, this ); - setCaption(tr("Freecell")); - setCentralWidget(cardGame); - //cardGame->newGame(); // Until we know how to handle reading freecell config - cardGame->readConfig( cfg ); - setCardBacks(); + cardGame = new FreecellCardGame( &canvas, snapOn, this ); + setCaption(tr("Freecell")); + setCentralWidget(cardGame); + //cardGame->newGame(); // Until we know how to handle reading freecell config + cardGame->readConfig( cfg ); + setCardBacks(); } else if ( gameType == 2 ) { - cardGame = new ChicaneCardGame( &canvas, snapOn, this ); - cardGame->setNumberToDraw(1); - setCaption(tr("Chicane")); - setCentralWidget(cardGame); - cardGame->readConfig( cfg ); - setCardBacks(); + cardGame = new ChicaneCardGame( &canvas, snapOn, this ); + cardGame->setNumberToDraw(1); + setCaption(tr("Chicane")); + setCentralWidget(cardGame); + cardGame->readConfig( cfg ); + setCardBacks(); } else if ( gameType == 3 ) { - cardGame = new HarpCardGame( &canvas, snapOn, this ); - cardGame->setNumberToDraw(1); - setCaption(tr("Harp")); - setCentralWidget(cardGame); - cardGame->readConfig( cfg ); - setCardBacks(); + cardGame = new HarpCardGame( &canvas, snapOn, this ); + cardGame->setNumberToDraw(1); + setCaption(tr("Harp")); + setCentralWidget(cardGame); + cardGame->readConfig( cfg ); + setCardBacks(); } else if ( gameType == 4 ) { - cardGame = new TeeclubCardGame( &canvas, snapOn, this ); - cardGame->setNumberToDraw(1); - setCaption(tr("Teeclub")); - setCentralWidget(cardGame); - cardGame->readConfig( cfg ); - setCardBacks(); + cardGame = new TeeclubCardGame( &canvas, snapOn, this ); + cardGame->setNumberToDraw(1); + setCaption(tr("Teeclub")); + setCentralWidget(cardGame); + cardGame->readConfig( cfg ); + setCardBacks(); } else { - // Probably there isn't a config file or it is broken - // Start a new game - initPatience(); + // Probably there isn't a config file or it is broken + // Start a new game + initPatience(); } updateDraw(); } CanvasCardWindow::~CanvasCardWindow() { if (cardGame) { - Config cfg("Patience"); - cfg.setGroup( "GlobalSettings" ); - cfg.writeEntry( "GameType", gameType ); - cfg.writeEntry( "SnapOn", snapOn ); - cfg.writeEntry( "DrawThree", drawThree); - cardGame->writeConfig( cfg ); - delete cardGame; + Config cfg("Patience"); + cfg.setGroup( "GlobalSettings" ); + cfg.writeEntry( "GameType", gameType ); + cfg.writeEntry( "SnapOn", snapOn ); + cfg.writeEntry( "DrawThree", drawThree); + cfg.write(); + cardGame->writeConfig( cfg ); + delete cardGame; } } void CanvasCardWindow::resizeEvent(QResizeEvent *) { @@ -181,13 +185,13 @@ void CanvasCardWindow::resizeEvent(QResizeEvent *) void CanvasCardWindow::initPatience() { // Create New Game if ( cardGame ) - delete cardGame; + delete cardGame; cardGame = new PatienceCardGame( &canvas, snapOn, this ); cardGame->setNumberToDraw(drawThree ? 3 : 1); gameType = 0; setCaption(tr("Patience")); setCentralWidget(cardGame); cardGame->newGame(); @@ -197,13 +201,13 @@ void CanvasCardWindow::initPatience() void CanvasCardWindow::initFreecell() { // Create New Game if ( cardGame ) { - delete cardGame; + delete cardGame; } cardGame = new FreecellCardGame( &canvas, snapOn, this ); gameType = 1; setCaption(tr("Freecell")); setCentralWidget(cardGame); cardGame->newGame(); @@ -212,13 +216,13 @@ void CanvasCardWindow::initFreecell() void CanvasCardWindow::initChicane() { // Create New Game if ( cardGame ) { - delete cardGame; + delete cardGame; } cardGame = new ChicaneCardGame( &canvas, snapOn, this ); cardGame->setNumberToDraw(1); gameType = 2; setCaption(tr("Chicane")); setCentralWidget(cardGame); @@ -227,13 +231,13 @@ void CanvasCardWindow::initChicane() } void CanvasCardWindow::initHarp() { // Create New Game if ( cardGame ) { - delete cardGame; + delete cardGame; } cardGame = new HarpCardGame( &canvas, snapOn, this ); cardGame->setNumberToDraw(1); gameType = 3; setCaption(tr("Harp")); setCentralWidget(cardGame); @@ -265,40 +269,46 @@ void CanvasCardWindow::snapToggle() cardGame->toggleSnap(); } void CanvasCardWindow::drawnToggle() { + drawThree=!drawThree; + Config cfg( "Patience" ); + cfg.setGroup( "GlobalSettings" ); cardGame->toggleCardsDrawn(); updateDraw(); + cfg.writeEntry( "DrawThree", drawThree); + cfg.write(); } void CanvasCardWindow::updateDraw() { - if(cardGame->cardsDrawn() == 3) - settings->changeItem(drawId, tr("Turn One Card")); - else - settings->changeItem(drawId, tr("Turn Three Cards")); + if(cardGame->cardsDrawn() == 3){ + settings->changeItem(drawId, tr("Turn One Card")); + } else { + settings->changeItem(drawId, tr("Turn Three Cards")); + } } void CanvasCardWindow::setCardBacks() { QCanvasItemList l = canvas.allItems(); for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) { - if ( (*it)->rtti() == canvasCardId ) - ((CanvasCard *)(*it))->setCardBack( cardBack ); + if ( (*it)->rtti() == canvasCardId ) + ((CanvasCard *)(*it))->setCardBack( cardBack ); } } void CanvasCardWindow::changeCardBacks() { cardBack++; if (cardBack == 5) - cardBack = 0; + cardBack = 0; setCardBacks(); } diff --git a/noncore/games/solitaire/opie-solitaire.control b/noncore/games/solitaire/opie-solitaire.control index f70fefa..4389360 100644 --- a/noncore/games/solitaire/opie-solitaire.control +++ b/noncore/games/solitaire/opie-solitaire.control @@ -1,7 +1,7 @@ -Files: bin/patience apps/Games/patience.desktop pics/cards +Files: bin/patience apps/Games/patience.desktop pics/cards Priority: optional Section: opie/games Maintainer: Martin Imobersteg <imm@gmx.ch> Architecture: arm Version: $QPE_VERSION-$SUB_VERSION Depends: opie-base ($QPE_VERSION) |