author | chicken <chicken> | 2004-03-01 20:30:56 (UTC) |
---|---|---|
committer | chicken <chicken> | 2004-03-01 20:30:56 (UTC) |
commit | 7b0bdb05e4ae29b2643d73e3b8f20a86a86dcccc (patch) (side-by-side diff) | |
tree | 0ec283bce345770910a2630e868afcde3d7c3dc9 | |
parent | 054b3c3e032bdb0a6061a3345487b4ff877eebfd (diff) | |
download | opie-7b0bdb05e4ae29b2643d73e3b8f20a86a86dcccc.zip opie-7b0bdb05e4ae29b2643d73e3b8f20a86a86dcccc.tar.gz opie-7b0bdb05e4ae29b2643d73e3b8f20a86a86dcccc.tar.bz2 |
fix includes
77 files changed, 2 insertions, 223 deletions
diff --git a/noncore/games/backgammon/backgammon.cpp b/noncore/games/backgammon/backgammon.cpp index e9e5467..51020a0 100644 --- a/noncore/games/backgammon/backgammon.cpp +++ b/noncore/games/backgammon/backgammon.cpp @@ -1,111 +1,108 @@ #include "backgammon.h" #include "aidialog.h" #include "filedialog.h" #include "playerdialog.h" #include "rulesdialog.h" #include "themedialog.h" -#include <qdatetime.h> #include <qfile.h> #include <qlayout.h> #include <qmessagebox.h> -#include <qstring.h> #include <qtimer.h> -#include <qmainwindow.h> #include <qpe/qpeapplication.h> #include <qpe/config.h> #include <qmenubar.h> #include <qpe/resource.h> #include <stdlib.h> BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl) { if (!name) setName("BackGammon"); setCaption(tr( "Backgammon") ); setIcon( Resource::loadPixmap( "backgammon" ) ); //general counter varaible int a=0; //the game engine move=new MoveEngine(); //load the default theme Config conf("backgammon"); if(!conf.isValid()) { qDebug("config file does not exist"); conf.setGroup("general"); conf.writeEntry("theme","default"); conf.setGroup("rules"); conf.writeEntry("move_with_pieces_out",false); conf.writeEntry("nice_dice",false); conf.setGroup("display"); conf.writeEntry("small",false); conf.writeEntry("warning",true); conf.setGroup("ai"); conf.writeEntry("rescue",6); conf.writeEntry("eliminate",4); conf.writeEntry("expose",1); conf.writeEntry("protect",5); conf.writeEntry("safe",3); conf.writeEntry("empty",2); } conf.setGroup("general"); theme_name=conf.readEntry("theme","default"); QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme"; //the rules conf.setGroup("rules"); rules.move_with_pieces_out=conf.readBoolEntry("move_with_pieces_out",false); rules.generous_dice=conf.readBoolEntry("nice_dice",false); move->setRules(rules); //get the AI settings AISettings ai; conf.setGroup("ai"); ai.rescue=conf.readNumEntry("rescue",6); ai.eliminate=conf.readNumEntry("eliminate",4); ai.expose=conf.readNumEntry("expose",1); ai.protect=conf.readNumEntry("protect",5); ai.safe=conf.readNumEntry("safe",3); ai.empty=conf.readNumEntry("empty",2); move->setAISettings(ai); //get the theme component names Config theme(theme_file,Config::File); if(!theme.isValid()) { qDebug("theme file does not exist"); theme.setGroup("theme"); theme.writeEntry("board","casino_board_1"); theme.writeEntry("pieces1","casino_pieces_blue"); theme.writeEntry("pieces2","casino_pieces_white"); theme.writeEntry("dice1","casino_dice"); theme.writeEntry("dice2","casino_dice"); theme.writeEntry("table","casino_table_green"); theme.writeEntry("odds","casino_odds"); } theme.setGroup("theme"); board_name=theme.readEntry("board","casino_board_1"); piecesA_name=theme.readEntry("pieces1","casino_pieces_blue"); piecesB_name=theme.readEntry("pieces2","casino_pieces_white"); diceA_name=theme.readEntry("dice1","casino_dice"); diceB_name=theme.readEntry("dice2","casino_dice"); table_name=theme.readEntry("table","casino_table_green"); odds_name=theme.readEntry("odds","casino_odds"); //the menu QMenuBar* menuBar = new QMenuBar(this); QPopupMenu* gamemenu= new QPopupMenu(this); gamemenu->insertItem(tr( "New" ),this,SLOT(newgame())); gamemenu->insertSeparator(); gamemenu->insertItem(tr( "Load" ),this,SLOT(loadgame())); gamemenu->insertItem(tr( "Save" ),this,SLOT(savegame())); diff --git a/noncore/games/backgammon/filedialog.cpp b/noncore/games/backgammon/filedialog.cpp index a5e71c9..e0a2914 100644 --- a/noncore/games/backgammon/filedialog.cpp +++ b/noncore/games/backgammon/filedialog.cpp @@ -1,65 +1,61 @@ #include "filedialog.h"
#include <qdir.h>
-#include <qfileinfo.h>
-#include <qmessagebox.h>
-#include <qpixmap.h>
-#include <qpushbutton.h>
#include <qpe/qpeapplication.h>
FileDialog::FileDialog(QWidget* parent,QString header,QString extension,const char* name,bool modal,WFlags f)
:QDialog(parent,name,modal,f)
{
setCaption(header);
ext=extension;
dirselector=new QListView(this);
dirselector->setGeometry(1,10,235,200);
dirselector->addColumn("Files");
connect(dirselector,SIGNAL(clicked(QListViewItem*)),this,SLOT(selectorclicked(QListViewItem*)));
getCurrentDir();
file_name="user";
fileinput=new QLineEdit(file_name,this);
fileinput->setGeometry(1,220,235,20);
QPEApplication::showDialog( this );
}
FileDialog::~FileDialog()
{}
void FileDialog::selectorclicked(QListViewItem* entry)
{
if(entry==NULL)
return;
file_name=entry->text(0);
fileinput->setText(file_name);
}
void FileDialog::getCurrentDir()
{
dirselector->clear();
QDir dir(QPEApplication::qpeDir()+"/backgammon");
dir.setFilter(QDir::Files);
QFileInfoListIterator it(*(dir.entryInfoList()));
QFileInfo* fi;
int ext_length=ext.length();
while((fi=it.current())) // go through all file and subdirs
{
QString file=fi->fileName();
if(file.right(ext_length)==ext && file)
{
file=file.left(file.length()-ext_length);
new QListViewItem(dirselector,file);
}
++it;
}
}
QString FileDialog::filename()
{
return file_name;
}
diff --git a/noncore/games/backgammon/main.cpp b/noncore/games/backgammon/main.cpp index 58ced10..6316040 100644 --- a/noncore/games/backgammon/main.cpp +++ b/noncore/games/backgammon/main.cpp @@ -1,8 +1,7 @@ -#include <qpe/qpeapplication.h> #include "backgammon.h" #include <opie/oapplicationfactory.h> OPIE_EXPORT_APP( OApplicationFactory<BackGammon> ) diff --git a/noncore/games/backgammon/moveengine.cpp b/noncore/games/backgammon/moveengine.cpp index 37b73a6..7de7147 100644 --- a/noncore/games/backgammon/moveengine.cpp +++ b/noncore/games/backgammon/moveengine.cpp @@ -1,99 +1,98 @@ #include "moveengine.h" -#include <qmessagebox.h> #include <qtimer.h> #include <stdlib.h> MoveEngine::MoveEngine() : QObject() { int offset=7; int a=0; //counter variable int xfill[]={210,185,170,155,140,125,110,85,70,55,40,25,10,10,25,40,55,70,85,110,125,140,155,170,185,210}; for(a=0;a<26;a++) { x_coord[a]=xfill[a]; } int yfill[]={10,25,40,55,70,10+offset,25+offset,40+offset,55+offset,25,40,55, 25+offset,40+offset,40}; int zfill[]={1,1,1,1,1,2,2,2,2,3,3,3,4,4,5}; for(a=0;a<15;a++) { yup_coord[a]=yfill[a]; ylow_coord[a]=185-(yfill[a]); z_coord[a]=zfill[a]; } for(a=0;a<5;a++) { if(a<3) { x_fin1[a]=65+a*15; x_fin2[a]=155-a*15; } y_fin[a]=225-a*5; } z_fin=1; reset(); } MoveEngine::~MoveEngine() {} void MoveEngine::position(Pieces& pieces,bool non_qte) { int player1_counter=0; int player2_counter=0; //non qte styles are smaller !! int offset=(non_qte) ? 5 : 0; for(int a=0;a<28;a++) { for(int b=0;b<abs(population[a].total);b++) { if(population[a].total>0) //player 1 pieces { pieces.player1[player1_counter].x=x_coord[a]-offset; if(a>=0 && a<13) { pieces.player1[player1_counter].y=yup_coord[b]-offset; pieces.player1[player1_counter].z=z_coord[b]; pieces.player1[player1_counter].side=false; player1_counter++; } else if(a>12 && a<26) { pieces.player1[player1_counter].y=ylow_coord[b]-offset; pieces.player1[player1_counter].z=z_coord[b]; pieces.player1[player1_counter].side=false; player1_counter++; } else if(a==26) { if(b<5) { pieces.player1[player1_counter].x=x_fin1[0]-offset; pieces.player1[player1_counter].y=y_fin[b]-offset; pieces.player1[player1_counter].z=z_fin; } else if(b>=5 && b<10) { pieces.player1[player1_counter].x=x_fin1[1]-offset; pieces.player1[player1_counter].y=y_fin[b-5]-offset; pieces.player1[player1_counter].z=z_fin; } else { pieces.player1[player1_counter].x=x_fin1[2]-offset; pieces.player1[player1_counter].y=y_fin[b-10]-offset; pieces.player1[player1_counter].z=z_fin; } pieces.player1[player1_counter].side=true; player1_counter++; } } else if(population[a].total<0) //player 2 pieces { diff --git a/noncore/games/backgammon/themedialog.cpp b/noncore/games/backgammon/themedialog.cpp index f342381..afd6a1b 100644 --- a/noncore/games/backgammon/themedialog.cpp +++ b/noncore/games/backgammon/themedialog.cpp @@ -1,102 +1,100 @@ #include "themedialog.h" #include <qdir.h> -#include <qfileinfo.h> #include <qlabel.h> -#include <qpushbutton.h> #include <qpe/qpeapplication.h> ThemeDialog::ThemeDialog(QWidget* parent,const char* name,bool modal,WFlags f) :QDialog(parent,name,modal,f) { setCaption("Theme Dialog"); QLabel* labelname=new QLabel("name",this); labelname->setGeometry(0,5,40,20); lineName=new QLineEdit("user",this); lineName->setGeometry(40,5,195,20); QLabel* labelboard=new QLabel("board",this); labelboard->setGeometry(0,30,40,20); boxboard=new QComboBox(this,""); boxboard->setGeometry(40,30,195,20); fillBox("boards",boxboard); QLabel* labelpiecesA=new QLabel("pieces1",this); labelpiecesA->setGeometry(0,70,40,20); boxpiecesA=new QComboBox(this); boxpiecesA->setGeometry(40,70,195,20); fillBox("pieces",boxpiecesA); QLabel* labelpiecesB=new QLabel("pieces2",this); labelpiecesB->setGeometry(0,95,40,20); boxpiecesB=new QComboBox(this); boxpiecesB->setGeometry(40,95,195,20); fillBox("pieces",boxpiecesB); QLabel* labeldiceA=new QLabel("dice1",this); labeldiceA->setGeometry(0,135,40,20); boxdiceA=new QComboBox(this); boxdiceA->setGeometry(40,135,195,20); fillBox("dice",boxdiceA); QLabel* labeldiceB=new QLabel("dice2",this); labeldiceB->setGeometry(0,160,40,20); boxdiceB=new QComboBox(this); boxdiceB->setGeometry(40,160,195,20); fillBox("dice",boxdiceB); QLabel* labelodds=new QLabel("odds",this); labelodds->setGeometry(0,200,40,20); boxodds=new QComboBox(this); boxodds->setGeometry(40,200,195,20); fillBox("odds",boxodds); boxodds->setEnabled(false); QLabel* labeltable=new QLabel("table",this); labeltable->setGeometry(0,225,40,20); boxtable=new QComboBox(this); boxtable->setGeometry(40,225,195,20); fillBox("table",boxtable); QPEApplication::showDialog( this ); } ThemeDialog::~ThemeDialog() {} ImageNames ThemeDialog::getNames() { ImageNames names; names.theme=lineName->text(); names.board=boxboard->currentText(); names.pieces1=boxpiecesA->currentText(); names.pieces2=boxpiecesB->currentText(); names.dice1=boxdiceA->currentText(); names.dice2=boxdiceB->currentText(); names.odds=boxodds->currentText(); names.table=boxtable->currentText(); return names; } void ThemeDialog::setCurrent(const ImageNames& current) { int a=0; lineName->setText(current.theme); for(a=0;a<boxboard->count();a++) { if(boxboard->text(a)==current.board) { boxboard->setCurrentItem(a); break; } } for(a=0;a<boxpiecesA->count();a++) { if(boxpiecesA->text(a)==current.pieces1) { boxpiecesA->setCurrentItem(a); break; } } diff --git a/noncore/games/bounce/game.cpp b/noncore/games/bounce/game.cpp index 6ded218..c07f453 100644 --- a/noncore/games/bounce/game.cpp +++ b/noncore/games/bounce/game.cpp @@ -1,119 +1,118 @@ /* * Copyright (C) 2000 Stefan Schimanski <1Stein@gmx.de> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <stdlib.h> #include <qtimer.h> #include <qpe/qpeapplication.h> -#include <qimage.h> #include "game.h" #define TILE_SIZE 9 #define TILE_FIRST ((FIELD_WIDTH-2)*(FIELD_HEIGHT-2)) #define TILE_FREE (TILE_FIRST + 0) #define TILE_BORDER (TILE_FIRST + 1) #define TILE_WALLEND (TILE_FIRST + 2) #define TILE_WALLUP (TILE_FIRST + 3) #define TILE_WALLDOWN (TILE_FIRST + 4) #define TILE_WALLLEFT (TILE_FIRST + 5) #define TILE_WALLRIGHT (TILE_FIRST + 6) #define GAME_DELAY 15 #define BALL_ANIM_DELAY 60 #define WALL_DELAY 100 #define MS2TICKS( ms ) ((ms)/GAME_DELAY) Arrow::Arrow(QCanvasPixmapArray* array, QCanvas* canvas) : QCanvasSprite( array, canvas ) { m_vertical = true; move(3,3); } void Arrow::update() { if ( m_vertical ) setFrame( 0 ); else setFrame( 1 ); } void Arrow::changeDirection() { m_vertical = ! m_vertical; update(); } Ball::Ball(QCanvasPixmapArray* array, QCanvas* canvas) : QCanvasSprite( array, canvas ), m_animDelay( 0 ), m_soundDelay( MS2TICKS(BALL_ANIM_DELAY)/2 ) { } void Ball::update() { m_animDelay--; if ( m_animDelay<=0 ) { m_animDelay = MS2TICKS(BALL_ANIM_DELAY); int frameNum = frame(); frameNum++; if ( frameNum>=frameCount() ) frameNum = 0; setFrame( frameNum ); } } void Ball::advance(int stage) { bool reflectX = false; bool reflectY = false; // check for collisions if ( collide(xVelocity(), 0) ) reflectX = true; if ( collide(0, yVelocity()) ) reflectY = true; if ( !reflectX && !reflectY && collide(xVelocity(), yVelocity()) ) reflectX = reflectY = true; // emit collision QRect r = boundingRect(); r.moveBy( xVelocity(), yVelocity() ); JezzField* field = (JezzField *)canvas(); int ul = field->tile( r.left() / TILE_SIZE, r.top() / TILE_SIZE ); int ur = field->tile( r.right() / TILE_SIZE, r.top() / TILE_SIZE ); int bl = field->tile( r.left() / TILE_SIZE, r.bottom() / TILE_SIZE ); int br = field->tile( r.right() / TILE_SIZE, r.bottom() / TILE_SIZE ); if ( ul!=TILE_FREE ) field->emitBallCollisiton( this, r.left() / TILE_SIZE, r.top() / TILE_SIZE, ul ); else if ( ur!=TILE_FREE ) field->emitBallCollisiton( this, r.right() / TILE_SIZE, r.top() / TILE_SIZE, ur ); else if ( bl!=TILE_FREE ) field->emitBallCollisiton( this, r.left() / TILE_SIZE, r.bottom() / TILE_SIZE, bl ); else if ( br!=TILE_FREE ) field->emitBallCollisiton( this, r.right() / TILE_SIZE, r.bottom() / TILE_SIZE, br ); // apply reflection if ( reflectX ) setXVelocity( -xVelocity() ); if ( reflectY ) setYVelocity( -yVelocity() ); // update field update(); QCanvasSprite::advance( stage ); } bool Ball::collide( double dx, double dy ) diff --git a/noncore/games/bounce/kbounce.cpp b/noncore/games/bounce/kbounce.cpp index 211f0ff..3b0cb6f 100644 --- a/noncore/games/bounce/kbounce.cpp +++ b/noncore/games/bounce/kbounce.cpp @@ -1,124 +1,120 @@ /* * Copyright (C) 2000 Stefan Schimanski <1Stein@gmx.de> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License,Life or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <qlayout.h> #include <qtimer.h> -#include <qlcdnumber.h> #include <qmessagebox.h> -#include <qmainwindow.h> -#include <qpe/qpeapplication.h> #include "kbounce.h" #include "game.h" -#include <qlabel.h> KJezzball::KJezzball(QWidget *p, const char* n, WFlags f) : QMainWindow(p,n,f), m_gameWidget( 0 ) { setCaption(tr("Bounce")); // setup variables m_game.level = 1; m_game.score = 0; m_state = Idle; menu = menuBar(); game = new QPopupMenu; game->insertItem(tr("&New game"), this, SLOT(newGame()), Key_N ); game->insertItem(tr("&Pause game"), this, SLOT(pauseGame()), Key_P ); game->insertSeparator(); game->insertItem(tr("&About"), this, SLOT(about())); menu->insertItem( tr("&Game"), game ); // create widgets m_view = new QWidget( this, "m_view" ); setCentralWidget( m_view ); m_layout = new QGridLayout( m_view ); m_layout->setSpacing( 0 ); m_layout->setMargin( 0 ); ScoreLabel = new QLabel( m_view, "ScoreLabel" ); ScoreLabel->setText( tr( "Score: 00" ) ); ScoreLabel->setAlignment( int( QLabel::AlignCenter ) ); m_layout->addWidget( ScoreLabel, 1, 0 ); LivesLabel = new QLabel( m_view, "LivesLabel" ); LivesLabel->setText( tr( "Lives: 0%" ) ); LivesLabel->setAlignment( int( QLabel::AlignCenter ) ); m_layout->addWidget( LivesLabel, 1, 2 ); FilledLabel = new QLabel( m_view, "FilledLabel" ); FilledLabel->setText( tr( "Filled: 00%" ) ); FilledLabel->setAlignment( int( QLabel::AlignCenter ) ); m_layout->addWidget( FilledLabel, 1, 1 ); TimeLabel = new QLabel( m_view, "TimeLabel" ); TimeLabel->setText( tr( "Time: 00" ) ); TimeLabel->setAlignment( int( QLabel::AlignCenter ) ); m_layout->addWidget( TimeLabel, 1, 3 ); // create timers m_nextLevelTimer = new QTimer( this, "m_nextLevelTimer" ); connect( m_nextLevelTimer, SIGNAL(timeout()), this, SLOT(switchLevel()) ); m_gameOverTimer = new QTimer( this, "m_gameOverTimer" ); connect( m_gameOverTimer, SIGNAL(timeout()), this, SLOT(gameOverNow()) ); m_timer = new QTimer( this, "m_timer" ); connect( m_timer, SIGNAL(timeout()), this, SLOT(second()) ); // create demo game createLevel( 1 ); } void KJezzball::newGame() { // Check for running game closeGame(); if ( m_state==Idle ) { // update displays m_game.level = 1; m_game.score = 0; setCaption(tr("Bounce Level %1").arg(m_game.level)); ScoreLabel->setText( tr( "Score: %1" ).arg(m_game.score) ); // start new game m_state = Running; createLevel( m_game.level ); startLevel(); } } void KJezzball::about() { QMessageBox::information( this, tr("About"), tr("Written by: Stefan Schimanski\n" "Ported by: Martin Imobersteg\n" "\n" "Click to form walls.\n" "Hit space to switch wall direction.\n" "Try to reduce total space by 75%.\n" "\n" diff --git a/noncore/games/bounce/main.cpp b/noncore/games/bounce/main.cpp index 9ea86a6..a070c4b 100644 --- a/noncore/games/bounce/main.cpp +++ b/noncore/games/bounce/main.cpp @@ -1,24 +1,23 @@ /* * Copyright (C) 2000 Stefan Schimanski <schimmi@kde.org> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <qpe/qpeapplication.h> #include "kbounce.h" #include <opie/oapplicationfactory.h> OPIE_EXPORT_APP( OApplicationFactory<KJezzball> ) diff --git a/noncore/games/buzzword/buzzword.cpp b/noncore/games/buzzword/buzzword.cpp index f746065..13eb481 100644 --- a/noncore/games/buzzword/buzzword.cpp +++ b/noncore/games/buzzword/buzzword.cpp @@ -1,116 +1,115 @@ /* * Copyright (C) 2002 Martin Imobersteg <imm@gmx.ch> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2 of the License,Life or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <qlayout.h> -#include <qmessagebox.h> #include <qmainwindow.h> #include <qlabel.h> #include <qgrid.h> #include <qcolor.h> #include <qbutton.h> #include <qfile.h> #include <qtextstream.h> #include <qstringlist.h> #include <qmessagebox.h> #include <qdir.h> #include <math.h> #include <stdlib.h> #include <qpe/qpeapplication.h> #include "buzzword.h" BuzzLabel::BuzzLabel( QWidget *parent, const char *name ) : QLabel( parent, name ) { } void BuzzLabel::mousePressEvent(QMouseEvent *e) { if(e->button() == LeftButton) { emit clicked(); } } BuzzItem::BuzzItem( int row, int column, QString text, QWidget *parent, const char *name ) : QVBox( parent, name ), _row(row), _column(column) { setFrameStyle( QFrame::Panel | QFrame::Raised ); setLineWidth( 1 ); label = new BuzzLabel(this, "label"); label->setText(text); label->setAlignment( int( QLabel::AlignCenter ) ); connect( label, SIGNAL(clicked()), this, SLOT(flip()) ); } void BuzzItem::flip() { setLineWidth( 1 ); label->setBackgroundColor(label->colorGroup().highlight()); emit clicked(_row, _column); } BuzzWord::BuzzWord(QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) { setCaption(tr("buZzword")); menu = menuBar(); game = new QPopupMenu; game->insertItem(tr("&New game"), this, SLOT(newGame()), Key_N ); menu->insertItem( tr("&Game"), game ); gridVal = 4; grid = NULL; gameOver = false; newGame(); } void BuzzWord::drawGrid() { QStringList l; QString path = QPEApplication::qpeDir()+"share/buzzword/"; QFile f( path + "buzzwords" ); if ( !f.open( IO_ReadOnly ) ) return; QTextStream t( &f ); while (!t.atEnd()) { l << t.readLine(); } f.close(); grid = new QGrid(gridVal, this); // grid->setFixedSize( 480, 480 ); for( int c = 0 ; c < gridVal ; c++ ) { for( int r = 0 ; r < gridVal ; r++ ) { uint pos = rand() % l. count(); QString word = QStringList::split(" ", l[pos]).join("\n"); BuzzItem* bi = new BuzzItem( c, r, word, grid ); connect( bi, SIGNAL(clicked(int, int)), this, SLOT(clicked(int,int)) ); map[c][r] = 0; diff --git a/noncore/games/buzzword/main.cpp b/noncore/games/buzzword/main.cpp index 67f2c26..95b3176 100644 --- a/noncore/games/buzzword/main.cpp +++ b/noncore/games/buzzword/main.cpp @@ -1,24 +1,23 @@ /* * Copyright (C) 2002 Martin Imobersteg <imm@gmx.ch> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2 of the License,Life or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <qpe/qpeapplication.h> #include <opie/oapplicationfactory.h> #include "buzzword.h" OPIE_EXPORT_APP( OApplicationFactory<BuzzWord> ) diff --git a/noncore/games/fifteen/fifteen.cpp b/noncore/games/fifteen/fifteen.cpp index b4e0308..506e87a 100644 --- a/noncore/games/fifteen/fifteen.cpp +++ b/noncore/games/fifteen/fifteen.cpp @@ -1,132 +1,127 @@ /********************************************************************** ** 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 "fifteen.h" #include <qtopia/resource.h> #include <qtopia/config.h> #include <qvbox.h> #include <qaction.h> -#include <qlayout.h> #include <qpainter.h> -#include <qpopupmenu.h> #include <qmessagebox.h> #include <qtoolbar.h> #include <qmenubar.h> -#include <qstringlist.h> -#include <qapplication.h> -#include <qtoolbutton.h> #include <stdlib.h> #include <time.h> FifteenMainWindow::FifteenMainWindow(QWidget *parent, const char* name, WFlags fl) : QMainWindow( parent, name, fl ) { // random seed srand(time(0)); setCaption( tr("Fifteen Pieces") ); QToolBar *toolbar = new QToolBar(this); toolbar->setHorizontalStretchable( FALSE ); QMenuBar *menubar = new QMenuBar( toolbar ); menubar->setMargin(0); QPopupMenu *game = new QPopupMenu( this ); QWidget *spacer = new QWidget( toolbar ); spacer->setBackgroundMode( PaletteButton ); toolbar->setStretchableWidget( spacer ); setToolBarsMovable( FALSE ); QVBox *vbox = new QVBox( this ); PiecesTable *table = new PiecesTable( vbox ); setCentralWidget(vbox); QAction *a = new QAction( tr( "Randomize" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), table, SLOT( slotRandomize() ) ); a->addTo( game ); a->addTo( toolbar ); /* This is pointless and confusing. a = new QAction( tr( "Solve" ), Resource::loadIconSet( "repeat" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), table, SLOT( slotReset() ) ); a->addTo( game ); a->addTo( toolbar ); */ menubar->insertItem( tr( "Game" ), game ); } PiecesTable::PiecesTable(QWidget* parent, const char* name ) : QTableView(parent, name), _menu(0), _randomized(false) { // setup table view setFrameStyle(StyledPanel | Sunken); setBackgroundMode(NoBackground); setMouseTracking(true); setNumRows(4); setNumCols(4); // init arrays initMap(); readConfig(); initColors(); // set font QFont f = font(); f.setPixelSize(18); f.setBold( TRUE ); setFont(f); } PiecesTable::~PiecesTable() { writeConfig(); } void PiecesTable::writeConfig() { Config cfg("Fifteen"); cfg.setGroup("Game"); QStringList map; for (int i = 0; i < 16; i++) map.append( QString::number( _map[i] ) ); cfg.writeEntry("Map", map, '-'); cfg.writeEntry("Randomized", _randomized ); } void PiecesTable::readConfig() { Config cfg("Fifteen"); cfg.setGroup("Game"); QStringList map = cfg.readListEntry("Map", '-'); _randomized = cfg.readBoolEntry( "Randomized", FALSE ); int i = 0; for ( QStringList::Iterator it = map.begin(); it != map.end(); ++it ) { _map[i] = (*it).toInt(); i++; if ( i > 15 ) break; } diff --git a/noncore/games/go/gowidget.cpp b/noncore/games/go/gowidget.cpp index cf89267..79820b1 100644 --- a/noncore/games/go/gowidget.cpp +++ b/noncore/games/go/gowidget.cpp @@ -1,134 +1,130 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 "gowidget.h" #include <qpe/config.h> #include <qpe/resource.h> #include <qpainter.h> -#include <qpixmap.h> #include <qpe/qpetoolbar.h> #include <qmenubar.h> -#include <qpopupmenu.h> #include <qaction.h> #include <qapplication.h> //processEvents() #include <qlabel.h> //#include <stdio.h> -#include "amigo.h" -#include "goplayutils.h" static const enum bVal computer_color = BLACK; static int current_handicap = 1; static QBrush *goBrush; //static QImage *newBlackStone; //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, WFlags fl) : QMainWindow( parent, name, fl ) { setToolBarsMovable( FALSE ); GoWidget *go = new GoWidget(this); setCentralWidget(go); toolbar = new QToolBar(this); toolbar->setHorizontalStretchable( TRUE ); addToolBar(toolbar); QMenuBar *mb = new QMenuBar( toolbar ); mb->setMargin(0); QPopupMenu *file = new QPopupMenu( this ); QAction *a = new QAction( tr( "New Game" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), go, SLOT( newGame() ) ); a->addTo( file ); a = new QAction( tr( "Pass" ), Resource::loadPixmap( "pass" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), go, SLOT( pass() ) ); a->addTo( file ); a->addTo( toolbar ); a = new QAction( tr( "Resign" ), Resource::loadPixmap( "reset" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), go, SLOT( resign() ) ); a->addTo( file ); a = new QAction( tr( "Two player option" ), QString::null, 0, this, 0 ); a->setToggleAction( TRUE ); connect( a, SIGNAL( toggled(bool) ), go, SLOT( setTwoplayer(bool) ) ); a->addTo( file ); mb->insertItem( tr( "Game" ), file ); QLabel *turnLabel = new QLabel( toolbar ); turnLabel->setBackgroundMode( PaletteButton ); connect( go, SIGNAL(showTurn(const QPixmap&)), turnLabel, SLOT(setPixmap(const QPixmap&)) ); QLabel * scoreLabel = new QLabel( toolbar ); scoreLabel->setBackgroundMode( PaletteButton ); connect( go, SIGNAL(showScore(const QString&)), scoreLabel, SLOT(setText(const QString&)) ); toolbar->setStretchableWidget( scoreLabel ); go->readConfig(); } void GoMainWidget::resizeEvent( QResizeEvent * ) { //### this won't work because of the text label... /* if ( width() > height() ) moveToolBar( toolbar, Left ); else moveToolBar( toolbar, Top ); */ } GoWidget *GoWidget::self = 0; GoWidget::GoWidget( QWidget *parent, const char* name) : QWidget( parent, name ) { if ( self ) fatal( "Only one Go widget allowed" ); self = this; twoplayer = FALSE; d = bx = by = 1; QPixmap pix = Resource::loadPixmap( "go/pine" ); goBrush = new QBrush( black, pix ); /* QString fn = Resource::findPixmap("Go-black"); blackStone = new QImage( fn ); diff --git a/noncore/games/go/main.cpp b/noncore/games/go/main.cpp index f24e3c3..66f34ab 100644 --- a/noncore/games/go/main.cpp +++ b/noncore/games/go/main.cpp @@ -1,28 +1,27 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 "gowidget.h" -#include <qpe/qpeapplication.h> #include <opie/oapplicationfactory.h> OPIE_EXPORT_APP( OApplicationFactory<GoMainWidget> ) diff --git a/noncore/games/kbill/MCursor.cc b/noncore/games/kbill/MCursor.cc index a3cb340..c581693 100644 --- a/noncore/games/kbill/MCursor.cc +++ b/noncore/games/kbill/MCursor.cc @@ -1,69 +1,64 @@ /*************************************************************************** MCursor.cc - description ------------------- begin : Thu Dec 30 1999 copyright : (C) 1999 by Jurrien Loonstra email : j.h.loonstra@st.hanze.nl ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "MCursor.h" -#include "objects.h" -#include <qcursor.h> -#include <qbitmap.h> -#include <qwidget.h> -#include <qstring.h> #ifdef KDEVER #include <kapp.h> #include <kstandarddirs.h> #endif #include <iostream> #include <qpe/resource.h> MCursor::~MCursor() { delete cursor; } void MCursor::load(const char *name, int masked) { #ifdef KDEVER QString file, mfile; KStandardDirs dirs; file = dirs.findResource("data","kbill/bitmaps/" + QString::fromLocal8Bit(name) + ".xbm"); QBitmap bitmap, mask; if (bitmap.load(file) == FALSE) { std::cerr << "cannot open " << file << std::endl; exit(1); } if (masked == SEP_MASK) { // mfile.sprintf ("%sbitmaps/%s_mask.xbm", (const char*)dir, name); mfile = file = dirs.findResource("data","kbill/bitmaps/" + QString::fromLocal8Bit(name) + "_mask.xbm"); if (mask.load(mfile) == FALSE) { std::cerr << "cannot open " << file << std::endl; exit(1); } } else mask = bitmap; #endif QBitmap bitmap, mask; bitmap = Resource::loadBitmap("kbill/bitmaps/" + QString::fromLocal8Bit(name)); if (masked == SEP_MASK) mask = bitmap = Resource::loadBitmap("kbill/bitmaps/" + QString::fromLocal8Bit(name) + "_mask.xbm"); else mask = bitmap; cursor = new QCursor(bitmap, mask, bitmap.width() / 2, bitmap.height() / 2); } diff --git a/noncore/games/kbill/Picture.cc b/noncore/games/kbill/Picture.cc index fe0eff8..9d46257 100644 --- a/noncore/games/kbill/Picture.cc +++ b/noncore/games/kbill/Picture.cc @@ -1,72 +1,70 @@ /*************************************************************************** Picture.cc - description ------------------- begin : Thu Dec 30 1999 copyright : (C) 1999 by Jurrien Loonstra email : j.h.loonstra@st.hanze.nl ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "Picture.h" -#include "objects.h" #include <iostream> -#include <qstring.h> #include <qpe/resource.h> #ifdef KDEVER #include <kapp.h> #include <kstandarddirs.h> #include <kdebug.h> #endif void Picture::load(const char *name, int index) { //QString dir = KApplication::kde_datadir(), file; // QString dir = locate("data",""),file; // dir += "/kbill/"; // if (index>=0) // file.sprintf ("%spixmaps/%s_%d.xpm", (const char *)dir, name, index); // else // file.sprintf("%spixmaps/%s.xpm", (const char *)dir, name); #ifdef KDEVER KStandardDirs dirs; QString file; if (index>=0) { //kdDebug() << "Here"; QString sindex; sindex.setNum(index); // kdDebug() << "kbill/pixmaps/" + QString::fromLocal8Bit(name) + "_" + sindex + ".xpm"; file = dirs.findResource("data","kbill/pixmaps/" + QString::fromLocal8Bit(name) + "_" + sindex + ".xpm"); } else { file = dirs.findResource("data","kbill/pixmaps/" + QString::fromLocal8Bit(name) + ".xpm"); } kdDebug() << file << std::endl; pix = new QPixmap(); if (pix->load(file) == FALSE) std::cerr << "cannot open " << file << std::endl; width = pix->width(); height = pix->height(); #endif QString sindex; pix = new QPixmap(); sindex.setNum(index); if (index>=0) pix->load(Resource::findPixmap("kbill/pixmaps/" + QString::fromLocal8Bit(name) +"_"+ sindex)); else pix->load(Resource::findPixmap("kbill/pixmaps/" + QString::fromLocal8Bit(name))); width = pix->width(); height = pix->height(); } QPixmap* Picture::getPixmap() { return pix; } diff --git a/noncore/games/kbill/UI.cpp b/noncore/games/kbill/UI.cpp index 2afaf9b..611cebf 100644 --- a/noncore/games/kbill/UI.cpp +++ b/noncore/games/kbill/UI.cpp @@ -1,121 +1,118 @@ /*************************************************************************** UI.cc - description ------------------- begin : Thu Dec 30 1999 copyright : (C) 1999 by Jurrien Loonstra email : j.h.loonstra@st.hanze.nl ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ -#include "kbill.h" #include "objects.h" #include "Strings.h" #ifdef KDEVER #include <kapplication.h> #endif -#include <qpixmap.h> #include <qmessagebox.h> -#include <qnamespace.h> #include "inputbox.h" /**************************/ /* Timer control routines */ /**************************/ UI::~UI() { paint.end(); delete pix; } void UI::restart_timer() { field->startTimer(); } void UI::kill_timer() { field->stopTimer(); } /*******************/ /* Window routines */ /*******************/ void UI::initialize(int *argc, char **argv) { #ifdef KDEVER app = new KApplication(*argc, argv, "kbill"); #endif app = new QPEApplication(*argc, argv); } void UI::graph_init() { pix = new QPixmap(Game::scrwidth, Game::scrheight); paint.begin(pix, field); paint.setPen(QPen(Qt::black, 3)); } void UI::make_mainwin() { main = new KBill(); app->showMainWidget(main,true); main->showMaximized(); field = main->getField(); } void UI::popup_dialog (int dialog) { kill_timer(); switch (dialog) { case Game::ENDGAME: QMessageBox::message(("Endgame"), QT_TR_NOOP(endgamestr)); break; case Game::HIGHSCORE: // QMessageBox::message(("HighScore"), highscorestr); break; case Game::ENTERNAME: { InputBox b(main, 0, ("Enter Name"), QT_TR_NOOP(enternamestr)); bool state = b.exec() == 2; char str[20], *nl; strcpy(str, b.getText()); if (!str[0] || state) strcpy(str, "Anonymous"); else if ((nl = strchr(str, '\n'))) *nl = '\0'; if (strlen(str) > 20) str[20] = 0; /* truncate string if too long */ // scores.recalc(str); } break; case Game::SCORE: QMessageBox::message(("Score"), scorestr); break; } restart_timer(); } /*********************/ /* Graphics routines */ /*********************/ void UI::set_cursor(int cursor) { QCursor *cur; switch (cursor) { case Game::BUCKETC: cur = bucket.cursor.cursor; break; case Game::DOWNC: cur = downcursor.cursor; break; case Game::DEFAULTC: cur = defaultcursor.cursor; break; default: cur = OS.cursor[cursor].cursor; } field->setCursor(*cur); } diff --git a/noncore/games/kbill/field.cpp b/noncore/games/kbill/field.cpp index a1b3560..a974ab2 100644 --- a/noncore/games/kbill/field.cpp +++ b/noncore/games/kbill/field.cpp @@ -1,84 +1,83 @@ /*************************************************************************** field.cpp - description ------------------- begin : Thu Dec 30 1999 copyright : (C) 1999 by Jurrien Loonstra email : j.h.loonstra@st.hanze.nl ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ -#include <qpainter.h> #include "objects.h" #include "field.h" Field::Field(QWidget *parent, const char *name ) : QWidget(parent,name) { setFixedSize(game.scrwidth, game.scrheight); setBackgroundColor(white); timer = new QTimer(this); playing = false; connect(timer, SIGNAL(timeout()), SLOT(Timer())); } Field::~Field(){ delete timer; } void Field::setPixmap(QPixmap *pix) { this->pix = pix; } // -------------------------------------------------------- void Field::mousePressEvent(QMouseEvent *e){ game.button_press(e->x(), e->y()); } void Field::mouseReleaseEvent(QMouseEvent *e){ game.button_release(e->x(), e->y()); } void Field::enterEvent(QEvent *) { if (playing && !timer->isActive()) { playing = true; timer->start(250, FALSE); } } void Field::leaveEvent(QEvent *) { if (timer->isActive() && playing) { playing = true; timer->stop(); } } void Field::stopTimer() { playing = false; if (timer->isActive()) timer->stop(); } void Field::startTimer() { playing = true; if (!timer->isActive()) timer->start(250, FALSE); } void Field::Timer(){ game.update(); } void Field::paintEvent(QPaintEvent *) { bitBlt(this, 0, 0, pix); }
\ No newline at end of file diff --git a/noncore/games/kbill/inputbox.cpp b/noncore/games/kbill/inputbox.cpp index b191ea8..5087fbb 100644 --- a/noncore/games/kbill/inputbox.cpp +++ b/noncore/games/kbill/inputbox.cpp @@ -1,51 +1,50 @@ /*************************************************************************** inputbox.cpp - description ------------------- begin : Sat Jan 1 2000 copyright : (C) 2000 by Jurrien Loonstra email : j.h.loonstra@st.hanze.nl ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "inputbox.h" -#include <qdialog.h> InputBox::InputBox(QWidget *parent, const char *name, const char *caption, const char *text) : QDialog(parent, name, TRUE) { // setCaption(caption); // // question = new QLabel(this); // question->setText(text); // question->setGeometry(10, 10, 240, 50); // // input = new QLineEdit(this); // input->setGeometry(10, 60, 240, 30); // input->setFocus(); // input->setMaxLength(19); // // ok = new QPushButton( "Ok", this ); // ok->setGeometry(10, 100, 100,30 ); // ok->setDefault(TRUE); // connect( ok, SIGNAL(clicked()), SLOT(accept()) ); // // cancel = new QPushButton( "Cancel", this ); // cancel->setGeometry(150, 100, 100,30 ); // connect( cancel, SIGNAL(clicked()), SLOT(reject()) ); } InputBox::~InputBox(){ delete ok; delete cancel; delete question; delete input; } QString InputBox::getText() const{ return input->text(); } diff --git a/noncore/games/kbill/kbill.cpp b/noncore/games/kbill/kbill.cpp index 18a6875..74d7c75 100644 --- a/noncore/games/kbill/kbill.cpp +++ b/noncore/games/kbill/kbill.cpp @@ -1,121 +1,117 @@ /*************************************************************************** kbill.cpp - description ------------------- begin : Thu Dec 30 16:55:55 CET 1999 copyright : (C) 1999 by Jurrien Loonstra email : j.h.loonstra@st.hanze.nl ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include <qmessagebox.h> -#include <qmultilinedit.h> #include <qmenubar.h> #include <qtextbrowser.h> -#include <qfont.h> -#include <qwidget.h> #include "kbill.h" -#include "inputbox.h" #include "helpdialog.h" #include "objects.h" #include "Strings.h" KBill::KBill() : QMainWindow() { setCaption(tr("kBill")); file = new QPopupMenu(); file->insertItem(tr("New game"), this, SLOT(NewGame())); pauseid = file->insertItem(tr("Pause game"), this, SLOT(Pause())); //these are dissabled until I fix them //file->insertItem(tr("Warp to level..."), this, SLOT(WarpTo())); //file->insertItem(tr("View high scores"), this, SLOT(ViewHighScores())); help = new QPopupMenu(); help->insertItem(tr("Story of kBill"), this, SLOT(Story())); help->insertItem(tr("Rules"), this, SLOT(Rules())); menu = new QMenuBar(this); menu->insertItem(tr("&File"), file); menu->insertSeparator(); menu->insertItem(tr("&Help"), help); field = new Field(this); //setView(field); //setMainWidget(field); //setMenu(menu); } KBill::~KBill() { } Field* KBill::getField() { return field; } // ----------------------------------------------------------------------- void KBill::Quit() { field->stopTimer(); qApp->quit(); } void KBill::About(){ // field->stopTimer(); // AboutBox about(this); // about.exec(); // field->startTimer(); } void KBill::NewGame() { field->stopTimer(); // if (KMsgBox::yesNo(this, i18n("New Game"), i18n(newgamestr), KMsgBox::QUESTION) == 1) game.start(1); // else field->startTimer(); } void KBill::Pause() { field->stopTimer(); QMessageBox::message(tr("Pause Game"), tr(pausestr), 0); field->startTimer(); } void KBill::WarpTo() { /* field->stopTimer(); InputBox b(this, 0, "Warp To Level", tr(warpstr)); bool status = b.exec() == 1; field->startTimer(); if (status) { bool ok; int level = b.getText().toUInt(&ok); if (ok) { field->startTimer(); game.warp_to_level(level); return; } }*/ } void KBill::ViewHighScores() { //ui.popup_dialog(Game::HIGHSCORE); } void KBill::Story() { field->stopTimer(); HelpDialog *stryDialog = new HelpDialog(this,"helpdialog",1); QString stryString = tr("<b>The Story</b><p>Yet again, the fate of the world rests in your hands! An evil computer hacker, known only by his handle 'Bill', has created the ultimate computer virus. A virus so powerful that it has the power to transmute an ordinary computer into a toaster oven. (oooh!) 'Bill' has cloned himself into a billion-jillion micro-Bills. Their sole purpose is to deliver the nefarious virus, which has been cleverly disguised as a popular operating system. As System Administrator and Exterminator, your job is to keep Bill from succeeding at his task."); stryDialog->setCaption(tr("The story of KBill")); stryDialog->TextBrowser1->setText(stryString); stryDialog->resize(200,200); stryDialog->show(); field->startTimer(); } diff --git a/noncore/games/kcheckers/kcheckers.cpp b/noncore/games/kcheckers/kcheckers.cpp index 2eb37e5..a27dd18 100644 --- a/noncore/games/kcheckers/kcheckers.cpp +++ b/noncore/games/kcheckers/kcheckers.cpp @@ -1,99 +1,98 @@ #include <qimage.h> -#include <qframe.h> #include <qlayout.h> #include <qmenubar.h> #include <qtoolbar.h> #include <qpe/config.h> #include <qwhatsthis.h> #include <qtoolbutton.h> #include <qmessagebox.h> #include <qapplication.h> #include "kcheckers.h" #include "echeckers.h" #include "rcheckers.h" #include "pics/logo.xpm" #include "pics/undo.xpm" #include "pics/exit.xpm" #include "pics/help.xpm" #include "pics/wood1.xpm" #include "pics/wood2.xpm" #include "pics/wood3.xpm" #include "pics/green1.xpm" #include "pics/green2.xpm" #include "pics/green3.xpm" #include "pics/marble1.xpm" #include "pics/marble2.xpm" #include "pics/marble3.xpm" #include "pics/biglogo.xpm" #include "pics/man_black.xpm" #include "pics/man_white.xpm" #include "pics/king_black.xpm" #include "pics/king_white.xpm" #include "pics/contexthelp.xpm" QString KCheckers::enNumeration="1 2 3 4 5 6 7 8 9 1011121314151617181920212223242526272829303132"; QString KCheckers::ruNumeration="B8D8F8H8A7C7E7G7B6D6F6H6A5C5E5G5B4D4F4H4A3C3E3G3B2D2F2H2A1C1E1G1"; const int KCheckers::t[]={6,7,8,9,11,12,13,14,17,18,19,20,22,23, 24,25,28,29,30,31,33,34,35,36,39,40,41,42,44,45,46,47}; KCheckers::KCheckers(QWidget *p, const char* n, WFlags ) :QMainWindow(p,n,WStyle_DialogBorder) { setCaption(tr("KCheckers") ); setIcon(QPixmap(biglogo_xpm)); setToolBarsMovable(false); // Make a menubar gameMenu=new QPopupMenu; CHECK_PTR(gameMenu); gameMenu->insertItem(QPixmap(logo_xpm),tr("&New"),this,SLOT(newGame()),CTRL+Key_N); gameMenu->insertSeparator(); undoID=gameMenu->insertItem(QPixmap(undo_xpm),tr("&Undo Move"),this,SLOT(undoMove()),CTRL+Key_Z); gameMenu->insertSeparator(); gameMenu->insertItem(QPixmap(exit_xpm),tr("&Quit"),qApp,SLOT(closeAllWindows()),CTRL+Key_Q); skillMenu=new QPopupMenu; CHECK_PTR(skillMenu); skillMenu->insertItem(tr("&Beginner"),this,SLOT(setSkillBeginner()),CTRL+Key_1,BEGINNER); skillMenu->insertItem(tr("&Novice"), this,SLOT(setSkillNovice()), CTRL+Key_2,NOVICE); skillMenu->insertItem(tr("&Average"), this,SLOT(setSkillAverage()), CTRL+Key_3,AVERAGE); skillMenu->insertItem(tr("&Good"), this,SLOT(setSkillGood()), CTRL+Key_4,GOOD); skillMenu->insertItem(tr("&Expert"), this,SLOT(setSkillExpert()), CTRL+Key_5,EXPERT); skillMenu->insertItem(tr("&Master"), this,SLOT(setSkillMaster()), CTRL+Key_6,MASTER); optionsMenu=new QPopupMenu; CHECK_PTR(optionsMenu); numID=optionsMenu->insertItem(tr("&Show Numeration"),this,SLOT(showNumeration())); optionsMenu->insertSeparator(); optionsMenu->insertItem(tr("&English Rules"),this,SLOT(setRulesEnglish()),0,ENGLISH); optionsMenu->insertItem(tr("&Russian Rules"),this,SLOT(setRulesRussian()),0,RUSSIAN); optionsMenu->insertSeparator(); optionsMenu->insertItem(tr("&Green Board"), this,SLOT(setPatternGreen()), 0,GREEN); optionsMenu->insertItem(tr("&Marble Board"),this,SLOT(setPatternMarble()),0,MARBLE); optionsMenu->insertItem(tr("&Wooden Board"),this,SLOT(setPatternWooden()),0,WOODEN); QPopupMenu* helpMenu=new QPopupMenu; CHECK_PTR(helpMenu); helpMenu->insertItem(QPixmap(contexthelp_xpm),tr("What's This"),this,SLOT(whatsThis()),SHIFT+Key_F1); helpMenu->insertItem(QPixmap(help_xpm),tr("&Rules of Play"),this,SLOT(help()),Key_F1); helpMenu->insertSeparator(); helpMenu->insertItem(QPixmap(logo_xpm),tr("&About KCheckers"),this,SLOT(about())); helpMenu->insertItem(tr("About &Qt"),this,SLOT(aboutQt())); QToolBar* menuToolBar=new QToolBar(this); CHECK_PTR(menuToolBar); QMenuBar* menuBar=new QMenuBar(menuToolBar); CHECK_PTR(menuBar); diff --git a/noncore/games/kcheckers/main.cpp b/noncore/games/kcheckers/main.cpp index 6ac570a..e22dbcc 100644 --- a/noncore/games/kcheckers/main.cpp +++ b/noncore/games/kcheckers/main.cpp @@ -1,10 +1,8 @@ -#include <qpe/qpeapplication.h> -#include <qfont.h> #include "kcheckers.h" #include <opie/oapplicationfactory.h> OPIE_EXPORT_APP( OApplicationFactory<KCheckers> ) diff --git a/noncore/games/kpacman/board.cpp b/noncore/games/kpacman/board.cpp index f95f699..f82b5f9 100644 --- a/noncore/games/kpacman/board.cpp +++ b/noncore/games/kpacman/board.cpp @@ -1,106 +1,103 @@ -#include "portable.h" #if defined( KDE2_PORT ) #include <kapp.h> #include <klocale.h> #endif -#include <qrect.h> -#include <qregexp.h> #include <qmessagebox.h> #include <qfile.h> #include <qtextstream.h> #include "board.h" #include "bitmaps.h" Board::Board(int size) : QArray<int> (size) { sz = size; // set size of board map = ""; mapName = ""; // no map loaded so far init(None); // initialize varibales } void Board::init(Image image, QString levelName) { prisonEntry = OUT; prisonExit = OUT; fruitHome = OUT; fruitPosition = OUT; pacmanHome = OUT; pacmanPosition = OUT; for (int m = 0; m < 8; m++) { monsterHome[m] = OUT; monsterPosition[m] = OUT; } for (int e = 0; e < 8; e++) { energizerPosition[e] = OUT; } for (int e = 0; e < 8; e++) { tunnelPosition[e] = OUT; } fill(0); numPoints = 0; numEnergizers = 0; numMonsters = 0; numTunnels = 0; if (!levelName.isNull() && !levelName.isEmpty()) if (mapName == levelName) image = File; else { QFile levelFile(levelName); if (!levelFile.open(IO_ReadOnly)) { QString msg = "The levelmap could not be constructed.\n\n" "The file '@LEVELNAME@' does not exist,\n" "or could not be opened for reading."; msg.replace(QRegExp("@LEVELNAME@"), levelName); // QMessageBox::information(0, tr("Initialization Error"), msg); printf("%s\n", msg.data()); } else { map.fill(' ', BoardHeight*BoardWidth); int height = 0; QTextStream levelStream(&levelFile); while (!levelStream.eof() && height < BoardHeight) { QString line = levelStream.readLine(); if (line.find(QRegExp("^ *;")) == -1) { line.replace(QRegExp(";.*"), ""); // strip off comments line.replace(QRegExp("\" *$"), ""); // strip off trailing " line.replace(QRegExp("^ *\""), ""); // strip off leading " map.replace(height*BoardWidth, (line.length() > BoardWidth) ? BoardWidth : line.length(), line.data()); height++; } } mapName = levelName; levelFile.close(); image = File; } } switch (image) { case Intro : // setup(demo_bits); break; case Demo : setup(demo_bits); break; case Level : setup(demo_bits); break; case File : setup((uchar *) map.data()); break; default : break; } } void Board::setup(const uchar *buf) diff --git a/noncore/games/kpacman/keys.cpp b/noncore/games/kpacman/keys.cpp index 07ce135..5200bc2 100644 --- a/noncore/games/kpacman/keys.cpp +++ b/noncore/games/kpacman/keys.cpp @@ -1,121 +1,116 @@ #include "portable.h" #if defined( KDE2_PORT ) #include <kapp.h> #include <kconfig.h> #include <klocale.h> #include <kstddirs.h> #include <kaccel.h> #include <keys.h> #include <keys.moc> #elif defined( QPE_PORT ) #include <qaccel.h> #include <qpe/qpeapplication.h> #include <qpe/config.h> #include "keys.h" #endif #include <qpushbt.h> -#include <qlabel.h> -#include <qframe.h> -#include <qkeycode.h> -#include <qpixmap.h> -#include <qstring.h> Keys::Keys( QWidget *parent, const char *name) : QDialog( parent, name, TRUE ) { //KStandardDirs *dirs = KGlobal::dirs(); QPushButton *okButton = new QPushButton(this); okButton->setText(tr("Ok")); okButton->setFixedSize(okButton->size()); connect( okButton, SIGNAL(clicked()),this, SLOT(ok()) ); okButton->move(20,210); QPushButton *defaultButton = new QPushButton(this); defaultButton->setText(tr("Defaults")); defaultButton->setFixedSize(defaultButton->size()); connect( defaultButton, SIGNAL(clicked()),this, SLOT(defaults()) ); defaultButton->move(140,210); QPushButton *cancelButton = new QPushButton(this); cancelButton->setText(tr("Cancel")); cancelButton->setFixedSize(cancelButton->size()); connect( cancelButton, SIGNAL(clicked()),this, SLOT(reject()) ); cancelButton->move(260,210); QFrame *separator = new QFrame(this); separator->setFrameStyle( QFrame::HLine | QFrame::Sunken ); separator->setGeometry( 20, 190, 340, 4 ); for ( int x = 0; x < 4; x++) { QLabel *l = new QLabel(this); l->setAlignment(AlignCenter); labels[x] = l; } labels[0]->setGeometry(120, 20, 140, 20 ); labels[1]->setGeometry(120,160, 140, 20 ); labels[2]->setGeometry( 20, 92, 100, 20 ); labels[3]->setGeometry(265, 92, 100, 20 ); QString pixPath; QPushButton *up = new QPushButton(this); pixPath = FIND_APP_DATA( "pics/up.xpm" ); up->setPixmap( QPixmap(pixPath)); up->setFixedSize(up->pixmap()->size()); connect( up, SIGNAL(clicked()),this, SLOT(butUp()) ); up->move(180, 50); QPushButton *down = new QPushButton(this); pixPath = FIND_APP_DATA( "pics/down.xpm"); down->setPixmap( QPixmap(pixPath)); down->setFixedSize(down->pixmap()->size()); connect( down, SIGNAL(clicked()),this, SLOT(butDown()) ); down->move(180, 130); QPushButton *left = new QPushButton(this); pixPath = FIND_APP_DATA( "pics/left.xpm"); left->setPixmap( QPixmap(pixPath)); left->setFixedSize(left->pixmap()->size()); connect( left, SIGNAL(clicked()),this, SLOT(butLeft()) ); left->move(140, 90); QPushButton *right = new QPushButton(this); pixPath = FIND_APP_DATA( "pics/right.xpm"); right->setPixmap( QPixmap(pixPath)); right->setFixedSize(right->pixmap()->size()); connect( right, SIGNAL(clicked()),this, SLOT(butRight()) ); right->move(220, 90); setCaption(tr("Change Direction Keys")); setFixedSize(380, 260); lab = 0; init(); } void Keys::keyPressEvent( QKeyEvent *e ) { uint kCode = e->key() & ~(SHIFT | CTRL | ALT); QString string = KAccel::keyToString(kCode); if (lab != 0) { if ( string.isNull() ) lab->setText(tr("Undefined key")); else lab->setText(string); } else if ( lab == 0 && e->key() == Key_Escape) reject(); } void Keys::butUp() { getKey(0); } diff --git a/noncore/games/kpacman/kpacman.cpp b/noncore/games/kpacman/kpacman.cpp index df27c76..be2e46d 100644 --- a/noncore/games/kpacman/kpacman.cpp +++ b/noncore/games/kpacman/kpacman.cpp @@ -1,115 +1,110 @@ #include "portable.h" #if defined( KDE2_PORT ) #include <kpacman.h> #include <kpacman.moc> #include <kcolordlg.h> #elif defined( QPE_PORT ) #include <qmenubar.h> #include <qpe/config.h> #include <qapplication.h> #include "kpacman.h" #endif -#include <qkeycode.h> -#include <qcolor.h> -#include <qstring.h> -#include <qpopmenu.h> -#include <qmsgbox.h> Kpacman::Kpacman(QWidget *parent, const char *name) : KTMainWindow(parent, name) { schemesPopup = new QList<QPopupMenu>; schemesPopup->setAutoDelete(TRUE); menu(); m_view = new QWidget( this, "m_view" ); m_view->setBackgroundColor( black ); m_layout = new QGridLayout( m_view ); m_layout->setMargin( 7 ); view = new KpacmanWidget( this, QString(name)+"widget"); m_layout->addWidget( view, 0, 0 ); setCaption( tr("KPacman") ); view->referee->setFocus(); connect(view->referee, SIGNAL(setScore(int, int)), view->score, SLOT(setScore(int, int))); connect(view->referee, SIGNAL(setPoints(int)), view->score, SLOT(set(int))); connect(view->referee, SIGNAL(setLifes(int)), view->status, SLOT(setLifes(int))); connect(view->referee, SIGNAL(setLevel(int)), view->status, SLOT(setLevel(int))); connect(view->referee, SIGNAL(forcedHallOfFame(bool)), this, SLOT(forcedHallOfFame(bool))); connect(view->referee, SIGNAL(togglePaused()), this, SLOT(togglePaused())); connect(view->referee, SIGNAL(toggleNew()), this, SLOT(toggleNew())); connect(view->score, SIGNAL(toggleNew()), this, SLOT(toggleNew())); connect(view->score, SIGNAL(forcedHallOfFame(bool)), this, SLOT(forcedHallOfFame(bool))); APP_CONFIG_BEGIN( cfg ); focusOutPause = !cfg->readBoolEntry("FocusOutPause", TRUE); focusInContinue = !cfg->readBoolEntry("FocusInContinue", TRUE); hideMouseCursor = !cfg->readBoolEntry("HideMouseCursor", TRUE); APP_CONFIG_END( cfg ); toggleFocusOutPause(); toggleFocusInContinue(); toggleHideMouseCursor(); setCentralWidget( m_view ); } Kpacman::~Kpacman() { /* APP_CONFIG_BEGIN( cfg ); cfg->writeEntry("FocusOutPause", focusOutPause); cfg->writeEntry("FocusInContinue", focusInContinue); cfg->writeEntry("HideMouseCursor", hideMouseCursor); APP_CONFIG_END( cfg ); */ delete _menuBar; } void Kpacman::menu() { gamePopup = new QPopupMenu(); CHECK_PTR( gamePopup ); newID = gamePopup->insertItem(tr("&New"), this, SLOT(newKpacman()),Key_F2); pauseID = gamePopup->insertItem(tr("&Pause"), this, SLOT(pauseKpacman()), Key_F3); hofID = gamePopup->insertItem(tr("&Hall of fame"), this, SLOT(toggleHallOfFame()), Key_F4); gamePopup->insertSeparator(); gamePopup->insertItem(tr("&Quit"), this, SLOT(quitKpacman()), CTRL+Key_Q); gamePopup->setCheckable(TRUE); optionsPopup = new QPopupMenu(); CHECK_PTR(optionsPopup); modesPopup = new QPopupMenu(); CHECK_PTR(modesPopup); hideMouseCursorID = optionsPopup->insertItem(tr("&Hide Mousecursor"), this, SLOT(toggleHideMouseCursor()), CTRL+Key_H); optionsPopup->insertSeparator(); if (lookupSchemes() > 0) { optionsPopup->insertItem(tr("&Select graphic scheme"), modesPopup); optionsPopup->insertSeparator(); } focusOutPauseID = optionsPopup->insertItem(tr("&Pause in Background"), this, SLOT(toggleFocusOutPause())); focusInContinueID = optionsPopup->insertItem(tr("&Continue in Foreground"), this, SLOT(toggleFocusInContinue())); optionsPopup->insertSeparator(); diff --git a/noncore/games/kpacman/kpacmanwidget.cpp b/noncore/games/kpacman/kpacmanwidget.cpp index 823d2bf..9631495 100644 --- a/noncore/games/kpacman/kpacmanwidget.cpp +++ b/noncore/games/kpacman/kpacmanwidget.cpp @@ -1,117 +1,112 @@ #include "portable.h" #if defined( KDE2_PORT ) #include <kapp.h> #include <kconfig.h> #include <kstddirs.h> #include <kpacmanwidget.h> #include <kpacmanwidget.moc> #elif defined( QPE_PORT ) #include <qpe/qpeapplication.h> #include <qpe/config.h> #include "kpacmanwidget.h" #endif -#include <qmessagebox.h> -#include "bitfont.h" -#include "score.h" -#include "referee.h" -#include "status.h" KpacmanWidget::KpacmanWidget( QWidget *parent, const char *name) : QWidget( parent, name ) { score = 0l; referee = 0l; status = 0l; bitfont = NULL; fontName = ""; scheme = mode = -1; confScheme(); score = new Score(this, name, scheme, mode, bitfont); referee = new Referee( this, name, scheme, mode, bitfont); status = new Status(this, name, scheme, mode); setBackgroundColor( black ); } KpacmanWidget::~KpacmanWidget() { } void KpacmanWidget::confMisc(bool defGroup) { APP_CONFIG_BEGIN( cfg ); //KStandardDirs *dirs = KGlobal::dirs(); QString findPath; if (defGroup || cfg->hasKey("Font")) { fontName = cfg->readEntry("Font"); if (fontName.left(1) != "/" && fontName.left(1) != "~") fontName.insert(0, "fonts/"); if (fontName.right(1) == "/") fontName.append("font.xbm"); //findPath = dirs->findResource("appdata", fontName); findPath = FIND_APP_DATA( fontName ); if (!findPath.isEmpty()) fontName = findPath; bitfontFirstChar = cfg->readNumEntry("FontFirstChar", 0x0e); bitfontLastChar = cfg->readNumEntry("FontLastChar", 0x5f); } APP_CONFIG_END( cfg ); } void KpacmanWidget::confScheme() { APP_CONFIG_BEGIN( cfg ); QString lastFontName = fontName; SAVE_CONFIG_GROUP( cfg, oldgroup ); QString newgroup; // if not set, read mode and scheme from the configfile if (mode == -1 && scheme == -1) { scheme = cfg->readNumEntry("Scheme", -1); mode = cfg->readNumEntry("Mode", -1); // if mode is not set in the defGroup-group, lookup the scheme group if (scheme != -1 || mode == -1) { newgroup.sprintf("Scheme %d", scheme); cfg->setGroup(newgroup); mode = cfg->readNumEntry("Mode", -1); RESTORE_CONFIG_GROUP( cfg, oldgroup ); } } confMisc(); if (mode != -1) { newgroup.sprintf("Mode %d", mode); cfg->setGroup(newgroup); confMisc(FALSE); } if (scheme != -1) { newgroup.sprintf("Scheme %d", scheme); cfg->setGroup(newgroup); confMisc(FALSE); } if (lastFontName != fontName) { if (bitfont != 0) delete bitfont; bitfont = new Bitfont(fontName, bitfontFirstChar, bitfontLastChar); if (bitfont->width() == 0 || bitfont->height() == 0) { QString msg = tr("The bitfont could not be contructed.\n\n" "The file '@FONTNAME@' does not exist,\n" diff --git a/noncore/games/kpacman/monster.cpp b/noncore/games/kpacman/monster.cpp index 2f402b4..80b4655 100644 --- a/noncore/games/kpacman/monster.cpp +++ b/noncore/games/kpacman/monster.cpp @@ -1,98 +1,97 @@ #include "monster.h" -#include "board.h" Monster::Monster(Board *b, int mid) { board = b; ID = mid; setREM(0); setHarmless(0, 0, 0); setArrested(0, 0); setFreedom(board->position(prisonexit)); if (mid == 0) setPrison(board->position(prisonentry)); else setPrison(board->position(monsterhome, mid)); actualPosition = lastPosition = OUT; feetPosition = 0; IQ = 0; maxBodyPixmaps = 0; maxEyesPixmaps = 0; } void Monster::setMaxPixmaps(int maxBody, int maxEyes) { if (feetPosition >= (maxBody/10)) feetPosition = 0; maxBodyPixmaps = maxBody; maxEyesPixmaps = maxEyes; } void Monster::setArrested(int ticks, int duration) { actualState = dangerous; pauseDuration = ticks; pause = 0; arrestDuration = arrestLeft = duration; arrestPause = ticks; harmlessLeft = 0; } void Monster::setDangerous(int ticks, int iq) { actualState = dangerous; pauseDuration = ticks; pause = 0; dangerousPause = ticks; harmlessLeft = 0; IQ = iq; } void Monster::setHarmless(int ticks, int hDuration, int wDuration) { actualState = harmless; pauseDuration = ticks; pause = 0; harmlessDuration = harmlessLeft = hDuration; warningDuration = wDuration; } void Monster::setREM(int ticks) { actualState = rem; pauseDuration = ticks; pause = 0; } void Monster::setPosition(int pos) { board->reset(lastPosition, monster, ID); // reset old position on the board actualPosition = lastPosition = pos; // set position of monster board->set(actualPosition, monster, ID); feetPosition = 0; } void Monster::setPrison(int pos) { prisonPosition = pos; } void Monster::setFreedom(int pos) { freedomPosition = pos; } void Monster::setDirection(int dir) { if (dir == X) lastDirection = actualDirection; actualDirection = dir; } monsterState Monster::state() { return actualState; } diff --git a/noncore/games/kpacman/pacman.cpp b/noncore/games/kpacman/pacman.cpp index 40f60a8..82524b4 100644 --- a/noncore/games/kpacman/pacman.cpp +++ b/noncore/games/kpacman/pacman.cpp @@ -1,98 +1,97 @@ #include "pacman.h" -#include "board.h" Pacman::Pacman(Board *b) { board = b; setDemo(FALSE); setAlive(0); actualPosition = lastPosition = OUT; mouthPosition = 0; lastPix = 0; maxPixmaps = 0; } void Pacman::setMaxPixmaps(int max) { if (actualDirection == X && lastPix >= 0) { actualDirection = lastPix / (maxPixmaps/4); if (max < maxPixmaps) mouthPosition = 0; else mouthPosition = lastPix % (maxPixmaps/4); maxPixmaps = max; lastPix = pix(); actualDirection = X; } else maxPixmaps = max; } void Pacman::setAlive(int ticks) { actualState = alive; pauseDuration = ticks; pause = 0; } void Pacman::setPosition(int pos) { board->reset(lastPosition, pacman); actualPosition = lastPosition = pos; board->set(actualPosition, pacman); mouthPosition = 0; } void Pacman::setDirection(int dir, bool forced) { if (forced || board->isWay(actualPosition, dir, empty) || board->isWay(actualPosition, dir, tunnel)) { if (dir == X) lastPix = pix(); actualDirection = dir; nextDirection = X; } else nextDirection = dir; } void Pacman::setDemo(bool yes) { demo = yes; } pacmanState Pacman::state() { return actualState; } int Pacman::position() { return actualPosition; } int Pacman::direction() { return actualDirection; } bool Pacman::move() { if (pause-- > 0) return FALSE; else pause = pauseDuration; if (actualDirection == X || actualPosition == OUT) return FALSE; lastPosition = actualPosition; if (demo) { int d = actualDirection; do // try new direction, but not the opposite d = rand() % 4; // direction, to prevent hectic movement. while (d == board->turn(actualDirection)); diff --git a/noncore/games/kpacman/painter.cpp b/noncore/games/kpacman/painter.cpp index d8c7460..410d3f5 100644 --- a/noncore/games/kpacman/painter.cpp +++ b/noncore/games/kpacman/painter.cpp @@ -1,120 +1,112 @@ #include "portable.h" #if defined( KDE2_PORT ) #include <kapp.h> #include <kconfig.h> #include <kstddirs.h> #elif defined( QPE_PORT ) #include <qpe/qpeapplication.h> #include <qpe/config.h> #endif -#include <qcolor.h> -#include <qpainter.h> -#include <qpixmap.h> -#include <qbitmap.h> -#include <qrect.h> -#include <qstring.h> - -#include <qmessagebox.h> + #include <qfileinfo.h> #include "painter.h" -#include "board.h" Painter::Painter( Board *b, QWidget *parent, int Scheme, int Mode, Bitfont *font) { w = parent; board = b; pointPix = NULL; wallPix = NULL; prisonPix = NULL; energizerPix = NULL; fruitPix = NULL; pacmanPix = NULL; dyingPix = NULL; eyesPix = NULL; monsterPix = NULL; fruitScorePix = NULL; monsterScorePix = NULL; lastPointPixmapName = ""; lastWallPixmapName = ""; lastPrisonPixmapName = ""; lastEnergizerPixmapName = ""; lastFruitPixmapName = ""; lastPacmanPixmapName = ""; lastDyingPixmapName = ""; lastEyesPixmapName = ""; lastMonsterPixmapName = ""; lastFruitScorePixmapName = ""; lastMonsterScorePixmapName = ""; bitfont = font; scheme = Scheme; mode = Mode; level = 0; confScheme(); } QList<QPixmap> *Painter::loadPixmap(QWidget*, QString pixmapName, QList<QPixmap> *pixmaps) { if (pixmaps == NULL) { pixmaps = new QList<QPixmap>; pixmaps->setAutoDelete(TRUE); } if (!pixmaps->isEmpty()) pixmaps->clear(); QPixmap PIXMAP(pixmapName); if (PIXMAP.isNull() || PIXMAP.mask() == NULL) { QString msg = "The pixmap could not be contructed.\n\n" "The file '@PIXMAPNAME@' does not exist,\n" "or is of an unknown format."; msg.replace(QRegExp("@PIXMAPNAME@"), pixmapName); // QMessageBox::critical(parent, tr("Initialization Error"), msg); printf("%s\n", msg.data()); return 0; } int height = PIXMAP.height(); int width = (height == 0) ? 0 : PIXMAP.width()/(PIXMAP.width()/height); QBitmap BITMAP; QBitmap MASK; BITMAP = *PIXMAP.mask(); MASK.resize(width, height); for (int x = 0; x < PIXMAP.width()/width; x++) { QPixmap *pixmap = new QPixmap(width, height); pixmaps->append(pixmap); bitBlt(pixmap, 0, 0, &PIXMAP, x*width, 0, width, height, QPixmap::CopyROP, TRUE); bitBlt(&MASK, 0, 0, &BITMAP, x*width, 0, width, height, QPixmap::CopyROP, TRUE); pixmap->setMask(MASK); } return pixmaps; } QList<QPixmap> *Painter::textPixmap(QStrList &str, QList<QPixmap> *pixmaps, QColor fg, QColor bg) { if (pixmaps == NULL) { pixmaps = new QList<QPixmap>; pixmaps->setAutoDelete(TRUE); } if (!pixmaps->isEmpty()) pixmaps->clear(); for (uint s = 0; s < str.count(); s++) { QPixmap *pixmap = new QPixmap(bitfont->text(str.at(s), fg, bg)); pixmaps->append(pixmap); } diff --git a/noncore/games/kpacman/referee.cpp b/noncore/games/kpacman/referee.cpp index 1b810d8..2d0f3be 100644 --- a/noncore/games/kpacman/referee.cpp +++ b/noncore/games/kpacman/referee.cpp @@ -1,126 +1,117 @@ #include "portable.h" #if defined( KDE2_PORT ) #include <kapp.h> #include <kconfig.h> #include <kstddirs.h> #include <kaccel.h> #include <referee.h> #include <referee.moc> #elif defined( QPE_PORT ) #include <qaccel.h> #include <qpe/qpeapplication.h> #include <qpe/config.h> #include "referee.h" #endif -#include <qdatetm.h> #include <stdlib.h> #include <qtimer.h> -#include <qevent.h> -#include <qcolor.h> -#include <qkeycode.h> #include <qfileinfo.h> -#include "board.h" -#include "pacman.h" -#include "monster.h" -#include "fruit.h" -#include "painter.h" Referee::Referee( QWidget *parent, const char *name, int Scheme, int Mode, Bitfont *font) : QWidget( parent, name ) { gameState.resize(12); gameTimer = 0; energizerTimer = 0; focusedPause = FALSE; setFocusPolicy(QWidget::StrongFocus); initKeys(); scheme = Scheme; mode = Mode; confScheme(); board = new Board(BoardWidth*BoardHeight); pix = new Painter(board, this, scheme, mode, font); setFixedSize(pix->levelPix().size()); pacman = new Pacman(board); fruit = new Fruit(board); monsters = new QList<Monster>; monsters->setAutoDelete(TRUE); monsterRect = new QList<QRect>; monsterRect->setAutoDelete(TRUE); energizers = new QList<Energizer>; energizers->setAutoDelete(TRUE); energizerRect = new QList<QRect>; energizerRect->setAutoDelete(TRUE); pacmanRect.setRect(0, 0, 0, 0); fruitRect.setRect(0, 0, 0, 0); QTime midnight( 0, 0, 0 ); srand( midnight.secsTo(QTime::currentTime()) ); lifes = 0; points = 0; emit setLifes(lifes); emit setPoints(points); intro(); } void Referee::paintEvent( QPaintEvent *e) { if (gameState.testBit(HallOfFame)) return; QRect rect = e->rect(); if (!rect.isEmpty()) { QPixmap p = pix->levelPix(); bitBlt(this, rect.x(), rect.y(), &p, rect.x(), rect.y(), rect.width(), rect.height()); } if ((gameState.testBit(GameOver) || gameState.testBit(Demonstration)) && rect.intersects(pix->rect(board->position(fruithome), tr("GAME OVER")))) pix->draw(board->position(fruithome), Widget, tr("GAME OVER"), RED); for (Energizer *e = energizers->first(); e != 0; e = energizers->next()) { if (e && e->state() == on && rect.intersects(pix->rect(e->position(), EnergizerPix)) && !(e->position() == pacman->position() && gameState.testBit(Scoring))) { if (e->pix() != -1) pix->draw(e->position(), Widget, EnergizerPix, e->pix()); } } if (!gameState.testBit(Init)) { if (!gameState.testBit(Dying) && (fruit->pix() != -1)) if (fruit->state() != active) { if (rect.intersects(pix->rect(fruit->position(), FruitScorePix, fruit->pix()))) pix->draw(fruit->position(), Widget, FruitScorePix, fruit->pix()); } else { if (rect.intersects(pix->rect(fruit->position(), FruitPix, fruit->pix()))) pix->draw(fruit->position(), Widget, FruitPix, fruit->pix()); } for (Monster *m = monsters->first(); m != 0; m = monsters->next()) if (m && m->state() == harmless && rect.intersects(pix->rect(m->position(), MonsterPix)) && !(m->position() == pacman->position() && gameState.testBit(Scoring))) { if (m->body() != -1) pix->draw(m->position(), Widget, MonsterPix, m->body()); diff --git a/noncore/games/kpacman/score.cpp b/noncore/games/kpacman/score.cpp index e91771b..6878b81 100644 --- a/noncore/games/kpacman/score.cpp +++ b/noncore/games/kpacman/score.cpp @@ -1,125 +1,119 @@ #include "portable.h" #if defined( KDE2_PORT ) #include <score.h> #include <score.moc> #include <kaccel.h> #include <kapp.h> #include <kconfig.h> #include <kstddirs.h> #include <kmessagebox.h> #elif defined( QPE_PORT ) #include <qaccel.h> #include <qpe/config.h> #include "score.h" #endif #include <stdlib.h> #include <ctype.h> -#include <qpixmap.h> -#include <qstring.h> -#include <qdstream.h> -#include <qkeycode.h> #include <qtimer.h> -#include <qfileinfo.h> -#include "bitfont.h" Score::Score(QWidget *parent, const char *name, int Scheme, int Mode, Bitfont *font) : QWidget(parent, name) { setFocusPolicy(QWidget::StrongFocus); paused = FALSE; lastScore = -1; lastPlayer = -1; cursorBlinkTimer = 0; cursorBlinkMS = -1; cursor.x = -1; cursor.y = -1; cursor.on = FALSE; cursor.chr = QChar('?'); initKeys(); scheme = Scheme; mode = Mode; confScheme(); bitfont = font; highscoreFile.setName(locateHighscoreFilePath().filePath()); read(); for (int p = 0; p < maxPlayer; p++) { playerScore[p] = 0; playerName[p] = getenv("LOGNAME"); if (playerName[p].length() < minPlayerNameLength) playerName[p].setExpand(minPlayerNameLength-1, ' '); for (uint i = 0; i < playerName[p].length(); i++) if (playerName[p].at(i) < bitfont->firstChar() || playerName[p].at(i) > bitfont->lastChar()) playerName[p].at(i) = playerName[p].at(i).upper(); } } Score::~Score() { // write(); } void Score::paintEvent( QPaintEvent *e) { if (rect(1, 0, tr(" 1UP ")).intersects(e->rect())) { QPixmap pix; QColor fg = BLACK; if (cursor.on || paused || lastPlayer != 0) fg = WHITE; pix = bitfont->text(tr(" 1UP "), fg, BLACK); bitBlt(this, x(1), y(0), &pix); } if (rect(8, 0, tr(" HIGH SCORE ")).intersects(e->rect())) { QPixmap pix = bitfont->text(tr(" HIGH SCORE "), WHITE, BLACK); bitBlt(this, x(8), y(0), &pix); } if (maxPlayer > 1 && rect(21, 0, tr(" 2UP ")).intersects(e->rect())) { QPixmap pix; QColor fg = BLACK; if (cursor.on || paused || lastPlayer != 1) fg = WHITE; pix = bitfont->text(tr(" 2UP "), fg, BLACK); bitBlt(this, x(21), y(0), &pix); } QString s; s.sprintf("%6d0", playerScore[0]/10); if (rect(0, 1, s).intersects(e->rect())) { QPixmap pix = bitfont->text(s, WHITE, BLACK); bitBlt(this, x(0), y(1), &pix); } s.sprintf("%8d0", HighScore/10); if (rect(8, 1, s).intersects(e->rect())) { QPixmap pix = bitfont->text(s, WHITE, BLACK); bitBlt(this, x(8), y(1), &pix); } if (lastScore >= 0) { if (rect(1, 4*1.25, tr(" CONGRATULATIONS ")).intersects(e->rect())) { QPixmap pix = bitfont->text(tr(" CONGRATULATIONS "), YELLOW, BLACK); bitBlt(this, x(1), y(4*1.25), &pix); } if (rect(1, 6*1.25, tr(" YOU HAVE ARCHIEVED ")).intersects(e->rect())) { QPixmap pix = bitfont->text(tr(" YOU HAVE ARCHIEVED "), CYAN, BLACK); bitBlt(this, x(1), y(6*1.25), &pix); } if (rect(1, 7*1.25, tr(" A SCORE IN THE TOP 10. ")).intersects(e->rect())) { QPixmap pix = bitfont->text(tr(" A SCORE IN THE TOP 10. "), CYAN, BLACK); diff --git a/noncore/games/kpacman/status.cpp b/noncore/games/kpacman/status.cpp index 2a17c21..02ff63d 100644 --- a/noncore/games/kpacman/status.cpp +++ b/noncore/games/kpacman/status.cpp @@ -1,114 +1,112 @@ #include "portable.h" #if defined( KDE2_PORT ) #include <kapp.h> #include <klocale.h> #include <kstddirs.h> #include <status.h> #include <status.moc> #elif defined( QPE_PORT ) #include <qpe/qpeapplication.h> #include <qpe/config.h> #include "status.h" #endif -#include <qpixmap.h> #include <qbitmap.h> -#include <qstring.h> #include <qmsgbox.h> #include <qfileinfo.h> Status::Status( QWidget *parent, const char *name, int Scheme, int Mode ) : QWidget( parent, name ) { qWarning("Status::Status"); actualLifes = 0; actualLevel = 0; lifesPix = NULL; levelPix = NULL; scheme = Scheme; mode = Mode; level = 0; confScheme(); } QList<QPixmap> *Status::loadPixmap(QWidget *parent, QString pixmapName, QList<QPixmap> *pixmaps) { if (pixmaps == NULL) { pixmaps = new QList<QPixmap>; pixmaps->setAutoDelete(TRUE); } if (!pixmaps->isEmpty()) pixmaps->clear(); QPixmap PIXMAP(pixmapName); if (PIXMAP.isNull() || PIXMAP.mask() == NULL) { QString msg = tr("The pixmap could not be contructed.\n\n" "The file '@PIXMAPNAME@' does not exist,\n" "or is of an unknown format."); msg.replace(QRegExp("@PIXMAPNAME@"), pixmapName); QMessageBox::information(parent, tr("Initialization Error"), (const char *) msg); return 0; } int height = PIXMAP.height(); int width = (height == 0) ? 0 : PIXMAP.width()/(PIXMAP.width()/height); QBitmap BITMAP; QBitmap MASK; BITMAP = *PIXMAP.mask(); MASK.resize(width, height); for (int x = 0; x < PIXMAP.width()/width; x++) { QPixmap *pixmap = new QPixmap(width, height); pixmaps->append(pixmap); bitBlt(pixmap, 0, 0, &PIXMAP, x*width, 0, width, height, CopyROP, TRUE); bitBlt(&MASK, 0, 0, &BITMAP, x*width, 0, width, height, CopyROP, TRUE); pixmap->setMask(MASK); } return pixmaps; } void Status::paintEvent( QPaintEvent *) { for (int x = 0; x < actualLifes && !lifesPix->isEmpty(); x++) bitBlt(this, lifesPix->at(0)->width()+(lifesPix->at(0)->width()*x), (height()-lifesPix->at(0)->height())/2, lifesPix->at(0), 0, 0, lifesPix->at(0)->width(), lifesPix->at(0)->height()); for (int x = 0; x < actualLevel && !levelPix->isEmpty(); x++) { erase((width()-levelPix->at(x)->width()*2)-(levelPix->at(x)->width()*levelPos[x]), (height()-levelPix->at(x)->height())/2, levelPix->at(x)->width(), levelPix->at(x)->height()); bitBlt(this, (width()-levelPix->at(x)->width()*2)-(levelPix->at(x)->width()*levelPos[x]), (height()-levelPix->at(x)->height())/2, levelPix->at(x), 0, 0, levelPix->at(x)->width(), levelPix->at(x)->height()); } } void Status::initPixmaps() { if (lastLifesPixmapName != lifesPixmapName.at(level)) { lifesPix = loadPixmap(this, lifesPixmapName.at(level), lifesPix); lastLifesPixmapName = lifesPixmapName.at(level); } if (lastLevelPixmapName != levelPixmapName.at(level)) { levelPix = loadPixmap(this, levelPixmapName.at(level), levelPix); lastLevelPixmapName = levelPixmapName.at(level); } } QString Status::decodeHexOctString(QString s) { QString value; diff --git a/noncore/games/mindbreaker/mindbreaker.cpp b/noncore/games/mindbreaker/mindbreaker.cpp index e1f43d0..2b924c6 100644 --- a/noncore/games/mindbreaker/mindbreaker.cpp +++ b/noncore/games/mindbreaker/mindbreaker.cpp @@ -1,129 +1,125 @@ /********************************************************************** ** 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 <qtopia/config.h> #include <qtopia/qpeapplication.h> #include <qtoolbar.h> -#include <qpainter.h> -#include <qpixmap.h> #include <qtoolbutton.h> -#include <qpushbutton.h> #include <qmessagebox.h> -#include <qlabel.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; static int adjusted_first_peg_x_diff; static int adjusted_first_peg_y_diff; static int adjusted_peg_spacing; static int adjusted_answerpegx; static int adjusted_answerpegy; static int adjusted_answerpeg_xdiff; static int adjusted_answerpeg_ydiff; static int adjusted_board_height; static int adjusted_board_width; static void setupBoardSize(int w, int h) { adjusted_panel_width = w * 3/4; adjusted_title_width = w * 3/4; adjusted_title_height = h/10; adjusted_panel_height = (h-adjusted_title_height)/9; adjusted_bin_margin = w * 10/240; adjusted_peg_size = adjusted_panel_height*3/4; adjusted_answerpeg_size = QMIN(adjusted_panel_width*15/180,adjusted_panel_height*15/25); // looks a bit dodgy on larger sizes if ( adjusted_peg_size > 40 ) adjusted_peg_size = 40; adjusted_first_peg_x_diff = w * 31/240-adjusted_peg_size/2; adjusted_first_peg_y_diff = (adjusted_panel_height - adjusted_peg_size)/2; adjusted_peg_spacing = w * 30/240; // looks a bit dodgy on larger sizes (still does though, but not as much...) if ( adjusted_answerpeg_size > 22 ) adjusted_answerpeg_size = 22; adjusted_answerpegx = adjusted_panel_width * 159/180 - adjusted_answerpeg_size/2; adjusted_answerpegy = adjusted_panel_height/3 - adjusted_answerpeg_size/2; adjusted_answerpeg_xdiff = adjusted_panel_width * 10/180; adjusted_answerpeg_ydiff = adjusted_panel_height * 9/25; adjusted_board_height = adjusted_title_height + (adjusted_panel_height * 9); adjusted_board_width = adjusted_panel_width + (adjusted_bin_margin * 2) + adjusted_peg_size; // qDebug("Adjusted width %d height %d", adjusted_board_width, adjusted_board_height); } /* helper class, */ class Peg : public QCanvasRectangle { public: Peg(QCanvas *canvas, int type, int go = -1, int pos = -1); int rtti() const {return pegRTTI; } void advance(int phase); bool hit( const QPoint &) const; /* a placed peg is one that has been set down on the board correctly and should not be moved, only copied */ bool placed() const; void setPlaced(bool); int pegGo() const; int pegPos() const; void setPegPos(int); int type() const; static void buildImages(); static QImage imageForType(int t); static int eggLevel; protected: void drawShape(QPainter &); private: diff --git a/noncore/games/minesweep/main.cpp b/noncore/games/minesweep/main.cpp index bd70f7c..e187be5 100644 --- a/noncore/games/minesweep/main.cpp +++ b/noncore/games/minesweep/main.cpp @@ -1,27 +1,26 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 "minesweep.h" -#include <qpe/qpeapplication.h> #include <opie/oapplicationfactory.h> OPIE_EXPORT_APP( OApplicationFactory<MineSweep> ) diff --git a/noncore/games/minesweep/minefield.cpp b/noncore/games/minesweep/minefield.cpp index 1790110..72c05b0 100644 --- a/noncore/games/minesweep/minefield.cpp +++ b/noncore/games/minesweep/minefield.cpp @@ -1,124 +1,120 @@ /********************************************************************** ** 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 "minefield.h" #include <qtopia/config.h> #include <qtopia/qpeapplication.h> -#include <qpainter.h> -#include <qdrawutil.h> -#include <qpixmap.h> -#include <qimage.h> #include <qtimer.h> #include <stdlib.h> static const char *pix_flag[]={ "13 13 3 1", "# c #000000", "x c #ff0000", ". c None", ".............", ".............", ".....#xxxxxx.", ".....#xxxxxx.", ".....#xxxxxx.", ".....#xxxxxx.", ".....#.......", ".....#.......", ".....#.......", ".....#.......", "...#####.....", "..#######....", "............."}; static const char *pix_mine[]={ "13 13 3 1", "# c #000000", ". c None", "a c #ffffff", "......#......", "......#......", "..#.#####.#..", "...#######...", "..##aa#####..", "..##aa#####..", "#############", "..#########..", "..#########..", "...#######...", "..#.#####.#..", "......#......", "......#......"}; static const int maxGrid = 28; static const int minGrid = 12; class Mine : public Qt { public: enum MineState { Hidden = 0, Empty, Mined, Flagged, #ifdef MARK_UNSURE Unsure, #endif Exploded, Wrong }; Mine( MineField* ); void paint( QPainter * p, const QColorGroup & cg, const QRect & cr ); QSize sizeHint() const { return QSize( maxGrid, maxGrid ); } void activate( bool sure = TRUE ); void setHint( int ); void setState( MineState ); MineState state() const { return st; } bool isMined() const { return mined; } void setMined( bool m ) { mined = m; } static void paletteChange(); private: bool mined; int hint; MineState st; MineField *field; static QPixmap* knownField; static QPixmap* unknownField; static QPixmap* flag_pix; static QPixmap* mine_pix; }; QPixmap* Mine::knownField = 0; QPixmap* Mine::unknownField = 0; QPixmap* Mine::flag_pix = 0; QPixmap* Mine::mine_pix = 0; diff --git a/noncore/games/minesweep/minesweep.cpp b/noncore/games/minesweep/minesweep.cpp index d707dab..4a6a92c 100644 --- a/noncore/games/minesweep/minesweep.cpp +++ b/noncore/games/minesweep/minesweep.cpp @@ -1,133 +1,128 @@ /********************************************************************** ** 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 "minesweep.h" #include "minefield.h" #include <qtopia/qpeapplication.h> #include <qtopia/resource.h> #include <qtopia/config.h> #include <qtoolbar.h> #include <qmenubar.h> -#include <qpopupmenu.h> #include <qpushbutton.h> #include <qlcdnumber.h> -#include <qmessagebox.h> #include <qtimer.h> -#include <qpalette.h> -#include <qapplication.h> -#include <qlayout.h> #include <qlabel.h> #include <stdlib.h> #include <time.h> static const char *pix_new[]={ "20 20 3 1", " c None", "# c #00FF00", ". c #000000", " ", " ...... ", " ..######.. ", " .##########. ", " .############. ", " .##############. ", " .##############. ", " .################. ", " .################. ", " .################. ", " .################. ", " .################. ", " .################. ", " .##############. ", " .##############. ", " .############. ", " .##########. ", " ..######.. ", " ...... ", " "}; /* XPM */ static const char * happy_xpm[] = { "20 20 3 1", " c None", ". c #ffff3f ", "# c #000000", " ", " ###### ", " ##......## ", " #..........# ", " #............# ", " #..............# ", " #..............# ", " #....##....##....# ", " #....##....##....# ", " #................# ", " #................# ", " #................# ", " #...#........#...# ", " #.##........##.# ", " #...########...# ", " #...######...# ", " #..........# ", " ##......## ", " ###### ", " "}; /* XPM */ static const char * worried_xpm[] = { "20 20 3 1", " c None", ". c #ffff3f", "# c #000000", " ", " ###### ", " ##......## ", " #..........# ", " #............# ", " #..............# ", " #..............# ", " #....##....##....# ", " #....##....##....# ", " #................# ", " #................# ", " #................# ", " #................# ", " #....######....# ", " #..............# ", " #............# ", " #..........# ", " ##......## ", " ###### ", " "}; /* XPM */ static const char * dead_xpm[] = { "20 20 3 1", " c None", ". c #ffff3f", diff --git a/noncore/games/oyatzee/oyatzee.cpp b/noncore/games/oyatzee/oyatzee.cpp index 0bd22f6..86318db 100644 --- a/noncore/games/oyatzee/oyatzee.cpp +++ b/noncore/games/oyatzee/oyatzee.cpp @@ -1,108 +1,102 @@ #include "oyatzee.h" #include <qmessagebox.h> -#include <qapplication.h> -#include <qdir.h> -#include <qlabel.h> #include <qpushbutton.h> -#include <qtimer.h> -#include <qvbox.h> #include <qpainter.h> #include <qlayout.h> -#include <qpoint.h> #include <stdlib.h> OYatzee::OYatzee( QWidget *parent , const char *name, WFlags fl ) : QMainWindow( parent , name , fl ) { QWidget *thing = new QWidget( this ); setCentralWidget( thing ); setCaption( tr( "OYatzee" ) ); setPlayerNumber( 4 ); setRoundsNumber( 1 ); lastPlayerFinished = false; currentPlayer = 1; ps.append( new Player( "Carsten" ) ); ps.append( new Player( "Julia" ) ); ps.append( new Player( "Christine" ) ); ps.append( new Player( "Stephan" ) ); QVBoxLayout *vbox = new QVBoxLayout( thing ); sb = new Scoreboard( ps, thing , "sb" ); connect( sb->pb , SIGNAL( item( int ) ), this , SLOT( slotEndRound( int ) ) ); dw = new DiceWidget( thing , "dw" ); dw->setMaximumHeight( this->height()/4 ); connect( dw->rollButton, SIGNAL( clicked() ), this , SLOT( slotRollDices() ) ); vbox->addWidget( sb ); vbox->addWidget( dw ); } void OYatzee::slotEndRound( int item ) { qDebug( "Der User hat Nummer %d ausgewählt" , item ); /* * if the user clicked on Total, Bonus or Score and thus not on a * selectable item return and do nothing */ if ( item == 7 || item == 8 || item == 16 ) return; /* * check if the user can really click on that item */ if ( posibilities.find( item ) == posibilities.end() ) return; QValueListInt numbers; Dice *d = dw->diceList.first(); for ( ; d != 0 ; d = dw->diceList.next() ) { numbers.append( d->hasValue() ); } int points = 0; switch ( item ) { case Ones: points = getPoints( 1 , numbers ); break; case Twos: points = getPoints( 2 , numbers ); break; case Threes: points = getPoints( 3 , numbers ); break; case Fours: points = getPoints( 4 , numbers ); break; case Fives: points = getPoints( 5 , numbers ); break; case Sixes: points = getPoints( 6 , numbers ); break; case ThreeOfAKind: points = oakPoints; break; case FourOfAKind: points = oakPoints; break; case FullHouse: points = 25; break; case SStraight: points = 30; break; case LStraight: points = 40; break; case Yatzee: diff --git a/noncore/games/parashoot/base.cpp b/noncore/games/parashoot/base.cpp index cdf1dfa..5f3c79d 100644 --- a/noncore/games/parashoot/base.cpp +++ b/noncore/games/parashoot/base.cpp @@ -1,77 +1,75 @@ /********************************************************************** ** 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 "codes.h" #include "base.h" -#include "man.h" #include <qtopia/resource.h> -#include <qregexp.h> int damage; Base::Base(QCanvas* canvas) : QCanvasSprite(0, canvas), kaboom("landmine"), ohdear("crmble01") { basearray = new QCanvasPixmapArray(); QString b0 = Resource::findPixmap("parashoot/b0001"); b0.replace(QRegExp("0001"),"%1"); basearray->readPixmaps(b0, 4); setSequence(basearray); setFrame(0); move(2, canvas->height()-50); setZ(10); show(); damage = 0; } void Base::damageBase() { damage++; switch(damage) { case 1: setFrame(1); ohdear.play(); break; case 2: setFrame(2); ohdear.play(); break; case 3: setFrame(3); kaboom.play(); break; } show(); } bool Base::baseDestroyed() { return (damage >= 3); } Base::~Base() { } int Base::rtti() const { return base_rtti; } void Base::reposition(void) { move(2, canvas()->height()-50); } diff --git a/noncore/games/parashoot/cannon.cpp b/noncore/games/parashoot/cannon.cpp index 5671351..330d850 100644 --- a/noncore/games/parashoot/cannon.cpp +++ b/noncore/games/parashoot/cannon.cpp @@ -1,119 +1,118 @@ /********************************************************************** ** 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 <qtopia/resource.h> -#include <qregexp.h> #include "codes.h" #include "cannon.h" Cannon::Cannon(QCanvas* canvas) : QCanvasSprite(0, canvas) { shotsfired=0; index = 8; cannonx = 0; cannony = 0; cannonarray = new QCanvasPixmapArray(); QString c0 = Resource::findPixmap("parashoot/can0001"); c0.replace(QRegExp("0001"),"%1"); cannonarray->readPixmaps(c0,17); setSequence(cannonarray); setFrame(index); reposition(); movedir = NoDir; moveDelay = 0; setAnimated(TRUE); show(); } void Cannon::advance(int stage) { if ( stage == 1 && moveDelay-- == 0 ) { if (movedir == Left) { if (index > 0) { setFrame(index-1); index--; } } if (movedir == Right) { if (index < 16) { setFrame(index+1); index++; } } moveDelay = 0; } } void Cannon::pointCannon(Direction dir) { movedir = dir; moveDelay = 0; advance(1); moveDelay = 1; } void Cannon::setCoords() { switch(index) { case 0: cannonx = barrelxpos-29; cannony = barrelypos-8; break; case 1: cannonx = barrelxpos-27; cannony = barrelypos-8; break; case 2: cannonx = barrelxpos-25; cannony = barrelypos-6; break; case 3: cannonx = barrelxpos-23; cannony = barrelypos-4; break; case 4: cannonx = barrelxpos-21; cannony = barrelypos-2; break; case 5: cannonx = barrelxpos-19; cannony = barrelypos; break; case 6: cannonx = barrelxpos-15; cannony = barrelypos; break; case 7: cannonx = barrelxpos-10; cannony = barrelypos; break; case 8: cannonx = barrelxpos; cannony = barrelypos; break; case 9: cannonx = barrelxpos+2; cannony = barrelypos; break; case 10: cannonx = barrelxpos+6; cannony = barrelypos; break; case 11: cannonx = barrelxpos+8; cannony = barrelypos; break; case 12: cannonx = barrelxpos+12; cannony = barrelypos-2; break; case 13: cannonx = barrelxpos+18; cannony = barrelypos-4; break; case 14: cannonx = barrelxpos+22; cannony = barrelypos-6; break; case 15: cannonx = barrelxpos+26; cannony = barrelypos-8; break; case 16: cannonx = barrelxpos+28; cannony = barrelypos-8; break; } } double Cannon::shootAngle() { switch(index) { case 0: return 30.0; case 1: return 37.5; case 2: return 45.0; case 3: return 52.5; case 4: return 60.0; case 5: return 67.5; case 6: return 75.0; case 7: return 82.5; case 8: return 90.0; case 9: return 97.5; case 10: return 105.0; case 11: return 112.5; case 12: return 120.0; case 13: return 127.5; case 14: return 135.0; case 15: return 142.5; case 16: return 150.0; diff --git a/noncore/games/parashoot/helicopter.cpp b/noncore/games/parashoot/helicopter.cpp index 036b21e..7d91cd1 100644 --- a/noncore/games/parashoot/helicopter.cpp +++ b/noncore/games/parashoot/helicopter.cpp @@ -1,120 +1,119 @@ /********************************************************************** ** 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 "helicopter.h" #include "man.h" #include "codes.h" #include <qtopia/resource.h> -#include <qregexp.h> static QList<Helicopter> all; Helicopter::Helicopter(QCanvas* canvas) : QCanvasSprite(0, canvas), chikachika("aland01") { all.append(this); hits = 0; QCanvasPixmapArray* helicopterarray = new QCanvasPixmapArray(); QString h0 = Resource::findPixmap("parashoot/helicopter0001"); h0.replace(QRegExp("0001"),"%1"); helicopterarray->readPixmaps(h0,4 ); setSequence(helicopterarray); setAnimated(true); move(canvas->width(), 5); setVelocity(-2, 0); chikachika.playLoop(); show(); } Helicopter::~Helicopter() { all.remove(this); } int fr = 0; void Helicopter::advance(int phase) { QCanvasSprite::advance(phase); if (phase == 0) { if (frame() == 3) { delete this; return; } if (hits >= 2) { setFrame(3); } else { setFrame(fr%3); fr++; checkCollision(); } } } void Helicopter::checkCollision() { if (x() == 6) { setAnimated(false); //setVelocity(0, 0); dropman(); } if (x() < 0) done(); } void Helicopter::dropman() { (void)new Man(canvas(), 15, 25); (void)new Man(canvas(), 35, 25); takeOff(); } void Helicopter::done() { hits++; } void Helicopter::takeOff() { setVelocity(-1, 0); } int Helicopter::rtti() const { return helicopter_rtti; } void Helicopter::silenceAll() { for (Helicopter* h = all.first(); h; h = all.next()) h->chikachika.stop(); } void Helicopter::deleteAll() { Helicopter* h; while ((h = all.first())) delete h; } diff --git a/noncore/games/parashoot/interface.cpp b/noncore/games/parashoot/interface.cpp index 948b92c..5c9b0ef 100644 --- a/noncore/games/parashoot/interface.cpp +++ b/noncore/games/parashoot/interface.cpp @@ -1,126 +1,122 @@ /********************************************************************** ** 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 "interface.h" #include "man.h" #include <qtopia/qpeapplication.h> #include <qtopia/resource.h> -#include <qlabel.h> -#include <qmessagebox.h> -#include <qapplication.h> -#include <qstyle.h> #include <qtoolbar.h> #include <qtoolbutton.h> ParaShoot::ParaShoot(QWidget* parent, const char* name, WFlags f) : QMainWindow(parent,name,f), canvas( 232, 258 ), cannon(NULL), base(NULL), gamestopped( true ), waitover( false ), fanfare("level_up"), score(0) { QPEApplication::grabKeyboard(); QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff ); updatespeed = 80; canvas.setAdvancePeriod(80); pb = new QCanvasView(&canvas, this); pb->setFocus(); setToolBarsMovable( FALSE ); QToolBar* toolbar = new QToolBar(this); toolbar->setHorizontalStretchable( TRUE ); setCaption( tr("ParaShoot") ); new QToolButton( Resource::loadIconSet("new"), tr("New Game"), 0, this, SLOT(newGame()), toolbar, "New Game"); levelscore = new QLabel(toolbar); levelscore->setBackgroundMode( PaletteButton ); levelscore->setAlignment( AlignRight | AlignVCenter | ExpandTabs ); toolbar->setStretchableWidget( levelscore ); showScore(0,0); setCentralWidget(pb); autoDropTimer = new QTimer(this); connect (autoDropTimer, SIGNAL(timeout()), this, SLOT(play()) ); pauseTimer = new QTimer(this); connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) ); setFocusPolicy(StrongFocus); } void ParaShoot::resizeEvent(QResizeEvent *) { QSize s = centralWidget()->size(); int fw = style().defaultFrameWidth(); canvas.resize( s.width() - fw - 2, s.height() - fw - 2); QImage bgimage = Resource::loadImage("parashoot/sky"); QPixmap bgpixmap; bgpixmap.convertFromImage(bgimage.smoothScale(canvas.width(), canvas.height()), QPixmap::Auto); canvas.setBackgroundPixmap(bgpixmap); if (base) { base->reposition(); } if (cannon) { cannon->reposition(); } } void ParaShoot::focusOutEvent (QFocusEvent *) { if (!gamestopped) canvas.setAdvancePeriod(-1); } void ParaShoot::focusInEvent (QFocusEvent *) { if (!gamestopped) canvas.setAdvancePeriod(updatespeed); } void ParaShoot::showScore( int score, int level ) { levelscore->setText(tr(" Level: %1 Score: %2 ").arg(score).arg(level) ); } void ParaShoot::newGame() { clear(); if (pauseTimer->isActive()) pauseTimer->stop(); clear(); Man::setManCount(0); diff --git a/noncore/games/parashoot/main.cpp b/noncore/games/parashoot/main.cpp index ee36d26..40f809f 100644 --- a/noncore/games/parashoot/main.cpp +++ b/noncore/games/parashoot/main.cpp @@ -1,27 +1,26 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 "interface.h" -#include <qpe/qpeapplication.h> #include <opie/oapplicationfactory.h> OPIE_EXPORT_APP( OApplicationFactory<ParaShoot> ) diff --git a/noncore/games/parashoot/man.cpp b/noncore/games/parashoot/man.cpp index 94807c2..0a151b0 100644 --- a/noncore/games/parashoot/man.cpp +++ b/noncore/games/parashoot/man.cpp @@ -1,123 +1,122 @@ /********************************************************************** ** 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 "codes.h" #include "man.h" #include "base.h" #include <qtopia/resource.h> -#include <qregexp.h> int mancount; Man::Man(QCanvas* canvas) : QCanvasSprite(0, canvas), splat("lose") // No tr { manarray = new QCanvasPixmapArray(); QString m0 = Resource::findPixmap("parashoot/man0001"); m0.replace(QRegExp("0001"),"%1"); manarray->readPixmaps(m0, 7); setSequence(manarray); setAnimated(true); mancount++; dead = false; start(); } Man::Man(QCanvas* canvas, int x, int y) : QCanvasSprite(0, canvas), splat("bang") // No tr { manarray = new QCanvasPixmapArray(); QString m0 = Resource::findPixmap("parashoot/man0001"); m0.replace(QString("0001"),"%1"); manarray->readPixmaps(m0, 7); setSequence(manarray); move(x, y); setFrame(5); setZ(300); show(); static bool first_time = TRUE; if (first_time) { first_time = FALSE; QTime midnight(0, 0, 0); srand(midnight.secsTo(QTime::currentTime()) ); } int yfallspeed = 0; yfallspeed = (rand() % 3) + 1; setVelocity(0, yfallspeed); mancount++; dead = false; } int f = 0; void Man::advance(int phase) { QCanvasSprite::advance(phase); if (phase == 0) { checkCollision(); if (dead) { if (count < 10) { setFrame(6); setVelocity(0,0); count++; } else { delete this; return; } } if (y() > canvas()->height()-43) { setFrame(f%5); f++; move(x(), canvas()->height()-26); setVelocity(-2, 0); } else if (xVelocity() == -2) { // // There's been a resize event while this Man has // been on the ground. Move the man back to the // new ground location. This is not neat. // move(x(), canvas()->height()-26); } } } void Man::setInitialCoords() { static bool first_time = TRUE; if (first_time) { first_time = FALSE; QTime midnight(0, 0, 0); srand(midnight.secsTo(QTime::currentTime()) ); } dx = rand() % (canvas()->width()-16); dy = -43; //height of a man off the screen } //check if man has reached the base void Man::checkCollision() { if ( (x() < 23) && (y() == canvas()->height()-26)) { QCanvasItem* item; QCanvasItemList l=collisions(FALSE); diff --git a/noncore/games/qasteroids/main.cpp b/noncore/games/qasteroids/main.cpp index c762990..18a13eb 100644 --- a/noncore/games/qasteroids/main.cpp +++ b/noncore/games/qasteroids/main.cpp @@ -1,27 +1,26 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 "toplevel.h" -#include <qpe/qpeapplication.h> #include <opie/oapplicationfactory.h> OPIE_EXPORT_APP( OApplicationFactory<KAstTopLevel> ) diff --git a/noncore/games/qasteroids/toplevel.cpp b/noncore/games/qasteroids/toplevel.cpp index c4fea89..9053d3d 100644 --- a/noncore/games/qasteroids/toplevel.cpp +++ b/noncore/games/qasteroids/toplevel.cpp @@ -1,132 +1,130 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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. ** **********************************************************************//* * KAsteroids - Copyright (c) Martin R. Jones 1997 * * Part of the KDE project */ // --- toplevel.cpp --- #include "toplevel.h" #include "ledmeter.h" #include <qpe/qpeapplication.h> #include <qpe/resource.h> -#include <qaccel.h> #include <qlabel.h> #include <qlayout.h> #include <qlcdnumber.h> -#include <qpushbutton.h> #include <sys/utsname.h> #define SB_SCORE 1 #define SB_LEVEL 2 #define SB_SHIPS 3 struct SLevel { int nrocks; double rockSpeed; }; #define MAX_LEVELS 16 SLevel levels[MAX_LEVELS] = { { 1, 0.4 }, { 1, 0.6 }, { 2, 0.5 }, { 2, 0.7 }, { 2, 0.8 }, { 3, 0.6 }, { 3, 0.7 }, { 3, 0.8 }, { 4, 0.6 }, { 4, 0.7 }, { 4, 0.8 }, { 5, 0.7 }, { 5, 0.8 }, { 5, 0.9 }, { 5, 1.0 } }; const char *soundEvents[] = { "ShipDestroyed", "RockDestroyed", 0 }; const char *soundDefaults[] = { "Explosion.wav", "ploop.wav", 0 }; KAstTopLevel::KAstTopLevel( QWidget *parent, const char *_name, WFlags fl ) : QMainWindow( parent, _name, fl ) { setCaption( tr("Asteroids") ); QPEApplication::grabKeyboard(); QWidget *border = new QWidget( this ); border->setBackgroundColor( black ); setCentralWidget( border ); QVBoxLayout *borderLayout = new QVBoxLayout( border ); QWidget *mainWin = new QWidget( border ); borderLayout->addWidget( mainWin, 2, AlignHCenter ); view = new KAsteroidsView( mainWin ); connect( view, SIGNAL( shipKilled() ), SLOT( slotShipKilled() ) ); connect( view, SIGNAL( rockHit(int) ), SLOT( slotRockHit(int) ) ); connect( view, SIGNAL( rocksRemoved() ), SLOT( slotRocksRemoved() ) ); connect( view, SIGNAL( updateVitals() ), SLOT( slotUpdateVitals() ) ); QVBoxLayout *vb = new QVBoxLayout( mainWin ); QHBoxLayout *hb = new QHBoxLayout; QHBoxLayout *hbd = new QHBoxLayout; vb->addLayout( hb ); QFont labelFont( "helvetica", 12 ); QColorGroup grp( darkGreen, black, QColor( 128, 128, 128 ), QColor( 64, 64, 64 ), black, darkGreen, black ); QPalette pal( grp, grp, grp ); mainWin->setPalette( pal ); QLabel *label; label = new QLabel( tr("Score"), mainWin ); label->setFont( labelFont ); label->setPalette( pal ); // label->setFixedWidth( label->sizeHint().width() ); hb->addWidget( label ); scoreLCD = new QLCDNumber( 5, mainWin ); scoreLCD->setFrameStyle( QFrame::NoFrame ); scoreLCD->setSegmentStyle( QLCDNumber::Flat ); scoreLCD->setFixedHeight( 16 ); scoreLCD->setPalette( pal ); diff --git a/noncore/games/qasteroids/view.cpp b/noncore/games/qasteroids/view.cpp index 448a54a..352c63b 100644 --- a/noncore/games/qasteroids/view.cpp +++ b/noncore/games/qasteroids/view.cpp @@ -1,127 +1,124 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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. ** **********************************************************************//* * KAsteroids - Copyright (c) Martin R. Jones 1997 * * Part of the KDE project */ #include "view.h" #include <qpe/resource.h> -#include <qapplication.h> -#include <qkeycode.h> -#include <qaccel.h> #include <stdlib.h> #include <math.h> #define IMG_BACKGROUND "qasteroids/bg.png" #define REFRESH_DELAY 33 #define SHIP_SPEED 0.3 #define MISSILE_SPEED 10.0 #define SHIP_STEPS 64 #define ROTATE_RATE 2 #define SHIELD_ON_COST 1 #define SHIELD_HIT_COST 30 #define BRAKE_ON_COST 4 #define MAX_ROCK_SPEED 2.5 #define MAX_POWERUP_SPEED 1.5 #define MAX_SHIP_SPEED 8 #define MAX_BRAKES 5 #define MAX_SHIELDS 5 #define MAX_FIREPOWER 5 #define TEXT_SPEED 4 #define PI_X_2 6.283185307 #ifndef M_PI #define M_PI 3.141592654 #endif struct { int id; const char *path; int frames; } kas_animations [] = { // { ID_ROCK_LARGE, "rock1/rock1\%1.png", 32 }, { ID_ROCK_MEDIUM, "rock2/rock2\%1.png", 32 }, { ID_ROCK_SMALL, "rock3/rock3\%1.png", 32 }, { ID_SHIP, "ship/ship\%1.png", 32 }, { ID_MISSILE, "missile/missile.png", 0 }, { ID_BIT, "bits/bits\%1.png", 16 }, { ID_EXHAUST, "exhaust/exhaust.png", 0 }, { ID_ENERGY_POWERUP, "powerups/energy.png", 0 }, // { ID_TELEPORT_POWERUP, "powerups/teleport%1.png", 12 }, { ID_BRAKE_POWERUP, "powerups/brake.png", 0 }, { ID_SHIELD_POWERUP, "powerups/shield.png", 0 }, { ID_SHOOT_POWERUP, "powerups/shoot.png", 0 }, { ID_SHIELD, "shield/shield\%1.png", 6 }, { 0, 0, 0 } }; KAsteroidsView::KAsteroidsView( QWidget *parent, const char *name ) : QWidget( parent, name ), field(200, 200), view(&field,this) { view.setVScrollBarMode( QScrollView::AlwaysOff ); view.setHScrollBarMode( QScrollView::AlwaysOff ); rocks.setAutoDelete( TRUE ); missiles.setAutoDelete( TRUE ); bits.setAutoDelete( TRUE ); powerups.setAutoDelete( TRUE ); exhaust.setAutoDelete( TRUE ); QPixmap pm( Resource::loadPixmap(IMG_BACKGROUND) ); field.setBackgroundPixmap( pm ); textSprite = new QCanvasText( &field ); QFont font( "helvetica", 14 ); textSprite->setFont( font ); shield = 0; shieldOn = FALSE; refreshRate = REFRESH_DELAY; readSprites(); shieldTimer = new QTimer( this ); connect( shieldTimer, SIGNAL(timeout()), this, SLOT(hideShield()) ); mTimerId = -1; shipPower = MAX_POWER_LEVEL; vitalsChanged = TRUE; can_destroy_powerups = FALSE; mPaused = TRUE; } // - - - KAsteroidsView::~KAsteroidsView() { diff --git a/noncore/games/sfcave/helpwindow.cpp b/noncore/games/sfcave/helpwindow.cpp index 544e237..8a5d034 100644 --- a/noncore/games/sfcave/helpwindow.cpp +++ b/noncore/games/sfcave/helpwindow.cpp @@ -1,81 +1,79 @@ /*************************************************************************** helpwindow.cpp - description ------------------- begin : Sun Sep 8 2002 copyright : (C) 2002 by Andy Qua email : andy.qua@blueyonder.co.uk ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ -#include <qwidget.h> #include <qlayout.h> -#include <qstring.h> #include <qtextview.h> #include <qpe/qpeapplication.h> #include "helpwindow.h" #define HELP_TEXT \ "<qt><h1>SFCave Help</h1><p> " \ "SFCave is a flying game for the Zaurus.<br><br> " \ "The aim is to stay alive for as long as possible and get the highest score " \ "you can.<br><br>" \ "There are three game types currently - SFCave, Gates, and Fly.<br>" \ "<b>SFCave</b> is a remake of the classic SFCave game - fly through the " \ "cavern avoiding all the blocks that just happen to be hanging in " \ "midair<br><br>" \ "<b>Gates</b> is similar to SFCave but instead you must fly through the " \ "without crashing.<br><br>" \ "<b>Fly</b> is somewhat different to SFCave and above. Instead, you have " \ "are flying in the open air above a scrolling landscape, and the aim is to " \ "hug the ground - the closer to the land you fly the more points " \ "scored.<br><br><br>" \ "Basic instruction - Press <b>Up</B> or <b>Down</b> on the circle pad to " \ "start a new game, press the middle of the pad to apply thrust (makes you " \ "go up), and release the pad to remove thrust and drop down.<br><br>" \ "Also, if playing the Fly game, you can press z to toggle the display " \ "of the scoring zones. This will display 4 red lines at varying heights " \ "above the landscape - if your ship falls into this zone, point are scored. " \ "The closer to the landscape you get the more points you get.<br><br>" \ "In addition, SFCave has replays - save and load too so you can show off to all " \ "your friends (or vice versa). Currently, this is in its infancy but will improve.<br>" \ "To use, once you have crashed, press 'r' to replay the last game.<br>" \ "To save the replay press 's'.<br>" \ "To load a saved replay press 'l' (after you've crashed at least once).<br><br>" \ "Replays are currently saved to your home directory in a file called sfcave.replay." \ "This file can be copied and given to others as long as it it put in their home directory.<br><br>" \ "Have lots of fun.<br>" \ "Andy" \ "</p></qt>" HelpWindow::HelpWindow( QWidget *parent, const char *name, bool modal, WFlags flags ) : QDialog( parent, name, modal, flags ) { // resize( 230, 280 ); setCaption( "Help for SFCave" ); QVBoxLayout *layout = new QVBoxLayout( this ); QString text = HELP_TEXT;; QTextView *view = new QTextView( text, 0, this, "view" ); layout->insertSpacing( -1, 5 ); layout->insertWidget( -1, view ); layout->insertSpacing( -1, 5 ); QPEApplication::showDialog( this ); } HelpWindow::~HelpWindow() { } diff --git a/noncore/games/snake/interface.cpp b/noncore/games/snake/interface.cpp index 2c60693..b5fb5bf 100644 --- a/noncore/games/snake/interface.cpp +++ b/noncore/games/snake/interface.cpp @@ -1,126 +1,122 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 "interface.h" #include <qpe/resource.h> -#include <qpe/qpeapplication.h> #include <qpe/qpetoolbar.h> #include <qtoolbutton.h> -#include <qstyle.h> -#include <qapplication.h> -#include <qmessagebox.h> SnakeGame::SnakeGame(QWidget* parent, const char* name, WFlags f) : QMainWindow(parent,name,f), canvas(232, 258) { setCaption( tr("Snake") ); QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff ); QPixmap bg = Resource::loadPixmap("snake/grass"); canvas.setBackgroundPixmap(bg); canvas.setUpdatePeriod(100); snake = 0; cv = new QCanvasView(&canvas, this); pauseTimer = new QTimer(this); connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) ); setToolBarsMovable( FALSE ); QToolBar* toolbar = new QToolBar( this); toolbar->setHorizontalStretchable( TRUE ); QPixmap newicon = Resource::loadPixmap("ksnake"); setIcon(newicon); (void)new QToolButton(newicon, tr("New Game"), 0, this, SLOT(newGame()), toolbar, "New Game"); scorelabel = new QLabel(toolbar); showScore(0); scorelabel->setBackgroundMode( PaletteButton ); scorelabel->setAlignment( AlignRight | AlignVCenter | ExpandTabs ); toolbar->setStretchableWidget( scorelabel ); setFocusPolicy(StrongFocus); setCentralWidget(cv); QTimer::singleShot( 16, this, SLOT(welcomescreen()) ); gamestopped = true; waitover = true; } SnakeGame::~SnakeGame() { delete snake; } void SnakeGame::resizeEvent(QResizeEvent *) { QSize s = centralWidget()->size(); int fw = style().defaultFrameWidth(); canvas.resize( s.width() - fw - 2, s.height() - fw - 2); } void SnakeGame::welcomescreen() { QCanvasText* title = new QCanvasText(tr("SNAKE!"), &canvas); title->setColor(yellow); title->setFont( QFont("times", 18, QFont::Bold) ); int w = title->boundingRect().width(); title->move(canvas.width()/2 -w/2, canvas.height()/2-110); title->show(); QCanvasPixmapArray* titlearray = new QCanvasPixmapArray(Resource::findPixmap("snake/title")); QCanvasSprite* titlepic = new QCanvasSprite(titlearray, &canvas); titlepic->move(canvas.width()/2 - 33, canvas.height()/2-85); titlepic->show(); QCanvasText* instr = new QCanvasText(tr("Use the arrow keys to guide the\n" "snake to eat the mouse. You must not\n" "crash into the walls, edges or its tail."), &canvas); w = instr->boundingRect().width(); instr->move(canvas.width()/2-w/2, canvas.height()/2-20); instr->setColor(white); instr->show(); QCanvasText* cont = new QCanvasText(tr("Press any key to start"), &canvas); w = cont->boundingRect().width(); cont->move(canvas.width()/2-w/2, canvas.height()-20); cont->setColor(yellow); cont->show(); } void SnakeGame::newGame() { clear(); snake = new Snake(&canvas); connect(snake, SIGNAL(dead()), this, SLOT(gameOver()) ); connect(snake, SIGNAL(targethit()), this, SLOT(levelUp()) ); connect(snake, SIGNAL(scorechanged()), this, SLOT(scoreInc()) ); connect(this, SIGNAL(moveFaster()), snake, SLOT(increaseSpeed()) ); last = 0; targetamount = 1; notargets = 1; level = 1; stage = 1; showScore(0); diff --git a/noncore/games/snake/main.cpp b/noncore/games/snake/main.cpp index 77a2769..9a9b167 100644 --- a/noncore/games/snake/main.cpp +++ b/noncore/games/snake/main.cpp @@ -1,29 +1,28 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 "interface.h" -#include <qpe/qpeapplication.h> #include <opie/oapplicationfactory.h> OPIE_EXPORT_APP( OApplicationFactory<SnakeGame> ) diff --git a/noncore/games/snake/snake.cpp b/noncore/games/snake/snake.cpp index 9f19841..8a683ab 100644 --- a/noncore/games/snake/snake.cpp +++ b/noncore/games/snake/snake.cpp @@ -1,123 +1,121 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 "snake.h" #include "target.h" -#include "codes.h" #include <qpe/resource.h> -#include <qregexp.h> static int Piecekey[4][4] = { {6, 0, 4, 3 }, {0, 6, 2, 1 }, { 1, 3, 5, 0 }, {2, 4, 0, 5 } }; Snake::Snake(QCanvas* c) { canvas = c; score = 0; snakelist.setAutoDelete(true); autoMoveTimer = new QTimer(this); connect( autoMoveTimer, SIGNAL(timeout()), this, SLOT(moveSnake()) ); createSnake(); } void Snake::createSnake() { snakeparts = new QCanvasPixmapArray(); QString s0 = Resource::findPixmap("snake/s0001"); s0.replace(QRegExp("0001"),"%1"); snakeparts->readPixmaps(s0, 15); grow = 0; last = Key_Right; QCanvasSprite* head = new QCanvasSprite(snakeparts, canvas ); head->setFrame(7); snakelist.insert(0, head); head->show(); head->move(34, 16); QCanvasSprite* body = new QCanvasSprite(snakeparts, canvas ); body->setFrame(6); snakelist.append( body ); body->show(); body->move(18, 16); QCanvasSprite* end = new QCanvasSprite(snakeparts, canvas ); end->setFrame(11); snakelist.append( end ); end->show(); end->move(2, 16); currentdir = right; speed = 250; autoMoveTimer->start(speed); moveSnake(); } void Snake::increaseSpeed() { if (speed > 150) speed = speed - 5; autoMoveTimer->start(speed); } void Snake::go(int newkey) { // check key is a direction if (!( (newkey == Key_Up) || (newkey == Key_Left) || (newkey == Key_Right) || (newkey == Key_Down) )) return; // check move is possible if ( ((currentdir == left) && ((newkey == Key_Right) || (newkey == Key_Left)) ) || ((currentdir == right) && ((newkey == Key_Left) || (newkey == Key_Right)) ) || ((currentdir == up) && ((newkey == Key_Down) || (newkey == Key_Up)) ) || ((currentdir == down) && ((newkey == Key_Up) || (newkey == Key_Down)) ) ) return; else { Snake::changeHead(newkey); Snake::moveSnake(); } } void Snake::move(Direction dir) { autoMoveTimer->start(speed); int x = 0; int y = 0; newdir = dir; switch (dir) { case right: x = 16; break; case left: x = -16; break; case down: y = 16; break; case up: y = -16; break; } int index = lookUpPiece(currentdir, newdir); QCanvasSprite* sprite = new QCanvasSprite(snakeparts, canvas ); sprite->setFrame(index); snakelist.insert(1, sprite); sprite->move(snakelist.first()->x(), snakelist.first()->y() ); snakelist.first()->moveBy(x, y); if (grow <= 0) changeTail(); else grow--; sprite->show(); diff --git a/noncore/games/solitaire/canvascard.cpp b/noncore/games/solitaire/canvascard.cpp index 7c4a5ba..c36da6c 100644 --- a/noncore/games/solitaire/canvascard.cpp +++ b/noncore/games/solitaire/canvascard.cpp @@ -1,125 +1,120 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 "cardgame.h" #include "canvascard.h" #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 // 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) { #ifdef QT_NO_TRANSFORMATIONS int w = srcBitmap->width(); int h = srcBitmap->height(); QBitmap *dstBitmap = new QBitmap( w, h ); // ### this is very poorly implemented and probably could be much faster for (int i = 0; i < w; i++) for (int j = 0; j < h; j++) bitBlt( dstBitmap, i, j, srcBitmap, w - i - 1, h - j - 1, 1, 1 ); return dstBitmap; #else QWMatrix m; m.rotate( 180.0 ); return new QBitmap( srcBitmap->xForm( m ) ); #endif } QPixmap *CreateScaledPixmap(QPixmap *srcPixmap, double scaleX, double scaleY) { #ifdef QT_NO_TRANSFORMATIONS int w = srcPixmap->width(); int h = srcPixmap->height(); int newW = (int)(w * scaleX); int newH = (int)(h * scaleY); QPixmap *dstPixmap = new QPixmap( newW, newH ); // ### this is very poorly implemented and probably could be much faster for (int i = 0; i < newW; i++) { int srcX = w * i / newW; if (newH == h) { // Optimise for scaleing in the X-axis only bitBlt( dstPixmap, i, 0, srcPixmap, srcX, 0, 1, h ); } else { for (int j = 0; j < newH; j++) { int srcY = h * j / newH; bitBlt( dstPixmap, i, j, srcPixmap, srcX, srcY, 1, 1 ); } } } return dstPixmap; #else QWMatrix s; s.scale( scaleX, scaleY ); return new QPixmap( srcPixmap->xForm( s ) ); #endif } // 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" ) ); } 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() ); setPen( NoPen ); flipping = FALSE; } diff --git a/noncore/games/solitaire/canvascardgame.cpp b/noncore/games/solitaire/canvascardgame.cpp index 9ae2a23..ed5748e 100644 --- a/noncore/games/solitaire/canvascardgame.cpp +++ b/noncore/games/solitaire/canvascardgame.cpp @@ -1,127 +1,119 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 "cardgame.h" -#include "canvasshapes.h" -#include "canvascard.h" #include "canvascardgame.h" -#include <qpe/resource.h> -#include <qpe/config.h> -#include <qmainwindow.h> -#include <qmenubar.h> -#include <qpainter.h> #include <qgfx_qws.h> #include <stdlib.h> #include <limits.h> #include <time.h> #include <math.h> extern int highestZ; class CanvasCardPile : public QCanvasRectangle { public: CanvasCardPile( CanvasCardGame *ccg, QCanvas *canvas ) : QCanvasRectangle( canvas ), parent( ccg ) { pile = new QPixmap( 0, 0 ); pileHeight = 0; firstCard = NULL; } void addCard( CanvasCard *card ); void advance(int stage); void animatedMove() { animatedMove(savedX, savedY); } void savePos(void) { savedX = (int)x(); savedY = (int)y(); } void animatedMove(int x2, int y2, int steps = 7 ); protected: virtual void draw( QPainter& p ); private: CanvasCardGame *parent; QPixmap *pile; QImage tempImage32; CanvasCard *firstCard; int pileHeight; int destX, destY; int savedX, savedY; int animSteps; }; void CanvasCardPile::addCard( CanvasCard *card ) { int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13; int cardHeight = ( qt_screen->deviceWidth() < 200 ) ? 27 : 36; int cardWidth = ( qt_screen->deviceWidth() < 200 ) ? 20 : 23; if ( !firstCard ) firstCard = card; int height = cardHeight + pileHeight * offsetDown; setSize( cardWidth, height ); pile->resize( cardWidth, height ); QPainter p( pile ); p.translate( -card->x(), -card->y() + pileHeight * offsetDown ); card->draw( p ); pileHeight++; QImage tempImage; tempImage = *pile; tempImage32 = tempImage.convertDepth( 32 ); tempImage32.setAlphaBuffer( TRUE ); for ( int i = 0; i < tempImage32.width(); i++ ) for ( int j = 0; j < tempImage32.height(); j++ ) { QRgb col = tempImage32.pixel( i, j ); int a = 255-j*220/tempImage32.height(); QRgb alpha = qRgba( qRed( col ), qGreen( col ), qBlue( col ), a ); tempImage32.setPixel( i, j, alpha ); } QRgb alpha = qRgba( 0, 0, 0, 0 ); tempImage32.setPixel( 1, 0, alpha ); tempImage32.setPixel( 0, 0, alpha ); tempImage32.setPixel( 0, 1, alpha ); tempImage32.setPixel( cardWidth - 2, 0, alpha ); tempImage32.setPixel( cardWidth - 1, 0, alpha ); tempImage32.setPixel( cardWidth - 1, 1, alpha ); height--; tempImage32.setPixel( 1, height, alpha ); tempImage32.setPixel( 0, height - 1, alpha ); tempImage32.setPixel( 0, height, alpha ); tempImage32.setPixel( cardWidth - 2, height, alpha ); tempImage32.setPixel( cardWidth - 1, height, alpha ); tempImage32.setPixel( cardWidth - 1, height - 1, alpha ); } void CanvasCardPile::advance(int stage) { if ( stage==1 ) { if ( animSteps-- <= 0 ) { CanvasCard *item = firstCard; while (item) { item->show(); diff --git a/noncore/games/solitaire/canvascardwindow.cpp b/noncore/games/solitaire/canvascardwindow.cpp index c12344a..503bc92 100644 --- a/noncore/games/solitaire/canvascardwindow.cpp +++ b/noncore/games/solitaire/canvascardwindow.cpp @@ -1,128 +1,123 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 "canvascardwindow.h" -#include "patiencecardgame.h" #include "freecellcardgame.h" #include "chicanecardgame.h" #include "harpcardgame.h" #include "teeclubcardgame.h" -#include <qpe/resource.h> -#include <qmainwindow.h> -#include <qpopupmenu.h> -#include <qstyle.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" ) ); 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 ); 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); file->insertItem(tr("Chicane"), this, SLOT(initChicane()), CTRL+Key_F); file->insertItem(tr("Harp"), this, SLOT(initHarp()), CTRL+Key_F); file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub()), CTRL+Key_F); menu->insertItem(tr("&Game"), file); menu->insertSeparator(); settings = new QPopupMenu; settings->insertItem(tr("&Change card backs"), this, SLOT(changeCardBacks()), Key_F2); snap_id = settings->insertItem(tr("&Snap to position"), this, SLOT(snapToggle()), Key_F3); settings->setCheckable(TRUE); menu->insertItem(tr("&Settings"),settings); menu->insertSeparator(); QPopupMenu* help = new QPopupMenu; help->insertItem(tr("&About"), this, SLOT(help()), Key_F1); help->setItemChecked(dbf_id, TRUE); menu->insertItem(tr("&Help"),help); #else QMenuBar* menu = menuBar(); QPopupMenu* file = new QPopupMenu; file->insertItem(tr("Patience"), this, SLOT(initPatience())); file->insertItem(tr("Freecell"), this, SLOT(initFreecell())); file->insertItem(tr("Chicane"), this, SLOT(initChicane())); file->insertItem(tr("Harp"), this, SLOT(initHarp())); file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub())); menu->insertItem(tr("Play"), file); menu->insertSeparator(); settings = new QPopupMenu; settings->setCheckable(TRUE); 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", FALSE); if ( gameType == 0 ) { 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 ); diff --git a/noncore/games/solitaire/canvasshapes.cpp b/noncore/games/solitaire/canvasshapes.cpp index 6ccd4a4..011958d 100644 --- a/noncore/games/solitaire/canvasshapes.cpp +++ b/noncore/games/solitaire/canvasshapes.cpp @@ -1,114 +1,112 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 <qpainter.h> -#include <qcanvas.h> #include <qgfx_qws.h> #include "canvasshapes.h" CanvasRoundRect::CanvasRoundRect(int x, int y, QCanvas *canvas) : QCanvasRectangle( x, y, ( qt_screen->deviceWidth() < 200 ) ? 20 : 23, ( qt_screen->deviceWidth() < 200 ) ? 27 : 36, canvas) { setZ(0); show(); } void CanvasRoundRect::redraw() { hide(); show(); } void CanvasRoundRect::drawShape(QPainter &p) { 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) { show(); } void CanvasCircleOrCross::redraw() { hide(); show(); } void CanvasCircleOrCross::setCircle() { circleShape = TRUE; redraw(); } void CanvasCircleOrCross::setCross() { circleShape = FALSE; redraw(); } void CanvasCircleOrCross::drawShape(QPainter &p) { 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 { 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/card.cpp b/noncore/games/solitaire/card.cpp index 609e280..52e38ac 100644 --- a/noncore/games/solitaire/card.cpp +++ b/noncore/games/solitaire/card.cpp @@ -1,53 +1,50 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 "card.h" -#include <qpe/config.h> -#include <qpoint.h> -#include <qlist.h> /* Card( eValue v, eSuit s, bool f ) : val(v), suit(s), faceUp(f), showing(FALSE), ix(0), iy(0), iz(0), cardPile(NULL) { } virtual ~Card() { } eValue getValue() { return val; } eSuit getSuit() { return suit; } CardPile *getCardPile() { return cardPile; } bool isFacing() { return faceUp; } bool isShowing() { return showing; } bool isRed() { return ((suit == diamonds) || (suit == hearts)); } int getX(void) { return ix; } int getY(void) { return iy; } int getZ(void) { return iz; } void setCardPile(CardPile *p) { cardPile = p; } void setFace(bool f) { faceUp = f; } void flip(void) { flipTo(getX(), getY()); } virtual void setPos(int x, int y, int z) { ix = x; iy = y; iz = z; } virtual void move(int x, int y) { ix = x; iy = y; } virtual void move(QPoint p) { ix = p.x(); iy = p.y(); } virtual void flipTo(int x, int y, int steps = 8) { ix = x; iy = y; faceUp = !faceUp; redraw(); Q_UNUSED(steps); } virtual void showCard(void) { showing = TRUE; } virtual void hideCard(void) { showing = FALSE; } virtual void redraw(void) { } */ diff --git a/noncore/games/solitaire/cardpile.cpp b/noncore/games/solitaire/cardpile.cpp index aace2e2..1d572be 100644 --- a/noncore/games/solitaire/cardpile.cpp +++ b/noncore/games/solitaire/cardpile.cpp @@ -1,115 +1,113 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 "cardpile.h" #include "card.h" #include <qpe/config.h> -#include <qpoint.h> -#include <qlist.h> CardPile::CardPile(int x, int y) : pileX(x), pileY(y), dealing(FALSE), PileResize(FALSE) { pileWidth = 0; pileHeight = 0; pileNextX = pileX; pileNextY = pileY; pileCenterX = x + pileWidth / 2; pileCenterY = y + pileHeight / 2; pileRadius = (pileWidth > pileHeight) ? pileWidth : pileHeight; pileOffsetDown = 13; } int CardPile::distanceFromPile(int x, int y) { return (pileCenterX-x)*(pileCenterX-x)+(pileCenterY-y)*(pileCenterY-y); } int CardPile::distanceFromNextPos(int x, int y) { return (pileNextX-x)*(pileNextX-x)+(pileNextY-y)*(pileNextY-y); } Card *CardPile::cardInfront(Card *c) { CardPile *p = c->getCardPile(); if (p) { p->at(p->find(c)); return p->next(); } else { return NULL; } } bool CardPile::kingOnTop() { Card *top = cardOnTop(); return top && top->getValue() == king; } bool CardPile::addCardToTop(Card *c) { if (dealing || isAllowedOnTop(c)) { append((const Card *)c); cardAddedToTop(c); return TRUE; } return FALSE; } bool CardPile::addCardToBottom(Card *c) { if (dealing || isAllowedOnBottom(c)) { prepend((const Card *)c); cardAddedToBottom(c); return TRUE; } return FALSE; } bool CardPile::removeCard(Card *c) { if (dealing || isAllowedToBeMoved(c)) { take(find(c)); cardRemoved(c); return TRUE; } return FALSE; } void CardPile::writeConfig( Config& cfg, QString name ) { int numberOfCards = 0; cfg.setGroup( name ); Card *card = cardOnBottom(); while ( card ) { QString cardStr; cardStr.sprintf( "%i", numberOfCards ); int val = (int)card->getValue()-1 + ((int)card->getSuit()-1)*13 + (int)card->getDeckNumber()*52; cfg.writeEntry( "Card" + cardStr, val ); cfg.writeEntry( "CardFacing" + cardStr, card->isFacing() ); card = cardInfront( card ); numberOfCards++; } cfg.writeEntry("NumberOfCards", numberOfCards); } diff --git a/noncore/games/solitaire/chicanecardgame.cpp b/noncore/games/solitaire/chicanecardgame.cpp index 6729a94..6c607b9 100644 --- a/noncore/games/solitaire/chicanecardgame.cpp +++ b/noncore/games/solitaire/chicanecardgame.cpp @@ -1,125 +1,124 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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. ** ** ** created on base of patiencecardgame by cam (C.A.Mader) 2002 ** Rules for this game: ** use 2 decks = 104 cards ** deal 8 rows with 3 hidden cards and one open card ** append red to black and vice versa ** each card can be layed on a free place ** deal 8 cards at once ** **********************************************************************/ -#include <qgfx_qws.h> #include "chicanecardgame.h" extern int highestZ; ChicaneCardGame::ChicaneCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent, 2) // Use 2 Decks { highestZ = 0; for (int i = 0; i < 8; i++) { discardPiles[i] = new ChicaneDiscardPile( 27 + i * 26, 10, canvas() ); addCardPile(discardPiles[i]); } for (int i = 0; i < 8; i++) { workingPiles[i] = new ChicaneWorkingPile( 27 + i * 26, 50, canvas() ); addCardPile(workingPiles[i]); } faceDownDealingPile = new ChicaneFaceDownDeck( 2, 10, canvas() ); } void ChicaneCardGame::deal(void) { highestZ = 1; int t = 0; beginDealing(); for (int i = 0; i < 8; i++) { for (int k = 0; k < 4; k++, t++) { Card *card = cards[t]; workingPiles[i]->addCardToTop(card); card->setCardPile( workingPiles[i] ); card->setPos( 0, 0, highestZ ); card->setFace(k==3); card->move( workingPiles[i]->getCardPos( card ) ); card->showCard(); highestZ++; } } for ( ; t < getNumberOfCards(); t++) { Card *card = cards[t]; faceDownDealingPile->addCardToTop(card); card->setCardPile( faceDownDealingPile ); QPoint p = faceDownDealingPile->getCardPos( card ); card->setPos( p.x(), p.y(), highestZ ); card->showCard(); highestZ++; } endDealing(); } void ChicaneCardGame::readConfig( Config& cfg ) { cfg.setGroup("GameState"); // Create Cards, but don't shuffle or deal them yet createDeck(); // Move the cards to their piles (deal them to their previous places) beginDealing(); highestZ = 1; for (int i = 0; i < 8; i++) { QString pile; pile.sprintf( "ChicaneDiscardPile%i", i ); readPile( cfg, discardPiles[i], pile, highestZ ); } for (int i = 0; i < 8; i++) { QString pile; pile.sprintf( "ChicaneWorkingPile%i", i ); readPile( cfg, workingPiles[i], pile, highestZ ); } readPile( cfg, faceDownDealingPile, "ChicaneFaceDownDealingPile", highestZ ); highestZ++; endDealing(); } void ChicaneCardGame::writeConfig( Config& cfg ) { cfg.setGroup("GameState"); for ( int i = 0; i < 8; i++ ) { QString pile; pile.sprintf( "ChicaneDiscardPile%i", i ); discardPiles[i]->writeConfig( cfg, pile ); } diff --git a/noncore/games/solitaire/freecellcardgame.cpp b/noncore/games/solitaire/freecellcardgame.cpp index aeb32fc..d474f4e 100644 --- a/noncore/games/solitaire/freecellcardgame.cpp +++ b/noncore/games/solitaire/freecellcardgame.cpp @@ -1,116 +1,115 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 <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( xOrigin + i * spaceBetweenPiles, 10, canvas() ); addCardPile(freecellPiles[i]); } for (int i = 0; i < 4; i++) { 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( xOrigin + spacing + 2 + i * spaceBetweenPiles, 50, canvas() ); addCardPile(workingPiles[i]); } } void FreecellCardGame::deal(void) { highestZ = 1; beginDealing(); for (int i = 0; i < 52; i++) { Card *card = cards[i]; card->setFace( TRUE ); card->setPos( 0, 0, highestZ ); card->setCardPile( workingPiles[i%8] ); workingPiles[i%8]->addCardToTop( card ); card->move( workingPiles[i%8]->getCardPos( card ) ); card->showCard(); highestZ++; } endDealing(); } // checks if smaller card with different color, that could be put on top on the // card, is present in working or freecell pile bool FreecellCardGame::checkNeeded(Card *card) { if (card->getValue() > 2){ int i; Card *c; for (i=0;i<4;i++){ c = freecellPiles[i]->cardOnBottom(); if (c != NULL){ if (card->isRed()!= c->isRed() && card->getValue()== c->getValue()+1){ return (false); } } } for (i=0;i<8;i++){ c=workingPiles[i]->cardOnBottom(); while (c!=NULL){ if (card->isRed() != c->isRed() && card->getValue() == c->getValue()+1) { return (false); } c=workingPiles[i]->cardInfront(c); } } } return(true); } // added to move cards, on which no card can be moved, to discard pile void FreecellCardGame::checkUnusable() { int i,j; // printf("void FreecellCardGame::checkUnusable()\n"); Card *top_one; for (i=0;i < 8;i++) { top_one = workingPiles[i]->cardOnTop(); if (top_one != NULL) { j = 0; while ((j < 4)) { if (discardPiles[j]->isAllowedOnTop(top_one)){ if (checkNeeded(top_one)){ top_one->setCardPile(discardPiles[j]); diff --git a/noncore/games/solitaire/harpcardgame.cpp b/noncore/games/solitaire/harpcardgame.cpp index 0711622..d13d73b 100644 --- a/noncore/games/solitaire/harpcardgame.cpp +++ b/noncore/games/solitaire/harpcardgame.cpp @@ -1,127 +1,126 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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. ** ** ** created on base of patiencecardgame by cam (C.A.Mader) 2002 ** Rules for this game: ** use 2 decks = 104 cards ** deal 8 rows with one open card in the first place ** one hidden and one open in the second place and so on ** append red to black and vice versa ** each card can be layed on a free place ** deal 8 cards at once ** ** **********************************************************************/ -#include <qgfx_qws.h> #include "harpcardgame.h" extern int highestZ; HarpCardGame::HarpCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent, 2) // Use 2 Decks { highestZ = 0; for (int i = 0; i < 8; i++) { discardPiles[i] = new HarpDiscardPile( 27 + i * 26, 10, canvas() ); addCardPile(discardPiles[i]); } for (int i = 0; i < 8; i++) { workingPiles[i] = new HarpWorkingPile( 27 + i * 26, 50, canvas() ); addCardPile(workingPiles[i]); } faceDownDealingPile = new HarpFaceDownDeck( 2, 10, canvas() ); } void HarpCardGame::deal(void) { highestZ = 1; int t = 0; beginDealing(); for (int i = 0; i < 8; i++) { for (int k = 0; k < i+1; k++, t++) { Card *card = cards[t]; workingPiles[i]->addCardToTop(card); card->setCardPile( workingPiles[i] ); card->setPos( 0, 0, highestZ ); card->setFace(k==i); card->move( workingPiles[i]->getCardPos( card ) ); card->showCard(); highestZ++; } } for ( ; t < getNumberOfCards(); t++) { Card *card = cards[t]; faceDownDealingPile->addCardToTop(card); card->setCardPile( faceDownDealingPile ); QPoint p = faceDownDealingPile->getCardPos( card ); card->setPos( p.x(), p.y(), highestZ ); card->showCard(); highestZ++; } endDealing(); } void HarpCardGame::readConfig( Config& cfg ) { cfg.setGroup("GameState"); // Create Cards, but don't shuffle or deal them yet createDeck(); // Move the cards to their piles (deal them to their previous places) beginDealing(); highestZ = 1; for (int i = 0; i < 8; i++) { QString pile; pile.sprintf( "HarpDiscardPile%i", i ); readPile( cfg, discardPiles[i], pile, highestZ ); } for (int i = 0; i < 8; i++) { QString pile; pile.sprintf( "HarpWorkingPile%i", i ); readPile( cfg, workingPiles[i], pile, highestZ ); } readPile( cfg, faceDownDealingPile, "HarpFaceDownDealingPile", highestZ ); highestZ++; endDealing(); } void HarpCardGame::writeConfig( Config& cfg ) { cfg.setGroup("GameState"); for ( int i = 0; i < 8; i++ ) { QString pile; pile.sprintf( "HarpDiscardPile%i", i ); discardPiles[i]->writeConfig( cfg, pile ); } diff --git a/noncore/games/solitaire/main.cpp b/noncore/games/solitaire/main.cpp index bd3cf8b..9301171 100644 --- a/noncore/games/solitaire/main.cpp +++ b/noncore/games/solitaire/main.cpp @@ -1,26 +1,25 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 "canvascardwindow.h" -#include <qpe/qpeapplication.h> #include <opie/oapplicationfactory.h> OPIE_EXPORT_APP( OApplicationFactory<CanvasCardWindow> )
\ No newline at end of file diff --git a/noncore/games/solitaire/patiencecardgame.cpp b/noncore/games/solitaire/patiencecardgame.cpp index 96a599c..756577a 100644 --- a/noncore/games/solitaire/patiencecardgame.cpp +++ b/noncore/games/solitaire/patiencecardgame.cpp @@ -1,116 +1,115 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 <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; 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( 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() ); } } PatienceCardGame::~PatienceCardGame() { delete circleCross; delete rectangle; delete faceDownDealingPile; delete faceUpDealingPile; } void PatienceCardGame::deal(void) { highestZ = 1; int t = 0; beginDealing(); for (int i = 0; i < 7; i++) { cards[t]->setFace(TRUE); for (int k = i; k < 7; k++, t++) { Card *card = cards[t]; workingPiles[k]->addCardToTop(card); card->setCardPile( workingPiles[k] ); QPoint p = workingPiles[k]->getCardPos( card ); card->setPos( p.x(), p.y(), highestZ ); card->showCard(); highestZ++; } } for ( ; t < 52; t++) { Card *card = cards[t]; faceDownDealingPile->addCardToTop(card); card->setCardPile( faceDownDealingPile ); QPoint p = faceDownDealingPile->getCardPos( card ); card->setPos( p.x(), p.y(), highestZ ); card->showCard(); highestZ++; } endDealing(); } diff --git a/noncore/games/solitaire/teeclubcardgame.cpp b/noncore/games/solitaire/teeclubcardgame.cpp index 0941e0d..b1af757 100644 --- a/noncore/games/solitaire/teeclubcardgame.cpp +++ b/noncore/games/solitaire/teeclubcardgame.cpp @@ -1,127 +1,126 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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. ** ** ** created on base of patiencecardgame by cam (C.A.Mader) 2002 ** Rules for this game: ** use 2 decks = 104 cards ** deal 9 rows with 5 open cards each ** append one card to each other card which is one step higher ** move only columns of cards which are equal in suit ** each card can be layed on a free place ** deal 1 card at once on the first pile ** ** **********************************************************************/ -#include <qgfx_qws.h> #include "teeclubcardgame.h" extern int highestZ; TeeclubCardGame::TeeclubCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent, 2) // Use 2 Decks { highestZ = 0; for (int i = 0; i < 8; i++) { discardPiles[i] = new TeeclubDiscardPile( 27 + i * 26, 10, canvas() ); addCardPile(discardPiles[i]); } for (int i = 0; i < 9; i++) { workingPiles[i] = new TeeclubWorkingPile( 2 + i * 26, 50, canvas() ); addCardPile(workingPiles[i]); } faceDownDealingPile = new TeeclubFaceDownDeck( 2, 10, canvas() ); } void TeeclubCardGame::deal(void) { highestZ = 1; int t = 0; beginDealing(); for (int i = 0; i < 9; i++) { workingPiles[i]->setOffsetDown(13); workingPiles[i]->beginPileResize(); for (int k = 0; k < 5; k++, t++) { Card *card = cards[t]; workingPiles[i]->addCardToTop(card); card->setCardPile( workingPiles[i] ); card->setPos( 0, 0, highestZ ); card->setFace(TRUE); card->move( workingPiles[i]->getCardPos( card ) ); card->showCard(); highestZ++; } } for ( ; t < getNumberOfCards(); t++) { Card *card = cards[t]; faceDownDealingPile->addCardToTop(card); card->setCardPile( faceDownDealingPile ); QPoint p = faceDownDealingPile->getCardPos( card ); card->setPos( p.x(), p.y(), highestZ ); card->showCard(); highestZ++; } endDealing(); } void TeeclubCardGame::resizePiles() { beginDealing(); for (int i = 0; i < 9; i++) { while ((workingPiles[i]->getCardPos(NULL).y() > 230) && (workingPiles[i]->getOffsetDown()>1)) { // resize the pile workingPiles[i]->setOffsetDown(workingPiles[i]->getOffsetDown()-1); Card *card = workingPiles[i]->cardOnBottom(); int p=0; while (card != NULL) { card->setPos( 0, 0, p++ ); card->move( workingPiles[i]->getCardPos( card ) ); card = workingPiles[i]->cardInfront(card); } } } endDealing(); } void TeeclubCardGame::readConfig( Config& cfg ) { cfg.setGroup("GameState"); // Create Cards, but don't shuffle or deal them yet createDeck(); // Move the cards to their piles (deal them to their previous places) beginDealing(); highestZ = 1; for (int i = 0; i < 8; i++) { QString pile; pile.sprintf( "TeeclubDiscardPile%i", i ); readPile( cfg, discardPiles[i], pile, highestZ ); } diff --git a/noncore/games/tetrix/main.cpp b/noncore/games/tetrix/main.cpp index fcf4b33..bf1242f 100644 --- a/noncore/games/tetrix/main.cpp +++ b/noncore/games/tetrix/main.cpp @@ -1,28 +1,27 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 "qtetrix.h" -#include <qpe/qpeapplication.h> #include <opie/oapplicationfactory.h> OPIE_EXPORT_APP( OApplicationFactory<QTetrix> ) diff --git a/noncore/games/tetrix/ohighscoredlg.cpp b/noncore/games/tetrix/ohighscoredlg.cpp index 7581f51..8d8079e 100644 --- a/noncore/games/tetrix/ohighscoredlg.cpp +++ b/noncore/games/tetrix/ohighscoredlg.cpp @@ -1,116 +1,115 @@ /*************************************************************************** begin : January 2003 copyright : ( C ) 2003 by Carsten Niehaus email : cniehaus@handhelds.org **************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * ( at your option ) any later version. * * * **************************************************************************/ #include <qdialog.h> -#include <qpe/config.h> #include <qlayout.h> -#include <qpe/config.h> #include <qpe/qpeapplication.h> +#include <qpe/config.h> #include <qstring.h> #include <qhbox.h> #include <qvbox.h> #include <qlabel.h> #include <qlistview.h> #include <qlineedit.h> #include "ohighscoredlg.h" OHighscore::OHighscore( int score , int playerLevel ) { pLevel = playerLevel; getList(); checkIfItIsANewhighscore( score ); } OHighscore::~OHighscore() { std::list<t_playerData*>::iterator deleteIterator = playerData.begin(); for ( ; deleteIterator != playerData.end() ; deleteIterator++ ) { delete ( *deleteIterator ); } } void OHighscore::getList() { Config cfg ( "tetrix" ); cfg.setGroup( QString::number( 1 ) ); lowest = cfg.readNumEntry( "Points" ); playerData.clear(); int rest = 1; //for the filling up later for ( int i = 1 ; i < 11 ; i++ ) { if ( cfg.hasGroup( QString::number( i ) ) ) { cfg.setGroup( QString::number( i ) ); int temp = cfg.readNumEntry( "Points" ); t_playerData *pPlayerData = new t_playerData; pPlayerData->sName = cfg.readEntry( "Name" ); pPlayerData->points = temp; pPlayerData->level = cfg.readNumEntry( "Level" ); playerData.push_back( pPlayerData ); if ( (temp < lowest) ) lowest = temp; rest++; } } //now I fill up the rest of the list if ( rest < 11 ) //only go in this loop if there are less than //10 highscoreentries { lowest = 0; for ( ; rest < 11 ; rest++ ) { t_playerData *pPlayerData = new t_playerData; pPlayerData->sName = tr( "empty"); pPlayerData->points = 0; pPlayerData->level = 0; playerData.push_back( pPlayerData ); } } } void OHighscore::checkIfItIsANewhighscore( int points) { if ( points > lowest ) isNewhighscore = true; else isNewhighscore = false; } void OHighscore::insertData( QString name , int punkte , int playerLevel ) { Config cfg ( "tetrix" ); int entryNumber = 1; std::list<t_playerData*>::iterator insertIterator = playerData.begin(); while ( insertIterator != playerData.end() ) { if ( punkte > ( *insertIterator )->points ) { t_playerData* temp = new t_playerData; temp->sName = name; temp->points = punkte; temp->level = playerLevel; playerData.insert( insertIterator , temp ); //now we have to delete the last entry diff --git a/noncore/games/tetrix/qtetrix.cpp b/noncore/games/tetrix/qtetrix.cpp index 6d29c3f..20cf1a7 100644 --- a/noncore/games/tetrix/qtetrix.cpp +++ b/noncore/games/tetrix/qtetrix.cpp @@ -1,127 +1,124 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 "qtetrix.h" #include <qpe/resource.h> -#include <qpe/config.h> -#include <qapplication.h> #include <qlabel.h> #include <qdatetime.h> #include <qlayout.h> -#include <qstring.h> #include "ohighscoredlg.h" void drawTetrixButton( QPainter *p, int x, int y, int w, int h, const QColor *color ) { QColor fc; if ( color ) { QPointArray a; a.setPoints( 3, x,y+h-1, x,y, x+w-1,y ); p->setPen( color->light() ); p->drawPolyline( a ); a.setPoints( 3, x+1,y+h-1, x+w-1,y+h-1, x+w-1,y+1 ); p->setPen( color->dark() ); p->drawPolyline( a ); x++; y++; w -= 2; h -= 2; fc = *color; } else fc = p->backgroundColor(); p->fillRect( x, y, w, h, fc ); } ShowNextPiece::ShowNextPiece( QWidget *parent, const char *name ) : QFrame( parent, name ) { setFrameStyle( QFrame::Panel | QFrame::Sunken ); xOffset = -1; // -1 until first resizeEvent. } void ShowNextPiece::resizeEvent( QResizeEvent *e ) { QSize sz = e->size(); blockWidth = (sz.width() - 3)/5; blockHeight = (sz.height() - 3)/6; xOffset = (sz.width() - 3)/5; yOffset = (sz.height() - 3)/6; } void ShowNextPiece::paintEvent( QPaintEvent * ) { QPainter p( this ); drawFrame( &p ); p.end(); // explicit end() so any slots can paint too emit update(); } void ShowNextPiece::drawNextSquare(int x, int y,QColor *color) { if (xOffset == -1) // Before first resizeEvent? return; QPainter paint; paint.begin(this); drawTetrixButton( &paint, xOffset+x*blockWidth, yOffset+y*blockHeight, blockWidth, blockHeight, color ); paint.end(); } QTetrix::QTetrix( QWidget *parent, const char *name, WFlags f ) : QMainWindow( parent, name, f ) { setIcon( Resource::loadPixmap( "tetrix_icon" ) ); setCaption( tr("Tetrix" ) ); QTime t = QTime::currentTime(); TetrixPiece::setRandomSeed( (((double)t.hour())+t.minute()+t.second())/ (24+60+60) ); QWidget *gameArea = new QWidget( this ); setCentralWidget( gameArea ); QGridLayout *gl = new QGridLayout( gameArea, 5, 3, 8 ); QLabel *l; l = new QLabel( tr("Next"), gameArea ); gl->addWidget( l, 0, 0 ); showNext = new ShowNextPiece(gameArea); showNext->setBackgroundColor(QColor(0,0,0)); gl->addWidget( showNext, 0, 1 ); l = new QLabel( tr("Score"), gameArea ); gl->addWidget( l, 1, 0 ); showScore = new QLabel(gameArea); gl->addWidget( showScore, 1, 1 ); l = new QLabel( tr("Level"), gameArea ); gl->addWidget( l, 2, 0 ); showLevel = new QLabel(gameArea); diff --git a/noncore/games/tetrix/qtetrixb.cpp b/noncore/games/tetrix/qtetrixb.cpp index 521f171..3c179df 100644 --- a/noncore/games/tetrix/qtetrixb.cpp +++ b/noncore/games/tetrix/qtetrixb.cpp @@ -1,122 +1,120 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 "qtetrixb.h" #include "qtetrix.h" #include <qtimer.h> -#include <qkeycode.h> -#include <qpainter.h> const int waitAfterLineTime = 500; QTetrixBoard::QTetrixBoard( QWidget *p, const char *name ) : QFrame( p, name ) { setFrameStyle( QFrame::Panel | QFrame::Sunken ); paint = 0; timer = new QTimer(this); connect( timer, SIGNAL(timeout()), SLOT(timeout()) ); colors[0].setRgb(200,100,100); colors[1].setRgb(100,200,100); colors[2].setRgb(100,100,200); colors[3].setRgb(200,200,100); colors[4].setRgb(200,100,200); colors[5].setRgb(100,200,200); colors[6].setRgb(218,170, 0); xOffset = -1; // -1 until a resizeEvent is received. blockWidth = 20; yOffset = 30; blockHeight = 20; noGame = TRUE; isPaused = FALSE; waitingAfterLine = FALSE; updateTimeoutTime(); // Sets timeoutTime } void QTetrixBoard::startGame(int gameType,int fillRandomLines) { if ( isPaused ) return; // ignore if game is paused noGame = FALSE; GenericTetrix::startGame( gameType, fillRandomLines ); // Note that the timer is started by updateLevel! } void QTetrixBoard::pause() { if ( noGame ) // game not active return; isPaused = !isPaused; if ( isPaused ) { timer->stop(); hideBoard(); } else timer->start(timeoutTime); update(); } void QTetrixBoard::drawSquare(int x,int y,int value) { if (xOffset == -1) // Before first resizeEvent? return; const int X = xOffset + x*blockWidth; const int Y = yOffset + (y - 1)*blockHeight; bool localPainter = paint == 0; QPainter *p; if ( localPainter ) p = new QPainter( this ); else p = paint; drawTetrixButton( p, X, Y, blockWidth, blockHeight, value == 0 ? 0 : &colors[value-1] ); /* if ( value != 0 ) { QColor tc, bc; tc = colors[value-1].light(); bc = colors[value-1].dark(); p->drawShadePanel( X, Y, blockWidth, blockHeight, tc, bc, 1, colors[value-1], TRUE ); } else p->fillRect( X, Y, blockWidth, blockHeight, backgroundColor() ); */ if ( localPainter ) delete p; } void QTetrixBoard::drawNextSquare( int x, int y, int value ) { if ( value == 0 ) emit drawNextSquareSignal (x, y, 0 ); else emit drawNextSquareSignal( x, y, &colors[value-1] ); } void QTetrixBoard::updateRemoved( int noOfLines ) { if ( noOfLines > 0 ) { diff --git a/noncore/games/tictac/main.cpp b/noncore/games/tictac/main.cpp index cfff683..9aafe4c 100644 --- a/noncore/games/tictac/main.cpp +++ b/noncore/games/tictac/main.cpp @@ -1,13 +1,12 @@ /**************************************************************************** ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. ** ** This file is part of an example program for Qt. This example ** program may be used, distributed and modified without limitation. ** *****************************************************************************/ -#include <qpe/qpeapplication.h> #include <opie/oapplicationfactory.h> #include "tictac.h" OPIE_EXPORT_APP( OApplicationFactory<TicTacToe> ) diff --git a/noncore/games/tictac/tictac.cpp b/noncore/games/tictac/tictac.cpp index 9de3b58..12ce35f 100644 --- a/noncore/games/tictac/tictac.cpp +++ b/noncore/games/tictac/tictac.cpp @@ -1,117 +1,113 @@ /**************************************************************************** ** tictac.cpp,v 1.3.8.1 2003/08/29 06:50:40 harlekin Exp ** ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. ** ** This file is part of an example program for Qt. This example ** program may be used, distributed and modified without limitation. ** *****************************************************************************/ #include "tictac.h" #include <qpe/qpeapplication.h> -#include <qpainter.h> #include <qdrawutil.h> #include <qcombobox.h> -#include <qcheckbox.h> #include <qlabel.h> #include <qlayout.h> #include <stdlib.h> // rand() function -#include <qdatetime.h> // seed for rand() -#include <qstringlist.h> //needed for proper internationalization //*************************************************************************** //* TicTacButton member functions //*************************************************************************** // -------------------------------------------------------------------------- // Creates a TicTacButton // TicTacButton::TicTacButton( QWidget *parent ) : QPushButton( parent ) { t = Blank; // initial type } // -------------------------------------------------------------------------- // Paints TicTacButton // void TicTacButton::drawButtonLabel( QPainter *p ) { QRect r = rect(); p->setPen( QPen( white,2 ) ); // set fat pen if ( t == Circle ) { p->drawEllipse( r.left()+4, r.top()+4, r.width()-8, r.height()-8 ); } else if ( t == Cross ) { // draw cross p->drawLine( r.topLeft() +QPoint(4,4), r.bottomRight()-QPoint(4,4)); p->drawLine( r.bottomLeft()+QPoint(4,-4),r.topRight() -QPoint(4,-4)); } } //*************************************************************************** //* TicTacGameBoard member functions //*************************************************************************** // -------------------------------------------------------------------------- // Creates a game board with N x N buttons and connects the "clicked()" // signal of all buttons to the "buttonClicked()" slot. // TicTacGameBoard::TicTacGameBoard( int n, QWidget *parent, const char *name ) : QWidget( parent, name ) { QPEApplication::showWidget( this ); st = Init; // initial state nBoard = n; n *= n; // make square comp_starts = FALSE; // human starts buttons = new TicTacButtons(n); // create real buttons btArray = new TicTacArray(n); // create button model QGridLayout * grid = new QGridLayout( this, 3, 3, 4 ); QPalette p( blue ); for ( int i=0; i<n; i++ ) { // create and connect buttons TicTacButton *ttb = new TicTacButton( this ); ttb->setPalette( p ); ttb->setEnabled( FALSE ); connect( ttb, SIGNAL(clicked()), SLOT(buttonClicked()) ); grid->addWidget( ttb, i%3, i/3 ); buttons->insert( i, ttb ); btArray->at(i) = TicTacButton::Blank; // initial button type } QTime t = QTime::currentTime(); // set random seed srand( t.hour()*12+t.minute()*60+t.second()*60 ); } TicTacGameBoard::~TicTacGameBoard() { delete buttons; delete btArray; } // -------------------------------------------------------------------------- // TicTacGameBoard::computerStarts( bool v ) // // Computer starts if v=TRUE. The human starts by default. // void TicTacGameBoard::computerStarts( bool v ) { comp_starts = v; } // -------------------------------------------------------------------------- // TicTacGameBoard::newGame() // // Clears the game board and prepares for a new game // void TicTacGameBoard::newGame() { st = HumansTurn; for ( int i=0; i<nBoard*nBoard; i++ ) btArray->at(i) = TicTacButton::Blank; diff --git a/noncore/games/wordgame/main.cpp b/noncore/games/wordgame/main.cpp index f32acff..eb3e2f2 100644 --- a/noncore/games/wordgame/main.cpp +++ b/noncore/games/wordgame/main.cpp @@ -1,28 +1,27 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 "wordgame.h" -#include <qpe/qpeapplication.h> #include <opie/oapplicationfactory.h> OPIE_EXPORT_APP( OApplicationFactory<WordGame> ) diff --git a/noncore/games/wordgame/wordgame.cpp b/noncore/games/wordgame/wordgame.cpp index c01551d..43a54f8 100644 --- a/noncore/games/wordgame/wordgame.cpp +++ b/noncore/games/wordgame/wordgame.cpp @@ -1,145 +1,136 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of 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 "wordgame.h" -#include <qpe/applnk.h> #include <qpe/global.h> -#include <qpe/filemanager.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qapplication.h> #include <qmessagebox.h> #include <qcombobox.h> -#include <qdatetime.h> -#include <qfileinfo.h> -#include <qfile.h> #include <qdir.h> -#include <qiconset.h> -#include <qlabel.h> #include <qlineedit.h> #include <qpushbutton.h> #include <qtextstream.h> #include <qtimer.h> #include <qpe/qpetoolbar.h> #include <qtoolbutton.h> #include <qvbox.h> #include <qwidgetstack.h> -#include <qpainter.h> #include <qlayout.h> -#include <qregexp.h> #include <stdlib.h> #include <unistd.h> #include <pwd.h> #include <sys/types.h> 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" "030000000000030\n" "002002000200200\n" "000300020003000\n" "000020000020000\n" "102001000100201\n" "000000202000000\n" "400200050002004\n" "000000202000000\n" "102001000100201\n" "000020000020000\n" "000300020003000\n" "002002000200200\n" "030000000000030\n" "400001040100004\n" "1 2 3 66 67 194 100 0\n" "1 j 8\n" "1 q 7\n" "1 x 6\n" "1 z 6\n" "1 w 4\n" "1 k 4\n" "1 v 3\n" "1 f 3\n" "2 y 3\n" "2 h 2\n" "2 b 2\n" "2 m 2\n" "3 p 2\n" "3 g 2\n" "3 u 2\n" "4 d 2\n" "4 c 2\n" "5 l 1\n" "5 o 1\n" "7 t 1\n" "7 n 1\n" "7 a 1\n" "7 r 1\n" "8 s 1\n" "8 i 1\n" "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/WordGame.png" ) ); setCaption( tr("Word Game") ); setToolBarsMovable( FALSE ); vbox = new QVBox(this); setCentralWidget(vbox); toolbar = new QToolBar(this); addToolBar(toolbar, Bottom); reset = new QToolButton(Resource::loadPixmap("back"), tr("Back"), "", this, SLOT(resetTurn()), toolbar); done = new QToolButton(Resource::loadPixmap("done"), tr("Done"), "", this, SLOT(endTurn()), toolbar); scoreinfo = new ScoreInfo(toolbar); scoreinfo->setFont(QFont("Helvetica",10)); new QToolButton(Resource::loadPixmap("finish"), tr("Close"), "", this, SLOT(endGame()), toolbar); toolbar->setStretchableWidget(scoreinfo); diff --git a/noncore/games/zlines/ballpainter.cpp b/noncore/games/zlines/ballpainter.cpp index c2b34e1..622ec29 100644 --- a/noncore/games/zlines/ballpainter.cpp +++ b/noncore/games/zlines/ballpainter.cpp @@ -1,124 +1,121 @@ /*************************************************************************** ballpainter.cpp - description ------------------- begin : Fri May 19 2000 copyright : (C) 2000 by Roman Merzlyakov email : roman@sbrf.barrt.ru copyright : (C) 2000 by Roman Razilov email : Roman.Razilov@gmx.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include <qpe/resource.h> -#include <qapplication.h> #include "ballpainter.h" //#include "shotcounter.h" #include <qpainter.h> -#include "linesboard.h" //#include <qcolor.h> -#include <qjpegio.h> #define PIXSIZE 21 int colorLinesArr[NCOLORS] = {0x0000ff, 0x00ff00, 0xff0000, 0x00ffff, 0xff00ff, 0xffff00, 0x005080}; // 0x00bbggrr // red , green , blue , yellow , violet , cyan , brown BallPainter::BallPainter() : QObject() { createPixmap(); } BallPainter::~BallPainter() { } QPixmap* BallPainter::pixmap( enum Pixmaps pix ) { QString name; switch(pix) { case Field: name = QString::fromLatin1("zlines/field"); break; case Balls: name = QString::fromLatin1("zlines/balls"); break; case Fire: name = QString::fromLatin1("zlines/fire"); break; } return new QPixmap(Resource::loadPixmap(name) ); } void BallPainter::createPixmap() { // warning( kapp->kde_datadir() +"/klines/data/balls.bmp"); backgroundPix = pixmap(Field); QPixmap *balls = pixmap(Balls); QPixmap *fire = pixmap(Fire); if (balls->isNull() ||backgroundPix->isNull() || fire->isNull() ) fatal("Cannot open data files.\nHave you correctly installed klines?"); warning("Pixsize %i", PIXSIZE); for(int c=0; c<NCOLORS; c++) { for(int t=0; t<PIXTIME + FIREBALLS + BOOMBALLS + 1 ; t++) { imgCash[c][t] = new QPixmap(CELLSIZE, CELLSIZE); QPainter p(imgCash[c][t]); p.drawPixmap(0,0,(*backgroundPix),0,0,CELLSIZE,CELLSIZE); p.drawPixmap(1,1,(*balls),t*PIXSIZE,c*PIXSIZE,PIXSIZE,PIXSIZE); } for(int t=0; t < FIREPIX ; t++) { firePix[t] = new QPixmap(CELLSIZE, CELLSIZE); QPainter p(firePix[t]); p.drawPixmap(0,0,(*backgroundPix),0,0,CELLSIZE,CELLSIZE); p.drawPixmap(1,1,(*fire),t*PIXSIZE,0,PIXSIZE,PIXSIZE); } } delete balls; delete fire; } QPixmap* BallPainter::GetBall(int color, int animstep, int panim) { // return backgroundPix; if( (color<0) || (color>=NCOLORS) || (animstep<0) || color == NOBALL ) { // warning("BallPainter::Background"); return backgroundPix; } if ( panim == ANIM_JUMP ) { if ( ( animstep < 0 ) || ( animstep >= PIXTIME ) ) return backgroundPix; else return imgCash[color][animstep]; } else if ( panim == ANIM_BURN ) { if ( animstep < FIREBALLS ) return imgCash[color][animstep + PIXTIME + BOOMBALLS + 1]; else if ( animstep < FIREBALLS + FIREPIX ) return firePix[animstep - FIREBALLS]; } else if ( panim == ANIM_BORN ) { diff --git a/noncore/games/zlines/field.cpp b/noncore/games/zlines/field.cpp index 2a87739..0adf4ac 100644 --- a/noncore/games/zlines/field.cpp +++ b/noncore/games/zlines/field.cpp @@ -1,116 +1,115 @@ /*************************************************************************** field.cpp - description ------------------- begin : Fri May 19 2000 copyright : (C) 2000 by Roman Merzlyakov email : roman@sbrf.barrt.ru copyright : (C) 2000 by Roman Razilov email : Roman.Razilov@gmx.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include <stdlib.h> -#include "cfg.h" #include "field.h" Field::Field(QWidget* parent, const char* name) : QWidget( parent, name ) { clearField(); } Field::~Field() { } void Field::clearField() { for(int y=0; y<NUMCELLSH; y++) for(int x=0; x<NUMCELLSW; x++) field[y][x].clear(); } void Field::clearAnim() { for(int y=0; y<NUMCELLSH; y++) for(int x=0; x<NUMCELLSW; x++) field[y][x].setAnim( ANIM_NO ); } int Field::deleteAnimatedBalls() { int deleted = 0; for(int y=0; y<NUMCELLSH; y++) for(int x=0; x<NUMCELLSW; x++) { if ( field[y][x].getAnim() != ANIM_NO ) { deleted++; field[y][x].clear(); } } return deleted; } bool Field::checkBounds(int x, int y) { return (x>=0) && (x<NUMCELLSW) && (y>=0) && (y<NUMCELLSH); } void Field::putBall(int x, int y, int color) { if( checkBounds(x,y) ) field[y][x].setColor(color); } /* void Field::putBall(int x, int y, char color) { if( checkBounds(x,y) ){ field[y][x].setColor(color); erase5Balls(); repaint(FALSE); } }*/ void Field::moveBall(int xa, int ya, int xb, int yb) { if( checkBounds(xa,ya) && checkBounds(xb,yb) && field[yb][xb].isFree() && ( xa != xb || ya != yb) ) { field[yb][xb].moveBall(field[ya][xa]); } } int Field::getBall(int x, int y) { if( checkBounds(x,y) ) return field[y][x].getColor(); else return NOBALL; } int Field::getAnim(int x, int y) { if( checkBounds(x,y) ) return field[y][x].getAnim(); else return NOBALL; } void Field::setAnim(int x, int y, int anim) { if( checkBounds(x,y) ) field[y][x].setAnim( anim ); } void Field::removeBall(int x, int y ) { if( checkBounds(x,y) ) field[y][x].clear(); } int Field::freeSpace() { int s = 0; for(int y=0; y<NUMCELLSH; y++) for(int x=0; x<NUMCELLSW; x++) diff --git a/noncore/games/zlines/klines.cpp b/noncore/games/zlines/klines.cpp index 02ff0db..76c94e2 100644 --- a/noncore/games/zlines/klines.cpp +++ b/noncore/games/zlines/klines.cpp @@ -1,137 +1,128 @@ /*************************************************************************** klines.cpp - description ------------------- begin : Fri May 19 2000 copyright : (C) 2000 by Roman Merzlyakov email : roman@sbrf.barrt.ru copyright : (C) 2000 by Roman Razilov email : Roman.Razilov@gmx.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ /* changes 21.05.2000 Roman Razilov Menu game/Next */ // // The implementation of the KLines widget // -#include <qkeycode.h> -#include <qlabel.h> -#include <qpushbutton.h> -#include <qtooltip.h> -#include <qstring.h> #include <stdlib.h> #include <unistd.h> #include <time.h> #include <qapplication.h> -#include <qmenubar.h> -#include <qpopupmenu.h> -#include "cfg.h" -#include <qstatusbar.h> #include "klines.h" /* Creates the KLines widget and sets saved options (if any). */ KLines::KLines(QWidget *par, const char* n, WFlags fl) : QMainWindow(par,n,fl) { time_t t; time(&t); srand((unsigned int)t + getpid()); setCaption(QString("ZLines")); mwidget = new MainWidget(this); setCentralWidget( mwidget ); lsb = mwidget->GetLsb(); lPrompt = mwidget->GetPrompt(); menu = menuBar(); game = new QPopupMenu; edit = new QPopupMenu; game->insertItem(tr("&New game"), this, SLOT(stopGame()), CTRL+Key_N ); game->insertSeparator(); game->insertItem(tr("Ne&xt"), this, SLOT(makeTurn()), Key_N ); game->insertSeparator(); idMenuPrompt = game->insertItem( tr("&Show next"), this, SLOT(switchPrompt()), CTRL+Key_P ); game->setCheckable(true); game->setItemChecked(idMenuPrompt, lPrompt->getState()); game->insertSeparator(); game->insertItem(tr("&Quit"), qApp, SLOT(quit()), CTRL+Key_Q ); idMenuUndo = edit->insertItem(tr("Und&o"), this, SLOT(undo()), CTRL+Key_Z ); menu->insertItem( tr("&Game"), game ); menu->insertItem( tr("&Edit"), edit ); menu->show(); score = 0; prev_score = 0; mwidget->setMessage(tr("Points: 0")); startGame(); } /* Saves the options and destroys the KLines widget. */ KLines::~KLines() { } /* Resize event of the KLines widget. */ void KLines::resizeEvent( QResizeEvent *e ) { QMainWindow::resizeEvent(e); } void KLines::setMinSize() { // setMinimumSize( gr->wHint(), gr->hHint() + menu->height() + stat->height() + // tool->height() ); } void KLines::startGame() { score = 0; prev_score = 0; bUndo=TRUE; lsb->clearField(); generateRandomBalls(); placeBalls(); generateRandomBalls(); edit->setItemEnabled(idMenuUndo, FALSE ); updateStat(); } void KLines::stopGame() { debug("Klines::stopGame"); endGame(); } void KLines::searchBallsLine() { } diff --git a/noncore/games/zlines/linesboard.cpp b/noncore/games/zlines/linesboard.cpp index 0965b2c..1e59aeb 100644 --- a/noncore/games/zlines/linesboard.cpp +++ b/noncore/games/zlines/linesboard.cpp @@ -1,118 +1,115 @@ /*************************************************************************** linesboard.cpp - description ------------------- begin : Fri May 19 2000 copyright : (C) 2000 by Roman Merzlyakov email : roman@sbrf.barrt.ru copyright : (C) 2000 by Roman Razilov email : Roman.Razilov@gmx.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include <qpainter.h> -#include <qpixmap.h> -#include <qcolor.h> -#include <qkeycode.h> #include <stdlib.h> #include "linesboard.h" /* Constructs a LinesBoard widget. */ LinesBoard::LinesBoard( BallPainter * abPainter, QWidget* parent, const char* name ) : Field( parent, name ) { anim = ANIM_NO; // waypos = 0; // waylen = 0; // jumpingRow = -1; // jumpingCol = -1; painting = 0; way = new Waypoints[NUMCELLSW*NUMCELLSH]; bPainter = abPainter; setFocusPolicy( NoFocus ); setBackgroundColor( gray ); setMouseTracking( FALSE ); setFixedSize(wHint(), hHint()); timer = new QTimer(this); connect( timer, SIGNAL(timeout()), SLOT(timerSlot()) ); timer->start( TIMERCLOCK, FALSE ); } /* Destructor: deallocates memory for contents */ LinesBoard::~LinesBoard() { // debug("stop"); timer->stop(); delete timer; delete []way; } void LinesBoard::placeBalls(int pnextBalls[BALLSDROP]) { debug("LinesBoard::placeBalls( )"); for(int i=0; i < BALLSDROP; i++){ nextBalls[i] = pnextBalls[i]; } nextBallToPlace = 0; placeBall(); debug("LinesBoard::placeBalls End "); } void LinesBoard::placeBall( ) { int color = nextBalls[nextBallToPlace]; debug("LinesBoard::placeBall( ) color=%i, nextBallToPlace = %i", color, nextBallToPlace); char* xx = (char*)malloc( sizeof(char)*NUMCELLSW*NUMCELLSH ); char* yy = (char*)malloc( sizeof(char)*NUMCELLSW*NUMCELLSH ); // int nb=3; // if( freeSpace() < 3) nb = freeSpace(); int empty=0; for(int y=0; y<NUMCELLSH; y++) for(int x=0; x<NUMCELLSW; x++) if( getBall(x,y) == NOBALL ) { xx[empty] = x; yy[empty] = y; empty++; }; // debug("empty = %i",empty); if ( empty > 0) { int pos = rand()%empty; putBall( xx[pos], yy[pos], color ); clearAnim(); setAnim( xx[pos], yy[pos], ANIM_BORN ); nextBallToPlace++; AnimStart(ANIM_BORN); free(xx); free(yy); } else { free(xx); free(yy); emit endGame(); } debug("LinesBoard::placeBall END"); } /*id LinesBoard::doAfterBalls() { diff --git a/noncore/games/zlines/main.cpp b/noncore/games/zlines/main.cpp index ff41f95..238e7d3 100644 --- a/noncore/games/zlines/main.cpp +++ b/noncore/games/zlines/main.cpp @@ -1,30 +1,29 @@ /*************************************************************************** main.cpp - description ------------------- begin : Fri May 19 2000 copyright : (C) 2000 by Roman Merzlyakov email : roman@sbrf.barrt.ru copyright : (C) 2000 by Roman Razilov email : Roman.Razilov@gmx.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ /* * Roman Razilov 2000-05-19 debug dummmy * Roman Razilov 2000-05-21 qimgio */ -#include <qglobal.h> #include <opie/oapplicationfactory.h> #include "klines.h" OPIE_EXPORT_APP( OApplicationFactory<KLines> ) diff --git a/noncore/games/zlines/mwidget.cpp b/noncore/games/zlines/mwidget.cpp index 6641fa2..211d3d3 100644 --- a/noncore/games/zlines/mwidget.cpp +++ b/noncore/games/zlines/mwidget.cpp @@ -1,84 +1,83 @@ /*************************************************************************** mwidget.cpp - description ------------------- begin : Fri May 19 2000 copyright : (C) 2000 by Roman Merzlyakov email : roman@sbrf.barrt.ru copyright : (C) 2000 by Roman Razilov email : Roman.Razilov@gmx.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "mwidget.h" #include <qlayout.h> -#include "ballpainter.h" #include <qhbox.h> #include <qlabel.h> MainWidget::MainWidget( QWidget* parent, const char* name ) : QFrame( parent, name ) { BallPainter *bPainter = new BallPainter(); QGridLayout *Form1Layout = new QGridLayout( this ); Form1Layout->setSpacing( 4 ); Form1Layout->setMargin( 4 ); QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); Form1Layout->addItem( spacer, 0, 0 ); lsb = new LinesBoard(bPainter, this); Form1Layout->addWidget( lsb, 0, 1 ); QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); Form1Layout->addItem( spacer_2, 0, 2 ); QHBox *bottom=new QHBox(this); mPoints=new QLabel(bottom); bottom->setStretchFactor(mPoints, 2); lPrompt = new LinesPrompt(bPainter, bottom); Form1Layout->addWidget( bottom, 1, 1 ); QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); Form1Layout->addItem( spacer_3, 2, 1 ); connect(lsb, SIGNAL(endTurn()), parent, SLOT(makeTurn())); connect(lsb, SIGNAL(eraseLine(int)), parent, SLOT(addScore(int))); connect(lsb, SIGNAL(endGame()), parent, SLOT(stopGame())); connect(lPrompt, SIGNAL(PromptPressed()), parent, SLOT(switchPrompt())); } void MainWidget::setMessage(const QString &message) { mPoints->setText(message); } /* Destructor: deallocates memory for contents */ MainWidget::~MainWidget() { } LinesBoard * MainWidget::GetLsb() { return lsb; } LinesPrompt * MainWidget::GetPrompt() { return lPrompt; } diff --git a/noncore/games/zsame/StoneWidget.cpp b/noncore/games/zsame/StoneWidget.cpp index 49fa1a4..646fc9c 100644 --- a/noncore/games/zsame/StoneWidget.cpp +++ b/noncore/games/zsame/StoneWidget.cpp @@ -1,124 +1,119 @@ /* * ksame 0.4 - simple Game * Copyright (C) 1997,1998 Marcus Kreutzberger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ #include <stdio.h> #include <stdlib.h> -#include <qpainter.h> -#include <qpixmap.h> -#include <qbitmap.h> -#include <qimage.h> -#include <qcursor.h> #include <qpe/resource.h> #include <time.h> #include <assert.h> #include "StoneWidget.h" struct StoneSlice { QPixmap stone; }; StoneWidget::StoneWidget( QWidget *parent, int x, int y ) : QWidget(parent,"StoneWidget"), stonefield(x,y) { // setBackgroundPixmap(QPixmap(locate("wallpaper", "Time-For-Lunch-2.jpg"))); // QPixmap stonemap(locate("appdata", "stones.png")); QPixmap stonemap = Resource::loadPixmap("zsame/stones" ); assert(!stonemap.isNull()); slice=0; maxslices=30; maxcolors=4; sizex=x; sizey=y; stone_width=stonemap.width()/(maxslices+1); stone_height=stonemap.height()/maxcolors; map = new StoneSlice*[maxcolors]; QBitmap mask; for (int c = 0; c < maxcolors; c++) { map[c] = new StoneSlice[maxslices]; for (int s = 0; s < maxslices; s++) { map[c][s].stone.resize(stone_width, stone_height); assert(!map[c][s].stone.isNull()); bitBlt(&map[c][s].stone, 0, 0, &stonemap, stone_width * s, c*stone_height, stone_width,stone_height,CopyROP,false); QImage im = map[c][s].stone.convertToImage(); mask = im.createHeuristicMask(); map[c][s].stone.setMask(mask); } } field_height=stone_height*sizey; field_width=stone_width*sizex; setMouseTracking(true); // QColor c(115,115,115); // setBackgroundColor(c); // emit s_sizechanged(); startTimer( 100 ); history.setAutoDelete(true); } StoneWidget::~StoneWidget() { for (int c = 0; c < maxcolors; c++) { delete [] map[c]; } delete [] map; setMouseTracking(false); killTimers(); } unsigned int StoneWidget::board() { return stonefield.getBoard(); } int StoneWidget::score() { return stonefield.getScore(); } int StoneWidget::marked() { return stonefield.getMarked(); } QSize StoneWidget::size() { return QSize(sizex,sizey); } diff --git a/noncore/games/zsame/ZSameWidget.cpp b/noncore/games/zsame/ZSameWidget.cpp index 5001b55..45a877f 100644 --- a/noncore/games/zsame/ZSameWidget.cpp +++ b/noncore/games/zsame/ZSameWidget.cpp @@ -1,139 +1,132 @@ /* Yo Emacs, this is -*- C++ -*- */ /* * ksame 0.4 - simple Game * Copyright (C) 1997,1998 Marcus Kreutzberger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ #include <stdio.h> -#include <qwidget.h> -#include <qpushbutton.h> -#include <qpixmap.h> -#include <qvbox.h> -#include <qpopupmenu.h> #include <qtoolbar.h> #include <qmenubar.h> #include <qapplication.h> #include <qaction.h> #include <qmessagebox.h> #include <qpe/resource.h> #include <opie/oapplicationfactory.h> #include <kapplication.h> #include "ZSameWidget.h" -#include "StoneWidget.h" -#include "version.h" static int default_colors=3; #define i18n tr OPIE_EXPORT_APP( OApplicationFactory<ZSameWidget> ) ZSameWidget::ZSameWidget( QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) { setCaption(tr("ZSame")); setToolBarsMovable( false ); QToolBar* con = new QToolBar( this ); con->setHorizontalStretchable( true ); QMenuBar* mb = new QMenuBar( con ); QToolBar* tb = new QToolBar( this ); QPopupMenu* fileMenu = new QPopupMenu( this ); QAction* a = new QAction(tr("New Game"), Resource::loadIconSet("new") , QString::null, 0, this, "new_icon"); a->addTo( fileMenu ); a->addTo( tb ); connect(a, SIGNAL(activated()), this, SLOT(m_new())); a = new QAction(tr("Restart This Board"), Resource::loadIconSet("redo"), QString::null, 0, this, "restart_board" ); a->addTo( fileMenu ); connect( a, SIGNAL(activated()), this, SLOT(m_restart())); restart = a; a = new QAction( tr("Undo"), Resource::loadIconSet("undo"), QString::null, 0, this, "undo_action" ); a->addTo( fileMenu ); a->addTo( tb ); connect( a, SIGNAL(activated()), this, SLOT(m_undo())); a = new QAction(tr("Quit"), Resource::loadIconSet("quit_icon"), QString::null, 0, this, "quit_action"); a->addTo( fileMenu ); a->addTo( tb ); connect(a, SIGNAL(activated()), this, SLOT(m_quit())); mb->insertItem(tr("Game" ), fileMenu ); int foo[2]; desktop_widget(foo); stone = new StoneWidget(this,foo[0],foo[1]); connect( stone, SIGNAL(s_gameover()), this, SLOT(gameover())); connect( stone, SIGNAL(s_colors(int)), this, SLOT(setColors(int))); connect( stone, SIGNAL(s_board(int)), this, SLOT(setBoard(int))); connect( stone, SIGNAL(s_marked(int)), this, SLOT(setMarked(int))); connect( stone, SIGNAL(s_score(int)), this, SLOT(setScore(int))); connect( stone, SIGNAL(s_remove(int,int)), this, SLOT(stonesRemoved(int,int))); connect(stone, SIGNAL(s_sizechanged()), this, SLOT(sizeChanged())); sizeChanged(); setCentralWidget(stone); setScore(0); } ZSameWidget::~ZSameWidget() { } void ZSameWidget::readProperties(Config *conf) { /* Q_ASSERT(conf); stone->readProperties(conf); */ } void ZSameWidget::saveProperties(Config *conf) { /* Q_ASSERT(conf); stone->saveProperties(conf); conf->sync(); */ } void ZSameWidget::sizeChanged() { // stone->setFixedSize(stone->sizeHint()); } void ZSameWidget::newGame(unsigned int board,int colors) { while (board>=1000000) board-=1000000; // kdDebug() << "newgame board " << board << " colors " << colors << endl; |