summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/games/backgammon/backgammon.control2
-rw-r--r--noncore/games/backgammon/backgammon.h1
-rw-r--r--noncore/games/backgammon/backgammon.pro4
-rw-r--r--noncore/games/backgammon/main.cpp10
-rw-r--r--noncore/games/bounce/bounce.pro4
-rw-r--r--noncore/games/bounce/kbounce.cpp3
-rw-r--r--noncore/games/bounce/kbounce.h3
-rw-r--r--noncore/games/bounce/main.cpp9
-rw-r--r--noncore/games/bounce/opie-bounce.control2
-rw-r--r--noncore/games/buzzword/buzzword.cpp2
-rw-r--r--noncore/games/buzzword/buzzword.h3
-rw-r--r--noncore/games/buzzword/buzzword.pro5
-rw-r--r--noncore/games/buzzword/main.cpp15
-rw-r--r--noncore/games/buzzword/opie-buzzword.control2
-rw-r--r--noncore/games/fifteen/opie-fifteen.control2
-rw-r--r--noncore/games/go/go.pro6
-rw-r--r--noncore/games/go/gowidget.cpp4
-rw-r--r--noncore/games/go/gowidget.h3
-rw-r--r--noncore/games/go/main.cpp11
-rw-r--r--noncore/games/go/opie-go.control4
-rw-r--r--noncore/games/kcheckers/kcheckers.cpp5
-rw-r--r--noncore/games/kcheckers/kcheckers.h3
-rw-r--r--noncore/games/kcheckers/kcheckers.pro5
-rw-r--r--noncore/games/kcheckers/main.cpp12
-rw-r--r--noncore/games/kcheckers/opie-kcheckers.control2
-rw-r--r--noncore/games/mindbreaker/main.cpp10
-rw-r--r--noncore/games/mindbreaker/mindbreaker.cpp371
-rw-r--r--noncore/games/mindbreaker/mindbreaker.h27
-rw-r--r--noncore/games/mindbreaker/mindbreaker.pro5
-rw-r--r--noncore/games/mindbreaker/opie-mindbreaker.control2
-rw-r--r--noncore/games/minesweep/main.cpp11
-rw-r--r--noncore/games/minesweep/minefield.cpp2
-rw-r--r--noncore/games/minesweep/minesweep.cpp2
-rw-r--r--noncore/games/minesweep/minesweep.h1
-rw-r--r--noncore/games/minesweep/minesweep.pro4
-rw-r--r--noncore/games/minesweep/opie-minesweep.control2
-rw-r--r--noncore/games/parashoot/interface.cpp3
-rw-r--r--noncore/games/parashoot/interface.h1
-rw-r--r--noncore/games/parashoot/main.cpp13
-rw-r--r--noncore/games/parashoot/opie-parashoot.control2
-rw-r--r--noncore/games/parashoot/parashoot.pro6
-rw-r--r--noncore/games/qasteroids/main.cpp13
-rw-r--r--noncore/games/qasteroids/opie-qasteroids.control2
-rw-r--r--noncore/games/qasteroids/qasteroids.pro6
-rw-r--r--noncore/games/qasteroids/toplevel.cpp7
-rw-r--r--noncore/games/qasteroids/toplevel.h4
-rw-r--r--noncore/games/snake/interface.cpp2
-rw-r--r--noncore/games/snake/interface.h3
-rw-r--r--noncore/games/snake/main.cpp10
-rw-r--r--noncore/games/snake/opie-snake.control2
-rw-r--r--noncore/games/snake/snake.pro5
-rw-r--r--noncore/games/solitaire/canvascardwindow.cpp1
-rw-r--r--noncore/games/solitaire/canvascardwindow.h1
-rw-r--r--noncore/games/solitaire/carddeck.cpp2
-rw-r--r--noncore/games/solitaire/main.cpp14
-rwxr-xr-xnoncore/games/solitaire/solitaire.pro5
-rw-r--r--noncore/games/tetrix/main.cpp9
-rw-r--r--noncore/games/tetrix/opie-tetrix.control2
-rw-r--r--noncore/games/tetrix/qtetrix.h1
-rw-r--r--noncore/games/tetrix/tetrix.pro7
-rw-r--r--noncore/games/wordgame/main.cpp10
-rw-r--r--noncore/games/wordgame/wordgame.h1
-rw-r--r--noncore/games/wordgame/wordgame.pro5
63 files changed, 390 insertions, 306 deletions
diff --git a/noncore/games/backgammon/backgammon.control b/noncore/games/backgammon/backgammon.control
index 6468181..d78b547 100644
--- a/noncore/games/backgammon/backgammon.control
+++ b/noncore/games/backgammon/backgammon.control
@@ -1,10 +1,10 @@
Package: backgammon
-Files: bin/backgammon apps/Games/backgammon.desktop pics/backgammon help/en/html/backgammon.html
+Files: plugins/application/libbackgammon.so* bin/backgammon apps/Games/backgammon.desktop pics/backgammon help/en/html/backgammon.html
Priority: optional
Section: opie/games
Maintainer: Ralf Waspe <rwaspe@web.de>
Architecture: arm
Depends: task-opie-minimal
Description: Backgammon Game
A Backgammon game for the Opie environment.
Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/backgammon/backgammon.h b/noncore/games/backgammon/backgammon.h
index e3276f1..fb50500 100644
--- a/noncore/games/backgammon/backgammon.h
+++ b/noncore/games/backgammon/backgammon.h
@@ -1,120 +1,121 @@
#ifndef BACKGAMMON_H
#define BACKGAMMON_H
#include "backgammonview.h"
#include "canvasimageitem.h"
//#include "rulesdialog.h"
#include "moveengine.h"
#include <qlabel.h>
#include <qmainwindow.h>
//#include <qwidget.h>
class BackGammon : public QMainWindow
{
Q_OBJECT
private:
//GUI
//the "status" bar
QLabel* message;
//the main drawing area
QCanvas* area;
BackGammonView* boardview;
CanvasImageItem* board;
CanvasImageItem* table;
CanvasImageItem** p1;
CanvasImageItem** p2;
CanvasImageItem** p1_side;
CanvasImageItem** p2_side;
CanvasImageItem** diceA1;
CanvasImageItem** diceA2;
CanvasImageItem** diceB1;
CanvasImageItem** diceB2;
//CanvasImageItem** oddsDice;
CanvasImageItem* nomove_marker;
QCanvasRectangle* marker_current;
QCanvasRectangle* marker_next[4];
//ENGINE
MoveEngine* move;
//the dice values
int diceA1_value;
int diceA2_value;
int diceA3_value;
int diceA4_value;
int diceB1_value;
int diceB2_value;
int diceB3_value;
int diceB4_value;
int player;
bool dice1_played;
bool dice2_played;
bool dice3_played;
bool dice4_played;
bool dice_rolled;
//computer opponent
bool player1_auto;
bool player2_auto;
//the images;
QString theme_name;
QString board_name;
QString piecesA_name;
QString piecesB_name;
QString diceA_name;
QString diceB_name;
QString odds_name;
QString table_name;
//save game
QString game_name;
//the rules
Rules rules;
//display settings
Display display;
//is the game finished ?
bool gameFinished;
public:
+ static QString appName() { return QString::fromLatin1("backgammon"); }
BackGammon( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
~BackGammon();
private slots:
void newgame();
void playerselect();
void loadgame();
void savegame();
void deletegame();
void newtheme();
void loadtheme();
void savetheme();
void themedefault();
void deletetheme();
void modify_AI();
void setrules();
void mouse(int x,int y);
void done_dice1();
void done_dice2();
void done_dice3();
void done_dice4();
void nomove();
void nomove2();
void finished(int theplayer);
void autoroll_dice1();
void autoroll_dice2();
private:
void draw();
void showdice();
void setplayer();
void applytheme();
};
#endif //BACKGAMMON_H
diff --git a/noncore/games/backgammon/backgammon.pro b/noncore/games/backgammon/backgammon.pro
index 4be9491..063d617 100644
--- a/noncore/games/backgammon/backgammon.pro
+++ b/noncore/games/backgammon/backgammon.pro
@@ -1,34 +1,32 @@
-TEMPLATE = app
-CONFIG = qt warn_on release
+CONFIG = qt warn_on release quick-app
HEADERS = backgammon.h \
backgammonview.h \
canvasimageitem.h \
themedialog.h \
moveengine.h \
filedialog.h \
playerdialog.h \
aidialog.h \
rulesdialog.h \
definition.h
SOURCES = main.cpp \
backgammon.cpp \
backgammonview.cpp \
canvasimageitem.cpp \
themedialog.cpp \
moveengine.cpp \
filedialog.cpp \
playerdialog.cpp \
aidialog.cpp \
rulesdialog.cpp \
definition.cpp
TARGET = backgammon
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lstdc++
-DESTDIR = $(OPIEDIR)/bin
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/games/backgammon/main.cpp b/noncore/games/backgammon/main.cpp
index 86b452d..58ced10 100644
--- a/noncore/games/backgammon/main.cpp
+++ b/noncore/games/backgammon/main.cpp
@@ -1,14 +1,8 @@
#include <qpe/qpeapplication.h>
#include "backgammon.h"
+#include <opie/oapplicationfactory.h>
-int main( int argc, char** argv )
-{
- QPEApplication app( argc, argv );
+OPIE_EXPORT_APP( OApplicationFactory<BackGammon> )
- BackGammon* view= new BackGammon();
- app.showMainWidget(view);
-
- return app.exec();
-}
diff --git a/noncore/games/bounce/bounce.pro b/noncore/games/bounce/bounce.pro
index 338daf6..75e4a6b 100644
--- a/noncore/games/bounce/bounce.pro
+++ b/noncore/games/bounce/bounce.pro
@@ -1,12 +1,10 @@
-TEMPLATE = app
#CONFIG = qt warn_on debug
-CONFIG = qt warn_on release
+CONFIG = qt warn_on release quick-app
HEADERS = game.h kbounce.h
SOURCES = game.cpp kbounce.cpp main.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe
-DESTDIR = $(OPIEDIR)/bin
TARGET = bounce
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/games/bounce/kbounce.cpp b/noncore/games/bounce/kbounce.cpp
index 50f4ef6..211f0ff 100644
--- a/noncore/games/bounce/kbounce.cpp
+++ b/noncore/games/bounce/kbounce.cpp
@@ -1,286 +1,287 @@
/*
* 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() : QMainWindow(0), m_gameWidget( 0 )
+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"
"This program is distributed under\n"
"the terms of the GPL v2.") );
}
void KJezzball::closeGame()
{
if ( m_state!=Idle )
{
stopLevel();
m_state = Idle;
}
}
void KJezzball::pauseGame()
{
switch ( m_state )
{
case Running:
m_state = Paused;
m_gameWidget->display( tr("Game paused.\nPress P to continue!") );
stopLevel();
break;
case Paused:
case Suspend:
m_state = Running;
m_gameWidget->display( QString::null );
startLevel();
break;
case Idle:
break;
}
}
void KJezzball::gameOver()
{
stopLevel();
m_gameOverTimer->start( 100, TRUE );
}
void KJezzball::gameOverNow()
{
m_state = Idle;
QString score;
score.setNum( m_game.score );
QMessageBox::information( this, "Game Over", tr("Game Over!\nScore: %1").arg(score) );
}
void KJezzball::focusOutEvent( QFocusEvent *ev )
{
if ( m_state==Running )
{
stopLevel();
m_state = Suspend;
}
QMainWindow::focusOutEvent( ev );
}
void KJezzball::focusInEvent ( QFocusEvent *ev )
{
if ( m_state==Suspend )
{
startLevel();
m_state = Running;
}
QMainWindow::focusInEvent( ev );
}
void KJezzball::second()
{
m_level.time--;
TimeLabel->setText( tr( "Time: %1" ).arg(m_level.time) );
if ( m_level.time<=0 )
{
gameOver();
}
}
void KJezzball::died()
{
m_level.lifes--;
LivesLabel->setText( tr( "Lives: %1" ).arg(m_level.lifes) );
if ( m_level.lifes==0 ) gameOver();
}
void KJezzball::newPercent( int percent )
{
FilledLabel->setText( tr( "Filled: %1%" ).arg(percent) );
if ( percent>=75 )
{
m_level.score = m_level.lifes*15 + (percent-75)*2*(m_game.level+5);
nextLevel();
}
}
void KJezzball::createLevel( int level )
{
// destroy old game
if ( m_gameWidget ) delete m_gameWidget;
m_gameWidget = new JezzGame( level+1, m_view, "m_gameWidget" );
m_gameWidget->show();
m_layout->addMultiCellWidget( m_gameWidget, 0, 0, 0, 3 );
connect( m_gameWidget, SIGNAL(died()), this, SLOT(died()) );
connect( m_gameWidget, SIGNAL(newPercent(int)), this, SLOT(newPercent(int)) );
// update displays
m_level.lifes = level+1;
LivesLabel->setText( tr( "Lives: %1" ).arg(m_level.lifes) );
FilledLabel->setText( tr( "Filled: 0%" ) );
m_level.time = (level+2)*30;
TimeLabel->setText( tr( "Time: %1" ).arg(m_level.time) );
m_level.score = 0;
}
void KJezzball::startLevel()
{
if ( m_gameWidget )
{
m_timer->start( 1000 );
m_gameWidget->start();
}
}
void KJezzball::stopLevel()
{
if ( m_gameWidget )
{
m_gameWidget->stop();
m_timer->stop();
}
}
void KJezzball::nextLevel()
{
stopLevel();
m_nextLevelTimer->start( 100, TRUE );
}
void KJezzball::switchLevel()
{
m_game.score += m_level.score;
ScoreLabel->setText( tr( "Score: %1" ).arg(m_game.score) );
QString score;
score.setNum( m_level.score );
QString level;
level.setNum( m_game.level );
QString foo = QString(
tr("Successfully cleared more than 75%.\n") +
tr("%1 points: 15 points per life\n").arg(m_level.lifes*15) +
tr("%1 points: Bonus\n").arg((m_gameWidget->percent()-75)*2*(m_game.level+5)) +
tr("%1 points: Total score\n").arg(score) +
diff --git a/noncore/games/bounce/kbounce.h b/noncore/games/bounce/kbounce.h
index de41710..c59109f 100644
--- a/noncore/games/bounce/kbounce.h
+++ b/noncore/games/bounce/kbounce.h
@@ -1,99 +1,100 @@
/*
* 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.
*/
#ifndef KJEZZBALL_H_INCLUDED
#define KJEZZBALL_H_INCLUDED
#include <qmainwindow.h>
#include <qmenubar.h>
#include <qlabel.h>
class JezzGame;
class QLCDNumber;
class QGridLayout;
class KJezzball : public QMainWindow
{
Q_OBJECT
public:
- KJezzball();
+ static QString appName() { return QString::fromLatin1("bounce"); }
+ KJezzball(QWidget *, const char*, WFlags );
public slots:
void newGame();
void pauseGame();
void closeGame();
void about();
protected slots:
void died();
void newPercent( int percent );
void second();
void switchLevel();
void gameOverNow();
protected:
void createLevel( int level );
void startLevel();
void stopLevel();
void nextLevel();
void gameOver();
void initXMLUI();
void focusOutEvent( QFocusEvent * );
void focusInEvent ( QFocusEvent * );
void keyPressEvent( QKeyEvent *ev );
JezzGame *m_gameWidget;
QWidget *m_view;
QGridLayout *m_layout;
QLCDNumber *m_levelLCD;
QLCDNumber *m_lifesLCD;
QLCDNumber *m_scoreLCD;
QLCDNumber *m_percentLCD;
QLCDNumber *m_timeLCD;
QTimer *m_timer;
QTimer *m_nextLevelTimer;
QTimer *m_gameOverTimer;
enum { Idle, Running, Paused, Suspend } m_state;
struct
{
int lifes;
int time;
int score;
} m_level;
struct
{
int level;
int score;
} m_game;
private:
QMenuBar *menu;
QPopupMenu *game;
QLabel* ScoreLabel;
QLabel* LivesLabel;
QLabel* FilledLabel;
QLabel* TimeLabel;
};
#endif
diff --git a/noncore/games/bounce/main.cpp b/noncore/games/bounce/main.cpp
index a6b7c1a..9ea86a6 100644
--- a/noncore/games/bounce/main.cpp
+++ b/noncore/games/bounce/main.cpp
@@ -1,29 +1,24 @@
/*
* 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>
-int main(int argc, char **argv)
-{
- QPEApplication a( argc, argv );
- KJezzball *top = new KJezzball;
- a.showMainWidget(top);
+OPIE_EXPORT_APP( OApplicationFactory<KJezzball> )
- return a.exec();
-}
diff --git a/noncore/games/bounce/opie-bounce.control b/noncore/games/bounce/opie-bounce.control
index 8b3fdb9..bfe85d3 100644
--- a/noncore/games/bounce/opie-bounce.control
+++ b/noncore/games/bounce/opie-bounce.control
@@ -1,11 +1,11 @@
Package: opie-bounce
-Files: bin/bounce apps/Games/bounce.desktop pics/bounce/*.png
+Files: plugins/application/libbounce.so* bin/bounce apps/Games/bounce.desktop pics/bounce/*.png
Version: 0.6-$SUB_VERSION
Depends: task-opie-minimal
Priority: optional
Section: opie/games
Maintainer: Martin Imobersteg <imm@gmx.ch>
Architecture: arm
License: GPL
Description: bounce
A JezzGame like game for Qtopia.
diff --git a/noncore/games/buzzword/buzzword.cpp b/noncore/games/buzzword/buzzword.cpp
index 97a17a1..f746065 100644
--- a/noncore/games/buzzword/buzzword.cpp
+++ b/noncore/games/buzzword/buzzword.cpp
@@ -1,182 +1,182 @@
/*
* 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() : QMainWindow(0)
+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;
l.remove( l.at( pos ));
}
}
}
void BuzzWord::clicked(int row, int column)
{
if ( ! gameOver )
{
int rowTotal = 0;
int columnTotal = 0;
map[column][row] = 1;
for( int c = 0 ; c < gridVal ; c++ )
{
for( int r = 0 ; r < gridVal ; r++ )
{
if ( map[c][r] == 1 )
rowTotal++;
if ( rowTotal == 4 )
{
bingo();
}
}
rowTotal = 0;
}
for( int r = 0 ; r < gridVal ; r++ )
{
for( int c = 0 ; c < gridVal ; c++ )
{
if ( map[c][r] == 1 )
columnTotal++;
if ( columnTotal == 4 )
{
bingo();
}
}
columnTotal = 0;
}
if ( map[0][0] && map[1][1] && map[2][2] && map[3][3] )
bingo();
if ( map[0][3] && map[1][2] && map[2][1] && map[3][0] )
bingo();
}
}
void BuzzWord::bingo()
{
gameOver = true;
QMessageBox::information( this, "BUZZWORD", tr("<h1><b>BINGO !</b></h1>"));
}
void BuzzWord::newGame()
{
gameOver = false;
delete grid;
drawGrid();
setCentralWidget(grid);
}
diff --git a/noncore/games/buzzword/buzzword.h b/noncore/games/buzzword/buzzword.h
index 37dd5b4..c0e43d0 100644
--- a/noncore/games/buzzword/buzzword.h
+++ b/noncore/games/buzzword/buzzword.h
@@ -1,88 +1,89 @@
/*
* 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.
*/
#ifndef BUZZWORD_H
#define BUZZWORD_H
#include <qmainwindow.h>
#include <qmenubar.h>
#include <qlabel.h>
#include <qvbox.h>
class QGrid;
class BuzzLabel : public QLabel
{
Q_OBJECT
public:
BuzzLabel( QWidget *parent=0, const char *name=0 );
protected:
virtual void mousePressEvent(QMouseEvent *e);
signals:
void clicked();
};
class BuzzItem : public QVBox
{
Q_OBJECT
public:
BuzzItem( int row, int column, QString text, QWidget *parent=0, const char *name=0 );
private:
QLabel* label;
int _row;
int _column;
public slots:
void flip();
signals:
void clicked(int row,int column);
};
class BuzzWord : public QMainWindow
{
Q_OBJECT
public:
- BuzzWord();
+ BuzzWord( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
+ static QString appName() { return QString::fromLatin1("buzzword"); }
private:
void drawGrid();
void bingo();
QString getWord();
QMenuBar *menu;
QPopupMenu *game;
QGrid *grid;
int gridVal;
int map[4][4];
bool gameOver;
public slots:
void newGame();
void clicked(int row, int column);
};
#endif
diff --git a/noncore/games/buzzword/buzzword.pro b/noncore/games/buzzword/buzzword.pro
index 0faede8..247b593 100644
--- a/noncore/games/buzzword/buzzword.pro
+++ b/noncore/games/buzzword/buzzword.pro
@@ -1,11 +1,10 @@
-TEMPLATE = app
-CONFIG = qt warn_on release
+CONFIG = qt warn_on release quick-app
HEADERS = buzzword.h
SOURCES = buzzword.cpp main.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
-DESTDIR = $(OPIEDIR)/bin
LIBS += -lqpe
+
TARGET = buzzword
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/games/buzzword/main.cpp b/noncore/games/buzzword/main.cpp
index 2d9ff81..67f2c26 100644
--- a/noncore/games/buzzword/main.cpp
+++ b/noncore/games/buzzword/main.cpp
@@ -1,35 +1,24 @@
/*
* 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 <stdlib.h>
-#include <time.h>
+#include <opie/oapplicationfactory.h>
#include "buzzword.h"
-int main(int argc, char **argv)
-{
- srand(time(0));
-
- QPEApplication a( argc, argv );
- BuzzWord *top = new BuzzWord;
- a.showMainWidget(top);
-
- return a.exec();
-}
+OPIE_EXPORT_APP( OApplicationFactory<BuzzWord> )
diff --git a/noncore/games/buzzword/opie-buzzword.control b/noncore/games/buzzword/opie-buzzword.control
index 08b442b..b3e2496 100644
--- a/noncore/games/buzzword/opie-buzzword.control
+++ b/noncore/games/buzzword/opie-buzzword.control
@@ -1,11 +1,11 @@
Package: opie-buzzword
-Files: bin/buzzword apps/Games/buzzword.desktop pics/buzzword/buzzword.png share/buzzword/buzzwords
+Files: plugins/application/libbuzzword.so* bin/buzzword apps/Games/buzzword.desktop pics/buzzword/buzzword.png share/buzzword/buzzwords
Version: 1.1-$SUB_VERSION
Depends: task-opie-minimal
Priority: optional
Section: opie/games
Maintainer: Martin Imobersteg <imm@gmx.ch>
Architecture: arm
License: GPL
Description: BuzzWord
A BuzzWord Bingo for Qtopia.
diff --git a/noncore/games/fifteen/opie-fifteen.control b/noncore/games/fifteen/opie-fifteen.control
index 8fa355f..a6e8314 100644
--- a/noncore/games/fifteen/opie-fifteen.control
+++ b/noncore/games/fifteen/opie-fifteen.control
@@ -1,11 +1,11 @@
Package: opie-fifteen
-Files: bin/fifteen apps/Games/fifteen.desktop pics/fifteen
+Files: plugins/application/libfifteen.so* bin/fifteen apps/Games/fifteen.desktop pics/fifteen
Priority: optional
Section: opie/games
Maintainer: Martin Imobersteg <imm@gmx.ch>
Architecture: arm
Arch: iPAQ
Depends: task-opie-minimal
Description: Fifteen pieces game
A game for the Opie environment.
Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/go/go.pro b/noncore/games/go/go.pro
index 2bc0787..f6c6a54 100644
--- a/noncore/games/go/go.pro
+++ b/noncore/games/go/go.pro
@@ -1,19 +1,19 @@
-DESTDIR = $(OPIEDIR)/bin
-TEMPLATE = app
-CONFIG = qt warn_on release
+CONFIG = qt warn_on release quick-app
HEADERS = amigo.h \
go.h \
goplayutils.h \
gowidget.h
SOURCES = amigo.c \
goplayer.c \
goplayutils.c \
killable.c \
gowidget.cpp \
main.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe
TARGET = go
+
+
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/games/go/gowidget.cpp b/noncore/games/go/gowidget.cpp
index 6d06f3b..cf89267 100644
--- a/noncore/games/go/gowidget.cpp
+++ b/noncore/games/go/gowidget.cpp
@@ -1,311 +1,311 @@
/**********************************************************************
** 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) :
- QMainWindow( parent, name )
+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 );
fn = Resource::findPixmap("Go-black-highlight");
newBlackStone = new QImage( fn );
fn = Resource::findPixmap("Go-white");
whiteStone = new QImage( fn );
*/
blackStone = new QPixmap(Resource::loadPixmap( "Go-black" ));
whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" ));
newBlackStone = new QPixmap(Resource::loadPixmap( "Go-black-highlight" ));
init();
}
GoWidget::~GoWidget()
{
writeConfig();
}
void GoWidget::writeConfig()
{
Config cfg("Go");
cfg.setGroup("Game");
cfg.writeEntry("TwoPlayer", twoplayer);
cfg.writeEntry("CurrentPlayer", currentPlayer);
cfg.writeEntry("NPassed", nPassed);
QString b;
for (int i=0; i<19; i++)
for (int j=0; j<19; j++)
b += board[i][j] == BLACK ? 'B' : board[i][j] == WHITE ? 'W' : '.';
cfg.writeEntry("Board", b);
cfg.writeEntry("LastX", lastX);
cfg.writeEntry("LastY", lastY);
extern int blackPrisoners, whitePrisoners;
cfg.writeEntry("BlackPrisoners", blackPrisoners);
cfg.writeEntry("WhitePrisoners", whitePrisoners);
}
void GoWidget::readConfig()
{
init();
Config cfg("Go");
cfg.setGroup("Game");
twoplayer = cfg.readBoolEntry("TwoPlayer");
currentPlayer = (bVal)cfg.readNumEntry("CurrentPlayer",1);
nPassed = cfg.readNumEntry("NPassed",0);
QString b = cfg.readEntry("Board");
if ( b.length() == 19*19 )
for (int i=0; i<19; i++)
for (int j=0; j<19; j++) {
QChar ch = b[j+19*i];
if ( ch != '.' )
GoPlaceStone( ch == 'B' ? BLACK : WHITE, i, j );
}
lastX = cfg.readNumEntry("LastX");
lastY = cfg.readNumEntry("LastY");
extern int blackPrisoners, whitePrisoners;
blackPrisoners = cfg.readNumEntry("BlackPrisoners",0);
whitePrisoners = cfg.readNumEntry("WhitePrisoners",0);
reportPrisoners(blackPrisoners,whitePrisoners);
emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone );
}
void GoWidget::resizeEvent( QResizeEvent * )
{
d = QMIN(width(),height())/19;
// int r = (d/2-1);
bx = (width() - 18*d)/2 ;
by = (height() - 18*d)/2 ;
if ( d < 10 && !smallStones ) {
blackStone->convertFromImage( blackStone->convertToImage().smoothScale(8,8) );
whiteStone->convertFromImage( whiteStone->convertToImage().smoothScale(8,8) );
newBlackStone->convertFromImage( newBlackStone->convertToImage().smoothScale(8,8) );
smallStones = TRUE;
} else if ( d >= 10 && smallStones ) {
blackStone = new QPixmap(Resource::loadPixmap( "Go-black" ));
whiteStone = new QPixmap(Resource::loadPixmap( "Go-white" ));
newBlackStone = new QPixmap(Resource::loadPixmap( "Go-black-highlight" ));
smallStones = FALSE;
}
}
void GoWidget::init()
{
lastX = lastY = newX = newY = -1;
nPassed = 0;
for ( int i = 0; i < 19; i++ )
for ( int j = 0; j < 19; j++ )
board[i][j]=-1;
gameActive = TRUE;
goRestart(current_handicap);
if ( twoplayer ) {
currentPlayer = BLACK;
} else {
doComputerMove();
currentPlayer = WHITE;
}
emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone );
}
void GoWidget::paintEvent( QPaintEvent *e )
{
int i,j;
int r = whiteStone->width()/2;
QPainter p(this);
p.fillRect( bx - d/2, by - d/2, 19*d, 19*d, *goBrush );
int xMin = QMAX( x2board(e->rect().left()), 0 );
int xMax = QMIN( x2board(e->rect().right()), 18 );
int yMin = QMAX( y2board(e->rect().top()), 0 );
int yMax = QMIN( y2board(e->rect().bottom()), 18 );
QColor pine( 255, 186, 89 );
p.setPen( pine.dark() );
for ( i = xMin; i < xMax+1 ; i ++ ) {
p.drawLine( bx+i*d, by, bx+i*d, by+18*d );
}
for ( j = yMin; j < yMax+1 ; j ++ ) {
p.drawLine( bx, by+j*d, bx+18*d, by+j*d);
}
// dots are at (3,3), (3,9), (3,15) and so on
p.setBrush( black );
for ( i = 3; i < xMax+1; i+=6 )
for ( j = 3; j < yMax+1; j+=6 )
p.drawEllipse( bx+i*d-2, by+j*d-2, 5, 5 );
for ( i = xMin; i < xMax+1; i++ )
for ( j = yMin; j < yMax+1; j++ ) {
if ( board[i][j] == WHITE ||
currentPlayer==WHITE && newX == i && newY == j )
p.drawPixmap( bx+i*d - r, by+j*d - r, *whiteStone );
else if ( i == lastX && j == lastY )
p.drawPixmap( bx+i*d - r, by+j*d - r, *newBlackStone );
else if ( board[i][j] == BLACK ||
currentPlayer==BLACK && newX == i && newY == j)
p.drawPixmap( bx+i*d - r, by+j*d - r, *blackStone );
}
}
void GoWidget::doMove( int x, int y )
{
if ( !GoPlaceStone( currentPlayer, x, y ) ) {
//printf( "Illegal move (%d,%d)\n", x, y );
return;
}
//printf( "you do (%d,%d)\n", x, y );
nPassed = 0;
if ( twoplayer )
currentPlayer = (currentPlayer==WHITE) ? BLACK : WHITE;
else
doComputerMove();
emit showTurn( currentPlayer == WHITE ? *whiteStone : *blackStone );
}
void GoWidget::pass()
{
if ( !gameActive )
return;
nPassed++;
if ( nPassed >= 2 )
endGame();
else if ( !twoplayer )
doComputerMove();
}
void GoWidget::resign()
{
if ( gameActive )
diff --git a/noncore/games/go/gowidget.h b/noncore/games/go/gowidget.h
index 94de2cc..429dc33 100644
--- a/noncore/games/go/gowidget.h
+++ b/noncore/games/go/gowidget.h
@@ -1,111 +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.
**
**********************************************************************/
#ifndef GOWIDGET_H
#define GOWIDGET_H
#include <qmainwindow.h>
#include "amigo.h"
class QToolBar;
class GoMainWidget : public QMainWindow
{
Q_OBJECT
public:
- GoMainWidget( QWidget *parent=0, const char* name=0);
+ static QString appName() { return QString::fromLatin1("go"); }
+ GoMainWidget( QWidget *parent=0, const char* name=0, WFlags fl = 0);
protected:
void resizeEvent( QResizeEvent * );
private:
QToolBar *toolbar;
};
class QLabel;
class GoWidget : public QWidget
{
Q_OBJECT
public:
GoWidget( QWidget *parent=0, const char* name=0);
~GoWidget();
void doMove( int x, int y );
void doComputerMove();
void readConfig();
void writeConfig();
public slots:
void pass();
void resign();
void newGame();
void setTwoplayer( bool );
void setHandicap( int );
signals:
void showScore( const QString& );
void showTurn( const QPixmap& );
protected:
void paintEvent( QPaintEvent * );
void mousePressEvent( QMouseEvent * );
void mouseMoveEvent( QMouseEvent * );
void mouseReleaseEvent( QMouseEvent * );
void resizeEvent( QResizeEvent * );
private:
void init();
void removeStone(short x, short y);
void placeStone (enum bVal c, short x, short y );
void refresh( int x, int y );
void showStone( int x, int y, enum bVal );
void reportPrisoners(int,int);
inline int x2board( int x ) { return (x-bx+d/2)/d; }
inline int y2board( int y ) { return (y-by+d/2)/d; }
void endGame();
bool twoplayer;
enum bVal currentPlayer;
bool gameActive;
int nPassed;
signed char board[19][19];
int d; //distance between lines
int bx; //vertical baseline
int by; //horizontal baseline
int lastX,lastY;
int newX,newY;
static GoWidget *self;
friend void removestone(short x, short y);
friend void intrPrisonerReport( short, short );
friend void placestone(enum bVal c, short x, short y );
};
#endif
diff --git a/noncore/games/go/main.cpp b/noncore/games/go/main.cpp
index c7e2669..f24e3c3 100644
--- a/noncore/games/go/main.cpp
+++ b/noncore/games/go/main.cpp
@@ -1,35 +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 "gowidget.h"
#include <qpe/qpeapplication.h>
-#include <stdio.h>
+#include <opie/oapplicationfactory.h>
-int main( int argc, char ** argv)
-{
- QPEApplication app( argc, argv );
+OPIE_EXPORT_APP( OApplicationFactory<GoMainWidget> )
- GoMainWidget m;
- m.setCaption( GoWidget::tr("Go") );
- app.showMainWidget( &m );
- return app.exec();
-}
diff --git a/noncore/games/go/opie-go.control b/noncore/games/go/opie-go.control
index b07e8be..95b319e 100644
--- a/noncore/games/go/opie-go.control
+++ b/noncore/games/go/opie-go.control
@@ -1,10 +1,10 @@
Package: opie-go
-Files: bin/go apps/Games/go.desktop pics/go
+Files: plugins/application/libgo.so* bin/go apps/Games/go.desktop pics/go
Priority: optional
Section: opie/games
-Maintainer: Opie Project <opie@handhelds.org>
+Maintainer: Warwick Allison <warwick@trolltech.com>
Architecture: arm
Depends: task-opie-minimal
Description: The game of Go
A game for the Opie environment.
Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/kcheckers/kcheckers.cpp b/noncore/games/kcheckers/kcheckers.cpp
index c2eba0d..2eb37e5 100644
--- a/noncore/games/kcheckers/kcheckers.cpp
+++ b/noncore/games/kcheckers/kcheckers.cpp
@@ -1,303 +1,304 @@
#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():QMainWindow(0,0,WStyle_DialogBorder)
+KCheckers::KCheckers(QWidget *p, const char* n, WFlags )
+ :QMainWindow(p,n,WStyle_DialogBorder)
{
- setCaption("KCheckers");
+ 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);
menuBar->insertItem(tr("&Game"), gameMenu);
menuBar->insertItem(tr("&Skill"), skillMenu);
menuBar->insertItem(tr("&Options"),optionsMenu);
menuBar->insertItem(tr("&Help"), helpMenu);
// Restore a settings
readConfig();
skillMenu->setItemChecked(skill,true);
optionsMenu->setItemChecked(rules,true);
optionsMenu->setItemChecked(numID,false);
// Make a toolbar
QToolBar* emptyToolBar=new QToolBar(this);
emptyToolBar->setHorizontalStretchable(true);
QToolBar* toolBar=new QToolBar(this);
CHECK_PTR(toolBar);
QSize buttonSize(24,24);
QToolButton* gameButton=new QToolButton(QPixmap(logo_xpm),tr(" New Game ") ,"",this,SLOT(newGame()),toolBar);
CHECK_PTR(gameButton);
gameButton->setMinimumSize(buttonSize);
undoButton=new QToolButton(QPixmap(undo_xpm),tr(" Undo Move "),"",this,SLOT(undoMove()),toolBar);
CHECK_PTR(undoButton);
undoButton->setMinimumSize(buttonSize);
QToolButton* helpButton=new QToolButton(QPixmap(help_xpm),tr(" Rules of Play "),"",this,SLOT(help()),toolBar);
CHECK_PTR(helpButton);
helpButton->setMinimumSize(buttonSize);
// Make a checkers board
imageMan1=new QImage(man_black_xpm); CHECK_PTR(imageMan1);
imageMan2=new QImage(man_white_xpm); CHECK_PTR(imageMan2);
imageKing1=new QImage(king_black_xpm); CHECK_PTR(imageKing1);
imageKing2=new QImage(king_white_xpm); CHECK_PTR(imageKing2);
imageWood1=new QImage(wood1_xpm); CHECK_PTR(imageWood1);
imageWood2=new QImage(wood2_xpm); CHECK_PTR(imageWood2);
imageWood3=new QImage(wood3_xpm); CHECK_PTR(imageWood3);
imageGreen1=new QImage(green1_xpm); CHECK_PTR(imageGreen1);
imageGreen2=new QImage(green2_xpm); CHECK_PTR(imageGreen2);
imageGreen3=new QImage(green3_xpm); CHECK_PTR(imageGreen3);
imageMarble1=new QImage(marble1_xpm); CHECK_PTR(imageMarble1);
imageMarble2=new QImage(marble2_xpm); CHECK_PTR(imageMarble2);
imageMarble3=new QImage(marble3_xpm); CHECK_PTR(imageMarble3);
QWidget* centralWidget=new QWidget(this);
setCentralWidget(centralWidget);
QFrame* frame=new QFrame(centralWidget);
CHECK_PTR(frame);
frame->setFrameStyle(QFrame::Box|QFrame::Plain);
frame->setFixedSize(SIZE*8+2,SIZE*8+2);
statusLabel = new QLabel(centralWidget);
statusLabel->setAlignment(Qt::AlignHCenter);
QVBoxLayout* vlayout=new QVBoxLayout(centralWidget);
vlayout->addStretch();
vlayout->addWidget(frame);
vlayout->addStretch();
vlayout->addWidget(statusLabel);
vlayout->addStretch();
for(int i=0;i<64;i++)
{
field[i]=new Field(frame,i);
CHECK_PTR(field[i]);
}
QGridLayout* grid=new QGridLayout(frame,8,8,1,0);
CHECK_PTR(grid);
for(int i=0;i<4;i++)
{
for(int k=0;k<4;k++)
{
grid->addWidget(field[i*8+k+32],i*2, k*2 );
grid->addWidget(field[i*8+k ],i*2, k*2+1);
grid->addWidget(field[i*8+k+4 ],i*2+1,k*2 );
grid->addWidget(field[i*8+k+36],i*2+1,k*2+1);
}
}
for(int i=0;i<32;i++)
connect(field[i],SIGNAL(click(int)),this,SLOT(click(int)));
selected=false;
setPattern(pattern);
QWhatsThis::add(frame,"A checkers board");
userFirst=false;
game=NULL;
newGame();
}
void KCheckers::readConfig()
{
Config config("KCheckers");
config.setGroup("KCheckers");
QString entry;
entry=config.readEntry("skill","novice");
if(entry=="beginner") skill=BEGINNER;
else if(entry=="average") skill=AVERAGE;
else if(entry=="good") skill=GOOD;
else if(entry=="expert") skill=EXPERT;
else if(entry=="master") skill=MASTER;
else skill=NOVICE;
entry=config.readEntry("rules","english");
if(entry=="russian") rules=RUSSIAN;
else rules=ENGLISH;
entry=config.readEntry("theme","wooden");
if(entry=="green") pattern=GREEN;
else if(entry=="marble") pattern=MARBLE;
else pattern=WOODEN;
}
void KCheckers::closeEvent(QCloseEvent* event)
{
Config config("KCheckers");
config.setGroup("KCheckers");
QString entry;
if(skill==BEGINNER) entry="beginner";
if(skill==NOVICE) entry="novice";
if(skill==AVERAGE) entry="average";
if(skill==GOOD) entry="good";
if(skill==EXPERT) entry="expert";
if(skill==MASTER) entry="master";
config.writeEntry("skill",entry);
if(rules==ENGLISH) entry="english";
if(rules==RUSSIAN) entry="russian";
config.writeEntry("rules",entry);
if(pattern==GREEN) entry="green";
if(pattern==MARBLE) entry="marble";
if(pattern==WOODEN) entry="wooden";
config.writeEntry("theme",entry);
event->accept();
}
void KCheckers::setSkill(int set)
{
skillMenu->setItemChecked(skill,false);
skill=set;
skillMenu->setItemChecked(skill,true);
game->setLevel(skill);
}
void KCheckers::setRules(int set)
{
optionsMenu->setItemChecked(rules,false);
rules=set;
optionsMenu->setItemChecked(rules,true);
colorChange();
newGame();
}
void KCheckers::setPattern(int set)
{
optionsMenu->setItemChecked(pattern,false);
pattern=set;
optionsMenu->setItemChecked(pattern,true);
switch(pattern)
{
case GREEN:
imagePat1=imageGreen1;
imagePat2=imageGreen2;
imageFrame=imageGreen3;
break;
case MARBLE:
imagePat1=imageMarble1;
imagePat2=imageMarble2;
imageFrame=imageMarble3;
break;
case WOODEN:
imagePat1=imageWood1;
imagePat2=imageWood2;
imageFrame=imageWood3;
diff --git a/noncore/games/kcheckers/kcheckers.h b/noncore/games/kcheckers/kcheckers.h
index ccf5bae..bd4afc7 100644
--- a/noncore/games/kcheckers/kcheckers.h
+++ b/noncore/games/kcheckers/kcheckers.h
@@ -1,125 +1,126 @@
#ifndef KCHECKERS_H
#define KCHECKERS_H
#include <qmainwindow.h>
#include <qlabel.h>
#include "field.h"
#include "checkers.h"
#define WOODEN 1
#define GREEN 2
#define MARBLE 3
#define ENGLISH 11
#define RUSSIAN 12
#define BEGINNER 2
#define NOVICE 4
#define AVERAGE 6
#define GOOD 7
#define EXPERT 8
#define MASTER 9
class QToolButton;
class KCheckers:public QMainWindow
{
Q_OBJECT
public:
- KCheckers();
+ static QString appName() { return QString::fromLatin1("kcheckers"); }
+ KCheckers(QWidget *parent, const char* name, WFlags fl);
protected:
void closeEvent(QCloseEvent*);
private slots:
void help();
void about();
void aboutQt();
void newGame();
void undoMove();
void click(int);
void showNumeration();
void setSkillBeginner() {setSkill(BEGINNER);};
void setSkillNovice() {setSkill(NOVICE);};
void setSkillAverage() {setSkill(AVERAGE);};
void setSkillGood() {setSkill(GOOD);};
void setSkillExpert() {setSkill(EXPERT);};
void setSkillMaster() {setSkill(MASTER);};
void setPatternWooden() {setPattern(WOODEN);};
void setPatternGreen() {setPattern(GREEN);};
void setPatternMarble() {setPattern(MARBLE);};
void setRulesEnglish() {setRules(ENGLISH);};
void setRulesRussian() {setRules(RUSSIAN);};
private:
void compGo();
bool userGo(int);
void drawBoard(int);
void drawNumeration();
void colorChange();
void unselect();
void readConfig();
void setSkill(int);
void setRules(int);
void setPattern(int);
int from; // Selected by user
int skill;
int rules;
int pattern;
int numID; // Show Numeration
int undoID; // Undo Move
int undoBoard[32];
bool gameOver;
bool selected;
bool userFirst;
Field* field[64]; // Fields of board
QImage* imagePat1; // Patterns
QImage* imagePat2;
QImage* imageFrame; // Frame of selected field
QImage* imageWood1;
QImage* imageWood2;
QImage* imageWood3;
QImage* imageGreen1;
QImage* imageGreen2;
QImage* imageGreen3;
QImage* imageMarble1;
QImage* imageMarble2;
QImage* imageMarble3;
QImage* imageMan1;
QImage* imageMan2;
QImage* imageKing1;
QImage* imageKing2;
Checkers* game;
QPopupMenu* gameMenu;
QPopupMenu* skillMenu;
QPopupMenu* optionsMenu;
QToolButton* undoButton;
QLabel* statusLabel;
static QString enNumeration;
static QString ruNumeration;
static const int t[32]; // Translate table
};
#endif
diff --git a/noncore/games/kcheckers/kcheckers.pro b/noncore/games/kcheckers/kcheckers.pro
index a23e83a..0d417bf 100644
--- a/noncore/games/kcheckers/kcheckers.pro
+++ b/noncore/games/kcheckers/kcheckers.pro
@@ -1,20 +1,19 @@
-TEMPLATE = app
-CONFIG = qt warn_on release
+CONFIG = qt warn_on release quick-app
HEADERS = checkers.h \
echeckers.h \
field.h \
kcheckers.h \
rcheckers.h
SOURCES = checkers.cpp \
echeckers.cpp \
field.cpp \
kcheckers.cpp \
main.cpp \
rcheckers.cpp
INTERFACES =
INCLUDEPATH += $(OPIEDIR)/include
LIBS += -lqpe
-DESTDIR = $(OPIEDIR)/bin
TARGET = kcheckers
+
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/games/kcheckers/main.cpp b/noncore/games/kcheckers/main.cpp
index b8dd620..6ac570a 100644
--- a/noncore/games/kcheckers/main.cpp
+++ b/noncore/games/kcheckers/main.cpp
@@ -1,18 +1,10 @@
#include <qpe/qpeapplication.h>
#include <qfont.h>
#include "kcheckers.h"
+#include <opie/oapplicationfactory.h>
+OPIE_EXPORT_APP( OApplicationFactory<KCheckers> )
-int main(int argc, char *argv[])
-{
- QPEApplication app(argc,argv);
-
- KCheckers kcheckers;
- app.setMainWidget(&kcheckers);
- kcheckers.showMaximized();
-
- return app.exec();
-}
diff --git a/noncore/games/kcheckers/opie-kcheckers.control b/noncore/games/kcheckers/opie-kcheckers.control
index e228209..71f83af 100644
--- a/noncore/games/kcheckers/opie-kcheckers.control
+++ b/noncore/games/kcheckers/opie-kcheckers.control
@@ -1,10 +1,10 @@
Package: opie-kcheckers
-Files: bin/kcheckers apps/Games/kcheckers.desktop pics/kcheckers
+Files: plugins/application/libkcheckers.so* bin/kcheckers apps/Games/kcheckers.desktop pics/kcheckers
Priority: optional
Section: opie/games
Maintainer: leseb <prudhomme@laposte.net>
Architecture: arm
Version: 0.3-$SUB_VERSION
Depends: task-opie-minimal
Description: The game of Checkers
A game for the Opie environment.
diff --git a/noncore/games/mindbreaker/main.cpp b/noncore/games/mindbreaker/main.cpp
index 8ba0fde..2ca16e3 100644
--- a/noncore/games/mindbreaker/main.cpp
+++ b/noncore/games/mindbreaker/main.cpp
@@ -1,35 +1,35 @@
/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
-** This file is part of Qtopia Environment.
+** 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 <qpe/qpeapplication.h>
+#include <qtopia/qpeapplication.h>
int main( int argc, char **argv )
{
QPEApplication a( argc, argv );
- MindBreaker w(0, "new window");
- w.setCaption("Mind Breaker");
+ MindBreaker w;
+ w.setCaption(MindBreaker::tr("Mind Breaker"));
QPEApplication::setInputMethodHint( &w, QPEApplication::AlwaysOff );
a.showMainWidget(&w);
return a.exec();
}
diff --git a/noncore/games/mindbreaker/mindbreaker.cpp b/noncore/games/mindbreaker/mindbreaker.cpp
index 7802e38..e1f43d0 100644
--- a/noncore/games/mindbreaker/mindbreaker.cpp
+++ b/noncore/games/mindbreaker/mindbreaker.cpp
@@ -1,818 +1,957 @@
/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
-** This file is part of Qtopia Environment.
+** 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 <qpe/resource.h>
-#include <qpe/config.h>
+#include <qtopia/resource.h>
+#include <qtopia/config.h>
+#include <qtopia/qpeapplication.h>
+#include <qtoolbar.h>
#include <qpainter.h>
#include <qpixmap.h>
-#include <qpe/qpetoolbar.h>
#include <qtoolbutton.h>
#include <qpushbutton.h>
#include <qmessagebox.h>
#include <qlabel.h>
-#include <qstyle.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:
static QVector<QImage> normalPegs;
static QVector<QImage> specialPegs;
bool isplaced;
int pegtype;
int peg_go;
int peg_pos;
int aniStep;
};
-
int Peg::eggLevel = 0;
QVector<QImage> Peg::normalPegs;
QVector<QImage> Peg::specialPegs;
void Peg::buildImages()
{
-
QImage pegs = Resource::loadImage("mindbreaker/pegs");
int x = 0;
int y = 0;
int i;
eggLevel = 0;
normalPegs.resize(10);
for (i = 0; i < 6; i++) {
- normalPegs.insert(i, new QImage(pegs.copy(x, y, peg_size, peg_size)));
+ normalPegs.insert(i, new QImage(pegs.copy(x, y, peg_size, peg_size).
+ smoothScale(adjusted_peg_size, adjusted_peg_size) ));
x += peg_size;
}
specialPegs.resize(5);
for (i = 0; i < 5; i++) {
- specialPegs.insert(i, new QImage(pegs.copy(x,y,peg_size, peg_size)));
+ specialPegs.insert(i, new QImage(pegs.copy(x,y,peg_size, peg_size).
+ smoothScale(adjusted_peg_size, adjusted_peg_size) ));
x += peg_size;
}
QImage image = Resource::loadImage("mindbreaker/mindbreaker");
/* copy from master image to functional images */
x = 0;
y = panel_height;
normalPegs.insert(8,
- new QImage(image.copy(x, y, panel_width, panel_height)));
+ new QImage( image.copy(x, y, panel_width, panel_height).
+ smoothScale( adjusted_panel_width, adjusted_panel_height)
+ ));
y += panel_height;
y += title_height;
normalPegs.insert(9,
- new QImage(image.copy(x, y, title_width, title_height)));
+ new QImage(image.copy(x, y, title_width, title_height).
+ smoothScale( adjusted_title_width, adjusted_title_height)
+ ));
y += title_height;
x = 6 * peg_size;
normalPegs.insert(6,
- new QImage(image.copy(x, y, answerpeg_size, answerpeg_size)));
+ new QImage(image.copy(x, y, answerpeg_size, answerpeg_size).
+ smoothScale( adjusted_answerpeg_size, adjusted_answerpeg_size) ));
x += answerpeg_size;
normalPegs.insert(7,
- new QImage(image.copy(x, y, answerpeg_size, answerpeg_size)));
+ new QImage(image.copy(x, y, answerpeg_size, answerpeg_size).
+ smoothScale( adjusted_answerpeg_size, adjusted_answerpeg_size) ));
}
QImage Peg::imageForType(int t)
{
if (eggLevel > t ) {
if( t < 5) {
return *specialPegs[t];
} else {
return *normalPegs[rand() % 6];
}
}
return *normalPegs[t];
}
Peg::Peg(QCanvas *canvas , int t, int g, int p)
: QCanvasRectangle(canvas)
{
setSize(normalPegs[t]->width(), normalPegs[t]->height() );
pegtype = t;
isplaced = FALSE;
peg_pos = p;
peg_go = g;
aniStep = rand() % 6;
setAnimated(TRUE);
}
void Peg::advance(int phase) {
if (phase == 0)
aniStep = (++aniStep) % 6;
else {
hide();
show();
}
}
void Peg::drawShape(QPainter &p )
{
if ((pegtype == 5) && eggLevel > 5) {
- p.drawImage(x(), y(), *normalPegs[aniStep]);
+ p.drawImage(int(x()), int(y()), *normalPegs[aniStep]);
} else
- p.drawImage(x(), y(), imageForType(pegtype));
+ p.drawImage(int(x()), int(y()), imageForType(pegtype));
}
bool Peg::hit( const QPoint &p ) const
{
int ix = p.x() - int(x());
int iy = p.y() - int(y());
if (!normalPegs[pegtype]->valid(ix, iy))
return FALSE;
QRgb pixel = normalPegs[pegtype]->pixel(ix, iy);
return (qAlpha(pixel ) != 0);
}
inline bool Peg::placed() const
{
return isplaced;
}
inline int Peg::pegGo() const
{
return peg_go;
}
inline int Peg::pegPos() const
{
return peg_pos;
}
inline void Peg::setPegPos(int p)
{
peg_pos = p;
}
inline void Peg::setPlaced(bool p)
{
isplaced = p;
}
inline int Peg::type() const
{
return pegtype;
}
/* Load the main image, copy from it the pegs, the board, and the answer image
* and use these to create the tray, answer and board
*/
MindBreaker::MindBreaker( QWidget *parent, const char *name, int wFlags )
-: QMainWindow(parent, name, wFlags),
- canvas(board_height, board_width)
+ : QMainWindow(parent, name, wFlags)
{
- MindBreakerBoard *m = new MindBreakerBoard(canvas, this);
- setCentralWidget(m);
+ setCaption( tr("Mind Breaker"));
+ QPEApplication::setInputMethodHint( this, QPEApplication::AlwaysOff );
+ setMinimumSize(160,210);
+
+ QWidget *w = new QWidget( this );
+ w->setBackgroundColor( black );
+ QHBoxLayout *hb = new QHBoxLayout( w );
+ hb->addStretch();
+ board = new MindBreakerBoard(w);
+ hb->addWidget( board, 100 );
+ hb->addStretch();
+
+ setCentralWidget(w);
setToolBarsMovable( FALSE );
QToolBar *tb = new QToolBar(this);
tb->setHorizontalStretchable( TRUE );
- QPixmap newicon = Resource::loadPixmap("new");
+ QIconSet newicon = Resource::loadIconSet("new");
new QToolButton(newicon, tr("New Game"), 0,
- m, SLOT(clear()), tb, "NewGame");
+ board, SLOT(clear()), tb, "NewGame");
score = new QToolButton(tb);
score->setText("");
score->setMaximumHeight(20);
score->setUsesTextLabel(TRUE);
tb->setStretchableWidget(score);
- connect(m, SIGNAL(scoreChanged(int, int)), this, SLOT(setScore(int, int)));
- connect(score, SIGNAL(clicked()), m, SLOT(resetScore()));
+ connect(board, SIGNAL(scoreChanged(int,int)), this, SLOT(setScore(int,int)));
+ connect(score, SIGNAL(clicked()), board, SLOT(resetScore()));
int a, b;
- m->getScore(&a, &b);
+ board->getScore(&a, &b);
setScore(a,b);
+
+ layout()->setResizeMode(QLayout::FreeResize);
}
void MindBreaker::setScore(int turns, int games)
{
double average;
double total_turns = turns;
double total_games = games;
if(total_games > 0)
average = total_turns / total_games;
else
average = 0.0;
score->setText(tr("win avg: %1 turns (%2 games)").arg(average).arg(games));
}
+void MindBreaker::resizeEvent( QResizeEvent *e )
+{
+ board->fixSize();
+ QMainWindow::resizeEvent( e );
+}
+
-MindBreakerBoard::MindBreakerBoard( QCanvas &canv, QWidget *parent,
+MindBreakerBoard::MindBreakerBoard( QWidget *parent,
const char *name, int wFlags )
- : QCanvasView(&canv, parent, name, wFlags)
+ : QCanvasView(0, parent, name, wFlags),
+ moving(0), game_over(FALSE), total_turns(0), total_games(0)
{
- int i, x, y;
+ setFrameStyle( NoFrame );
+ setupBoardSize(qApp->desktop()->width(),qApp->desktop()->height());
+ cnv.resize(100,100);
+ setCanvas(&cnv);
+ setBackgroundColor( black );
+
struct timeval tv;
current_go = 0;
gettimeofday(&tv, 0);
-
srand(tv.tv_usec);
canvas()->setAdvancePeriod(500);
+ current_highlight = 0;
- QImage image = Resource::loadImage("mindbreaker/mindbreaker");
-
- /* copy from master image to functional images */
- x = 0;
- y = 0;
- panelImage = image.copy(x,y, panel_width, panel_height);
- y += panel_height;
- y += panel_height;
-
- titleImage = image.copy(x, y, title_width, title_height);
-
- Peg::buildImages(); // must be done BEFORE any pegs are made
-
- current_highlight = new Peg(canvas(), 8);
- current_highlight->setPlaced(TRUE);
- current_highlight->setX(0);
- current_highlight->setY(board_height - ((current_go + 1) * panel_height));
- current_highlight->setZ(0);
- current_highlight->show();
+ widthTimer = new QTimer( this );
+ connect(widthTimer, SIGNAL(timeout()), this, SLOT(doFixSize()) );
+ setMaximumWidth( QMIN(qApp->desktop()->height(),qApp->desktop()->width()) );
+ //doFixSize(); // build images... needs to be done before reading config.
+ //readConfig(); // first read... to ensure initial labels and side look right.
+}
- /* set up the game */
+void MindBreakerBoard::readConfig()
+{
Config c("MindBreaker", Config::User);
c.setGroup("Board");
game_over = FALSE;
+ int i;
if (c.readNumEntry("Answer0") < 0) {
for (i = 0; i < 4; i++) {
answer[i] = rand() % 6;
current_guess[i] = 6;
}
total_turns = 0;
total_games = 0;
} else {
int j;
c.setGroup("Score");
total_turns = c.readNumEntry("Turns");
total_games = c.readNumEntry("Games");
if(total_turns < 0)
total_turns = 0;
if(total_games < 0)
total_games = 0;
checkScores();
c.setGroup("Board");
for(i = 0; i < 4; i++)
answer[i] = c.readNumEntry(QString("Answer%1").arg(i));
/* read, and parse past guesses */
current_go = 0;
for(j=0; j < 9; j++) {
current_guess[0] = c.readNumEntry(QString("Go%1p0").arg(j));
if (current_guess[0] < 0)
break;
placeGuessPeg(0, current_guess[0]);
current_guess[1] = c.readNumEntry(QString("Go%1p1").arg(j));
placeGuessPeg(1, current_guess[1]);
current_guess[2] = c.readNumEntry(QString("Go%1p2").arg(j));
placeGuessPeg(2, current_guess[2]);
current_guess[3] = c.readNumEntry(QString("Go%1p3").arg(j));
placeGuessPeg(3, current_guess[3]);
checkGuess();
}
for(i = 0; i < 4; i++) {
current_guess[i] = c.readNumEntry(QString("CurrentGo%1").arg(i));
if (current_guess[i] != 6)
placeGuessPeg(i, current_guess[i]);
}
}
-
- /* draw initial screen */
- drawBackground();
- canvas()->update();
}
MindBreakerBoard::~MindBreakerBoard()
{
- int i, j;
+ int i;
if (game_over) {
current_go = 0;
/* clear the answer, clear the guess */
for (i = 0; i < 4; i++) {
answer[i] = rand() % 6;
current_guess[i] = 6;
}
}
+ writeConfig();
+}
+void MindBreakerBoard::writeConfig()
+{
Config c("MindBreaker", Config::User);
c.setGroup("Board");
c.clearGroup();
/* write the board */
+ int i,j;
for (i = 0; i < current_go; i++) {
for(j = 0; j < 4; j++)
- c.writeEntry(tr("Go%1p%2").arg(i).arg(j), past_guesses[4*i+j]);
+ c.writeEntry(QString("Go%1p%2").arg(i).arg(j), past_guesses[4*i+j]);
}
for(j = 0; j < 4; j++)
- c.writeEntry(tr("CurrentGo%1").arg(j), current_guess[j]);
+ c.writeEntry(QString("CurrentGo%1").arg(j), current_guess[j]);
for(j = 0; j < 4; j++)
- c.writeEntry(tr("Answer%1").arg(j), answer[j]);
+ c.writeEntry(QString("Answer%1").arg(j), answer[j]);
c.setGroup("Score");
/* write the score */
c.writeEntry("Turns", total_turns);
c.writeEntry("Games", total_games);
}
void MindBreakerBoard::getScore(int *a, int *b)
{
*a = total_turns;
*b = total_games;
return;
}
+void MindBreakerBoard::fixSize()
+{
+ hide();
+ setMaximumWidth( parentWidget()->height() );
+ widthTimer->start( 20, TRUE );
+}
+
+void MindBreakerBoard::doFixSize()
+{
+ QSize s = size();
+ int fw = frameWidth();
+ s.setWidth(s.width() - fw);
+ s.setHeight(s.height() - fw);
+
+ /* min size is 200 x 260 */
+/*
+ if (s.width() < adjusted_board_width)
+ s.setWidth(adjusted_board_width);
+
+ if (s.height() < adjusted_board_height)
+ s.setHeight(adjusted_board_height);
+*/
+
+ if ( current_highlight ) // non-first resize
+ writeConfig();
+
+ setupBoardSize(s.width() - fw, s.height() - fw);
+ canvas()->resize(s.width() - fw, s.height() - fw);
+ Peg::buildImages(); // must be done BEFORE any pegs are made
+
+ QImage image = Resource::loadImage("mindbreaker/mindbreaker");
+
+ /* copy from master image to functional images */
+ int x = 0;
+ int y = 0;
+ panelImage = image.copy(x, y, panel_width, panel_height).
+ smoothScale( adjusted_panel_width, adjusted_panel_height);
+
+ y += panel_height;
+ y += panel_height;
+
+ titleImage = image.copy(x, y, title_width, title_height).
+ smoothScale( adjusted_title_width, adjusted_title_height);
+ show();
+
+ delete current_highlight;
+ current_highlight = new Peg(canvas(), 8);
+ current_highlight->setPlaced(TRUE);
+ current_highlight->setX(0);
+ current_highlight->setY(adjusted_board_height - ((current_go + 1) * adjusted_panel_height));
+ current_highlight->setZ(0);
+ current_highlight->show();
+
+ /* set up the game */
+ //readConfig();
+
+ /* draw initial screen */
+ //drawBackground();
+ //canvas()->update();
+ clear();
+
+ readConfig();
+}
+
void MindBreakerBoard::placeGuessPeg(int pos, int pegId)
{
- int x = first_peg_x_diff + (pos * peg_spacing);
- int y = board_height - ((current_go + 1) * panel_height)
- + first_peg_y_diff;
+ int x = adjusted_first_peg_x_diff + (pos * adjusted_peg_spacing);
+ int y = adjusted_board_height - ((current_go + 1) * adjusted_panel_height)
+ + adjusted_first_peg_y_diff;
Peg *peg = new Peg(canvas(), pegId, current_go, pos);
peg->setPegPos(pos);
peg->setPlaced(TRUE);
peg->setX(x);
peg->setY(y);
peg->setZ(2);
peg->show();
}
void MindBreakerBoard::drawBackground()
{
int i, j, x, y, x_gap, y_gap;
QPixmap background = QPixmap(canvas()->width(), canvas()->height());
QPainter painter(&background);
painter.fillRect(0, 0, canvas()->width(), canvas()->height(), QColor(0,0,0));
/* very first thing is to draw the bins, as everything else needs
* to be drawn over them */
QPen pen(QColor(85, 45, 27), 4);
painter.setPen(pen);
- x_gap = canvas()->width() - (panel_width + (2 * bin_margin));
+ x_gap = canvas()->width() - (adjusted_panel_width + (2 * adjusted_bin_margin));
//x_gap += peg_size >> 1;
if (x_gap < 1)
x_gap = 1;
- y_gap = board_height / 6;
- y_gap -= (2 * bin_margin);
+ y_gap = adjusted_board_height / 6;
+ y_gap -= (2 * adjusted_bin_margin);
//y_gap += peg_size >> 1;
if (y_gap < 1)
y_gap = 1;
- x = panel_width + bin_margin - (peg_size >> 1);
- y = bin_margin - (peg_size >> 1) + 2;
+ x = adjusted_panel_width + adjusted_bin_margin - (adjusted_peg_size >> 1);
+ y = adjusted_bin_margin - (adjusted_peg_size >> 1) + 2;
for (i = 0; i < 6; i++) {
for (j = 0; j < 10; j++) {
int rx = x + (rand() % x_gap);
int ry = y + (rand() % y_gap);
painter.drawImage(rx,ry, Peg::imageForType(i));
}
- y += board_height / 6;
+ y += adjusted_board_height / 6;
}
/* now draw the surrounding boxes */
- x_gap = canvas()->width() - panel_width;
+ x_gap = canvas()->width() - adjusted_panel_width;
if (x_gap < 1) x_gap = 1;
- y_gap = board_height / 6;
- x = panel_width;
+ y_gap = adjusted_board_height / 6;
+ x = adjusted_panel_width;
y = 1;
for (i = 0; i < 6; i++) {
painter.drawRect(x, y, x_gap, y_gap);
y += y_gap;
}
x = 0;
y = 0;
painter.drawImage(x,y, titleImage);
- y = title_height;
+ y = adjusted_title_height;
/* now nine gues panels */
for (i = 0; i < 9; i ++) {
painter.drawImage(x, y, panelImage);
- y += panel_height;
+ y += adjusted_panel_height;
}
painter.flush();
canvas()->setBackgroundPixmap(background);
}
void MindBreakerBoard::checkGuess()
{
int i,j;
int num_white = 0;
int num_black = 0;
int copy_answer[4];
int copy_guess[4];
for(i = 0; i < 4; i++) {
copy_answer[i] = answer[i];
copy_guess[i] = current_guess[i];
if (current_guess[i] == 6)
return;
if (answer[i] == current_guess[i]) {
num_black++;
copy_answer[i] = 6;
copy_guess[i] = 7;
}
}
/* now sure that user has completed a 'guess' */
for (i = 0; i < 4; i++) {
if (copy_guess[i] == 7)
continue; // already marked for a black
for (j = 0; j < 4; j++) {
if(copy_guess[i] == copy_answer[j]) {
copy_answer[j] = 6;
num_white++;
break;
}
}
}
- int x = answerpegx;
- int y = (board_height - ((current_go + 1) * panel_height)) + answerpegy;
+ int x = adjusted_answerpegx;
+ int y = (adjusted_board_height - ((current_go + 1) * adjusted_panel_height)) + adjusted_answerpegy;
if (num_black == 4)
game_over = TRUE;
while(num_black > 0) {
Peg *p = new Peg(canvas(), 7);
p->setPlaced(TRUE);
p->setX(x);
p->setY(y);
p->setZ(1);
p->show();
num_black--;
- if (x == answerpegx)
- x = answerpegx + answerpeg_diff;
+ if (x == adjusted_answerpegx)
+ x = adjusted_answerpegx + adjusted_answerpeg_xdiff;
else {
- x = answerpegx;
- y += answerpeg_diff;
+ x = adjusted_answerpegx;
+ y += adjusted_answerpeg_ydiff;
}
}
while(num_white > 0){
Peg *p = new Peg(canvas(), 6);
p->setPlaced(TRUE);
p->setX(x);
p->setY(y);
p->setZ(1);
p->show();
num_white--;
- if (x == answerpegx)
- x = answerpegx + answerpeg_diff;
+ if (x == adjusted_answerpegx)
+ x = adjusted_answerpegx + adjusted_answerpeg_xdiff;
else {
- x = answerpegx;
- y += answerpeg_diff;
+ x = adjusted_answerpegx;
+ y += adjusted_answerpeg_ydiff;
}
}
/* move to next go */
for(i = 0; i < 4; i++) {
past_guesses[4*current_go+i] = current_guess[i];
current_guess[i] = 6;
}
current_go++;
if((current_go > 8) || game_over) {
total_games++;
if(!game_over)
total_turns += 10;
else
total_turns += current_go;
emit scoreChanged(total_turns, total_games);
Peg *p = new Peg(canvas(), 9);
game_over = TRUE;
p->setPlaced(TRUE);
p->setX(0);
p->setY(0);
p->setZ(0);
p->show();
for (i = 0; i < 4; i++) {
p = new Peg(canvas(), answer[i], -1);
- p->setX(first_peg_x_diff + (i * peg_spacing));
- p->setY(5);
+ p->setX(adjusted_first_peg_x_diff + (i * adjusted_peg_spacing));
+ p->setY(adjusted_first_peg_y_diff);
p->setZ(3);
p->show();
}
} else {
- current_highlight->setY(board_height - ((current_go + 1) * panel_height));
+ current_highlight->setY(adjusted_board_height - ((current_go + 1) * adjusted_panel_height));
}
canvas()->update();
}
void MindBreakerBoard::clear()
{
if(!game_over) {
total_games++;
total_turns += 10;
emit scoreChanged(total_turns, total_games);
}
int i;
/* reset the game board */
game_over = FALSE;
/* clear the answer, clear the guess */
for (i = 0; i < 4; i++) {
answer[i] = rand() % 6;
current_guess[i] = 6;
}
current_go = 0;
QCanvasItemList list = canvas()->allItems();
QCanvasItemList::Iterator it = list.begin();
for (; it != list.end(); ++it) {
if (*it == current_highlight)
continue;
if (*it)
delete *it;
}
- current_highlight->setY(board_height - ((current_go + 1) * panel_height));
+ current_highlight->setY(adjusted_board_height - ((current_go + 1) * adjusted_panel_height));
checkScores();
drawBackground();
canvas()->update();
}
void MindBreakerBoard::resetScore()
{
/* are u sure */
if (QMessageBox::information(this, tr( "Reset Statistics" ),
tr( "Reset the win ratio?" ),
tr( "OK" ), tr( "Cancel" ) ) == 0) {
total_turns = 0;
total_games = 0;
Peg::eggLevel = 0;
drawBackground();
canvas()->update();
emit scoreChanged(total_turns, total_games);
}
}
/* EVENTS */
void MindBreakerBoard::contentsMousePressEvent(QMouseEvent *e)
{
+ if (game_over) {
+ null_press = TRUE;
+ null_point = e->pos();
+ moving = 0;
+ return;
+ }
+
copy_press = FALSE;
null_press = FALSE;
/* ok, first work out if it is one of the bins that
got clicked */
- if (e->x() > panel_width) {
+ if (e->x() > adjusted_panel_width) {
/* its a bin, but which bin */
- if(e->y() > board_height)
+ int bin = (e->y() + 2) / (adjusted_board_height / 6);
+ if (bin > 5)
return; // missed everything
- int bin = (e->y() + 2) / (board_height / 6);
/* make new peg... set it moving */
moving_pos = e->pos();
moving = new Peg(canvas(), bin, current_go);
- moving->setX(e->x() - (peg_size >> 1));
- moving->setY(e->y() - (peg_size >> 1));
+ moving->setX(e->x() - (adjusted_peg_size >> 1));
+ moving->setY(e->y() - (adjusted_peg_size >> 1));
moving->setZ(5);
moving->show();
canvas()->update();
return;
}
QCanvasItemList l = canvas()->collisions(e->pos());
for (QCanvasItemList::Iterator it=l.begin(); it !=l.end(); ++it) {
if ( (*it)->rtti() == pegRTTI ) {
Peg *item = (Peg *)(*it);
if (!item->hit(e->pos()))
continue;
if (item->type() > 5) {
null_press = TRUE;
null_point = e->pos();
continue; /* not a color peg */
}
if (item->placed()) {
/* copy */
if(item->pegGo() == -1)
return;
if(item->pegGo() == current_go) {
copy_press = TRUE;
copy_peg = item;
}
moving = new Peg(canvas(),
item->type(), current_go);
- moving->setX(e->x() - (peg_size >> 1));
- moving->setY(e->y() - (peg_size >> 1));
+ moving->setX(e->x() - (adjusted_peg_size >> 1));
+ moving->setY(e->y() - (adjusted_peg_size >> 1));
moving->setZ(5);
moving->show();
moving_pos = QPoint(e->x(), e->y());
canvas()->update();
return;
}
moving = (Peg *)*it;
moving_pos = e->pos();
canvas()->update();
return;
}
}
null_press = TRUE;
null_point = e->pos();
moving = 0;
}
void MindBreakerBoard::contentsMouseMoveEvent(QMouseEvent* e)
{
if (moving ) {
moving->moveBy(e->pos().x() - moving_pos.x(),
e->pos().y() - moving_pos.y());
moving_pos = e->pos();
canvas()->update();
return;
}
}
void MindBreakerBoard::contentsMouseReleaseEvent(QMouseEvent* e)
{
/* time to put down the peg */
if(moving) {
if(copy_press) {
/* check if collided with original. if so, delete both */
copy_press = FALSE;
QCanvasItemList l = canvas()->collisions(e->pos());
for (QCanvasItemList::Iterator it=l.begin(); it !=l.end(); ++it) {
if (*it == copy_peg)
copy_press = TRUE;
}
if (copy_press) {
current_guess[copy_peg->pegPos()] = 6;
delete copy_peg;
delete moving;
copy_press = FALSE;
moving = 0;
copy_peg = 0;
canvas()->update();
return;
}
}
/* first work out if in y */
- if (e->y() > (board_height - (current_go * panel_height))) {
+ if (e->y() > (adjusted_board_height - (current_go * adjusted_panel_height))) {
delete moving;
moving = 0;
canvas()->update();
return;
}
- if (e->y() < (board_height - ((current_go + 1) * panel_height))) {
+ if (e->y() < (adjusted_board_height - ((current_go + 1) * adjusted_panel_height))) {
delete moving;
moving = 0;
canvas()->update();
return;
}
/* ok, a valid go, but which peg */
- int x_bar = first_peg_x_diff - (peg_size >> 1);
- x_bar += peg_spacing;
+ int x_bar = adjusted_first_peg_x_diff - (adjusted_peg_size >> 1);
+ x_bar += adjusted_peg_spacing;
int pos = 0;
if (e->x() > x_bar)
pos = 1;
- x_bar += peg_spacing;
+ x_bar += adjusted_peg_spacing;
if (e->x() > x_bar)
pos = 2;
- x_bar += peg_spacing;
+ x_bar += adjusted_peg_spacing;
if (e->x() > x_bar)
pos = 3;
- x_bar += peg_spacing;
+ x_bar += adjusted_peg_spacing;
if (e->x() > x_bar) {
/* invalid x */
delete moving;
moving = 0;
canvas()->update();
return;
}
- int x = first_peg_x_diff + (pos * peg_spacing);
- int y = board_height - ((current_go + 1) * panel_height)
- + first_peg_y_diff;
+ int x = adjusted_first_peg_x_diff + (pos * adjusted_peg_spacing);
+ int y = adjusted_board_height - ((current_go + 1) * adjusted_panel_height)
+ + adjusted_first_peg_y_diff;
moving->setPegPos(pos);
moving->setX(x);
moving->setY(y);
moving->setZ(2);
/* remove all other pegs from this position */
QCanvasItemList l = canvas()->collisions(QPoint(x,y));
for (QCanvasItemList::Iterator it=l.begin(); it !=l.end(); ++it) {
if ( (*it)->rtti() == pegRTTI ) {
Peg *item = (Peg *)(*it);
if ((item != moving) && (item != current_highlight))
delete item;
}
}
current_guess[pos] = ((Peg *)moving)->type();
((Peg *)moving)->setPlaced(true);
canvas()->update();
return;
}
moving = 0;
null_point -= e->pos();
if(null_point.manhattanLength() < 6) {
if (game_over)
clear();
else
checkGuess();
}
}
void MindBreakerBoard::resizeEvent(QResizeEvent *e)
{
- QSize s = e->size();
- int fw = style().defaultFrameWidth();
- s.setWidth(s.width() - fw);
- s.setHeight(s.height() - fw);
-
- /* min size is 200 x 260 */
- if (s.width() < board_width)
- s.setWidth(board_width);
-
- if (s.height() < board_height)
- s.setHeight(board_height);
-
- canvas()->resize(s.width() - fw, s.height() - fw);
- drawBackground();
+ QCanvasView::resizeEvent(e);
+ fixSize();
}
/* Easter egg function... beat the clock */
void MindBreakerBoard::checkScores()
{
double games = total_games;
double turns = total_turns;
double g = games / 10.0;
Peg::eggLevel = 0;
double break_even = 5.0;
if (g < 1.0)
return;
double avg = turns / games;
g--;
while (break_even >= 0.0) {
if (avg >= (break_even + g))
return;
// score a peg.
break_even -= 1.0;
Peg::eggLevel = int(5.0 - break_even);
}
}
diff --git a/noncore/games/mindbreaker/mindbreaker.h b/noncore/games/mindbreaker/mindbreaker.h
index fca649a..3132e80 100644
--- a/noncore/games/mindbreaker/mindbreaker.h
+++ b/noncore/games/mindbreaker/mindbreaker.h
@@ -1,122 +1,139 @@
/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
-** This file is part of Qtopia Environment.
+** 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.
**
**********************************************************************/
#ifndef MINDBREAKER_H
#define MINDBREAKER_H
#include <qwidget.h>
#include <qmainwindow.h>
#include <qimage.h>
#include <qvector.h>
#include <qcanvas.h>
#include <qlabel.h>
static const int panel_height = 26;
static const int panel_width = 180;
static const int title_height = 25;
static const int title_width = 180;
static const int bin_margin = 10;
static const int peg_size = 20;
static const int answerpeg_size = 13;
static const int first_peg_x_diff = 21;
static const int first_peg_y_diff = ((panel_height - peg_size) >> 1);
static const int peg_spacing = 30;
static const int answerpegx = 152;
static const int answerpegy = 2;
static const int answerpeg_diff = 9;
static const int board_height = (title_height + (panel_height * 9));
static const int board_width = (panel_width + (bin_margin * 2) + peg_size);
class Peg;
class QToolButton;
+class QTimer;
class MindBreakerBoard : public QCanvasView // QWidget
{
Q_OBJECT
public:
- MindBreakerBoard(QCanvas &c, QWidget *parent=0, const char *name=0, int wFlags=0 );
+ MindBreakerBoard(QWidget *parent=0, const char *name=0, int wFlags=0 );
~MindBreakerBoard();
void getScore(int *, int *);
+
+ void resizeEvent(QResizeEvent*);
+ void fixSize();
+
signals:
void scoreChanged(int, int);
public slots:
void clear();
void resetScore();
+private slots:
+ void doFixSize();
+
protected:
void contentsMousePressEvent(QMouseEvent *);
void contentsMouseMoveEvent(QMouseEvent *);
void contentsMouseReleaseEvent(QMouseEvent *);
- void resizeEvent(QResizeEvent *);
private:
+ QCanvas cnv;
+
+ void readConfig();
+ void writeConfig();
+
void drawBackground();
void checkGuess();
void checkScores();
void placeGuessPeg(int pos, int pegId);
QImage panelImage;
QImage titleImage;
Peg *moving;
Peg *current_highlight;
QPoint moving_pos;
// the game stuff
int answer[4];
int current_guess[4];
int past_guesses[4*9];
int current_go;
int null_press;
QPoint null_point;
bool copy_press;
Peg *copy_peg;
bool game_over;
int total_turns;
int total_games;
+
+ QTimer *widthTimer;
};
class MindBreaker : public QMainWindow // QWidget
{
Q_OBJECT
public:
MindBreaker(QWidget *parent=0, const char *name=0, int wFlags=0 );
-
+ static QString appName() { return QString::fromLatin1("mindbreaker"); }
public slots:
void setScore(int, int);
+protected:
+ void resizeEvent( QResizeEvent * );
+
private:
QCanvas canvas;
MindBreakerBoard *board;
QToolButton *score;
};
#endif
diff --git a/noncore/games/mindbreaker/mindbreaker.pro b/noncore/games/mindbreaker/mindbreaker.pro
index 4ca3b84..0a37fa7 100644
--- a/noncore/games/mindbreaker/mindbreaker.pro
+++ b/noncore/games/mindbreaker/mindbreaker.pro
@@ -1,12 +1,11 @@
-TEMPLATE = app
-CONFIG += qt warn_on release
-DESTDIR = $(OPIEDIR)/bin
+CONFIG += qt warn_on release quick-app
HEADERS = mindbreaker.h
SOURCES = main.cpp \
mindbreaker.cpp
TARGET = mindbreaker
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe
+
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/games/mindbreaker/opie-mindbreaker.control b/noncore/games/mindbreaker/opie-mindbreaker.control
index 7b5ead6..5b342da 100644
--- a/noncore/games/mindbreaker/opie-mindbreaker.control
+++ b/noncore/games/mindbreaker/opie-mindbreaker.control
@@ -1,10 +1,10 @@
Package: opie-mindbreaker
-Files: bin/mindbreaker apps/Games/mindbreaker.desktop pics/mindbreaker
+Files: plugins/application/libmindbreaker.so* bin/mindbreaker apps/Games/mindbreaker.desktop pics/mindbreaker
Priority: optional
Section: opie/games
Maintainer: Martin Imobersteg <imm@gmx.ch>
Architecture: arm
Depends: task-opie-minimal
Description: Game: crack the coloured code
A game for the Opie environment.
Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/minesweep/main.cpp b/noncore/games/minesweep/main.cpp
index 83de9a3..bd70f7c 100644
--- a/noncore/games/minesweep/main.cpp
+++ b/noncore/games/minesweep/main.cpp
@@ -1,34 +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 "minesweep.h"
#include <qpe/qpeapplication.h>
+#include <opie/oapplicationfactory.h>
-int main( int argc, char** argv )
-{
- QPEApplication a( argc, argv );
+OPIE_EXPORT_APP( OApplicationFactory<MineSweep> )
- MineSweep ms;
- QPEApplication::setInputMethodHint( &ms, QPEApplication::AlwaysOff );
- a.showMainWidget( &ms );
-
- return a.exec();
-}
diff --git a/noncore/games/minesweep/minefield.cpp b/noncore/games/minesweep/minefield.cpp
index eca1a36..04cfb97 100644
--- a/noncore/games/minesweep/minefield.cpp
+++ b/noncore/games/minesweep/minefield.cpp
@@ -100,513 +100,513 @@ public:
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;
Mine::Mine( MineField *f )
{
mined = FALSE;
st = Hidden;
hint = 0;
field = f;
}
void Mine::activate( bool sure )
{
if ( !sure ) {
switch ( st ) {
case Hidden:
setState( Flagged );
break;
case Flagged:
#ifdef MARK_UNSURE
setState( Unsure );
break;
case Unsure:
#endif
setState( Hidden );
default:
break;
}
} else if ( st == Flagged ) {
return;
} else {
if ( mined ) {
setState( Exploded );
} else {
setState( Empty );
}
}
}
void Mine::setState( MineState s )
{
st = s;
}
void Mine::setHint( int h )
{
hint = h;
}
void Mine::paletteChange()
{
delete knownField;
knownField = 0;
delete unknownField;
unknownField = 0;
delete mine_pix;
mine_pix = 0;
delete flag_pix;
flag_pix = 0;
}
void Mine::paint( QPainter* p, const QColorGroup &cg, const QRect& cr )
{
int x = cr.x();
int y = cr.y();
if ( !knownField ) {
knownField = new QPixmap( cr.width(), cr.height() );
QPainter pp( knownField );
QBrush br( cg.button().dark(115) );
qDrawWinButton( &pp, cr, cg, TRUE, &br );
}
const int pmmarg=cr.width()/5;
if ( !unknownField ) {
unknownField = new QPixmap( cr.width(), cr.height() );
QPainter pp( unknownField );
QBrush br( cg.button() );
qDrawWinButton( &pp, cr, cg, FALSE, &br );
}
if ( !flag_pix ) {
flag_pix = new QPixmap( cr.width()-pmmarg*2, cr.height()-pmmarg*2 );
flag_pix->convertFromImage( QImage(pix_flag).smoothScale(cr.width()-pmmarg*2, cr.height()-pmmarg*2) );
}
if ( !mine_pix ) {
mine_pix = new QPixmap( cr.width()-pmmarg*2, cr.height()-pmmarg*2 );
mine_pix->convertFromImage( QImage(pix_mine).smoothScale(cr.width()-pmmarg*2, cr.height()-pmmarg*2) );
}
p->save();
switch(st) {
case Hidden:
p->drawPixmap( x, y, *unknownField );
break;
case Empty:
p->drawPixmap( x, y, *knownField );
if ( hint > 0 ) {
switch( hint ) {
case 1:
p->setPen( blue );
break;
case 2:
p->setPen( green.dark() );
break;
case 3:
p->setPen( red );
break;
case 4:
p->setPen( darkYellow.dark() );
break;
case 5:
p->setPen( darkMagenta );
break;
case 6:
p->setPen( darkRed );
break;
default:
p->setPen( black );
break;
}
p->drawText( cr, AlignHCenter | AlignVCenter, QString::number( hint ) );
}
break;
case Mined:
p->drawPixmap( x, y, *knownField );
p->drawPixmap( x+pmmarg, y+pmmarg, *mine_pix );
break;
case Exploded:
p->drawPixmap( x, y, *knownField );
p->drawPixmap( x+pmmarg, y+pmmarg, *mine_pix );
p->setPen( red );
p->drawText( cr, AlignHCenter | AlignVCenter, "X" );
break;
case Flagged:
p->drawPixmap( x, y, *unknownField );
p->drawPixmap( x+pmmarg, y+pmmarg, *flag_pix );
break;
#ifdef MARK_UNSURE
case Unsure:
p->drawPixmap( x, y, *unknownField );
p->drawText( cr, AlignHCenter | AlignVCenter, "?" );
break;
#endif
case Wrong:
p->drawPixmap( x, y, *unknownField );
p->drawPixmap( x+pmmarg, y+pmmarg, *flag_pix );
p->setPen( red );
p->drawText( cr, AlignHCenter | AlignVCenter, "X" );
break;
}
p->restore();
}
/*
MineField implementation
*/
MineField::MineField( QWidget* parent, const char* name )
: QScrollView( parent, name )
{
setState( GameOver );
setSizePolicy( QSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum ) );
setFocusPolicy( QWidget::NoFocus );
holdTimer = new QTimer( this );
connect( holdTimer, SIGNAL( timeout() ), this, SLOT( held() ) );
flagAction = NoAction;
ignoreClick = FALSE;
currRow = currCol = -1;
minecount=0;
mineguess=0;
nonminecount=0;
cellSize = -1;
mines = 0;
}
MineField::~MineField()
{
int i;
if ( mines )
{
for ( i = 0; i < numCols*numRows; i++ )
{
delete mines[i];
}
delete[] mines;
}
}
void MineField::setState( State st )
{
stat = st;
}
void MineField::setup( int level )
{
lev = level;
setState( Waiting );
//viewport()->setUpdatesEnabled( FALSE );
int i;
if ( mines )
{
for ( i = 0; i < numCols*numRows; i++ )
{
delete mines[i];
}
delete[] mines;
}
switch( lev ) {
case 1:
numRows = 9 ;
numCols = 9 ;
minecount = 12;
break;
case 2:
numRows = 16;
numCols = 16;
minecount = 45;
break;
case 3:
numCols = 18;
numRows = 18;
minecount = 66 ;
break;
}
- mines = new (Mine*)[numRows*numCols];
+ mines = new Mine*[numRows*numCols];
for ( i = 0; i < numCols*numRows; i++ )
mines[i] = new Mine( this );
nonminecount = numRows*numCols - minecount;
mineguess = minecount;
emit mineCount( mineguess );
Mine::paletteChange();
if ( availableRect.isValid() )
setCellSize(findCellSize());
// viewport()->setUpdatesEnabled( TRUE );
//viewport()->repaint( TRUE );
updateContents( 0, 0, numCols*cellSize, numRows*cellSize );
updateGeometry();
}
void MineField::drawContents( QPainter * p, int clipx, int clipy, int clipw, int cliph )
{
int c1 = clipx / cellSize;
int c2 = ( clipx + clipw - 1 ) / cellSize;
int r1 = clipy / cellSize;
int r2 = ( clipy + cliph - 1 ) / cellSize;
for ( int c = c1; c <= c2 ; c++ ) {
for ( int r = r1; r <= r2 ; r++ ) {
int x = c * cellSize;
int y = r * cellSize;
Mine *m = mine( r, c );
if ( m )
m->paint( p, colorGroup(), QRect(x, y, cellSize, cellSize ) );
}
}
}
// Chicken and egg problem: We need to know how big the parent is
// before we can decide how big to make the table.
void MineField::setAvailableRect( const QRect &r )
{
availableRect = r;
int newCellSize = findCellSize();
if ( newCellSize != cellSize ) {
viewport()->setUpdatesEnabled( FALSE );
setCellSize( newCellSize );
viewport()->setUpdatesEnabled( TRUE );
viewport()->repaint( TRUE );
}
}
int MineField::findCellSize()
{
int w = availableRect.width() - 1;
int h = availableRect.height() - 1;
int cellsize;
cellsize = QMIN( w/numCols, h/numRows );
cellsize = QMIN( QMAX( cellsize, minGrid ), maxGrid );
return cellsize;
}
void MineField::setCellSize( int cellsize )
{
cellSize = cellsize;
int w = availableRect.width();
int h = availableRect.height();
int w2 = cellsize*numCols;
int h2 = cellsize*numRows;
resizeContents( w2, h2 );
int b = 5;
setGeometry( availableRect.x() + (w-w2)/2, availableRect.y() + (h-h2)/2,
w2+b, h2+b );
// QMIN(w,w2+b), QMIN(h,h2+b) );
}
void MineField::placeMines()
{
int mines = minecount;
while ( mines ) {
int col = int((double(rand()) / double(RAND_MAX)) * numCols);
int row = int((double(rand()) / double(RAND_MAX)) * numRows);
Mine* m = mine( row, col );
if ( m && !m->isMined() && m->state() == Mine::Hidden ) {
m->setMined( TRUE );
mines--;
}
}
}
void MineField::updateCell( int r, int c )
{
updateContents( c*cellSize, r*cellSize, cellSize, cellSize );
}
void MineField::contentsMousePressEvent( QMouseEvent* e )
{
int c = e->pos().x() / cellSize;
int r = e->pos().y() / cellSize;
if ( onBoard( r, c ) )
cellPressed( r, c );
else
currCol = currRow = -1;
}
void MineField::contentsMouseReleaseEvent( QMouseEvent* e )
{
int c = e->pos().x() / cellSize;
int r = e->pos().y() / cellSize;
if ( onBoard( r, c ) && c == currCol && r == currRow )
cellClicked( r, c );
if ( flagAction == FlagNext ) {
flagAction = NoAction;
}
}
/*
state == Waiting means no "hold"
*/
void MineField::cellPressed( int row, int col )
{
if ( state() == GameOver )
return;
currRow = row;
currCol = col;
if ( state() == Playing )
holdTimer->start( 150, TRUE );
}
void MineField::held()
{
flagAction = FlagNext;
updateMine( currRow, currCol );
ignoreClick = TRUE;
}
void MineField::keyPressEvent( QKeyEvent* e )
{
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
flagAction = ( e->key() == Key_Up ) ? FlagOn : NoAction;
#else
flagAction = ( ( e->state() & ShiftButton ) == ShiftButton ) ? FlagOn : NoAction;
#endif
}
void MineField::keyReleaseEvent( QKeyEvent* )
{
flagAction = NoAction;
}
int MineField::getHint( int row, int col )
{
int hint = 0;
for ( int c = col-1; c <= col+1; c++ )
for ( int r = row-1; r <= row+1; r++ ) {
Mine* m = mine( r, c );
if ( m && m->isMined() )
hint++;
}
return hint;
}
void MineField::setHint( int row, int col )
{
Mine *m = mine( row, col );
if ( !m )
return;
int hint = getHint( row, col );
if ( !hint ) {
for ( int c = col-1; c <= col+1; c++ )
for ( int r = row-1; r <= row+1; r++ ) {
Mine* m = mine( r, c );
if ( m && m->state() == Mine::Hidden ) {
m->activate( TRUE );
nonminecount--;
setHint( r, c );
updateCell( r, c );
}
}
}
m->setHint( hint );
updateCell( row, col );
}
/*
Only place mines after first click, since it is pointless to
kill the player before the game has started.
*/
void MineField::cellClicked( int row, int col )
{
if ( state() == GameOver )
return;
if ( state() == Waiting ) {
Mine* m = mine( row, col );
if ( !m )
return;
m->setState( Mine::Empty );
nonminecount--;
placeMines();
setState( Playing );
emit gameStarted();
updateMine( row, col );
} else { // state() == Playing
holdTimer->stop();
if ( ignoreClick )
ignoreClick = FALSE;
else
updateMine( row, col );
}
}
void MineField::updateMine( int row, int col )
{
Mine* m = mine( row, col );
if ( !m )
return;
bool wasFlagged = m->state() == Mine::Flagged;
bool wasEmpty = m->state() == Mine::Empty;
m->activate( flagAction == NoAction );
if ( m->state() == Mine::Exploded ) {
emit gameOver( FALSE );
setState( GameOver );
return;
} else if ( m->state() == Mine::Empty ) {
setHint( row, col );
if ( !wasEmpty )
nonminecount--;
}
diff --git a/noncore/games/minesweep/minesweep.cpp b/noncore/games/minesweep/minesweep.cpp
index 48644b3..7214a73 100644
--- a/noncore/games/minesweep/minesweep.cpp
+++ b/noncore/games/minesweep/minesweep.cpp
@@ -1,405 +1,407 @@
/**********************************************************************
** 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 "minefield.h"
+#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include <qpe/config.h>
#include <qpe/qpetoolbar.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",
"# c #000000",
" ",
" ###### ",
" ##......## ",
" #..........# ",
" #............# ",
" #..............# ",
" #..#.#...#.#...# ",
" #....#.....#.....# ",
" #...#.#...#.#....# ",
" #................# ",
" #................# ",
" #................# ",
" #......####......# ",
" #....# #....# ",
" #...#......#...# ",
" #............# ",
" #..........# ",
" ##......## ",
" ###### ",
" "};
class ResultIndicator : private QLabel
{
public:
static void showResult( QWidget *ref, bool won );
private:
ResultIndicator( QWidget *parent, const char *name, WFlags f)
:QLabel( parent, name, f ) {}
void timerEvent( QTimerEvent *);
void center();
bool twoStage;
int timerId;
};
void ResultIndicator::showResult( QWidget *ref, bool won )
{
ResultIndicator *r = new ResultIndicator( ref, 0, WStyle_Customize | WStyle_Tool | WType_TopLevel );
r->setAlignment( AlignCenter );
r->setFrameStyle( Sunken|StyledPanel );
if ( won ) {
r->setText( MineSweep::tr("You won!") );
r->center();
r->show();
r->twoStage = FALSE;
r->timerId = r->startTimer(1500);
} else {
QPalette p( red );
r->setPalette( p );
r->setText( MineSweep::tr("You exploded!") );
r->resize( ref->size() );
r->move( ref->mapToGlobal(QPoint(0,0)) );
r->show();
r->twoStage = TRUE;
r->timerId =r->startTimer(200);
}
}
void ResultIndicator::center()
{
QWidget *w = parentWidget();
QPoint pp = w->mapToGlobal( QPoint(0,0) );
QSize s = sizeHint()*3;
pp = QPoint( pp.x() + w->width()/2 - s.width()/2,
pp.y() + w->height()/ 2 - s.height()/2 );
setGeometry( QRect(pp, s) );
}
void ResultIndicator::timerEvent( QTimerEvent *te )
{
if ( te->timerId() != timerId )
return;
killTimer( timerId );
if ( twoStage ) {
center();
twoStage = FALSE;
timerId = startTimer( 1000 );
} else {
delete this;
}
}
class MineFrame : public QFrame
{
public:
MineFrame( QWidget *parent, const char *name = 0 )
:QFrame( parent, name ) {}
void setField( MineField *f ) { field = f; }
protected:
void resizeEvent( QResizeEvent *e ) {
field->setAvailableRect( contentsRect());
QFrame::resizeEvent(e);
}
private:
MineField *field;
};
MineSweep::MineSweep( QWidget* parent, const char* name, WFlags f )
: QMainWindow( parent, name, f )
{
+ QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff );
srand(::time(0));
setCaption( tr("Mine Hunt") );
setIcon( Resource::loadPixmap( "minesweep_icon" ) );
QToolBar *toolBar = new QToolBar( this );
toolBar->setHorizontalStretchable( TRUE );
QMenuBar *menuBar = new QMenuBar( toolBar );
QPopupMenu *gameMenu = new QPopupMenu( this );
gameMenu->insertItem( tr("Beginner"), this, SLOT( beginner() ) );
gameMenu->insertItem( tr("Advanced"), this, SLOT( advanced() ) );
gameMenu->insertItem( tr("Expert"), this, SLOT( expert() ) );
menuBar->insertItem( tr("Game"), gameMenu );
guessLCD = new QLCDNumber( toolBar );
toolBar->setStretchableWidget( guessLCD );
QPalette lcdPal( red );
lcdPal.setColor( QColorGroup::Background, QApplication::palette().active().background() );
lcdPal.setColor( QColorGroup::Button, QApplication::palette().active().button() );
// guessLCD->setPalette( lcdPal );
guessLCD->setSegmentStyle( QLCDNumber::Flat );
guessLCD->setFrameStyle( QFrame::NoFrame );
guessLCD->setNumDigits( 2 );
guessLCD->setBackgroundMode( PaletteButton );
newGameButton = new QPushButton( toolBar );
newGameButton->setPixmap( QPixmap( pix_new ) );
newGameButton->setFocusPolicy(QWidget::NoFocus);
connect( newGameButton, SIGNAL(clicked()), this, SLOT(newGame()) );
timeLCD = new QLCDNumber( toolBar );
// timeLCD->setPalette( lcdPal );
timeLCD->setSegmentStyle( QLCDNumber::Flat );
timeLCD->setFrameStyle( QFrame::NoFrame );
timeLCD->setNumDigits( 5 ); // "mm:ss"
timeLCD->setBackgroundMode( PaletteButton );
setToolBarsMovable ( FALSE );
addToolBar( toolBar );
MineFrame *mainframe = new MineFrame( this );
mainframe->setFrameShape( QFrame::Box );
mainframe->setFrameShadow( QFrame::Raised );
mainframe->setLineWidth(2);
field = new MineField( mainframe );
mainframe->setField( field );
QFont fnt = field->font();
fnt.setBold( TRUE );
field->setFont( QFont( fnt ) );
field->setFocus();
setCentralWidget( mainframe );
connect( field, SIGNAL( gameOver( bool ) ), this, SLOT( gameOver( bool ) ) );
connect( field, SIGNAL( mineCount( int ) ), this, SLOT( setCounter( int ) ) );
connect( field, SIGNAL( gameStarted()), this, SLOT( startPlaying() ) );
timer = new QTimer( this );
connect( timer, SIGNAL( timeout() ), this, SLOT( updateTime() ) );
readConfig();
}
MineSweep::~MineSweep()
{
writeConfig();
}
void MineSweep::gameOver( bool won )
{
field->showMines();
if ( won ) {
newGameButton->setPixmap( QPixmap( happy_xpm ) );
} else {
newGameButton->setPixmap( QPixmap( dead_xpm ) );
}
ResultIndicator::showResult( this, won );
timer->stop();
}
void MineSweep::newGame()
{
newGame(field->level());
}
void MineSweep::newGame(int level)
{
timeLCD->display( "0:00" );
field->setup( level );
newGameButton->setPixmap( QPixmap( pix_new ) );
timer->stop();
}
void MineSweep::startPlaying()
{
newGameButton->setPixmap( QPixmap( worried_xpm ) );
starttime = QDateTime::currentDateTime();
timer->start( 1000 );
}
void MineSweep::beginner()
{
newGame(1);
}
void MineSweep::advanced()
{
newGame(2);
}
void MineSweep::expert()
{
newGame(3);
}
void MineSweep::setCounter( int c )
{
if ( !guessLCD )
return;
guessLCD->display( c );
}
void MineSweep::updateTime()
{
if ( !timeLCD )
return;
int s = starttime.secsTo(QDateTime::currentDateTime());
if ( s/60 > 99 )
timeLCD->display( "-----" );
else
timeLCD->display( QString().sprintf("%2d:%02d",s/60,s%60) );
}
void MineSweep::writeConfig() const
{
Config cfg("MineSweep");
cfg.setGroup("Panel");
cfg.writeEntry("Time",
timer->isActive() ? starttime.secsTo(QDateTime::currentDateTime()) : -1);
field->writeConfig(cfg);
}
void MineSweep::readConfig()
{
Config cfg("MineSweep");
field->readConfig(cfg);
cfg.setGroup("Panel");
int s = cfg.readNumEntry("Time",-1);
if ( s<0 ) {
newGame();
} else {
startPlaying();
starttime = QDateTime::currentDateTime().addSecs(-s);
updateTime();
}
}
diff --git a/noncore/games/minesweep/minesweep.h b/noncore/games/minesweep/minesweep.h
index e860573..527dc9e 100644
--- a/noncore/games/minesweep/minesweep.h
+++ b/noncore/games/minesweep/minesweep.h
@@ -1,67 +1,68 @@
/**********************************************************************
** 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.
**
**********************************************************************/
#ifndef MINESWEEP_H
#define MINESWEEP_H
#include <qmainwindow.h>
#include <qdatetime.h>
class MineField;
class QLCDNumber;
class QPushButton;
class MineSweep : public QMainWindow
{
Q_OBJECT
public:
+ static QString appName() { return QString::fromLatin1("minesweep"); }
MineSweep( QWidget* parent = 0, const char* name = 0, WFlags f = 0 );
~MineSweep();
public slots:
void gameOver( bool won );
void newGame();
protected slots:
void setCounter( int );
void updateTime();
void beginner();
void advanced();
void expert();
private slots:
void startPlaying();
private:
void readConfig();
void writeConfig() const;
void newGame(int);
MineField* field;
QLCDNumber* guessLCD;
QLCDNumber* timeLCD;
QPushButton* newGameButton;
QDateTime starttime;
QTimer* timer;
};
#endif // MINESWEEP_H
diff --git a/noncore/games/minesweep/minesweep.pro b/noncore/games/minesweep/minesweep.pro
index 8e4001e..9746651 100644
--- a/noncore/games/minesweep/minesweep.pro
+++ b/noncore/games/minesweep/minesweep.pro
@@ -1,15 +1,13 @@
-TEMPLATE = app
-CONFIG = qt warn_on release
-DESTDIR = $(OPIEDIR)/bin
+CONFIG = qt warn_on release quick-app
HEADERS = minefield.h \
minesweep.h
SOURCES = main.cpp \
minefield.cpp \
minesweep.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe
INTERFACES =
TARGET = minesweep
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/games/minesweep/opie-minesweep.control b/noncore/games/minesweep/opie-minesweep.control
index 32f0352..91343ea 100644
--- a/noncore/games/minesweep/opie-minesweep.control
+++ b/noncore/games/minesweep/opie-minesweep.control
@@ -1,10 +1,10 @@
Package: opie-minesweep
-Files: bin/minesweep apps/Games/minesweep.desktop pics/minesweep
+Files: plugins/application/libminesweep.so* bin/minesweep apps/Games/minesweep.desktop pics/minesweep
Priority: optional
Section: opie/games
Maintainer: Martin Imobersteg <imm@gmx.ch>
Architecture: arm
Depends: task-opie-minimal
Description: Game: find the mines
A game for the Opie environment.
Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/parashoot/interface.cpp b/noncore/games/parashoot/interface.cpp
index db98720..a40426d 100644
--- a/noncore/games/parashoot/interface.cpp
+++ b/noncore/games/parashoot/interface.cpp
@@ -1,247 +1,250 @@
/**********************************************************************
** 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 "man.h"
#include <qpe/resource.h>
+#include <qpe/qpeapplication.h>
#include <qlabel.h>
#include <qmessagebox.h>
#include <qapplication.h>
#include <qstyle.h>
#include <qpe/qpetoolbar.h>
#include <qtoolbutton.h>
ParaShoot::ParaShoot(QWidget* parent, const char* name, WFlags f) :
QMainWindow(parent,name,f),
canvas(232, 258),
fanfare("level_up"),
score(0)
{
+ QPEApplication::grabKeyboard();
+ QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff );
canvas.setAdvancePeriod(80);
QPixmap bg = Resource::loadPixmap("parashoot/sky");
canvas.setBackgroundPixmap(bg);
pb = new QCanvasView(&canvas, this);
pb->setFocus();
setToolBarsMovable( FALSE );
QToolBar* toolbar = new QToolBar(this);
toolbar->setHorizontalStretchable( TRUE );
setCaption( tr("ParaShoot") );
QPixmap newicon = Resource::loadPixmap("parashoot/manicon");
setIcon(newicon);
new QToolButton(newicon, 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);
newGame();
}
void ParaShoot::resizeEvent(QResizeEvent *)
{
QSize s = centralWidget()->size();
int fw = style().defaultFrameWidth();
canvas.resize( s.width() - fw - 2, s.height() - fw - 2);
}
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);
score = 0;
Bullet::setShotCount(0);
Bullet::setNobullets(0);
nomen = 2;
Bullet::setLimit(nomen);
level = 0;
updatespeed = 80;
showScore(0,0);
gamestopped = false;
Helicopter::deleteAll();
waitover = true;
base = new Base(&canvas);
cannon = new Cannon(&canvas);
connect( cannon, SIGNAL(score(int)), this, SLOT(increaseScore(int)));
autoDropTimer->start(100);
}
void ParaShoot::clear()
{
autoDropTimer->stop();
// QCanvasItem* item;
QCanvasItemList l = canvas.allItems();
for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) {
delete *it;
}
}
void ParaShoot::gameOver()
{
QCanvasItem* item;
QCanvasItemList l = canvas.allItems();
for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) {
item = *it;
if ((item->rtti()==1500) || (item->rtti()==1600) || item->rtti()==1900)
item->setAnimated(false);
}
autoDropTimer->stop();
Helicopter::silenceAll();
int shots = Bullet::getShotCount();
int shotsFired = cannon->shotsFired();
if ( shotsFired == 0 )
shotsFired = 1;
QCanvasText* gameover = new QCanvasText(
tr( " GAME OVER!\n"
" Your Score: %1\n"
" Parachuters Killed: %2\n"
" Accuracy: %3% " ).arg(score).arg(shots).arg(shots * 100 / shotsFired ),
&canvas);
gameover->setColor(red);
gameover->setFont( QFont("times", 18, QFont::Bold) );
gameover->move(canvas.width()/2 -110, canvas.height()/2 -50);
gameover->setZ(500);
gameover->show();
gamestopped = true;
waitover = false;
pauseTimer->start(3000);
}
void ParaShoot::wait()
{
waitover = true;
pauseTimer->stop();
}
void ParaShoot::play()
{
if (Man::getManCount() < nomen ) {
new Man(&canvas);
}
if (Base::baseDestroyed()) {
gameOver();
return;
}
}
void ParaShoot::increaseScore(int x)
{
score += x;
if ( score / 150 != (score-x) / 150 )
levelUp();
showScore(level,score);
}
void ParaShoot::levelUp()
{
level++;
int stage = level % 3;
switch(stage) {
case 0:
nomen++;
Bullet::setLimit(nomen);
fanfare.play();
break;
case 1:
new Helicopter(&canvas);
break;
case 2:
moveFaster();
fanfare.play();
break;
default: return;
}
}
void ParaShoot::moveFaster()
{
if (updatespeed > 50)
updatespeed = updatespeed-5;
else
updatespeed = updatespeed-3;
canvas.setAdvancePeriod(updatespeed);
}
void ParaShoot::keyPressEvent(QKeyEvent* event)
{
if (gamestopped) {
if (waitover)
newGame();
else
return;
} else {
switch(event->key()) {
case Key_Up:
case Key_F1:
case Key_F9:
case Key_Space:
cannon->shoot();
break;
case Key_Left:
cannon->pointCannon(Cannon::Left);
lastcannonkey=Key_Left;
break;
case Key_Right:
cannon->pointCannon(Cannon::Right);
lastcannonkey=Key_Right;
break;
default:
return;
}
}
}
void ParaShoot::keyReleaseEvent(QKeyEvent* event)
{
if ( lastcannonkey == event->key() )
cannon->pointCannon(Cannon::NoDir);
}
diff --git a/noncore/games/parashoot/interface.h b/noncore/games/parashoot/interface.h
index 3f36d0b..5abbe0b 100644
--- a/noncore/games/parashoot/interface.h
+++ b/noncore/games/parashoot/interface.h
@@ -1,79 +1,80 @@
/**********************************************************************
** 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 "cannon.h"
#include "base.h"
#include "helicopter.h"
#include <qpe/sound.h>
#include <qmainwindow.h>
#include <qtimer.h>
#include <qlabel.h>
class QCanvas;
class Helicopter;
//enum Direction{
// left, right, up, down };
class ParaShoot : public QMainWindow {
Q_OBJECT
public:
+ static QString appName() { return QString::fromLatin1("parashoot"); }
ParaShoot(QWidget* parent=0, const char* name=0, WFlags f=0);
void clear();
void gameOver();
int mancount;
void levelUp();
void moveFaster();
protected:
virtual void keyPressEvent(QKeyEvent*);
virtual void keyReleaseEvent(QKeyEvent*);
virtual void resizeEvent(QResizeEvent *e);
private slots:
void increaseScore(int);
void newGame();
void play();
void wait();
private:
void showScore( int score, int level );
QCanvasView* pb;
QCanvas canvas;
Cannon* cannon;
Base* base;
QCanvasText* gameover;
QLabel* levelscore;
int nomen;
int level;
int oldscore;
int updatespeed;
QTimer* autoDropTimer;
QTimer* pauseTimer;
bool gamestopped;
bool waitover;
Sound fanfare;
int score;
int lastcannonkey;
};
diff --git a/noncore/games/parashoot/main.cpp b/noncore/games/parashoot/main.cpp
index 60eea18..ee36d26 100644
--- a/noncore/games/parashoot/main.cpp
+++ b/noncore/games/parashoot/main.cpp
@@ -1,36 +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 "interface.h"
#include <qpe/qpeapplication.h>
+#include <opie/oapplicationfactory.h>
-int main(int argc, char **argv)
-{
- QPEApplication app(argc,argv);
+OPIE_EXPORT_APP( OApplicationFactory<ParaShoot> )
- QPEApplication::grabKeyboard();
-
- ParaShoot m;
- QPEApplication::setInputMethodHint( &m, QPEApplication::AlwaysOff );
- app.showMainWidget(&m);
-
- return app.exec();
-}
diff --git a/noncore/games/parashoot/opie-parashoot.control b/noncore/games/parashoot/opie-parashoot.control
index 758d24d..139dd3c 100644
--- a/noncore/games/parashoot/opie-parashoot.control
+++ b/noncore/games/parashoot/opie-parashoot.control
@@ -1,10 +1,10 @@
Package: opie-parashoot
-Files: bin/parashoot apps/Games/parashoot.desktop pics/parashoot
+Files: plugins/application/libparashoot.so* bin/parashoot apps/Games/parashoot.desktop pics/parashoot
Priority: optional
Section: opie/games
Maintainer: Martin Imobersteg <imm@gmx.ch>
Architecture: arm
Depends: task-opie-minimal
Description: Game: shoot the parachutists
A game for the Opie environment.
Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/parashoot/parashoot.pro b/noncore/games/parashoot/parashoot.pro
index c2746f9..f5d103a 100644
--- a/noncore/games/parashoot/parashoot.pro
+++ b/noncore/games/parashoot/parashoot.pro
@@ -1,11 +1,11 @@
-TEMPLATE = app
-CONFIG += qt warn_on release
-DESTDIR = $(OPIEDIR)/bin
+CONFIG += qt warn_on release quick-app
HEADERS = interface.h man.h cannon.h base.h bullet.h helicopter.h
SOURCES = main.cpp interface.cpp man.cpp cannon.cpp base.cpp bullet.cpp helicopter.cpp
TARGET = parashoot
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe
+
+
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/games/qasteroids/main.cpp b/noncore/games/qasteroids/main.cpp
index 7d1682c..c762990 100644
--- a/noncore/games/qasteroids/main.cpp
+++ b/noncore/games/qasteroids/main.cpp
@@ -1,36 +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 "toplevel.h"
#include <qpe/qpeapplication.h>
+#include <opie/oapplicationfactory.h>
-int main( int argc, char *argv[] )
-{
- QPEApplication app( argc, argv );
-
- QPEApplication::grabKeyboard();
-
- KAstTopLevel *mainWidget = new KAstTopLevel();
- app.showMainWidget( mainWidget );
-
- app.exec();
-}
+OPIE_EXPORT_APP( OApplicationFactory<KAstTopLevel> )
diff --git a/noncore/games/qasteroids/opie-qasteroids.control b/noncore/games/qasteroids/opie-qasteroids.control
index 25a49b4..8764578 100644
--- a/noncore/games/qasteroids/opie-qasteroids.control
+++ b/noncore/games/qasteroids/opie-qasteroids.control
@@ -1,10 +1,10 @@
Package: opie-qasteroids
-Files: bin/qasteroids apps/Games/qasteroids.desktop pics/qasteroids/*
+Files: plugins/application/libqasteroids.so* bin/qasteroids apps/Games/qasteroids.desktop pics/qasteroids/*
Priority: optional
Section: opie/games
Maintainer: Martin Jones <mjones@trolltech.com>
Architecture: arm
Depends: task-opie-minimal
Description: Game: shoot the asteroids
A game for the Opie environment.
Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/qasteroids/qasteroids.pro b/noncore/games/qasteroids/qasteroids.pro
index 1a3a8d5..aafc701 100644
--- a/noncore/games/qasteroids/qasteroids.pro
+++ b/noncore/games/qasteroids/qasteroids.pro
@@ -1,11 +1,11 @@
-TEMPLATE = app
-CONFIG += qt warn_on release
-DESTDIR = $(OPIEDIR)/bin
+CONFIG += qt warn_on release quick-app
HEADERS = ledmeter.h sprites.h toplevel.h view.h
SOURCES = ledmeter.cpp toplevel.cpp view.cpp main.cpp
TARGET = qasteroids
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe
+
+
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/games/qasteroids/toplevel.cpp b/noncore/games/qasteroids/toplevel.cpp
index 71daf60..c4fea89 100644
--- a/noncore/games/qasteroids/toplevel.cpp
+++ b/noncore/games/qasteroids/toplevel.cpp
@@ -1,346 +1,349 @@
/**********************************************************************
** 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 )
- : QMainWindow( parent, _name )
+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 );
hb->addWidget( scoreLCD );
hb->addStretch( 1 );
label = new QLabel( tr("Level"), mainWin );
label->setFont( labelFont );
label->setPalette( pal );
// label->setFixedWidth( label->sizeHint().width() );
hb->addWidget( label );
levelLCD = new QLCDNumber( 2, mainWin );
levelLCD->setFrameStyle( QFrame::NoFrame );
levelLCD->setSegmentStyle( QLCDNumber::Flat );
levelLCD->setFixedHeight( 16 );
levelLCD->setPalette( pal );
hb->addWidget( levelLCD );
hb->addStretch( 1 );
label = new QLabel( tr("Ships"), mainWin );
label->setFont( labelFont );
// label->setFixedWidth( label->sizeHint().width() );
label->setPalette( pal );
hb->addWidget( label );
shipsLCD = new QLCDNumber( 1, mainWin );
shipsLCD->setFrameStyle( QFrame::NoFrame );
shipsLCD->setSegmentStyle( QLCDNumber::Flat );
shipsLCD->setFixedHeight( 16 );
shipsLCD->setPalette( pal );
hb->addWidget( shipsLCD );
// hb->addStrut( 14 );
vb->addWidget( view, 10 );
// -- bottom layout:
vb->addLayout( hbd );
QFont smallFont( "helvetica", 12 );
hbd->addSpacing( 5 );
/*
label = new QLabel( tr( "T" ), mainWin );
label->setFont( smallFont );
label->setFixedWidth( label->sizeHint().width() );
label->setPalette( pal );
hbd->addWidget( label );
teleportsLCD = new QLCDNumber( 1, mainWin );
teleportsLCD->setFrameStyle( QFrame::NoFrame );
teleportsLCD->setSegmentStyle( QLCDNumber::Flat );
teleportsLCD->setPalette( pal );
teleportsLCD->setFixedHeight( 18 );
hbd->addWidget( teleportsLCD );
hbd->addSpacing( 10 );
*/
label = new QLabel( mainWin );
label->setPixmap( Resource::loadPixmap("qasteroids/powerups/brake.png") );
label->setFixedWidth( 16 );
label->setPalette( pal );
hbd->addWidget( label );
brakesLCD = new QLCDNumber( 1, mainWin );
brakesLCD->setFrameStyle( QFrame::NoFrame );
brakesLCD->setSegmentStyle( QLCDNumber::Flat );
brakesLCD->setPalette( pal );
brakesLCD->setFixedHeight( 16 );
hbd->addWidget( brakesLCD );
hbd->addSpacing( 5 );
label = new QLabel( mainWin );
label->setPixmap( Resource::loadPixmap("qasteroids/powerups/shield.png") );
label->setFixedWidth( 16 );
label->setPalette( pal );
hbd->addWidget( label );
shieldLCD = new QLCDNumber( 1, mainWin );
shieldLCD->setFrameStyle( QFrame::NoFrame );
shieldLCD->setSegmentStyle( QLCDNumber::Flat );
shieldLCD->setPalette( pal );
shieldLCD->setFixedHeight( 16 );
hbd->addWidget( shieldLCD );
hbd->addSpacing( 5 );
label = new QLabel( mainWin );
label->setPixmap( Resource::loadPixmap("qasteroids/powerups/shoot.png") );
label->setFixedWidth( 16 );
label->setPalette( pal );
hbd->addWidget( label );
shootLCD = new QLCDNumber( 1, mainWin );
shootLCD->setFrameStyle( QFrame::NoFrame );
shootLCD->setSegmentStyle( QLCDNumber::Flat );
shootLCD->setPalette( pal );
shootLCD->setFixedHeight( 16 );
hbd->addWidget( shootLCD );
hbd->addStretch( 1 );
label = new QLabel( tr( "Fuel" ), mainWin );
label->setFont( smallFont );
label->setFixedWidth( label->sizeHint().width() + 5 );
label->setPalette( pal );
hbd->addWidget( label );
powerMeter = new KALedMeter( mainWin );
powerMeter->setFrameStyle( QFrame::Box | QFrame::Plain );
powerMeter->setRange( MAX_POWER_LEVEL );
powerMeter->addColorRange( 10, darkRed );
powerMeter->addColorRange( 20, QColor(160, 96, 0) );
powerMeter->addColorRange( 70, darkGreen );
powerMeter->setCount( 15 );
powerMeter->setPalette( pal );
powerMeter->setFixedSize( 60, 12 );
hbd->addWidget( powerMeter );
shipsRemain = 3;
showHiscores = FALSE;
actions.insert( Qt::Key_Up, Thrust );
actions.insert( Qt::Key_Left, RotateLeft );
actions.insert( Qt::Key_Right, RotateRight );
actions.insert( Qt::Key_Enter, Shoot );
actions.insert( Qt::Key_Z, Teleport );
actions.insert( Qt::Key_Down, Brake );
actions.insert( Qt::Key_P, Pause );
struct utsname name; /* check for embedix kernel running on the zaurus, if
lineo change string, this break
*/
if (uname(&name) != -1) {
QString release=name.release;
if(release.find("embedix",0,TRUE) !=-1) {
actions.insert( Key_F12, Launch );
actions.insert( Key_F11, Shield );
actions.insert( Key_F9, NewGame );
} else {
// ipaq
actions.insert( Key_F12, Shoot );
actions.insert( Key_F11, Shield );
actions.insert( Key_F10, Launch );
actions.insert( Key_F9, NewGame );
}
}
// actions.insert( Qt::Key_S, Shield );
// actions.insert( Qt::Key_X, Brake );
// actions.insert( Qt::Key_L, Launch );
actions.insert( Qt::Key_Space, Shoot );
view->showText( tr( "Press Calendar to start playing" ), yellow );
setFocusPolicy( StrongFocus );
slotNewGame();
}
KAstTopLevel::~KAstTopLevel()
{
}
void KAstTopLevel::playSound( const char * )
{
}
void KAstTopLevel::keyPressEvent( QKeyEvent *event )
{
if ( event->isAutoRepeat() || !actions.contains( event->key() ) )
{
event->ignore();
return;
}
Action a = actions[ event->key() ];
switch ( a )
{
case RotateLeft:
view->rotateLeft( TRUE );
break;
case RotateRight:
view->rotateRight( TRUE );
break;
case Thrust:
view->thrust( TRUE );
break;
case Shoot:
view->shoot( TRUE );
break;
case Shield:
view->setShield( TRUE );
break;
case Teleport:
view->teleport( TRUE );
break;
case Brake:
view->brake( TRUE );
break;
default:
event->ignore();
return;
}
event->accept();
}
void KAstTopLevel::keyReleaseEvent( QKeyEvent *event )
{
diff --git a/noncore/games/qasteroids/toplevel.h b/noncore/games/qasteroids/toplevel.h
index 4e1ac9c..0270763 100644
--- a/noncore/games/qasteroids/toplevel.h
+++ b/noncore/games/qasteroids/toplevel.h
@@ -1,99 +1,101 @@
/**********************************************************************
** 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
*/
#ifndef __KAST_TOPLEVEL_H__
#define __KAST_TOPLEVEL_H__
#include <qmainwindow.h>
#include <qdict.h>
#include <qmap.h>
#include "view.h"
class KALedMeter;
class QLCDNumber;
class KAstTopLevel : public QMainWindow
{
Q_OBJECT
public:
- KAstTopLevel( QWidget *parent=0, const char *name=0 );
+ KAstTopLevel( QWidget *parent=0, const char *name=0, WFlags fl = 0 );
virtual ~KAstTopLevel();
+ static QString appName() { return QString::fromLatin1("qasteroids"); }
+
private:
void playSound( const char *snd );
void readSoundMapping();
void doStats();
protected:
virtual void showEvent( QShowEvent * );
virtual void hideEvent( QHideEvent * );
virtual void keyPressEvent( QKeyEvent *event );
virtual void keyReleaseEvent( QKeyEvent *event );
virtual void focusInEvent( QFocusEvent *event );
virtual void focusOutEvent( QFocusEvent *event );
private slots:
void slotNewGame();
void slotShipKilled();
void slotRockHit( int size );
void slotRocksRemoved();
void slotUpdateVitals();
private:
KAsteroidsView *view;
QLCDNumber *scoreLCD;
QLCDNumber *levelLCD;
QLCDNumber *shipsLCD;
QLCDNumber *teleportsLCD;
// QLCDNumber *bombsLCD;
QLCDNumber *brakesLCD;
QLCDNumber *shieldLCD;
QLCDNumber *shootLCD;
KALedMeter *powerMeter;
bool sound;
QDict<QString> soundDict;
// waiting for user to press Enter to launch a ship
bool waitShip;
bool isPaused;
int shipsRemain;
int score;
int level;
bool showHiscores;
enum Action { Launch, Thrust, RotateLeft, RotateRight, Shoot, Teleport,
Brake, Shield, Pause, NewGame };
QMap<int,Action> actions;
};
#endif
diff --git a/noncore/games/snake/interface.cpp b/noncore/games/snake/interface.cpp
index f1227cb..2c60693 100644
--- a/noncore/games/snake/interface.cpp
+++ b/noncore/games/snake/interface.cpp
@@ -1,221 +1,223 @@
/**********************************************************************
** 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);
gamestopped = false;
waitover = true;
int y = canvas.height()-50;
(void)new Obstacle(&canvas, 32);
(void)new Obstacle(&canvas, y);
createTargets();
}
void SnakeGame::showScore(int score)
{
scorelabel->setText(tr(" Score : %1 ").arg(score) );
}
void SnakeGame::scoreInc()
{
showScore( snake->getScore() );
}
void SnakeGame::levelUp()
{
notargets--;
if (notargets == 0) {
stage++;
if (stage == 3) {
level++;
emit moveFaster();
targetamount++;
stage = 0;
}
createTargets();
}
}
void SnakeGame::createTargets()
{
for (int i = 0; i < targetamount; i++)
(void)new Target(&canvas);
notargets = targetamount;
}
void SnakeGame::clear()
{
delete snake;
snake = 0;
QCanvasItemList l = canvas.allItems();
for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) {
delete *it;
}
}
void SnakeGame::gameOver()
{
int score = snake->getScore();
QString scoreoutput="";
scoreoutput.setNum(score);
QCanvasText* gameover = new QCanvasText(tr("GAME OVER!\n Your Score: %1").arg( scoreoutput), &canvas);
gameover->setZ(100);
gameover->setColor(yellow);
gameover->setFont( QFont("times", 18, QFont::Bold) );
int w = gameover->boundingRect().width();
gameover->move(canvas.width()/2 -w/2, canvas.height()/2 -50);
gameover->show();
gamestopped = true;
waitover = false;
pauseTimer->start(1500);
}
void SnakeGame::wait()
{
waitover = true;
pauseTimer->stop();
QCanvasText* cont = new QCanvasText(tr("Press any key to begin a new game."),
&canvas);
cont->setZ(100);
cont->setColor(white);
int w = cont->boundingRect().width();
cont->move(canvas.width()/2 -w/2, canvas.height()/2);
cont->show();
}
void SnakeGame::keyPressEvent(QKeyEvent* event)
{
if (gamestopped) {
if (waitover)
newGame();
else
return;
}
else {
int newkey = event->key();
snake->go(newkey);
}
}
diff --git a/noncore/games/snake/interface.h b/noncore/games/snake/interface.h
index 454d4ee..fa1dee4 100644
--- a/noncore/games/snake/interface.h
+++ b/noncore/games/snake/interface.h
@@ -1,69 +1,72 @@
/**********************************************************************
** 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 <qmainwindow.h>
+#include <qpe/qpeapplication.h>
#include <qcanvas.h>
#include <qlabel.h>
#include "snake.h"
#include "target.h"
#include "obstacle.h"
// class QCanvas;
class SnakeGame : public QMainWindow {
Q_OBJECT
public:
SnakeGame(QWidget* parent=0, const char* name=0, WFlags f=0);
~SnakeGame();
void clear();
void createTargets();
+ static QString appName() { return QString::fromLatin1("snake"); }
+
protected:
virtual void keyPressEvent(QKeyEvent*);
virtual void resizeEvent(QResizeEvent *e);
signals:
void moveFaster();
private slots:
void newGame();
void gameOver();
void wait();
void levelUp();
void scoreInc();
void welcomescreen();
private:
void showScore(int);
QCanvasView* cv;
QLabel* scorelabel;
QCanvas canvas;
QTimer* pauseTimer;
Snake* snake;
int last;
int level;
int stage;
int targetamount;
int notargets;
bool waitover;
bool gamestopped;
};
diff --git a/noncore/games/snake/main.cpp b/noncore/games/snake/main.cpp
index 90a93b7..77a2769 100644
--- a/noncore/games/snake/main.cpp
+++ b/noncore/games/snake/main.cpp
@@ -1,35 +1,29 @@
/**********************************************************************
** 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>
-int main(int argc, char **argv)
-{
- QPEApplication app(argc,argv);
+OPIE_EXPORT_APP( OApplicationFactory<SnakeGame> )
- SnakeGame* m = new SnakeGame;
- QPEApplication::setInputMethodHint( m, QPEApplication::AlwaysOff );
- app.showMainWidget(m);
- return app.exec();
-}
diff --git a/noncore/games/snake/opie-snake.control b/noncore/games/snake/opie-snake.control
index ef4fc61..f110acd 100644
--- a/noncore/games/snake/opie-snake.control
+++ b/noncore/games/snake/opie-snake.control
@@ -1,10 +1,10 @@
Package: opie-snake
-Files: bin/snake apps/Games/snake.desktop pics/snake
+Files: plugins/application/libsnake.so* bin/snake apps/Games/snake.desktop pics/snake
Priority: optional
Section: opie/games
Maintainer: Martin Imobersteg <imm@gmx.ch>
Architecture: arm
Depends: task-opie-minimal
Description: Game: control the snake
A game for the Opie environment.
Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/snake/snake.pro b/noncore/games/snake/snake.pro
index 3da8631..2b7444c 100644
--- a/noncore/games/snake/snake.pro
+++ b/noncore/games/snake/snake.pro
@@ -1,11 +1,10 @@
-TEMPLATE = app
-CONFIG += qt warn_on release
-DESTDIR = $(OPIEDIR)/bin
+CONFIG += qt warn_on release quick-app
HEADERS = snake.h target.h obstacle.h interface.h codes.h
SOURCES = snake.cpp target.cpp obstacle.cpp interface.cpp main.cpp
TARGET = snake
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe
+
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/games/solitaire/canvascardwindow.cpp b/noncore/games/solitaire/canvascardwindow.cpp
index dec5591..c12344a 100644
--- a/noncore/games/solitaire/canvascardwindow.cpp
+++ b/noncore/games/solitaire/canvascardwindow.cpp
@@ -1,295 +1,296 @@
/**********************************************************************
** 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 );
setCaption(tr("Freecell"));
setCentralWidget(cardGame);
//cardGame->newGame(); // Until we know how to handle reading freecell config
cardGame->readConfig( cfg );
setCardBacks();
} else if ( gameType == 2 ) {
cardGame = new ChicaneCardGame( &canvas, snapOn, this );
cardGame->setNumberToDraw(1);
setCaption(tr("Chicane"));
setCentralWidget(cardGame);
cardGame->readConfig( cfg );
setCardBacks();
} else if ( gameType == 3 ) {
cardGame = new HarpCardGame( &canvas, snapOn, this );
cardGame->setNumberToDraw(1);
setCaption(tr("Harp"));
setCentralWidget(cardGame);
cardGame->readConfig( cfg );
setCardBacks();
} else if ( gameType == 4 ) {
cardGame = new TeeclubCardGame( &canvas, snapOn, this );
cardGame->setNumberToDraw(1);
setCaption(tr("Teeclub"));
setCentralWidget(cardGame);
cardGame->readConfig( cfg );
setCardBacks();
} else {
// Probably there isn't a config file or it is broken
// Start a new game
initPatience();
}
updateDraw();
}
CanvasCardWindow::~CanvasCardWindow()
{
if (cardGame) {
Config cfg("Patience");
cfg.setGroup( "GlobalSettings" );
cfg.writeEntry( "GameType", gameType );
cfg.writeEntry( "SnapOn", snapOn );
cfg.writeEntry( "DrawThree", drawThree);
cfg.write();
cardGame->writeConfig( cfg );
delete cardGame;
}
}
void CanvasCardWindow::resizeEvent(QResizeEvent *)
{
QSize s = centralWidget()->size();
int fw = style().defaultFrameWidth();
canvas.resize( s.width() - fw - 2, s.height() - fw - 2);
}
void CanvasCardWindow::initPatience()
{
// Create New Game
if ( cardGame )
delete cardGame;
cardGame = new PatienceCardGame( &canvas, snapOn, this );
cardGame->setNumberToDraw(drawThree ? 3 : 1);
gameType = 0;
setCaption(tr("Patience"));
setCentralWidget(cardGame);
cardGame->newGame();
setCardBacks();
updateDraw();
}
void CanvasCardWindow::initFreecell()
{
// Create New Game
if ( cardGame ) {
delete cardGame;
}
cardGame = new FreecellCardGame( &canvas, snapOn, this );
gameType = 1;
setCaption(tr("Freecell"));
setCentralWidget(cardGame);
cardGame->newGame();
setCardBacks();
}
void CanvasCardWindow::initChicane()
{
// Create New Game
if ( cardGame ) {
delete cardGame;
}
cardGame = new ChicaneCardGame( &canvas, snapOn, this );
cardGame->setNumberToDraw(1);
gameType = 2;
setCaption(tr("Chicane"));
setCentralWidget(cardGame);
cardGame->newGame();
setCardBacks();
}
void CanvasCardWindow::initHarp()
{
// Create New Game
if ( cardGame ) {
delete cardGame;
}
cardGame = new HarpCardGame( &canvas, snapOn, this );
cardGame->setNumberToDraw(1);
gameType = 3;
setCaption(tr("Harp"));
setCentralWidget(cardGame);
cardGame->newGame();
setCardBacks();
}
void CanvasCardWindow::initTeeclub()
{
// Create New Game
if ( cardGame ) {
delete cardGame;
}
cardGame = new TeeclubCardGame( &canvas, snapOn, this );
cardGame->setNumberToDraw(1);
gameType = 4;
setCaption(tr("Teeclub"));
setCentralWidget(cardGame);
cardGame->newGame();
setCardBacks();
}
void CanvasCardWindow::snapToggle()
{
snapOn = !snapOn;
settings->setItemChecked(snap_id, snapOn);
cardGame->toggleSnap();
}
void CanvasCardWindow::drawnToggle()
{
drawThree=!drawThree;
Config cfg( "Patience" );
cfg.setGroup( "GlobalSettings" );
cardGame->toggleCardsDrawn();
updateDraw();
cfg.writeEntry( "DrawThree", drawThree);
cfg.write();
}
void CanvasCardWindow::updateDraw() {
if(cardGame->cardsDrawn() == 3){
settings->changeItem(drawId, tr("Turn one card"));
} else {
settings->changeItem(drawId, tr("Turn three cards"));
}
}
void CanvasCardWindow::setCardBacks()
{
QCanvasItemList l = canvas.allItems();
diff --git a/noncore/games/solitaire/canvascardwindow.h b/noncore/games/solitaire/canvascardwindow.h
index eddb184..abd6af6 100644
--- a/noncore/games/solitaire/canvascardwindow.h
+++ b/noncore/games/solitaire/canvascardwindow.h
@@ -1,73 +1,74 @@
/**********************************************************************
** 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.
**
**********************************************************************/
#ifndef CANVAS_CARD_WINDOW_H
#define CANVAS_CARD_WINDOW_H
#include <qmainwindow.h>
#include <qcanvas.h>
class CanvasCardGame;
class QPopupMenu;
class CanvasCardWindow : public QMainWindow {
Q_OBJECT
public:
+ static QString appName() { return QString::fromLatin1("patience"); }
CanvasCardWindow(QWidget* parent=0, const char* name=0, WFlags f=0);
virtual ~CanvasCardWindow();
public slots:
void setCardBacks();
void changeCardBacks();
void snapToggle();
void drawnToggle();
private slots:
void initFreecell();
void initPatience();
void initChicane();
void initHarp();
void initTeeclub();
protected:
virtual void resizeEvent(QResizeEvent *e);
void updateDraw();
private:
QCanvas canvas;
bool snapOn;
bool drawThree;
int drawId;
int cardBack;
int gameType;
CanvasCardGame *cardGame;
QPopupMenu* options;
QPopupMenu* settings;
int dbf_id;
int snap_id;
};
#endif
diff --git a/noncore/games/solitaire/carddeck.cpp b/noncore/games/solitaire/carddeck.cpp
index a2d0076..b130131 100644
--- a/noncore/games/solitaire/carddeck.cpp
+++ b/noncore/games/solitaire/carddeck.cpp
@@ -1,91 +1,91 @@
/**********************************************************************
** 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 <stdlib.h>
#include <time.h>
#include "card.h"
#include "carddeck.h"
CardDeck::CardDeck(int jokers, int numOfDecks) : numberOfJokers(jokers), numberOfDecks(numOfDecks), deckCreated(FALSE)
{
- cards = new (Card *)[getNumberOfCards()];
+ cards = new Card *[getNumberOfCards()];
}
CardDeck::~CardDeck()
{
for (int i = 0; i < getNumberOfCards(); i++)
delete cards[i];
delete cards;
}
void CardDeck::createDeck()
{
if (!deckCreated) {
for (int j = 0; j < getNumberOfDecks(); j++) {
for (int i = 0; i < 52; i++) {
cards[i+j*52] = newCard( (eValue)((i % 13) + 1), (eSuit)((i / 13) + 1), FALSE);
cards[i+j*52]->setDeckNumber(j);
}
}
for (int i = 0; i < getNumberOfJokers(); i++)
cards[52*getNumberOfDecks() + i] = newCard( jokerVal, jokerSuit, FALSE);
deckCreated = TRUE;
}
}
void CardDeck::shuffle()
{
srand(time(NULL));
for (int i = 0; i < getNumberOfCards(); i++) {
int index = rand() % getNumberOfCards();
Card *tmpCard = cards[i];
cards[i] = cards[index];
cards[index] = tmpCard;
}
}
int CardDeck::getNumberOfCards()
{
return 52*getNumberOfDecks() + getNumberOfJokers();
}
int CardDeck::getNumberOfDecks()
{
return numberOfDecks;
}
int CardDeck::getNumberOfJokers()
{
return numberOfJokers;
}
Card *CardDeck::newCard( eValue v, eSuit s, bool f)
{
return new Card(v, s, f);
}
diff --git a/noncore/games/solitaire/main.cpp b/noncore/games/solitaire/main.cpp
index f81aa3c..bd3cf8b 100644
--- a/noncore/games/solitaire/main.cpp
+++ b/noncore/games/solitaire/main.cpp
@@ -1,36 +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 "canvascardwindow.h"
#include <qpe/qpeapplication.h>
+#include <opie/oapplicationfactory.h>
-
-int main( int argc, char ** argv )
-{
- QPEApplication a( argc, argv );
-
- CanvasCardWindow m;
- m.setCaption( CanvasCardWindow::tr("Patience") );
- a.showMainWidget( &m );
-
- return a.exec();
-}
-
+OPIE_EXPORT_APP( OApplicationFactory<CanvasCardWindow> ) \ No newline at end of file
diff --git a/noncore/games/solitaire/solitaire.pro b/noncore/games/solitaire/solitaire.pro
index 1ac62c3..b1b8bda 100755
--- a/noncore/games/solitaire/solitaire.pro
+++ b/noncore/games/solitaire/solitaire.pro
@@ -1,21 +1,20 @@
-TEMPLATE = app
-CONFIG += qt warn_on release
-DESTDIR = $(OPIEDIR)/bin
+CONFIG += qt warn_on release quick-app
HEADERS = canvascard.h canvasshapes.h cardgame.h cardgamelayout.h cardpile.h card.h carddeck.h \
canvascardgame.h freecellcardgame.h chicanecardgame.h harpcardgame.h teeclubcardgame.h \
patiencecardgame.h canvascardwindow.h
SOURCES = canvascard.cpp canvasshapes.cpp cardgame.cpp cardgamelayout.cpp \
cardpile.cpp card.cpp carddeck.cpp canvascardgame.cpp freecellcardgame.cpp \
chicanecardgame.cpp harpcardgame.cpp teeclubcardgame.cpp \
patiencecardgame.cpp canvascardwindow.cpp main.cpp
TARGET = patience
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe
+
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/games/tetrix/main.cpp b/noncore/games/tetrix/main.cpp
index e36d52d..fcf4b33 100644
--- a/noncore/games/tetrix/main.cpp
+++ b/noncore/games/tetrix/main.cpp
@@ -1,33 +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 "qtetrix.h"
#include <qpe/qpeapplication.h>
-int main( int argc, char **argv )
-{
- QPEApplication a(argc,argv);
+#include <opie/oapplicationfactory.h>
- QTetrix *tetrix = new QTetrix;
- a.showMainWidget(tetrix);
+OPIE_EXPORT_APP( OApplicationFactory<QTetrix> )
- return a.exec();
-}
diff --git a/noncore/games/tetrix/opie-tetrix.control b/noncore/games/tetrix/opie-tetrix.control
index e901dbf..b1e0bcf 100644
--- a/noncore/games/tetrix/opie-tetrix.control
+++ b/noncore/games/tetrix/opie-tetrix.control
@@ -1,11 +1,11 @@
Package: opie-tetrix
-Files: bin/tetrix apps/Games/tetrix.desktop pics/tetrix/*
+Files: plugins/application/libtetrix.so* bin/tetrix apps/Games/tetrix.desktop pics/tetrix/*
Priority: optional
Section: opie/games
Maintainer: Martin Imobersteg <imm@gmx.ch>
Architecture: arm
Arch: iPAQ
Depends: task-opie-minimal
Description: Game: control falling blocks
A game for the Opie environment.
Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/games/tetrix/qtetrix.h b/noncore/games/tetrix/qtetrix.h
index cb33941..c8959c5 100644
--- a/noncore/games/tetrix/qtetrix.h
+++ b/noncore/games/tetrix/qtetrix.h
@@ -1,76 +1,77 @@
/**********************************************************************
** 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.
**
**********************************************************************/
#ifndef QTETRIX_H
#define QTETRIX_H
#include "qtetrixb.h"
#include <qframe.h>
#include <qlcdnumber.h>
#include <qpushbutton.h>
#include <qpainter.h>
#include <qmainwindow.h>
class QLabel;
class ShowNextPiece : public QFrame
{
Q_OBJECT
friend class QTetrix;
public:
ShowNextPiece( QWidget *parent=0, const char *name=0 );
public slots:
void drawNextSquare( int x, int y,QColor *color );
signals:
void update();
private:
void paintEvent( QPaintEvent * );
void resizeEvent( QResizeEvent * );
int blockWidth,blockHeight;
int xOffset,yOffset;
};
class QTetrix : public QMainWindow
{
Q_OBJECT
public:
+ static QString appName() { return QString::fromLatin1("tetrix"); }
QTetrix( QWidget *parent=0, const char *name=0, WFlags f=0 );
void startGame() { board->startGame(); }
public slots:
void gameOver();
void quit();
private:
void keyPressEvent( QKeyEvent *e ) { board->keyPressEvent(e); }
QTetrixBoard *board;
ShowNextPiece *showNext;
QLabel *showScore;
QLabel *showLevel;
QLabel *showLines;
};
void drawTetrixButton( QPainter *, int x, int y, int w, int h,
const QColor *color );
#endif
diff --git a/noncore/games/tetrix/tetrix.pro b/noncore/games/tetrix/tetrix.pro
index 35fe82b..3b95c84 100644
--- a/noncore/games/tetrix/tetrix.pro
+++ b/noncore/games/tetrix/tetrix.pro
@@ -1,21 +1,22 @@
-TEMPLATE = app
-CONFIG = qt warn_on release
-DESTDIR = $(OPIEDIR)/bin
+CONFIG = qt warn_on release quick-app
HEADERS = gtetrix.h \
qtetrix.h \
qtetrixb.h \
tpiece.h \
ohighscoredlg.h
SOURCES = main.cpp \
gtetrix.cpp \
qtetrix.cpp \
qtetrixb.cpp \
tpiece.cpp \
ohighscoredlg.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lstdc++
INTERFACES =
TARGET = tetrix
+
+
+
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/games/wordgame/main.cpp b/noncore/games/wordgame/main.cpp
index cd4600e..f32acff 100644
--- a/noncore/games/wordgame/main.cpp
+++ b/noncore/games/wordgame/main.cpp
@@ -1,34 +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 "wordgame.h"
#include <qpe/qpeapplication.h>
+#include <opie/oapplicationfactory.h>
-int main( int argc, char ** argv )
-{
- QPEApplication a( argc, argv );
- WordGame mw;
- //QPEApplication::setInputMethodHint( &mw, QPEApplication::AlwaysOff );
- a.showMainWidget(&mw);
+OPIE_EXPORT_APP( OApplicationFactory<WordGame> )
- return a.exec();
-}
diff --git a/noncore/games/wordgame/wordgame.h b/noncore/games/wordgame/wordgame.h
index f73c85a..020a4b5 100644
--- a/noncore/games/wordgame/wordgame.h
+++ b/noncore/games/wordgame/wordgame.h
@@ -56,325 +56,326 @@ public:
Tile(const QString& key);
int value() const { return val; }
bool isBlank() const { return blank; }
QString text() const { return txt; }
void setText(const QString& t)
{
txt = t;
}
int operator==(const Tile& o) const
{ return o.txt == txt && o.val == val && o.blank == blank; }
int operator!=(const Tile& o) const
{ return !operator==(o); }
Tile& operator=(const Tile& o)
{ txt=o.txt; val=o.val; blank=o.blank; return *this; }
QString key() const;
private:
QString txt;
int val;
bool blank;
};
class Bag {
public:
Bag();
void readConfig(Config&);
void writeConfig(Config&);
void add(const Tile&);
bool isEmpty() const { return tiles.isEmpty(); }
Tile takeRandom();
private:
QList<Tile> tiles;
};
class TileItem : public QCanvasRectangle {
public:
TileItem(const Tile& tile, bool b, QCanvas* c) :
QCanvasRectangle(0,0,
b?bigWidth():smallWidth(),
b?bigHeight():smallHeight(),c),
t(tile), big(b), s(Firm)
{
}
static int smallWidth();
static int smallHeight();
static int bigWidth();
static int bigHeight();
enum State { Firm, Floating };
void setState( State state );
State state() const { return s; }
const Tile& tile() const { return t; }
void setTile(const Tile&);
void setBig(bool);
protected:
void drawShape(QPainter&);
private:
Tile t;
bool big;
State s;
};
class Rack : public QCanvasView {
public:
Rack(int ntiles, QWidget* parent);
~Rack();
void readConfig(Config&);
void writeConfig(Config&);
bool isFull() const { return count()==max(); }
int max() const { return item.count(); }
int count() const { return n; }
void addTile(const Tile& t);
Tile tile(int i) const { return item[i]->tile(); }
const Tile* tileRef(int i) const { return &item[i]->tile(); }
void remove(int i);
void remove(Tile);
bool arrangeTiles(const Tile** s, int sn);
void setBlanks(const Tile*);
void setPlayerName(const QString& name) { nm = name; }
QString playerName() const { return nm; }
void setComputerization(int level) { cpu=level; }
bool computerized() const { return cpu>0; }
QSize sizeHint() const;
protected:
void resizeEvent(QResizeEvent*e);
void contentsMousePressEvent(QMouseEvent*);
void contentsMouseMoveEvent(QMouseEvent*);
void contentsMouseReleaseEvent(QMouseEvent*);
private:
void clear();
void layoutTiles();
int n;
QArray<TileItem*> item;
int dragging_adj;
QPoint dragstart;
QCanvasItem* dragging;
QString nm;
int cpu;
};
class Board : public QCanvasView {
Q_OBJECT
public:
Board(QPixmap bgshapes, int w, int h, QWidget* parent);
~Board();
void readConfig(Config&);
void writeConfig(Config&);
int xTiles() const { return canvas()->tilesHorizontally(); }
int yTiles() const { return canvas()->tilesVertically(); }
bool contains(const QPoint& p) const
{ return p.x() >= 0 && p.y() >= 0
&& p.x() < canvas()->tilesHorizontally()
&& p.y() < canvas()->tilesVertically(); }
const Tile* tile(const QPoint& p) const
{ TileItem* it=item(p); return it ? &it->tile() : 0; }
void setRules(const QString& shapes, const int* effects);
void clear();
void unsetTile(const QPoint& p);
void setTile(const QPoint& p, const Tile& t);
void setTileState(const QPoint& p, TileItem::State s)
{
TileItem* it=item(p);
if (it) it->setState(s);
}
void setCurrentRack(Rack*);
void resetRack();
void finalizeTurn();
void showTurn();
void scoreTurn(const QPoint& at, int n, const QPoint& d);
bool checkTurn();
int score(QPoint at, const Tile** tiles, int n,
const Tile* blankvalue,
const QPoint& d, bool ignoredict, QStringList* words) const;
int bonussedValue(const QPoint& at, int base, int& all_mult) const;
bool isStart(const QPoint& at) const;
int turnScore() const { return turn_score; }
QSize sizeHint() const;
signals:
void temporaryScore(int);
protected:
void contentsMousePressEvent(QMouseEvent*);
void contentsMouseMoveEvent(QMouseEvent*);
void contentsMouseReleaseEvent(QMouseEvent*);
private:
int idx(const QPoint& p) const
{ return p.x()+p.y()*canvas()->tilesHorizontally(); }
TileItem*& item(const QPoint& p) const
{ return grid[idx(p)]; }
TileItem **grid;
QString rule_shape;
const int* rule_effect;
int rack_tiles_bonus;
Rack* current_rack;
QPoint boardPos(const QPoint&) const;
QPoint dragstart;
QPoint shown_at;
int shown_n;
QPoint shown_step;
void unshowTurn();
int turn_score;
};
class ComputerPlayer
{
Board* board;
Rack* rack;
bool across;
int dict;
QPoint current;
const Tile** best;
int best_n;
Tile* best_blankvalues;
int best_blused;
int best_score;
QPoint best_dir;
QPoint best_start;
public:
ComputerPlayer(Board* b, Rack* r);
~ComputerPlayer();
bool step();
private:
void findBest(QPoint at, const QPoint& d, const QDawg::Node* node, ulong used, uchar *nletter, const Tile** tiles, int n, Tile* blankvalues, int blused);
void noteChoice(const Tile** tiles, int n, const QPoint& d, const Tile* blankvalues, int blused);
};
class ScoreInfo : public QLabel {
Q_OBJECT
public:
ScoreInfo( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
~ScoreInfo();
void init(const QStringList&);
void addScore(int player, int change);
int playerScore(int player) const { return score[player]; }
void setShowWinner(bool);
void setBoldOne(int);
void readConfig(Config&);
void writeConfig(Config&);
protected:
QSize sizeHint() const;
public slots:
void showTemporaryScore(int amount);
private slots:
void showScores();
private:
QStringList names;
int *score;
QTimer* msgtimer;
bool showwinner;
int boldone;
};
class NewGame;
class WordGame : public QMainWindow {
Q_OBJECT
public:
WordGame( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
~WordGame();
+ static QString appName() { return QString::fromLatin1("wordgame"); }
private slots:
void endTurn();
void resetTurn();
void passTurn();
void think();
void endGame();
void startGame();
private:
void writeConfig();
void readConfig();
void startGame(const QStringList& pnames);
bool mayEndGame();
void openGameSelector(const QStringList& initnames);
bool loadRules(const QString& filename);
void addPlayer(const QString& name);
void addPlayer(const QString& name, int cpu);
void nextPlayer();
bool refillRack(int i);
void readyRack(int i);
Rack* rack(int i) const;
QWidgetStack *racks;
QToolBar* toolbar;
QWidget *vbox;
Board *board;
Bag *bag;
ScoreInfo *scoreinfo;
QToolButton *done;
QToolButton *reset;
QTimer* aiheart;
ComputerPlayer *cpu;
int player;
int nplayers;
QStringList namelist;
bool gameover;
QString rules;
NewGame* newgame;
};
class NewGame : public NewGameBase {
Q_OBJECT
public:
NewGame(QWidget* parent);
QStringList ruleslist;
public slots:
void updateRuleSets();
};
class Rules : public RulesBase {
Q_OBJECT
public:
Rules(QWidget* parent);
signals:
void rulesChanged();
public slots:
void editRules();
private:
void deleteRuleSet();
};
#endif // WORDGAME_H
diff --git a/noncore/games/wordgame/wordgame.pro b/noncore/games/wordgame/wordgame.pro
index e997adc..7ef2bfd 100644
--- a/noncore/games/wordgame/wordgame.pro
+++ b/noncore/games/wordgame/wordgame.pro
@@ -1,13 +1,12 @@
-TEMPLATE = app
-CONFIG = qt warn_on release
-DESTDIR = $(OPIEDIR)/bin
+CONFIG = qt warn_on release quick-app
HEADERS = wordgame.h
SOURCES = main.cpp \
wordgame.cpp
INTERFACES = newgamebase.ui rulesbase.ui
TARGET = wordgame
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe
+
include ( $(OPIEDIR)/include.pro )