summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/kpacman/kpacman.cpp23
-rw-r--r--noncore/games/kpacman/kpacman.h18
-rw-r--r--noncore/games/kpacman/kpacmanwidget.cpp9
-rw-r--r--noncore/games/kpacman/referee.cpp4
-rw-r--r--noncore/games/kpacman/score.cpp61
5 files changed, 14 insertions, 101 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
@@ -1,121 +1,116 @@
1 1
2#include "portable.h" 2#include "portable.h"
3 3
4#if defined( KDE2_PORT ) 4#if defined( KDE2_PORT )
5#include <kpacman.h> 5#include <kpacman.h>
6#include <kpacman.moc> 6#include <kpacman.moc>
7#include <kcolordlg.h> 7#include <kcolordlg.h>
8#elif defined( QPE_PORT ) 8#elif defined( QPE_PORT )
9#include <qmenubar.h> 9#include <qmenubar.h>
10#include "config.h" 10#include "config.h"
11#include <qapplication.h> 11#include <qapplication.h>
12#include "kpacman.h" 12#include "kpacman.h"
13#endif 13#endif
14 14
15#include <qkeycode.h> 15#include <qkeycode.h>
16#include <qcolor.h> 16#include <qcolor.h>
17#include <qstring.h> 17#include <qstring.h>
18#include <qpopmenu.h> 18#include <qpopmenu.h>
19#include <qmsgbox.h> 19#include <qmsgbox.h>
20 20
21Kpacman::Kpacman(QWidget *parent, const char *name) 21Kpacman::Kpacman(QWidget *parent, const char *name)
22 : KTMainWindow(parent, name) 22 : KTMainWindow(parent, name)
23{ 23{
24 schemesPopup = new QList<QPopupMenu>; 24 schemesPopup = new QList<QPopupMenu>;
25 schemesPopup->setAutoDelete(TRUE); 25 schemesPopup->setAutoDelete(TRUE);
26 26
27 menu(); 27 menu();
28 28
29 view = new KpacmanWidget( this, QString(name)+"widget"); 29 m_view = new QWidget( this, "m_view" );
30 m_view->setBackgroundColor( black );
31 m_layout = new QGridLayout( m_view );
32 m_layout->setMargin( 7 );
30 33
31#ifndef QWS 34 view = new KpacmanWidget( this, QString(name)+"widget");
32 setFixedSize(view->width(), view->height()); 35 m_layout->addWidget( view, 0, 0 );
33#else 36
34 setCaption( "Kpacman" ); 37 setCaption( "KPacman" );
35#endif
36 38
37 view->referee->setFocus(); 39 view->referee->setFocus();
38 40
39 connect(view->referee, SIGNAL(setScore(int, int)), 41 connect(view->referee, SIGNAL(setScore(int, int)),
40 view->score, SLOT(setScore(int, int))); 42 view->score, SLOT(setScore(int, int)));
41 connect(view->referee, SIGNAL(setPoints(int)), 43 connect(view->referee, SIGNAL(setPoints(int)),
42 view->score, SLOT(set(int))); 44 view->score, SLOT(set(int)));
43 connect(view->referee, SIGNAL(setLifes(int)), 45 connect(view->referee, SIGNAL(setLifes(int)),
44 view->status, SLOT(setLifes(int))); 46 view->status, SLOT(setLifes(int)));
45 connect(view->referee, SIGNAL(setLevel(int)), 47 connect(view->referee, SIGNAL(setLevel(int)),
46 view->status, SLOT(setLevel(int))); 48 view->status, SLOT(setLevel(int)));
47 connect(view->referee, SIGNAL(forcedHallOfFame(bool)), 49 connect(view->referee, SIGNAL(forcedHallOfFame(bool)),
48 this, SLOT(forcedHallOfFame(bool))); 50 this, SLOT(forcedHallOfFame(bool)));
49 connect(view->referee, SIGNAL(togglePaused()), this, SLOT(togglePaused())); 51 connect(view->referee, SIGNAL(togglePaused()), this, SLOT(togglePaused()));
50 connect(view->referee, SIGNAL(toggleNew()), this, SLOT(toggleNew())); 52 connect(view->referee, SIGNAL(toggleNew()), this, SLOT(toggleNew()));
51 53
52 connect(view->score, SIGNAL(toggleNew()), this, SLOT(toggleNew())); 54 connect(view->score, SIGNAL(toggleNew()), this, SLOT(toggleNew()));
53 connect(view->score, SIGNAL(forcedHallOfFame(bool)), 55 connect(view->score, SIGNAL(forcedHallOfFame(bool)),
54 this, SLOT(forcedHallOfFame(bool))); 56 this, SLOT(forcedHallOfFame(bool)));
55 57
56 APP_CONFIG_BEGIN( cfg ); 58 APP_CONFIG_BEGIN( cfg );
57 focusOutPause = !cfg->readBoolEntry("FocusOutPause", TRUE); 59 focusOutPause = !cfg->readBoolEntry("FocusOutPause", TRUE);
58 focusInContinue = !cfg->readBoolEntry("FocusInContinue", TRUE); 60 focusInContinue = !cfg->readBoolEntry("FocusInContinue", TRUE);
59 hideMouseCursor = !cfg->readBoolEntry("HideMouseCursor", TRUE); 61 hideMouseCursor = !cfg->readBoolEntry("HideMouseCursor", TRUE);
60 APP_CONFIG_END( cfg ); 62 APP_CONFIG_END( cfg );
61 63
62 toggleFocusOutPause(); 64 toggleFocusOutPause();
63 toggleFocusInContinue(); 65 toggleFocusInContinue();
64 toggleHideMouseCursor(); 66 toggleHideMouseCursor();
65 67
66#ifndef QWS 68 setCentralWidget( m_view );
67 menuBar->show();
68 view->show();
69 setMenu(menuBar);
70 setView(view);
71#else
72 setCentralWidget( view );
73#endif
74} 69}
75 70
76Kpacman::~Kpacman() 71Kpacman::~Kpacman()
77{ 72{
78 APP_CONFIG_BEGIN( cfg ); 73 APP_CONFIG_BEGIN( cfg );
79 cfg->writeEntry("FocusOutPause", focusOutPause); 74 cfg->writeEntry("FocusOutPause", focusOutPause);
80 cfg->writeEntry("FocusInContinue", focusInContinue); 75 cfg->writeEntry("FocusInContinue", focusInContinue);
81 cfg->writeEntry("HideMouseCursor", hideMouseCursor); 76 cfg->writeEntry("HideMouseCursor", hideMouseCursor);
82 APP_CONFIG_END( cfg ); 77 APP_CONFIG_END( cfg );
83 delete _menuBar; 78 delete _menuBar;
84} 79}
85 80
86void Kpacman::menu() 81void Kpacman::menu()
87{ 82{
88 gamePopup = new QPopupMenu(); 83 gamePopup = new QPopupMenu();
89 CHECK_PTR( gamePopup ); 84 CHECK_PTR( gamePopup );
90 newID = gamePopup->insertItem(tr("&New"), this, SLOT(newKpacman()),Key_F2); 85 newID = gamePopup->insertItem(tr("&New"), this, SLOT(newKpacman()),Key_F2);
91 pauseID = gamePopup->insertItem(tr("&Pause"), 86 pauseID = gamePopup->insertItem(tr("&Pause"),
92 this, SLOT(pauseKpacman()), Key_F3); 87 this, SLOT(pauseKpacman()), Key_F3);
93 hofID = gamePopup->insertItem(tr("&Hall of fame"), 88 hofID = gamePopup->insertItem(tr("&Hall of fame"),
94 this, SLOT(toggleHallOfFame()), Key_F4); 89 this, SLOT(toggleHallOfFame()), Key_F4);
95 gamePopup->insertSeparator(); 90 gamePopup->insertSeparator();
96 gamePopup->insertItem(tr("&Quit"), this, SLOT(quitKpacman()), CTRL+Key_Q); 91 gamePopup->insertItem(tr("&Quit"), this, SLOT(quitKpacman()), CTRL+Key_Q);
97 gamePopup->setCheckable(TRUE); 92 gamePopup->setCheckable(TRUE);
98 93
99 optionsPopup = new QPopupMenu(); 94 optionsPopup = new QPopupMenu();
100 CHECK_PTR(optionsPopup); 95 CHECK_PTR(optionsPopup);
101 96
102 modesPopup = new QPopupMenu(); 97 modesPopup = new QPopupMenu();
103 CHECK_PTR(modesPopup); 98 CHECK_PTR(modesPopup);
104 99
105 hideMouseCursorID = optionsPopup->insertItem(tr("&Hide Mousecursor"), 100 hideMouseCursorID = optionsPopup->insertItem(tr("&Hide Mousecursor"),
106 this, SLOT(toggleHideMouseCursor()), 101 this, SLOT(toggleHideMouseCursor()),
107 CTRL+Key_H); 102 CTRL+Key_H);
108 optionsPopup->insertSeparator(); 103 optionsPopup->insertSeparator();
109 104
110 if (lookupSchemes() > 0) { 105 if (lookupSchemes() > 0) {
111 optionsPopup->insertItem(tr("&Select graphic scheme"), modesPopup); 106 optionsPopup->insertItem(tr("&Select graphic scheme"), modesPopup);
112 optionsPopup->insertSeparator(); 107 optionsPopup->insertSeparator();
113 } 108 }
114 109
115 focusOutPauseID = optionsPopup->insertItem(tr("&Pause in Background"), 110 focusOutPauseID = optionsPopup->insertItem(tr("&Pause in Background"),
116 this, SLOT(toggleFocusOutPause())); 111 this, SLOT(toggleFocusOutPause()));
117 focusInContinueID = optionsPopup->insertItem(tr("&Continue in Foreground"), 112 focusInContinueID = optionsPopup->insertItem(tr("&Continue in Foreground"),
118 this, SLOT(toggleFocusInContinue())); 113 this, SLOT(toggleFocusInContinue()));
119 optionsPopup->insertSeparator(); 114 optionsPopup->insertSeparator();
120 115
121 optionsPopup->insertItem(tr("Change &keys..."), this, SLOT(confKeys())); 116 optionsPopup->insertItem(tr("Change &keys..."), this, SLOT(confKeys()));
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
@@ -1,95 +1,83 @@
1#ifndef KPACMAN_H 1#ifndef KPACMAN_H
2#define KPACMAN_H 2#define KPACMAN_H
3 3
4#ifdef HAVE_CONFIG_H 4#ifdef HAVE_CONFIG_H
5#include <config.h> 5#include <config.h>
6#endif 6#endif
7 7
8#include "portable.h" 8#include "portable.h"
9 9
10#if defined( KDE2_PORT )
11#include <kapp.h>
12#include <klocale.h>
13#include <ktmainwindow.h>
14#include <kmenubar.h>
15#elif defined( QPE_PORT )
16#include <qmainwindow.h> 10#include <qmainwindow.h>
17class QMenuBar; 11class QMenuBar;
18#endif
19
20#include <qregexp.h> 12#include <qregexp.h>
21 13
22#include "kpacmanwidget.h" 14#include "kpacmanwidget.h"
23 15
24#include <qpopmenu.h> 16#include <qpopmenu.h>
25 17
26#include <qlist.h> 18#include <qlist.h>
27#include <qfileinf.h> 19#include <qfileinf.h>
20#include <qlayout.h>
28 21
29#if defined( KDE2_PORT )
30#include <referee.h>
31#include <status.h>
32#include <score.h>
33#include <keys.h>
34#elif defined( QPE_PORT )
35#include "referee.h" 22#include "referee.h"
36#include "status.h" 23#include "status.h"
37#include "score.h" 24#include "score.h"
38#include "keys.h" 25#include "keys.h"
39#endif
40 26
41class Kpacman : public KTMainWindow 27class Kpacman : public KTMainWindow
42{ 28{
43 Q_OBJECT 29 Q_OBJECT
44public: 30public:
45 Kpacman(QWidget *parent = 0, const char *name = 0); 31 Kpacman(QWidget *parent = 0, const char *name = 0);
46 virtual ~Kpacman(); 32 virtual ~Kpacman();
47 33
48public slots: 34public slots:
49 void forcedHallOfFame(bool); 35 void forcedHallOfFame(bool);
50 36
51private slots: 37private slots:
52 void newKpacman(); 38 void newKpacman();
53 void pauseKpacman(); 39 void pauseKpacman();
54 void toggleHallOfFame(); 40 void toggleHallOfFame();
55 void toggleNew(); 41 void toggleNew();
56 void togglePaused(); 42 void togglePaused();
57 void quitKpacman(); 43 void quitKpacman();
58 44
59 void schemeChecked(int); 45 void schemeChecked(int);
60 void toggleFocusOutPause(); 46 void toggleFocusOutPause();
61 void toggleFocusInContinue(); 47 void toggleFocusInContinue();
62 void toggleHideMouseCursor(); 48 void toggleHideMouseCursor();
63 void confKeys(); 49 void confKeys();
64 50
65protected: 51protected:
66 52
67private: 53private:
68 KpacmanWidget *view; 54 KpacmanWidget *view;
69 55
70 void menu(); 56 void menu();
71 57
72 int lookupSchemes(); 58 int lookupSchemes();
73 59
60 QGridLayout *m_layout;
61 QWidget *m_view;
74 KMenuBar *_menuBar; 62 KMenuBar *_menuBar;
75 QPopupMenu *gamePopup; 63 QPopupMenu *gamePopup;
76 QPopupMenu *optionsPopup; 64 QPopupMenu *optionsPopup;
77 QPopupMenu *modesPopup; 65 QPopupMenu *modesPopup;
78 QList<QPopupMenu> *schemesPopup; 66 QList<QPopupMenu> *schemesPopup;
79 67
80 int newID; 68 int newID;
81 int pauseID; 69 int pauseID;
82 int hofID; 70 int hofID;
83 QArray<int> modeID; 71 QArray<int> modeID;
84 QArray<int> schemeID; 72 QArray<int> schemeID;
85 QArray<int> schemeMode; 73 QArray<int> schemeMode;
86 int focusOutPauseID; 74 int focusOutPauseID;
87 int focusInContinueID; 75 int focusInContinueID;
88 int hideMouseCursorID; 76 int hideMouseCursorID;
89 77
90 bool focusOutPause; 78 bool focusOutPause;
91 bool focusInContinue; 79 bool focusInContinue;
92 bool hideMouseCursor; 80 bool hideMouseCursor;
93}; 81};
94 82
95#endif // KPACMAN_H 83#endif // KPACMAN_H
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
@@ -1,88 +1,84 @@
1 1
2#include "portable.h" 2#include "portable.h"
3 3
4#if defined( KDE2_PORT ) 4#if defined( KDE2_PORT )
5#include <kapp.h> 5#include <kapp.h>
6#include <kconfig.h> 6#include <kconfig.h>
7#include <kstddirs.h> 7#include <kstddirs.h>
8#include <kpacmanwidget.h> 8#include <kpacmanwidget.h>
9#include <kpacmanwidget.moc> 9#include <kpacmanwidget.moc>
10#elif defined( QPE_PORT ) 10#elif defined( QPE_PORT )
11#include <qpe/qpeapplication.h> 11#include <qpe/qpeapplication.h>
12#include "config.h" 12#include "config.h"
13#include "kpacmanwidget.h" 13#include "kpacmanwidget.h"
14#endif 14#endif
15 15
16#include <qmessagebox.h> 16#include <qmessagebox.h>
17 17
18#include "bitfont.h" 18#include "bitfont.h"
19#include "score.h" 19#include "score.h"
20#include "referee.h" 20#include "referee.h"
21#include "status.h" 21#include "status.h"
22 22
23KpacmanWidget::KpacmanWidget( QWidget *parent, const char *name) 23KpacmanWidget::KpacmanWidget( QWidget *parent, const char *name)
24 : QWidget( parent, name ) 24 : QWidget( parent, name )
25{ 25{
26 bitfont = NULL; 26 bitfont = NULL;
27 fontName = ""; 27 fontName = "";
28 28
29 scheme = mode = -1; 29 scheme = mode = -1;
30 confScheme(); 30 confScheme();
31 31
32 score = new Score(this, name, scheme, mode, bitfont); 32 score = new Score(this, name, scheme, mode, bitfont);
33 referee = new Referee( this, name, scheme, mode, bitfont); 33 referee = new Referee( this, name, scheme, mode, bitfont);
34 status = new Status(this, name, scheme, mode); 34 status = new Status(this, name, scheme, mode);
35 35
36#ifndef QWS
37 setFixedSize(referee->width(), bitfont->height()*3 + referee->height() + status->height());
38#else
39 setBackgroundColor( black ); 36 setBackgroundColor( black );
40#endif
41} 37}
42 38
43KpacmanWidget::~KpacmanWidget() 39KpacmanWidget::~KpacmanWidget()
44{ 40{
45} 41}
46 42
47void KpacmanWidget::confMisc(bool defGroup) 43void KpacmanWidget::confMisc(bool defGroup)
48{ 44{
49 APP_CONFIG_BEGIN( cfg ); 45 APP_CONFIG_BEGIN( cfg );
50 //KStandardDirs *dirs = KGlobal::dirs(); 46 //KStandardDirs *dirs = KGlobal::dirs();
51 QString findPath; 47 QString findPath;
52 48
53 if (defGroup || cfg->hasKey("Font")) { 49 if (defGroup || cfg->hasKey("Font")) {
54 fontName = cfg->readEntry("Font"); 50 fontName = cfg->readEntry("Font");
55 51
56 if (fontName.left(1) != "/" && fontName.left(1) != "~") 52 if (fontName.left(1) != "/" && fontName.left(1) != "~")
57 fontName.insert(0, "fonts/"); 53 fontName.insert(0, "fonts/");
58 if (fontName.right(1) == "/") 54 if (fontName.right(1) == "/")
59 fontName.append("font.xbm"); 55 fontName.append("font.xbm");
60 56
61 //findPath = dirs->findResource("appdata", fontName); 57 //findPath = dirs->findResource("appdata", fontName);
62 findPath = FIND_APP_DATA( fontName ); 58 findPath = FIND_APP_DATA( fontName );
63 if (!findPath.isEmpty()) 59 if (!findPath.isEmpty())
64 fontName = findPath; 60 fontName = findPath;
65 61
66 bitfontFirstChar = cfg->readNumEntry("FontFirstChar", 0x0e); 62 bitfontFirstChar = cfg->readNumEntry("FontFirstChar", 0x0e);
67 bitfontLastChar = cfg->readNumEntry("FontLastChar", 0x5f); 63 bitfontLastChar = cfg->readNumEntry("FontLastChar", 0x5f);
68 } 64 }
69 APP_CONFIG_END( cfg ); 65 APP_CONFIG_END( cfg );
70} 66}
71 67
72void KpacmanWidget::confScheme() 68void KpacmanWidget::confScheme()
73{ 69{
74 APP_CONFIG_BEGIN( cfg ); 70 APP_CONFIG_BEGIN( cfg );
75 QString lastFontName = fontName; 71 QString lastFontName = fontName;
76 SAVE_CONFIG_GROUP( cfg, oldgroup ); 72 SAVE_CONFIG_GROUP( cfg, oldgroup );
77 QString newgroup; 73 QString newgroup;
78 74
79 // if not set, read mode and scheme from the configfile 75 // if not set, read mode and scheme from the configfile
80 if (mode == -1 && scheme == -1) { 76 if (mode == -1 && scheme == -1) {
81 scheme = cfg->readNumEntry("Scheme", -1); 77 scheme = cfg->readNumEntry("Scheme", -1);
82 mode = cfg->readNumEntry("Mode", -1); 78 mode = cfg->readNumEntry("Mode", -1);
83 79
84 // if mode is not set in the defGroup-group, lookup the scheme group 80 // if mode is not set in the defGroup-group, lookup the scheme group
85 if (scheme != -1 || mode == -1) { 81 if (scheme != -1 || mode == -1) {
86 newgroup.sprintf("Scheme %d", scheme); 82 newgroup.sprintf("Scheme %d", scheme);
87 cfg->setGroup(newgroup); 83 cfg->setGroup(newgroup);
88 84
@@ -93,70 +89,65 @@ void KpacmanWidget::confScheme()
93 89
94 confMisc(); 90 confMisc();
95 91
96 if (mode != -1) { 92 if (mode != -1) {
97 newgroup.sprintf("Mode %d", mode); 93 newgroup.sprintf("Mode %d", mode);
98 cfg->setGroup(newgroup); 94 cfg->setGroup(newgroup);
99 95
100 confMisc(FALSE); 96 confMisc(FALSE);
101 } 97 }
102 98
103 if (scheme != -1) { 99 if (scheme != -1) {
104 newgroup.sprintf("Scheme %d", scheme); 100 newgroup.sprintf("Scheme %d", scheme);
105 cfg->setGroup(newgroup); 101 cfg->setGroup(newgroup);
106 102
107 confMisc(FALSE); 103 confMisc(FALSE);
108 } 104 }
109 105
110 if (lastFontName != fontName) { 106 if (lastFontName != fontName) {
111 107
112 if (bitfont != 0) 108 if (bitfont != 0)
113 delete bitfont; 109 delete bitfont;
114 110
115 bitfont = new Bitfont(fontName, bitfontFirstChar, bitfontLastChar); 111 bitfont = new Bitfont(fontName, bitfontFirstChar, bitfontLastChar);
116 if (bitfont->width() == 0 || bitfont->height() == 0) { 112 if (bitfont->width() == 0 || bitfont->height() == 0) {
117 QString msg = tr("The bitfont could not be contructed.\n\n" 113 QString msg = tr("The bitfont could not be contructed.\n\n"
118 "The file '@FONTNAME@' does not exist,\n" 114 "The file '@FONTNAME@' does not exist,\n"
119 "or is of an unknown format."); 115 "or is of an unknown format.");
120 msg.replace(QRegExp("@FONTNAME@"), fontName); 116 msg.replace(QRegExp("@FONTNAME@"), fontName);
121 // QMessageBox::critical(this, tr("Initialization Error"), msg); 117 // QMessageBox::critical(this, tr("Initialization Error"), msg);
122 printf("%s\n", msg.data()); 118 printf("%s\n", msg.data());
123 } 119 }
124 } 120 }
125 121
126 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 122 RESTORE_CONFIG_GROUP( cfg, oldgroup );
127 APP_CONFIG_END( cfg ); 123 APP_CONFIG_END( cfg );
128} 124}
129 125
130void KpacmanWidget::setScheme(int Scheme, int Mode) 126void KpacmanWidget::setScheme(int Scheme, int Mode)
131{ 127{
132 mode = Mode; 128 mode = Mode;
133 scheme = Scheme; 129 scheme = Scheme;
134 130
135 confScheme(); 131 confScheme();
136 132
137 score->setScheme(Scheme, Mode, bitfont); 133 score->setScheme(Scheme, Mode, bitfont);
138 referee->setScheme(Scheme, Mode, bitfont); 134 referee->setScheme(Scheme, Mode, bitfont);
139 status->setScheme(Scheme, Mode); 135 status->setScheme(Scheme, Mode);
140 136
141#ifndef QWS
142 setFixedSize(referee->width(),
143 bitfont->height()*3 + referee->height() + status->height());
144#endif
145
146 score->repaint(FALSE); 137 score->repaint(FALSE);
147 referee->repaint(FALSE); 138 referee->repaint(FALSE);
148 status->repaint(FALSE); 139 status->repaint(FALSE);
149} 140}
150 141
151void KpacmanWidget::resizeEvent( QResizeEvent * ) 142void KpacmanWidget::resizeEvent( QResizeEvent * )
152{ 143{
153 referee->setGeometry(0, bitfont->height()*3, referee->width(), referee->height()); 144 referee->setGeometry(0, bitfont->height()*3, referee->width(), referee->height());
154 referee->setBackgroundColor(BLACK); 145 referee->setBackgroundColor(BLACK);
155 146
156 status->setGeometry(0, bitfont->height()*3+referee->height(), referee->width(), 147 status->setGeometry(0, bitfont->height()*3+referee->height(), referee->width(),
157 status->height()); 148 status->height());
158 status->setBackgroundColor(BLACK); 149 status->setBackgroundColor(BLACK);
159 150
160 score->setGeometry(0, 0, referee->width(), bitfont->height()*3+referee->height()+status->height()); 151 score->setGeometry(0, 0, referee->width(), bitfont->height()*3+referee->height()+status->height());
161 score->setBackgroundColor(BLACK); 152 score->setBackgroundColor(BLACK);
162} 153}
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
@@ -686,100 +686,100 @@ void Referee::confScheme()
686 686
687 confMisc(FALSE); 687 confMisc(FALSE);
688 confTiming(FALSE); 688 confTiming(FALSE);
689 confScoring(FALSE); 689 confScoring(FALSE);
690 } 690 }
691 691
692 fillMapName(); 692 fillMapName();
693 693
694 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 694 RESTORE_CONFIG_GROUP( cfg, oldgroup );
695 APP_CONFIG_END( cfg ); 695 APP_CONFIG_END( cfg );
696} 696}
697 697
698void Referee::setScheme(int Scheme, int Mode, Bitfont *font) 698void Referee::setScheme(int Scheme, int Mode, Bitfont *font)
699{ 699{
700 mode = Mode; 700 mode = Mode;
701 scheme = Scheme; 701 scheme = Scheme;
702 702
703 confScheme(); 703 confScheme();
704 704
705 pix->setScheme(scheme, mode, font); 705 pix->setScheme(scheme, mode, font);
706 706
707 pacman->setMaxPixmaps(pix->maxPixmaps(PacmanPix)); 707 pacman->setMaxPixmaps(pix->maxPixmaps(PacmanPix));
708 fruit->setMaxPixmaps(pix->maxPixmaps(FruitPix)); 708 fruit->setMaxPixmaps(pix->maxPixmaps(FruitPix));
709 709
710 for (Monster *m = monsters->first(); m != 0; m = monsters->next()) 710 for (Monster *m = monsters->first(); m != 0; m = monsters->next())
711 if (m) 711 if (m)
712 m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix)); 712 m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix));
713 713
714 for (Energizer *e = energizers->first(); e != 0; e = energizers->next()) 714 for (Energizer *e = energizers->first(); e != 0; e = energizers->next())
715 if (e) 715 if (e)
716 e->setMaxPixmaps(pix->maxPixmaps(EnergizerPix)); 716 e->setMaxPixmaps(pix->maxPixmaps(EnergizerPix));
717 717
718 if (gameState.testBit(Introducing)) 718 if (gameState.testBit(Introducing))
719 for (int i = 0; i < (gameState.testBit(Init) ? timerCount : 15); i++) 719 for (int i = 0; i < (gameState.testBit(Init) ? timerCount : 15); i++)
720 introPaint(i); 720 introPaint(i);
721 721
722 setFixedSize(pix->levelPix().size()); 722 setFixedSize(pix->levelPix().size());
723 repaint(); 723 repaint();
724} 724}
725 725
726void Referee::keyPressEvent( QKeyEvent *k ) 726void Referee::keyPressEvent( QKeyEvent *k )
727{ 727{
728 uint key = k->key(); 728 uint key = k->key();
729#ifdef QWS 729#ifdef QWS
730 // "OK" => new game 730 // "OK" => new game
731 if ( key == Key_F33 || key == Key_F2 || key == Key_Enter ) 731 if ( key == Key_F33 || key == Key_F2 || key == Key_Enter )
732 play(); 732 play();
733 else if ( !gameState.testBit(Playing) && 733 else if ( !gameState.testBit(Playing) &&
734 key == Key_Up || 734 ( key == Key_Up ||
735 key == Key_Down || 735 key == Key_Down ||
736 key == Key_Right || 736 key == Key_Right ||
737 key == Key_Left ) 737 key == Key_Left ))
738 play(); 738 play();
739 // "Space" => pause 739 // "Space" => pause
740 //else if ( key == Key_Space || key == Key_F3 ) 740 //else if ( key == Key_Space || key == Key_F3 )
741 // pause(); 741 // pause();
742 // "Menu" => hall of fame 742 // "Menu" => hall of fame
743 //else if ( key == Key_F11 || key == Key_F4 ) 743 //else if ( key == Key_F11 || key == Key_F4 )
744 // toggleHallOfFame(); 744 // toggleHallOfFame();
745#endif 745#endif
746 746
747 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame) || 747 if (gameState.testBit(Paused) || gameState.testBit(HallOfFame) ||
748 gameState.testBit(Demonstration) || gameState.testBit(Dying) || 748 gameState.testBit(Demonstration) || gameState.testBit(Dying) ||
749 gameState.testBit(Ready) || gameState.testBit(LevelDone) || 749 gameState.testBit(Ready) || gameState.testBit(LevelDone) ||
750 !gameState.testBit(Playing)) 750 !gameState.testBit(Playing))
751 return; 751 return;
752 752
753 if (key == UpKey) 753 if (key == UpKey)
754 pacman->setDirection(N); 754 pacman->setDirection(N);
755 else if (key == DownKey) 755 else if (key == DownKey)
756 pacman->setDirection(S); 756 pacman->setDirection(S);
757 else if (key == RightKey) 757 else if (key == RightKey)
758 pacman->setDirection(E); 758 pacman->setDirection(E);
759 else if (key == LeftKey) 759 else if (key == LeftKey)
760 pacman->setDirection(W); 760 pacman->setDirection(W);
761 761
762#ifdef CHEATS 762#ifdef CHEATS
763 else if (key == Key_L) { printf("levelUp()\n"); levelUp(); } 763 else if (key == Key_L) { printf("levelUp()\n"); levelUp(); }
764 else if (key == Key_F) { printf("fruit->move(TRUE)\n"); fruit->move(TRUE); repaint(FALSE); } 764 else if (key == Key_F) { printf("fruit->move(TRUE)\n"); fruit->move(TRUE); repaint(FALSE); }
765 else if (key == Key_E) { printf("setLifes(++lifes)\n"); emit setLifes(++lifes); } 765 else if (key == Key_E) { printf("setLifes(++lifes)\n"); emit setLifes(++lifes); }
766#endif 766#endif
767 767
768 else { 768 else {
769 k->ignore(); 769 k->ignore();
770 return; 770 return;
771 } 771 }
772 k->accept(); 772 k->accept();
773} 773}
774 774
775void Referee::score(int p) 775void Referee::score(int p)
776{ 776{
777 if (!gameState.testBit(Playing)) 777 if (!gameState.testBit(Playing))
778 return; 778 return;
779 779
780 if ((points += p) < 0) 780 if ((points += p) < 0)
781 points = 0; 781 points = 0;
782 782
783 emit setPoints(points); 783 emit setPoints(points);
784 784
785 if (points >= nextExtraLifeScore) { 785 if (points >= nextExtraLifeScore) {
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
@@ -433,124 +433,96 @@ void Score::setScore(int level, int player)
433 cursor.x = 14; 433 cursor.x = 14;
434 cursor.y = 11+lastScore; 434 cursor.y = 11+lastScore;
435 cursor.chr = hallOfFame[lastScore].name.at(cursor.x-14); 435 cursor.chr = hallOfFame[lastScore].name.at(cursor.x-14);
436 436
437// startTimer(cursorBlinkMS); 437// startTimer(cursorBlinkMS);
438 setFocus(); 438 setFocus();
439} 439}
440 440
441/* 441/*
442 * Read the highscores, if no file or a file shorter than 4 bytes (versions before 0.2.4 stores only 442 * Read the highscores, if no file or a file shorter than 4 bytes (versions before 0.2.4 stores only
443 * the points of one highscore) exists - the highscores were initialized with default values. 443 * the points of one highscore) exists - the highscores were initialized with default values.
444 */ 444 */
445void Score::read() 445void Score::read()
446{ 446{
447 if (highscoreFile.exists() && highscoreFile.size() > 4) { 447 if (highscoreFile.exists() && highscoreFile.size() > 4) {
448 if (highscoreFile.open(IO_ReadOnly)) { 448 if (highscoreFile.open(IO_ReadOnly)) {
449 QDataStream s(&highscoreFile); 449 QDataStream s(&highscoreFile);
450 char *name; 450 char *name;
451 for (int i = 0; i < 10; i++) { 451 for (int i = 0; i < 10; i++) {
452 s >> hallOfFame[i].points >> hallOfFame[i].levels >> hallOfFame[i].duration >> 452 s >> hallOfFame[i].points >> hallOfFame[i].levels >> hallOfFame[i].duration >>
453 hallOfFame[i].moment >> name; 453 hallOfFame[i].moment >> name;
454 hallOfFame[i].name = QString::fromLatin1(name); 454 hallOfFame[i].name = QString::fromLatin1(name);
455 delete(name); 455 delete(name);
456 } 456 }
457 highscoreFile.close(); 457 highscoreFile.close();
458 } 458 }
459 } else { 459 } else {
460 for (int i = 0; i < 10; i++) { 460 for (int i = 0; i < 10; i++) {
461 hallOfFame[i].points = 5000; 461 hallOfFame[i].points = 5000;
462 hallOfFame[i].levels = 0; 462 hallOfFame[i].levels = 0;
463 hallOfFame[i].duration = QTime(); 463 hallOfFame[i].duration = QTime();
464 hallOfFame[i].moment = QDateTime(); 464 hallOfFame[i].moment = QDateTime();
465 hallOfFame[i].name = "???"; 465 hallOfFame[i].name = "???";
466 } 466 }
467 // write(); 467 // write();
468 } 468 }
469 469
470 for (int i = 0; i < 10; i++) 470 for (int i = 0; i < 10; i++)
471 for (uint j = 0; j < hallOfFame[i].name.length(); j++) 471 for (uint j = 0; j < hallOfFame[i].name.length(); j++)
472 if (hallOfFame[i].name.at(j) < bitfont->firstChar() || 472 if (hallOfFame[i].name.at(j) < bitfont->firstChar() ||
473 hallOfFame[i].name.at(j) > bitfont->lastChar()) 473 hallOfFame[i].name.at(j) > bitfont->lastChar())
474 hallOfFame[i].name.at(j) = hallOfFame[i].name.at(j).upper(); 474 hallOfFame[i].name.at(j) = hallOfFame[i].name.at(j).upper();
475 475
476 HighScore = hallOfFame[0].points; 476 HighScore = hallOfFame[0].points;
477} 477}
478 478
479void Score::write() 479void Score::write()
480{ 480{
481#ifndef QWS
482 if (!highscoreFile.exists() && highscoreFile.name() == systemHighscoreFileInfo.filePath())
483 KMessageBox::information(0,
484 tr("You're going to create the highscore-file\n"
485 "'%1'\n"
486 "for your maschine, that should be used systemwide.\n"
487 "\n"
488 "To grant access to the other users, set the appropriate rights (a+w)\n"
489 "on that file or ask your systemadministator for that favor.\n"
490 "\n"
491 "To use a different directory or filename for the highscores,"
492 "specify them in the configfile (kpacmanrc:highscoreFilePath)."
493 ).arg(systemHighscoreFileInfo.filePath()));
494
495 if (highscoreFile.name() == privateHighscoreFileInfo.filePath())
496 KMessageBox::information(0,
497 tr("You're using a private highscore-file, that's mostly because of\n"
498 "missing write-access to the systemwide file\n"
499 "'%1' .\n"
500 "\n"
501 "Ask your systemadministrator for granting you access to that file,\n"
502 "by setting the appropriate rights (a+w) on it.\n"
503 "\n"
504 "To use a different directory or filename for the highscores,"
505 "specify them in the configfile (kpacmanrc:highscoreFilePath)."
506 ).arg(systemHighscoreFileInfo.filePath()),
507 QString::null, "PrivateHighscore");
508#endif
509 if (highscoreFile.open(IO_WriteOnly)) { 481 if (highscoreFile.open(IO_WriteOnly)) {
510 QDataStream s(&highscoreFile); 482 QDataStream s(&highscoreFile);
511 for (int i = 0; i < 10; i++) 483 for (int i = 0; i < 10; i++)
512 s << hallOfFame[i].points << hallOfFame[i].levels << hallOfFame[i].duration << 484 s << hallOfFame[i].points << hallOfFame[i].levels << hallOfFame[i].duration <<
513 hallOfFame[i].moment << hallOfFame[i].name.latin1(); 485 hallOfFame[i].moment << hallOfFame[i].name.latin1();
514 highscoreFile.close(); 486 highscoreFile.close();
515 } 487 }
516} 488}
517 489
518void Score::setPause(bool Paused) 490void Score::setPause(bool Paused)
519{ 491{
520 paused = Paused; 492 paused = Paused;
521 493
522 QRect r = bitfont->rect(tr("PAUSED")); 494 QRect r = bitfont->rect(tr("PAUSED"));
523 r.moveCenter(QPoint(this->width()/2, this->height()/2)); 495 r.moveCenter(QPoint(this->width()/2, this->height()/2));
524 repaint(r, TRUE); 496 repaint(r, TRUE);
525 497
526 // repaint 1UP or 2UP 498 // repaint 1UP or 2UP
527 repaint(FALSE); 499 repaint(FALSE);
528} 500}
529 501
530void Score::end() 502void Score::end()
531{ 503{
532 if (paused) { 504 if (paused) {
533 QTimer::singleShot(afterPauseMS, this, SLOT(end())); 505 QTimer::singleShot(afterPauseMS, this, SLOT(end()));
534 return; 506 return;
535 } 507 }
536 508
537 // repaint 1UP or 2UP 509 // repaint 1UP or 2UP
538 lastPlayer = -1; 510 lastPlayer = -1;
539 repaint(FALSE); 511 repaint(FALSE);
540 512
541 emit forcedHallOfFame(FALSE); 513 emit forcedHallOfFame(FALSE);
542} 514}
543 515
544/* 516/*
545 * Return the date in a formatted QString. The format can be changed using internationalization 517 * Return the date in a formatted QString. The format can be changed using internationalization
546 * of the string "YY/MM/DD". Invalid QDate's where returned as "00/00/00". 518 * of the string "YY/MM/DD". Invalid QDate's where returned as "00/00/00".
547 */ 519 */
548QString Score::formatDate(QDate date) 520QString Score::formatDate(QDate date)
549{ 521{
550 QString s = tr("@YY@/@MM@/@DD@"); 522 QString s = tr("@YY@/@MM@/@DD@");
551 523
552 QString dd; 524 QString dd;
553 dd.sprintf("%02d", date.isValid() ? date.year() % 100 : 0); 525 dd.sprintf("%02d", date.isValid() ? date.year() % 100 : 0);
554 s.replace(QRegExp("@YY@"), dd); 526 s.replace(QRegExp("@YY@"), dd);
555 dd.sprintf("%02d", date.isValid() ? date.month() : 0); 527 dd.sprintf("%02d", date.isValid() ? date.month() : 0);
556 s.replace(QRegExp("@MM@"), dd); 528 s.replace(QRegExp("@MM@"), dd);
@@ -560,83 +532,50 @@ QString Score::formatDate(QDate date)
560 return s; 532 return s;
561} 533}
562 534
563QRect Score::rect(int col, float row, QString str, int align) 535QRect Score::rect(int col, float row, QString str, int align)
564{ 536{
565 QRect r = bitfont->rect(str); 537 QRect r = bitfont->rect(str);
566 r.moveBy(x(col), y(row)); 538 r.moveBy(x(col), y(row));
567 539
568 int dx = 0; 540 int dx = 0;
569 int dy = 0; 541 int dy = 0;
570 542
571 if (align & AlignLeft || align & AlignRight) { 543 if (align & AlignLeft || align & AlignRight) {
572 dx = (str.length()-1) * (bitfont->width()/2); 544 dx = (str.length()-1) * (bitfont->width()/2);
573 if (align & AlignRight) 545 if (align & AlignRight)
574 dx *= -1; 546 dx *= -1;
575 } 547 }
576 548
577 if (align & AlignTop || align & AlignBottom) { 549 if (align & AlignTop || align & AlignBottom) {
578 dy = bitfont->height()/2; 550 dy = bitfont->height()/2;
579 if (align & AlignBottom) 551 if (align & AlignBottom)
580 dy *= -1; 552 dy *= -1;
581 } 553 }
582 554
583 if (dx != 0 || dy != 0) 555 if (dx != 0 || dy != 0)
584 r.moveBy(dx, dy); 556 r.moveBy(dx, dy);
585 557
586 return r; 558 return r;
587} 559}
588 560
589int Score::x(int col) 561int Score::x(int col)
590{ 562{
591 return col*bitfont->width(); 563 return col*bitfont->width();
592} 564}
593 565
594int Score::y(float row) 566int Score::y(float row)
595{ 567{
596 return (int) (row*(bitfont->height()+bitfont->height()/4)); 568 return (int) (row*(bitfont->height()+bitfont->height()/4));
597} 569}
598 570
599/** 571/**
600 * Ermittelt die zu benutzende "highscore"-Datei, in die auch geschrieben werden kann. 572 * Ermittelt die zu benutzende "highscore"-Datei, in die auch geschrieben werden kann.
601 * Über den "highscoreFilePath"-KConfig-Eintrag, kann abweichend von der Standardlokation 573 * Über den "highscoreFilePath"-KConfig-Eintrag, kann abweichend von der Standardlokation
602 * der Standort der "highscore"-Datei spezifiziert werden. 574 * der Standort der "highscore"-Datei spezifiziert werden.
603 * Wenn die systemweite "highscore"-Datei nicht beschrieben werden kann, wird mit einer 575 * Wenn die systemweite "highscore"-Datei nicht beschrieben werden kann, wird mit einer
604 * privaten Datei gearbeitet. 576 * privaten Datei gearbeitet.
605 */ 577 */
606QFileInfo Score::locateHighscoreFilePath() 578QFileInfo Score::locateHighscoreFilePath()
607{ 579{
608#ifndef QWS
609 QFileInfo systemHighscoreDirPath;
610 QStringList systemHighscoreDirs;
611
612 // Schreibfähige "private" highscore-Datei ermitteln für den fallback.
613 privateHighscoreFileInfo.setFile(KGlobal::dirs()->saveLocation("appdata")+highscoreName);
614
615 // FilePath aus der Konfigurationsdatei benutzen
616 systemHighscoreFileInfo.setFile(cfg->readEntry("HighscoreFilePath"));
617
618 // Kein Wert aus der Konfiguration erhalten, dann die "system"-Datei suchen.
619 if (systemHighscoreFileInfo.filePath().isEmpty())
620 systemHighscoreDirs = KGlobal::dirs()->resourceDirs("appdata");
621 else
622 systemHighscoreDirs = QStringList(systemHighscoreFileInfo.filePath());
623
624 for (QStringList::Iterator i = systemHighscoreDirs.begin(); i != systemHighscoreDirs.end(); ++i) {
625
626 systemHighscoreFileInfo.setFile(*i);
627 if (systemHighscoreFileInfo.fileName().isEmpty())
628 systemHighscoreFileInfo.setFile(systemHighscoreFileInfo.dirPath()+"/"+highscoreName);
629
630 // privateHighscoreFileInfo für die "system" Suche ignorieren
631 if (systemHighscoreFileInfo.filePath() != privateHighscoreFileInfo.filePath())
632 if (!systemHighscoreFileInfo.exists()) {
633 systemHighscoreDirPath.setFile(systemHighscoreFileInfo.dirPath());
634 if (systemHighscoreDirPath.exists() && systemHighscoreDirPath.isWritable())
635 return systemHighscoreFileInfo;
636 } else
637 if (systemHighscoreFileInfo.isWritable())
638 return systemHighscoreFileInfo;
639 }
640#endif
641 return privateHighscoreFileInfo; 580 return privateHighscoreFileInfo;
642} 581}