Diffstat (limited to 'noncore/games/mindbreaker/mindbreaker.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/mindbreaker/mindbreaker.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/noncore/games/mindbreaker/mindbreaker.cpp b/noncore/games/mindbreaker/mindbreaker.cpp index 1f554d2..aa4afd7 100644 --- a/noncore/games/mindbreaker/mindbreaker.cpp +++ b/noncore/games/mindbreaker/mindbreaker.cpp @@ -1,47 +1,48 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** 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 "mindbreaker.h" -#include <qtopia/resource.h> +#include <opie2/oresource.h> + #include <qtopia/config.h> #include <qtopia/qpeapplication.h> #include <qtoolbar.h> #include <qtoolbutton.h> #include <qmessagebox.h> #include <qlayout.h> #include <qtimer.h> #include <stdlib.h> #include <sys/time.h> #include <unistd.h> static int pegRTTI = 3393393; static int adjusted_panel_height; static int adjusted_panel_width; static int adjusted_bin_margin; static int adjusted_peg_size; static int adjusted_answerpeg_size; static int adjusted_title_height; static int adjusted_title_width; @@ -118,67 +119,67 @@ public: static void buildImages(); static QImage imageForType(int t); static int eggLevel; protected: void drawShape(QPainter &); private: static QVector<QImage> normalPegs; static QVector<QImage> specialPegs; bool isplaced; int pegtype; int peg_go; int peg_pos; int aniStep; }; int Peg::eggLevel = 0; QVector<QImage> Peg::normalPegs; QVector<QImage> Peg::specialPegs; void Peg::buildImages() { - QImage pegs = Resource::loadImage("mindbreaker/pegs"); + QImage pegs = Opie::Core::OResource::loadImage("mindbreaker/pegs"); int x = 0; int y = 0; int i; eggLevel = 0; normalPegs.resize(10); for (i = 0; i < 6; i++) { normalPegs.insert(i, new QImage(pegs.copy(x, y, peg_size, peg_size). smoothScale(adjusted_peg_size, adjusted_peg_size) )); x += peg_size; } specialPegs.resize(5); for (i = 0; i < 5; i++) { specialPegs.insert(i, new QImage(pegs.copy(x,y,peg_size, peg_size). smoothScale(adjusted_peg_size, adjusted_peg_size) )); x += peg_size; } - QImage image = Resource::loadImage("mindbreaker/mindbreaker"); + QImage image = Opie::Core::OResource::loadImage("mindbreaker/mindbreaker"); /* copy from master image to functional images */ x = 0; y = panel_height; normalPegs.insert(8, new QImage( image.copy(x, y, panel_width, panel_height). smoothScale( adjusted_panel_width, adjusted_panel_height) )); y += panel_height; y += title_height; normalPegs.insert(9, new QImage(image.copy(x, y, title_width, title_height). smoothScale( adjusted_title_width, adjusted_title_height) )); y += title_height; x = 6 * peg_size; normalPegs.insert(6, new QImage(image.copy(x, y, answerpeg_size, answerpeg_size). smoothScale( adjusted_answerpeg_size, adjusted_answerpeg_size) )); x += answerpeg_size; normalPegs.insert(7, new QImage(image.copy(x, y, answerpeg_size, answerpeg_size). smoothScale( adjusted_answerpeg_size, adjusted_answerpeg_size) )); } @@ -268,51 +269,51 @@ inline int Peg::type() const * and use these to create the tray, answer and board */ MindBreaker::MindBreaker( QWidget *parent, const char *name, int wFlags ) : QMainWindow(parent, name, wFlags) { setCaption( tr("Mind Breaker")); QPEApplication::setInputMethodHint( this, QPEApplication::AlwaysOff ); setMinimumSize(160,210); QWidget *w = new QWidget( this ); w->setBackgroundColor( black ); QHBoxLayout *hb = new QHBoxLayout( w ); hb->addStretch(); board = new MindBreakerBoard(w); hb->addWidget( board, 100 ); hb->addStretch(); setCentralWidget(w); setToolBarsMovable( FALSE ); QToolBar *tb = new QToolBar(this); tb->setHorizontalStretchable( TRUE ); - QIconSet newicon = Resource::loadIconSet("new"); - new QToolButton(newicon, tr("New Game"), 0, - board, SLOT(clear()), tb, "NewGame"); + QToolButton *btn = new QToolButton( Opie::Core::OResource::loadPixmap("new", Opie::Core::OResource::SmallIcon), tr("New Game"), 0, + board, SLOT(clear()), tb, "NewGame"); + btn->setUsesBigPixmap( qApp->desktop()->size().width() > 330 ); score = new QToolButton(tb); score->setText(""); score->setMaximumHeight(20); score->setUsesTextLabel(TRUE); tb->setStretchableWidget(score); connect(board, SIGNAL(scoreChanged(int,int)), this, SLOT(setScore(int,int))); connect(score, SIGNAL(clicked()), board, SLOT(resetScore())); int a, b; board->getScore(&a, &b); setScore(a,b); layout()->setResizeMode(QLayout::FreeResize); } void MindBreaker::setScore(int turns, int games) { double average; double total_turns = turns; double total_games = games; if(total_games > 0) @@ -462,49 +463,49 @@ void MindBreakerBoard::fixSize() void MindBreakerBoard::doFixSize() { QSize s = size(); int fw = frameWidth(); s.setWidth(s.width() - fw); s.setHeight(s.height() - fw); /* min size is 200 x 260 */ /* if (s.width() < adjusted_board_width) s.setWidth(adjusted_board_width); if (s.height() < adjusted_board_height) s.setHeight(adjusted_board_height); */ if ( current_highlight ) // non-first resize writeConfig(); setupBoardSize(s.width() - fw, s.height() - fw); canvas()->resize(s.width() - fw, s.height() - fw); Peg::buildImages(); // must be done BEFORE any pegs are made - QImage image = Resource::loadImage("mindbreaker/mindbreaker"); + QImage image = Opie::Core::OResource::loadImage("mindbreaker/mindbreaker"); /* copy from master image to functional images */ int x = 0; int y = 0; panelImage = image.copy(x, y, panel_width, panel_height). smoothScale( adjusted_panel_width, adjusted_panel_height); y += panel_height; y += panel_height; titleImage = image.copy(x, y, title_width, title_height). smoothScale( adjusted_title_width, adjusted_title_height); show(); delete current_highlight; current_highlight = new Peg(canvas(), 8); current_highlight->setPlaced(TRUE); current_highlight->setX(0); current_highlight->setY(adjusted_board_height - ((current_go + 1) * adjusted_panel_height)); current_highlight->setZ(0); current_highlight->show(); /* set up the game */ //readConfig(); |