-rw-r--r-- | noncore/games/solitaire/canvascard.cpp | 51 | ||||
-rw-r--r-- | noncore/games/solitaire/canvascardgame.h | 1 | ||||
-rw-r--r-- | noncore/games/solitaire/canvascardwindow.cpp | 7 |
3 files changed, 26 insertions, 33 deletions
diff --git a/noncore/games/solitaire/canvascard.cpp b/noncore/games/solitaire/canvascard.cpp index c36da6c..cd298ef 100644 --- a/noncore/games/solitaire/canvascard.cpp +++ b/noncore/games/solitaire/canvascard.cpp @@ -7,33 +7,33 @@ ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** 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 "canvascard.h" -#include <qpe/resource.h> +#include <opie2/oresource.h> #include <qgfx_qws.h> // Needed to get the device's width #include <math.h> #if defined( QT_QWS_CASSIOPEIA ) #define SLOW_HARDWARE #endif // Seems to be fast enough to me even without Transformations in the library //#if defined( QT_NO_TRANSFORMATIONS ) && defined( QT_QWS_IPAQ ) //#define SLOW_HARDWARE //#endif QBitmap *Create180RotatedBitmap(QBitmap *srcBitmap) @@ -86,125 +86,120 @@ QPixmap *CreateScaledPixmap(QPixmap *srcPixmap, double scaleX, double scaleY) // Initialise static member variables to NULL QPixmap *CanvasCard::cardsFaces = NULL; QPixmap *CanvasCard::cardsBacks = NULL; QBitmap *CanvasCard::cardsChars = NULL; QBitmap *CanvasCard::cardsSuits = NULL; QBitmap *CanvasCard::cardsCharsUpsideDown = NULL; 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 ) { 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" ) ); + cardsFaces = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_face_small" ) ); + cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0001_small" ) ); + cardsChars = new QBitmap(); + *cardsChars = Opie::Core::OResource::loadPixmap( "cards/card_chars_small" ); + cardsSuits = new QBitmap(); + *cardsSuits = Opie::Core::OResource::loadPixmap( "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" ) ); + cardsFaces = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_face" ) ); + cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0001" ) ); + cardsChars = new QBitmap(); + *cardsChars = Opie::Core::OResource::loadPixmap( "cards/card_chars" ); + cardsSuits = new QBitmap(); + *cardsSuits = Opie::Core::OResource::loadPixmap( "cards/card_suits" ); } cardsCharsUpsideDown = Create180RotatedBitmap( cardsChars ); cardsSuitsUpsideDown = Create180RotatedBitmap( cardsSuits ); } xOff = cardsFaces->width() / 2; yOff = cardsFaces->height() / 2; setSize( cardsFaces->width(), cardsFaces->height() ); setPen( NoPen ); flipping = FALSE; } void CanvasCard::setCardBack(int b) { if ( cardBack != b ) { cardBack = b; if ( cardsBacks ) delete cardsBacks; if ( qt_screen->deviceWidth() < 200 ) { switch (cardBack) { case 0: - cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001_small" ) ); break; + cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0001_small" ) ); break; case 1: - cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0002_small" ) ); break; + cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0002_small" ) ); break; case 2: - cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0003_small" ) ); break; + cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0003_small" ) ); break; case 3: - cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0004_small" ) ); break; + cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0004_small" ) ); break; case 4: - cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0005_small" ) ); break; + cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0005_small" ) ); break; } } else { switch (cardBack) { case 0: - cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) ); break; + cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0001" ) ); break; case 1: - cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0002" ) ); break; + cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0002" ) ); break; case 2: - cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0003" ) ); break; + cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0003" ) ); break; case 3: - cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0004" ) ); break; + cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0004" ) ); break; case 4: - cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0005" ) ); break; + cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0005" ) ); break; } } if ( !isFacing() ) redraw(); } } void CanvasCard::draw(QPainter &painter) { int ix = (int)x(), iy = (int)y(); QPainter *p = &painter; QPixmap *unscaledCard = NULL; if ((scaleX <= 0.98) || (scaleY <= 0.98)) { p = new QPainter(); unscaledCard = new QPixmap( cardsFaces->width(), cardsFaces->height() ); p->begin(unscaledCard); ix = 0; iy = 0; } if ( isFacing() ) { -/* - // Now add the joker and card backs to the list of pixmaps - QPixmap *CardsBack = new QPixmap( Resource::loadPixmap( "cards/card_joker.png" ) ); - QPoint *newBackHotspot = new QPoint( 0, 0 ); - pixmaps->append((const QPixmap *)CardsBack); - hotspots->append((const QPoint *)newBackHotspot); -*/ - int w = cardsFaces->width(), h = cardsFaces->height(); -// p->setBrush( NoBrush ); p->setBrush( QColor( 0xFF, 0xFF, 0xFF ) ); if ( isRed() == TRUE ) p->setPen( QColor( 0xFF, 0, 0 ) ); else p->setPen( QColor( 0, 0, 0 ) ); 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 ); diff --git a/noncore/games/solitaire/canvascardgame.h b/noncore/games/solitaire/canvascardgame.h index b93cfbf..c559a90 100644 --- a/noncore/games/solitaire/canvascardgame.h +++ b/noncore/games/solitaire/canvascardgame.h @@ -11,33 +11,32 @@ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** 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. ** **********************************************************************/ #ifndef CANVAS_CARD_GAME_H #define CANVAS_CARD_GAME_H #include "cardgame.h" #include "canvasshapes.h" #include "canvascard.h" -#include <qpe/resource.h> #include <qpe/config.h> #include <qmainwindow.h> #include <qmenubar.h> #include <qpainter.h> #include <stdlib.h> #include <time.h> class CanvasCardPile; class CanvasCardGame : public QCanvasView, public CardGame { public: diff --git a/noncore/games/solitaire/canvascardwindow.cpp b/noncore/games/solitaire/canvascardwindow.cpp index 503bc92..956c5bd 100644 --- a/noncore/games/solitaire/canvascardwindow.cpp +++ b/noncore/games/solitaire/canvascardwindow.cpp @@ -11,50 +11,49 @@ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** 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 "canvascardwindow.h" #include "freecellcardgame.h" #include "chicanecardgame.h" #include "harpcardgame.h" #include "teeclubcardgame.h" - - +#include <opie2/oresource.h> CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) : QMainWindow(parent, name, f), canvas(230, 260), snapOn(TRUE), cardBack(4), gameType(0), cardGame(NULL) { - setIcon( Resource::loadPixmap( "cards" ) ); + setIcon( Opie::Core::OResource::loadPixmap( "cards" ) ); setCaption(tr("Patience")); // 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)); } else { QPixmap bg; - bg.convertFromImage( Resource::loadImage( "table_pattern" ), ThresholdDither ); + bg.convertFromImage( Opie::Core::OResource::loadImage( "table_pattern" ), ThresholdDither ); canvas.setBackgroundPixmap(bg); } #if defined( QT_QWS_CASSIOPEIA ) canvas.setAdvancePeriod(70); #else canvas.setAdvancePeriod(30); #endif #ifdef _PATIENCE_USE_ACCELS_ QMenuBar* menu = menuBar(); QPopupMenu* file = new QPopupMenu; file->insertItem(tr("Patience"), this, SLOT(initPatience()), CTRL+Key_F); file->insertItem(tr("Freecell"), this, SLOT(initFreecell()), CTRL+Key_F); |