-rw-r--r-- | noncore/games/kpacman/kpacman.cpp | 21 | ||||
-rw-r--r-- | noncore/games/kpacman/kpacman.h | 18 | ||||
-rw-r--r-- | noncore/games/kpacman/kpacmanwidget.cpp | 9 | ||||
-rw-r--r-- | noncore/games/kpacman/referee.cpp | 4 | ||||
-rw-r--r-- | noncore/games/kpacman/score.cpp | 61 |
5 files changed, 13 insertions, 100 deletions
diff --git a/noncore/games/kpacman/kpacman.cpp b/noncore/games/kpacman/kpacman.cpp index 7df6ef0..d9d2d69 100644 --- a/noncore/games/kpacman/kpacman.cpp +++ b/noncore/games/kpacman/kpacman.cpp @@ -23,19 +23,21 @@ Kpacman::Kpacman(QWidget *parent, const char *name) { schemesPopup = new QList<QPopupMenu>; schemesPopup->setAutoDelete(TRUE); menu(); + m_view = new QWidget( this, "m_view" ); + m_view->setBackgroundColor( black ); + m_layout = new QGridLayout( m_view ); + m_layout->setMargin( 7 ); + view = new KpacmanWidget( this, QString(name)+"widget"); + m_layout->addWidget( view, 0, 0 ); -#ifndef QWS - setFixedSize(view->width(), view->height()); -#else - setCaption( "Kpacman" ); -#endif + setCaption( "KPacman" ); view->referee->setFocus(); connect(view->referee, SIGNAL(setScore(int, int)), view->score, SLOT(setScore(int, int))); connect(view->referee, SIGNAL(setPoints(int)), @@ -60,20 +62,13 @@ Kpacman::Kpacman(QWidget *parent, const char *name) APP_CONFIG_END( cfg ); toggleFocusOutPause(); toggleFocusInContinue(); toggleHideMouseCursor(); -#ifndef QWS - menuBar->show(); - view->show(); - setMenu(menuBar); - setView(view); -#else - setCentralWidget( view ); -#endif + setCentralWidget( m_view ); } Kpacman::~Kpacman() { APP_CONFIG_BEGIN( cfg ); cfg->writeEntry("FocusOutPause", focusOutPause); diff --git a/noncore/games/kpacman/kpacman.h b/noncore/games/kpacman/kpacman.h index d7de9de..2c1de70 100644 --- a/noncore/games/kpacman/kpacman.h +++ b/noncore/games/kpacman/kpacman.h @@ -4,42 +4,28 @@ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include "portable.h" -#if defined( KDE2_PORT ) -#include <kapp.h> -#include <klocale.h> -#include <ktmainwindow.h> -#include <kmenubar.h> -#elif defined( QPE_PORT ) #include <qmainwindow.h> class QMenuBar; -#endif - #include <qregexp.h> #include "kpacmanwidget.h" #include <qpopmenu.h> #include <qlist.h> #include <qfileinf.h> +#include <qlayout.h> -#if defined( KDE2_PORT ) -#include <referee.h> -#include <status.h> -#include <score.h> -#include <keys.h> -#elif defined( QPE_PORT ) #include "referee.h" #include "status.h" #include "score.h" #include "keys.h" -#endif class Kpacman : public KTMainWindow { Q_OBJECT public: Kpacman(QWidget *parent = 0, const char *name = 0); @@ -68,12 +54,14 @@ private: KpacmanWidget *view; void menu(); int lookupSchemes(); + QGridLayout *m_layout; + QWidget *m_view; KMenuBar *_menuBar; QPopupMenu *gamePopup; QPopupMenu *optionsPopup; QPopupMenu *modesPopup; QList<QPopupMenu> *schemesPopup; diff --git a/noncore/games/kpacman/kpacmanwidget.cpp b/noncore/games/kpacman/kpacmanwidget.cpp index 215dcda..feb782c 100644 --- a/noncore/games/kpacman/kpacmanwidget.cpp +++ b/noncore/games/kpacman/kpacmanwidget.cpp @@ -30,17 +30,13 @@ KpacmanWidget::KpacmanWidget( QWidget *parent, const char *name) confScheme(); score = new Score(this, name, scheme, mode, bitfont); referee = new Referee( this, name, scheme, mode, bitfont); status = new Status(this, name, scheme, mode); -#ifndef QWS - setFixedSize(referee->width(), bitfont->height()*3 + referee->height() + status->height()); -#else setBackgroundColor( black ); -#endif } KpacmanWidget::~KpacmanWidget() { } @@ -135,17 +131,12 @@ void KpacmanWidget::setScheme(int Scheme, int Mode) confScheme(); score->setScheme(Scheme, Mode, bitfont); referee->setScheme(Scheme, Mode, bitfont); status->setScheme(Scheme, Mode); -#ifndef QWS - setFixedSize(referee->width(), - bitfont->height()*3 + referee->height() + status->height()); -#endif - score->repaint(FALSE); referee->repaint(FALSE); status->repaint(FALSE); } void KpacmanWidget::resizeEvent( QResizeEvent * ) diff --git a/noncore/games/kpacman/referee.cpp b/noncore/games/kpacman/referee.cpp index 70916f0..81f331b 100644 --- a/noncore/games/kpacman/referee.cpp +++ b/noncore/games/kpacman/referee.cpp @@ -728,16 +728,16 @@ void Referee::keyPressEvent( QKeyEvent *k ) uint key = k->key(); #ifdef QWS // "OK" => new game if ( key == Key_F33 || key == Key_F2 || key == Key_Enter ) play(); else if ( !gameState.testBit(Playing) && - key == Key_Up || + ( key == Key_Up || key == Key_Down || key == Key_Right || - key == Key_Left ) + key == Key_Left )) play(); // "Space" => pause //else if ( key == Key_Space || key == Key_F3 ) // pause(); // "Menu" => hall of fame //else if ( key == Key_F11 || key == Key_F4 ) diff --git a/noncore/games/kpacman/score.cpp b/noncore/games/kpacman/score.cpp index 17dbf0a..b3ff3d9 100644 --- a/noncore/games/kpacman/score.cpp +++ b/noncore/games/kpacman/score.cpp @@ -475,40 +475,12 @@ void Score::read() HighScore = hallOfFame[0].points; } void Score::write() { -#ifndef QWS - if (!highscoreFile.exists() && highscoreFile.name() == systemHighscoreFileInfo.filePath()) - KMessageBox::information(0, - tr("You're going to create the highscore-file\n" - "'%1'\n" - "for your maschine, that should be used systemwide.\n" - "\n" - "To grant access to the other users, set the appropriate rights (a+w)\n" - "on that file or ask your systemadministator for that favor.\n" - "\n" - "To use a different directory or filename for the highscores," - "specify them in the configfile (kpacmanrc:highscoreFilePath)." - ).arg(systemHighscoreFileInfo.filePath())); - - if (highscoreFile.name() == privateHighscoreFileInfo.filePath()) - KMessageBox::information(0, - tr("You're using a private highscore-file, that's mostly because of\n" - "missing write-access to the systemwide file\n" - "'%1' .\n" - "\n" - "Ask your systemadministrator for granting you access to that file,\n" - "by setting the appropriate rights (a+w) on it.\n" - "\n" - "To use a different directory or filename for the highscores," - "specify them in the configfile (kpacmanrc:highscoreFilePath)." - ).arg(systemHighscoreFileInfo.filePath()), - QString::null, "PrivateHighscore"); -#endif if (highscoreFile.open(IO_WriteOnly)) { QDataStream s(&highscoreFile); for (int i = 0; i < 10; i++) s << hallOfFame[i].points << hallOfFame[i].levels << hallOfFame[i].duration << hallOfFame[i].moment << hallOfFame[i].name.latin1(); highscoreFile.close(); @@ -602,41 +574,8 @@ int Score::y(float row) * der Standort der "highscore"-Datei spezifiziert werden. * Wenn die systemweite "highscore"-Datei nicht beschrieben werden kann, wird mit einer * privaten Datei gearbeitet. */ QFileInfo Score::locateHighscoreFilePath() { -#ifndef QWS - QFileInfo systemHighscoreDirPath; - QStringList systemHighscoreDirs; - - // Schreibfähige "private" highscore-Datei ermitteln für den fallback. - privateHighscoreFileInfo.setFile(KGlobal::dirs()->saveLocation("appdata")+highscoreName); - - // FilePath aus der Konfigurationsdatei benutzen - systemHighscoreFileInfo.setFile(cfg->readEntry("HighscoreFilePath")); - - // Kein Wert aus der Konfiguration erhalten, dann die "system"-Datei suchen. - if (systemHighscoreFileInfo.filePath().isEmpty()) - systemHighscoreDirs = KGlobal::dirs()->resourceDirs("appdata"); - else - systemHighscoreDirs = QStringList(systemHighscoreFileInfo.filePath()); - - for (QStringList::Iterator i = systemHighscoreDirs.begin(); i != systemHighscoreDirs.end(); ++i) { - - systemHighscoreFileInfo.setFile(*i); - if (systemHighscoreFileInfo.fileName().isEmpty()) - systemHighscoreFileInfo.setFile(systemHighscoreFileInfo.dirPath()+"/"+highscoreName); - - // privateHighscoreFileInfo für die "system" Suche ignorieren - if (systemHighscoreFileInfo.filePath() != privateHighscoreFileInfo.filePath()) - if (!systemHighscoreFileInfo.exists()) { - systemHighscoreDirPath.setFile(systemHighscoreFileInfo.dirPath()); - if (systemHighscoreDirPath.exists() && systemHighscoreDirPath.isWritable()) - return systemHighscoreFileInfo; - } else - if (systemHighscoreFileInfo.isWritable()) - return systemHighscoreFileInfo; - } -#endif return privateHighscoreFileInfo; } |