-rw-r--r-- | noncore/games/kpacman/kpacman.cpp | 4 | ||||
-rw-r--r-- | noncore/games/kpacman/kpacman.h | 4 | ||||
-rw-r--r-- | noncore/games/kpacman/kpacman.pro | 4 | ||||
-rw-r--r-- | noncore/games/kpacman/main.cpp | 27 | ||||
-rw-r--r-- | noncore/games/kpacman/opie-kpacman.control | 2 |
5 files changed, 9 insertions, 32 deletions
diff --git a/noncore/games/kpacman/kpacman.cpp b/noncore/games/kpacman/kpacman.cpp index 9820e5a..4a3b870 100644 --- a/noncore/games/kpacman/kpacman.cpp +++ b/noncore/games/kpacman/kpacman.cpp @@ -1,363 +1,363 @@ #include "portable.h" #if defined( KDE2_PORT ) #include <kpacman.h> #include <kpacman.moc> #include <kcolordlg.h> #elif defined( QPE_PORT ) #include <qmenubar.h> #include <qpe/config.h> #include <qapplication.h> #include "kpacman.h" #endif -Kpacman::Kpacman(QWidget *parent, const char *name) - : KTMainWindow(parent, name) +Kpacman::Kpacman(QWidget *parent, const char *name, WFlags fl) + : KTMainWindow(parent, name,fl) { schemesPopup = new QList<QPopupMenu>; schemesPopup->setAutoDelete(TRUE); menu(); m_view = new QWidget( this, "m_view" ); m_view->setBackgroundColor( black ); m_layout = new QGridLayout( m_view ); m_layout->setMargin( 7 ); view = new KpacmanWidget( this, QString(name)+"widget"); m_layout->addWidget( view, 0, 0 ); setCaption( tr("KPacman") ); view->referee->setFocus(); connect(view->referee, SIGNAL(setScore(int,int)), view->score, SLOT(setScore(int,int))); connect(view->referee, SIGNAL(setPoints(int)), view->score, SLOT(set(int))); connect(view->referee, SIGNAL(setLifes(int)), view->status, SLOT(setLifes(int))); connect(view->referee, SIGNAL(setLevel(int)), view->status, SLOT(setLevel(int))); connect(view->referee, SIGNAL(forcedHallOfFame(bool)), this, SLOT(forcedHallOfFame(bool))); connect(view->referee, SIGNAL(togglePaused()), this, SLOT(togglePaused())); connect(view->referee, SIGNAL(toggleNew()), this, SLOT(toggleNew())); connect(view->score, SIGNAL(toggleNew()), this, SLOT(toggleNew())); connect(view->score, SIGNAL(forcedHallOfFame(bool)), this, SLOT(forcedHallOfFame(bool))); APP_CONFIG_BEGIN( cfg ); focusOutPause = !cfg->readBoolEntry("FocusOutPause", TRUE); focusInContinue = !cfg->readBoolEntry("FocusInContinue", TRUE); hideMouseCursor = !cfg->readBoolEntry("HideMouseCursor", TRUE); APP_CONFIG_END( cfg ); toggleFocusOutPause(); toggleFocusInContinue(); toggleHideMouseCursor(); setCentralWidget( m_view ); } Kpacman::~Kpacman() { /* APP_CONFIG_BEGIN( cfg ); cfg->writeEntry("FocusOutPause", focusOutPause); cfg->writeEntry("FocusInContinue", focusInContinue); cfg->writeEntry("HideMouseCursor", hideMouseCursor); APP_CONFIG_END( cfg ); */ delete _menuBar; } void Kpacman::menu() { gamePopup = new QPopupMenu(); CHECK_PTR( gamePopup ); newID = gamePopup->insertItem(tr("&New"), this, SLOT(newKpacman()),Key_F2); pauseID = gamePopup->insertItem(tr("&Pause"), this, SLOT(pauseKpacman()), Key_F3); hofID = gamePopup->insertItem(tr("&Hall of fame"), this, SLOT(toggleHallOfFame()), Key_F4); gamePopup->insertSeparator(); gamePopup->insertItem(tr("&Quit"), this, SLOT(quitKpacman()), CTRL+Key_Q); gamePopup->setCheckable(TRUE); optionsPopup = new QPopupMenu(); CHECK_PTR(optionsPopup); modesPopup = new QPopupMenu(); CHECK_PTR(modesPopup); hideMouseCursorID = optionsPopup->insertItem(tr("&Hide Mousecursor"), this, SLOT(toggleHideMouseCursor()), CTRL+Key_H); optionsPopup->insertSeparator(); if (lookupSchemes() > 0) { optionsPopup->insertItem(tr("&Select graphic scheme"), modesPopup); optionsPopup->insertSeparator(); } focusOutPauseID = optionsPopup->insertItem(tr("&Pause in Background"), this, SLOT(toggleFocusOutPause())); focusInContinueID = optionsPopup->insertItem(tr("&Continue in Foreground"), this, SLOT(toggleFocusInContinue())); optionsPopup->insertSeparator(); optionsPopup->insertItem(tr("Change &keys..."), this, SLOT(confKeys())); #ifndef QPE_PORT QString aboutText = tr("@PACKAGE@ - @VERSION@\n\n" "Joerg Thoennissen (joe@dsite.de)\n\n" "A pacman game for the KDE Desktop\n\n" "The program based on the source of ksnake\n" "by Michel Filippi (mfilippi@sade.rhein-main.de).\n" "The design was strongly influenced by the pacman\n" "(c) 1980 MIDWAY MFG.CO.\n\n" "I like to thank my girlfriend Elke Krueers for\n" "the last 10 years of her friendship.\n"); aboutText.replace(QRegExp("@PACKAGE@"), PACKAGE); aboutText.replace(QRegExp("@VERSION@"), VERSION); QPopupMenu *helpPopup = helpMenu(aboutText, FALSE); #endif //_menuBar = new KMenuBar(this); //CHECK_PTR( _menuBar ); //_menuBar->insertItem(tr("&Game"), gamePopup); //_menuBar->insertItem(tr("&Options"), optionsPopup); //_menuBar->insertSeparator(); #ifndef QPE_PORT _menuBar->insertItem(tr("&Help"), helpPopup); #endif } int Kpacman::lookupSchemes() { APP_CONFIG_BEGIN( cfg ); int ModeCount = cfg->readNumEntry("ModeCount", 0); int Mode = cfg->readNumEntry("Mode", 0); int SchemeCount = cfg->readNumEntry("SchemeCount", 0); int Scheme = cfg->readNumEntry("Scheme", 0); /* if (SchemeCount == 0 || Scheme == -1) { QMessageBox::warning(this, tr("Configuration Error"), tr("There are no schemes defined,\n" "or no scheme is selected.")); APP_CONFIG_END( cfg ); return 0; } */ connect(modesPopup, SIGNAL(activated(int)), this, SLOT(schemeChecked(int))); modeID.resize(ModeCount > 0 ? ModeCount : 0); if (!schemesPopup->isEmpty()) schemesPopup->clear(); SAVE_CONFIG_GROUP( cfg, oldgroup ); QString ModeGroup; QString ModeName; for (int m = 0; m < ModeCount; m++) { ModeGroup.sprintf("Mode %d", m); cfg->setGroup(ModeGroup); ModeName = cfg->readEntry("Description", ModeGroup); QPopupMenu *p = new QPopupMenu; p->setCheckable(TRUE); connect(p, SIGNAL(activated(int)), this, SLOT(schemeChecked(int))); schemesPopup->append(p); modeID[m] = modesPopup->insertItem(ModeName, schemesPopup->at(m)); modesPopup->setItemEnabled(modeID[m], FALSE); modesPopup->setItemChecked(modeID[m], m == Mode); } schemeID.resize(SchemeCount); schemeMode.resize(SchemeCount); QString SchemeGroup; QString SchemeName; int SchemeMode; for (int i = 0; i < SchemeCount; i++) { SchemeGroup.sprintf("Scheme %d", i); cfg->setGroup(SchemeGroup); SchemeName = cfg->readEntry("Description", SchemeGroup); SchemeMode = cfg->readNumEntry("Mode", -1); schemeMode[i] = SchemeMode; if (SchemeMode == -1) { schemeID[i] = modesPopup->insertItem(SchemeName); modesPopup->setItemChecked(schemeID[i], i == Scheme); } else { schemeID[i] = schemesPopup->at(SchemeMode)->insertItem(SchemeName); schemesPopup->at(SchemeMode)-> setItemChecked(schemeID[i], i == Scheme); modesPopup->setItemEnabled(modeID[SchemeMode], TRUE); } } RESTORE_CONFIG_GROUP( cfg, oldgroup ); APP_CONFIG_END( cfg ); return SchemeCount; } void Kpacman::quitKpacman() { APP_QUIT(); } void Kpacman::newKpacman() { if (!gamePopup->isItemEnabled(hofID)) gamePopup->setItemEnabled(hofID, TRUE); if (gamePopup->isItemChecked(hofID)) toggleHallOfFame(); if (gamePopup->isItemChecked(pauseID)) pauseKpacman(); view->referee->play(); } void Kpacman::pauseKpacman() { view->referee->pause(); view->score->setPause(gamePopup->isItemChecked(pauseID)); } void Kpacman::toggleHallOfFame() { gamePopup->setItemChecked(hofID, !gamePopup->isItemChecked(hofID)); view->referee->toggleHallOfFame(); if (gamePopup->isItemChecked(hofID)) { view->referee->lower(); view->status->lower(); } else { view->status->raise(); view->referee->raise(); view->referee->setFocus(); } } /* * Disable or enable the "Hall of fame"-menuitem if the referee says so. * This is done, to disable turning off the "hall of fame"-display, in the automated * sequence of displaying the introduction, the demonstration (or playing) and the * hall of fame. * If on == TRUE then also lower the referee and the status widgets. */ void Kpacman::forcedHallOfFame(bool on) { if (!on && !gamePopup->isItemChecked(hofID)) return; gamePopup->setItemEnabled(hofID, !on); gamePopup->setItemChecked(hofID, on); view->referee->toggleHallOfFame(); if (on) { view->referee->lower(); view->status->lower(); } else { view->status->raise(); view->referee->raise(); view->referee->setFocus(); view->referee->intro(); } } void Kpacman::togglePaused() { static bool checked = FALSE; checked = !checked; gamePopup->setItemChecked( pauseID, checked ); view->score->setPause(gamePopup->isItemChecked(pauseID)); } /* * This disables the "New Game" menuitem to prevent interruptions of the current * play. */ void Kpacman::toggleNew() { gamePopup->setItemEnabled(newID, !gamePopup->isItemEnabled(newID)); } void Kpacman::toggleHideMouseCursor() { hideMouseCursor = !hideMouseCursor; optionsPopup->setItemChecked(hideMouseCursorID, hideMouseCursor); if (hideMouseCursor) view->setCursor(blankCursor); else view->setCursor(arrowCursor); } void Kpacman::toggleFocusOutPause() { focusOutPause = !focusOutPause; optionsPopup->setItemChecked(focusOutPauseID, focusOutPause); view->referee->setFocusOutPause(focusOutPause); } void Kpacman::toggleFocusInContinue() { focusInContinue = !focusInContinue; optionsPopup->setItemChecked(focusInContinueID, focusInContinue); view->referee->setFocusInContinue(focusInContinue); } void Kpacman::confKeys() { Keys *keys = new Keys(); if (keys->exec() == QDialog::Accepted) { view->referee->initKeys(); view->score->initKeys(); } delete keys; } void Kpacman::schemeChecked(int id) { int mode = 0, scheme = -1; for (uint s = 0; s < schemeID.size(); s++) { if (schemeID[s] == id) { scheme = s; mode = schemeMode[s]; } if (schemeMode[s] == -1) { modesPopup->setItemChecked(schemeID[s], schemeID[s] == id); } else { modesPopup->setItemChecked(modeID[schemeMode[s]], schemeMode[s] == mode); schemesPopup->at(schemeMode[s])->setItemChecked(schemeID[s], schemeID[s] == id); } } /* APP_CONFIG_BEGIN( cfg ); cfg->writeEntry("Scheme", scheme); cfg->writeEntry("Mode", mode); APP_CONFIG_END( cfg ); */ view->setScheme(scheme, mode); view->updateGeometry(); updateGeometry(); update(); repaint(TRUE); show(); } diff --git a/noncore/games/kpacman/kpacman.h b/noncore/games/kpacman/kpacman.h index 2c1de70..829714a 100644 --- a/noncore/games/kpacman/kpacman.h +++ b/noncore/games/kpacman/kpacman.h @@ -1,83 +1,85 @@ #ifndef KPACMAN_H #define KPACMAN_H #ifdef HAVE_CONFIG_H #include <config.h> #endif #include "portable.h" #include <qmainwindow.h> class QMenuBar; #include <qregexp.h> #include "kpacmanwidget.h" #include <qpopmenu.h> #include <qlist.h> #include <qfileinf.h> #include <qlayout.h> #include "referee.h" #include "status.h" #include "score.h" #include "keys.h" class Kpacman : public KTMainWindow { Q_OBJECT public: - Kpacman(QWidget *parent = 0, const char *name = 0); + Kpacman(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); + static QString appName() { return QString::fromLatin1("kpacman"); } + virtual ~Kpacman(); public slots: void forcedHallOfFame(bool); private slots: void newKpacman(); void pauseKpacman(); void toggleHallOfFame(); void toggleNew(); void togglePaused(); void quitKpacman(); void schemeChecked(int); void toggleFocusOutPause(); void toggleFocusInContinue(); void toggleHideMouseCursor(); void confKeys(); protected: private: KpacmanWidget *view; void menu(); int lookupSchemes(); QGridLayout *m_layout; QWidget *m_view; KMenuBar *_menuBar; QPopupMenu *gamePopup; QPopupMenu *optionsPopup; QPopupMenu *modesPopup; QList<QPopupMenu> *schemesPopup; int newID; int pauseID; int hofID; QArray<int> modeID; QArray<int> schemeID; QArray<int> schemeMode; int focusOutPauseID; int focusInContinueID; int hideMouseCursorID; bool focusOutPause; bool focusInContinue; bool hideMouseCursor; }; #endif // KPACMAN_H diff --git a/noncore/games/kpacman/kpacman.pro b/noncore/games/kpacman/kpacman.pro index 45314f9..a231b01 100644 --- a/noncore/games/kpacman/kpacman.pro +++ b/noncore/games/kpacman/kpacman.pro @@ -1,39 +1,37 @@ -TEMPLATE = app -CONFIG = qt warn_on +CONFIG = qt quick-app HEADERS = kpacmanwidget.h \ referee.h \ status.h \ painter.h \ score.h \ pacman.h \ monster.h \ keys.h \ fruit.h \ energizer.h \ board.h \ bitfont.h \ kpacman.h \ bitmaps.h \ colors.h \ portable.h SOURCES = kpacmanwidget.cpp \ referee.cpp \ status.cpp \ painter.cpp \ score.cpp \ pacman.cpp \ monster.cpp \ keys.cpp \ fruit.cpp \ energizer.cpp \ board.cpp \ bitfont.cpp \ kpacman.cpp \ main.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopiecore2 -DESTDIR = $(OPIEDIR)/bin TARGET = kpacman include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/games/kpacman/main.cpp b/noncore/games/kpacman/main.cpp index 76afb57..2906d2a 100644 --- a/noncore/games/kpacman/main.cpp +++ b/noncore/games/kpacman/main.cpp @@ -1,66 +1,43 @@ /*************************************************************************** main.cpp - description ------------------- begin : Sam Jan 19 13:37:57 CET 2002 copyright : (C) 2002 by Jörg Thönnissen email : joe@dsite.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "portable.h" #if defined( KDE2_PORT ) #include <kcmdlineargs.h> #include <kaboutdata.h> #include <klocale.h> #elif defined( QPE_PORT ) -#include <qpe/qpeapplication.h> +#include <opie2/oapplicationfactory.h> #endif #include "kpacman.h" #ifdef KDE2_PORT static const char *description = I18N_NOOP("Kpacman"); // INSERT A DESCRIPTION FOR YOUR APPLICATION HERE static KCmdLineOptions options[] = { { 0, 0, 0 } // INSERT YOUR COMMANDLINE OPTIONS HERE }; #endif -int main(int argc, char *argv[]) -{ -#if defined( KDE2_PORT ) - KAboutData aboutData( "kpacman", I18N_NOOP("Kpacman"), - VERSION, description, KAboutData::License_GPL, - "(c) 2002, Jörg Thönnissen", 0, 0, "joe@dsite.de"); - aboutData.addAuthor("Jörg Thönnissen",0, "joe@dsite.de"); - KCmdLineArgs::init( argc, argv, &aboutData ); - KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. - KApplication a; -#elif defined( QPE_PORT ) - QPEApplication a( argc, argv ); -#endif - Kpacman *kpacman = new Kpacman( NULL, "Kpacman" ); - a.setMainWidget(kpacman); -#if defined( KDE2_PORT ) - a.setTopWidget(kpacman); - kpacman->show(); -#elif defined( QPE_PORT ) - kpacman->showMaximized(); -#endif - - return a.exec(); -} +OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<Kpacman> ) diff --git a/noncore/games/kpacman/opie-kpacman.control b/noncore/games/kpacman/opie-kpacman.control index 15e3056..68487ec 100644 --- a/noncore/games/kpacman/opie-kpacman.control +++ b/noncore/games/kpacman/opie-kpacman.control @@ -1,11 +1,11 @@ Package: opie-kpacman -Files: bin/kpacman apps/Games/kpacman.desktop pics/kpacman/kpacman.png share/kpacman +Files: plugins/applications/libkpacman.so* bin/kpacman apps/Games/kpacman.desktop pics/kpacman/kpacman.png share/kpacman Version: 0.3.1-$SUB_VERSION Depends: task-opie-minimal Priority: optional Section: opie/games Maintainer: Catalin Climov <catalin@climov.com> Architecture: arm License: GPL Description: Kpacman A Pacman clone for Qtopia. |