summaryrefslogtreecommitdiff
path: root/noncore/games/kpacman/kpacman.cpp
Unidiff
Diffstat (limited to 'noncore/games/kpacman/kpacman.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/kpacman/kpacman.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/games/kpacman/kpacman.cpp b/noncore/games/kpacman/kpacman.cpp
index be2e46d..9820e5a 100644
--- a/noncore/games/kpacman/kpacman.cpp
+++ b/noncore/games/kpacman/kpacman.cpp
@@ -1,229 +1,229 @@
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 <qpe/config.h> 10#include <qpe/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 15
16Kpacman::Kpacman(QWidget *parent, const char *name) 16Kpacman::Kpacman(QWidget *parent, const char *name)
17 : KTMainWindow(parent, name) 17 : KTMainWindow(parent, name)
18{ 18{
19 schemesPopup = new QList<QPopupMenu>; 19 schemesPopup = new QList<QPopupMenu>;
20 schemesPopup->setAutoDelete(TRUE); 20 schemesPopup->setAutoDelete(TRUE);
21 21
22 menu(); 22 menu();
23 23
24 m_view = new QWidget( this, "m_view" ); 24 m_view = new QWidget( this, "m_view" );
25 m_view->setBackgroundColor( black ); 25 m_view->setBackgroundColor( black );
26 m_layout = new QGridLayout( m_view ); 26 m_layout = new QGridLayout( m_view );
27 m_layout->setMargin( 7 ); 27 m_layout->setMargin( 7 );
28 28
29 view = new KpacmanWidget( this, QString(name)+"widget"); 29 view = new KpacmanWidget( this, QString(name)+"widget");
30 m_layout->addWidget( view, 0, 0 ); 30 m_layout->addWidget( view, 0, 0 );
31 31
32 setCaption( tr("KPacman") ); 32 setCaption( tr("KPacman") );
33 33
34 view->referee->setFocus(); 34 view->referee->setFocus();
35 35
36 connect(view->referee, SIGNAL(setScore(int, int)), 36 connect(view->referee, SIGNAL(setScore(int,int)),
37 view->score, SLOT(setScore(int, int))); 37 view->score, SLOT(setScore(int,int)));
38 connect(view->referee, SIGNAL(setPoints(int)), 38 connect(view->referee, SIGNAL(setPoints(int)),
39 view->score, SLOT(set(int))); 39 view->score, SLOT(set(int)));
40 connect(view->referee, SIGNAL(setLifes(int)), 40 connect(view->referee, SIGNAL(setLifes(int)),
41 view->status, SLOT(setLifes(int))); 41 view->status, SLOT(setLifes(int)));
42 connect(view->referee, SIGNAL(setLevel(int)), 42 connect(view->referee, SIGNAL(setLevel(int)),
43 view->status, SLOT(setLevel(int))); 43 view->status, SLOT(setLevel(int)));
44 connect(view->referee, SIGNAL(forcedHallOfFame(bool)), 44 connect(view->referee, SIGNAL(forcedHallOfFame(bool)),
45 this, SLOT(forcedHallOfFame(bool))); 45 this, SLOT(forcedHallOfFame(bool)));
46 connect(view->referee, SIGNAL(togglePaused()), this, SLOT(togglePaused())); 46 connect(view->referee, SIGNAL(togglePaused()), this, SLOT(togglePaused()));
47 connect(view->referee, SIGNAL(toggleNew()), this, SLOT(toggleNew())); 47 connect(view->referee, SIGNAL(toggleNew()), this, SLOT(toggleNew()));
48 48
49 connect(view->score, SIGNAL(toggleNew()), this, SLOT(toggleNew())); 49 connect(view->score, SIGNAL(toggleNew()), this, SLOT(toggleNew()));
50 connect(view->score, SIGNAL(forcedHallOfFame(bool)), 50 connect(view->score, SIGNAL(forcedHallOfFame(bool)),
51 this, SLOT(forcedHallOfFame(bool))); 51 this, SLOT(forcedHallOfFame(bool)));
52 52
53 APP_CONFIG_BEGIN( cfg ); 53 APP_CONFIG_BEGIN( cfg );
54 focusOutPause = !cfg->readBoolEntry("FocusOutPause", TRUE); 54 focusOutPause = !cfg->readBoolEntry("FocusOutPause", TRUE);
55 focusInContinue = !cfg->readBoolEntry("FocusInContinue", TRUE); 55 focusInContinue = !cfg->readBoolEntry("FocusInContinue", TRUE);
56 hideMouseCursor = !cfg->readBoolEntry("HideMouseCursor", TRUE); 56 hideMouseCursor = !cfg->readBoolEntry("HideMouseCursor", TRUE);
57 APP_CONFIG_END( cfg ); 57 APP_CONFIG_END( cfg );
58 58
59 toggleFocusOutPause(); 59 toggleFocusOutPause();
60 toggleFocusInContinue(); 60 toggleFocusInContinue();
61 toggleHideMouseCursor(); 61 toggleHideMouseCursor();
62 62
63 setCentralWidget( m_view ); 63 setCentralWidget( m_view );
64} 64}
65 65
66Kpacman::~Kpacman() 66Kpacman::~Kpacman()
67{ 67{
68 /* APP_CONFIG_BEGIN( cfg ); 68 /* APP_CONFIG_BEGIN( cfg );
69 cfg->writeEntry("FocusOutPause", focusOutPause); 69 cfg->writeEntry("FocusOutPause", focusOutPause);
70 cfg->writeEntry("FocusInContinue", focusInContinue); 70 cfg->writeEntry("FocusInContinue", focusInContinue);
71 cfg->writeEntry("HideMouseCursor", hideMouseCursor); 71 cfg->writeEntry("HideMouseCursor", hideMouseCursor);
72 APP_CONFIG_END( cfg ); 72 APP_CONFIG_END( cfg );
73 */ 73 */
74 delete _menuBar; 74 delete _menuBar;
75} 75}
76 76
77void Kpacman::menu() 77void Kpacman::menu()
78{ 78{
79 gamePopup = new QPopupMenu(); 79 gamePopup = new QPopupMenu();
80 CHECK_PTR( gamePopup ); 80 CHECK_PTR( gamePopup );
81 newID = gamePopup->insertItem(tr("&New"), this, SLOT(newKpacman()),Key_F2); 81 newID = gamePopup->insertItem(tr("&New"), this, SLOT(newKpacman()),Key_F2);
82 pauseID = gamePopup->insertItem(tr("&Pause"), 82 pauseID = gamePopup->insertItem(tr("&Pause"),
83 this, SLOT(pauseKpacman()), Key_F3); 83 this, SLOT(pauseKpacman()), Key_F3);
84 hofID = gamePopup->insertItem(tr("&Hall of fame"), 84 hofID = gamePopup->insertItem(tr("&Hall of fame"),
85 this, SLOT(toggleHallOfFame()), Key_F4); 85 this, SLOT(toggleHallOfFame()), Key_F4);
86 gamePopup->insertSeparator(); 86 gamePopup->insertSeparator();
87 gamePopup->insertItem(tr("&Quit"), this, SLOT(quitKpacman()), CTRL+Key_Q); 87 gamePopup->insertItem(tr("&Quit"), this, SLOT(quitKpacman()), CTRL+Key_Q);
88 gamePopup->setCheckable(TRUE); 88 gamePopup->setCheckable(TRUE);
89 89
90 optionsPopup = new QPopupMenu(); 90 optionsPopup = new QPopupMenu();
91 CHECK_PTR(optionsPopup); 91 CHECK_PTR(optionsPopup);
92 92
93 modesPopup = new QPopupMenu(); 93 modesPopup = new QPopupMenu();
94 CHECK_PTR(modesPopup); 94 CHECK_PTR(modesPopup);
95 95
96 hideMouseCursorID = optionsPopup->insertItem(tr("&Hide Mousecursor"), 96 hideMouseCursorID = optionsPopup->insertItem(tr("&Hide Mousecursor"),
97 this, SLOT(toggleHideMouseCursor()), 97 this, SLOT(toggleHideMouseCursor()),
98 CTRL+Key_H); 98 CTRL+Key_H);
99 optionsPopup->insertSeparator(); 99 optionsPopup->insertSeparator();
100 100
101 if (lookupSchemes() > 0) { 101 if (lookupSchemes() > 0) {
102 optionsPopup->insertItem(tr("&Select graphic scheme"), modesPopup); 102 optionsPopup->insertItem(tr("&Select graphic scheme"), modesPopup);
103 optionsPopup->insertSeparator(); 103 optionsPopup->insertSeparator();
104 } 104 }
105 105
106 focusOutPauseID = optionsPopup->insertItem(tr("&Pause in Background"), 106 focusOutPauseID = optionsPopup->insertItem(tr("&Pause in Background"),
107 this, SLOT(toggleFocusOutPause())); 107 this, SLOT(toggleFocusOutPause()));
108 focusInContinueID = optionsPopup->insertItem(tr("&Continue in Foreground"), 108 focusInContinueID = optionsPopup->insertItem(tr("&Continue in Foreground"),
109 this, SLOT(toggleFocusInContinue())); 109 this, SLOT(toggleFocusInContinue()));
110 optionsPopup->insertSeparator(); 110 optionsPopup->insertSeparator();
111 111
112 optionsPopup->insertItem(tr("Change &keys..."), this, SLOT(confKeys())); 112 optionsPopup->insertItem(tr("Change &keys..."), this, SLOT(confKeys()));
113 113
114#ifndef QPE_PORT 114#ifndef QPE_PORT
115 QString aboutText = tr("@PACKAGE@ - @VERSION@\n\n" 115 QString aboutText = tr("@PACKAGE@ - @VERSION@\n\n"
116 "Joerg Thoennissen (joe@dsite.de)\n\n" 116 "Joerg Thoennissen (joe@dsite.de)\n\n"
117 "A pacman game for the KDE Desktop\n\n" 117 "A pacman game for the KDE Desktop\n\n"
118 "The program based on the source of ksnake\n" 118 "The program based on the source of ksnake\n"
119 "by Michel Filippi (mfilippi@sade.rhein-main.de).\n" 119 "by Michel Filippi (mfilippi@sade.rhein-main.de).\n"
120 "The design was strongly influenced by the pacman\n" 120 "The design was strongly influenced by the pacman\n"
121 "(c) 1980 MIDWAY MFG.CO.\n\n" 121 "(c) 1980 MIDWAY MFG.CO.\n\n"
122 "I like to thank my girlfriend Elke Krueers for\n" 122 "I like to thank my girlfriend Elke Krueers for\n"
123 "the last 10 years of her friendship.\n"); 123 "the last 10 years of her friendship.\n");
124 aboutText.replace(QRegExp("@PACKAGE@"), PACKAGE); 124 aboutText.replace(QRegExp("@PACKAGE@"), PACKAGE);
125 aboutText.replace(QRegExp("@VERSION@"), VERSION); 125 aboutText.replace(QRegExp("@VERSION@"), VERSION);
126 QPopupMenu *helpPopup = helpMenu(aboutText, FALSE); 126 QPopupMenu *helpPopup = helpMenu(aboutText, FALSE);
127#endif 127#endif
128 128
129 //_menuBar = new KMenuBar(this); 129 //_menuBar = new KMenuBar(this);
130 //CHECK_PTR( _menuBar ); 130 //CHECK_PTR( _menuBar );
131 //_menuBar->insertItem(tr("&Game"), gamePopup); 131 //_menuBar->insertItem(tr("&Game"), gamePopup);
132 //_menuBar->insertItem(tr("&Options"), optionsPopup); 132 //_menuBar->insertItem(tr("&Options"), optionsPopup);
133 //_menuBar->insertSeparator(); 133 //_menuBar->insertSeparator();
134#ifndef QPE_PORT 134#ifndef QPE_PORT
135 _menuBar->insertItem(tr("&Help"), helpPopup); 135 _menuBar->insertItem(tr("&Help"), helpPopup);
136#endif 136#endif
137} 137}
138 138
139int Kpacman::lookupSchemes() 139int Kpacman::lookupSchemes()
140{ 140{
141 APP_CONFIG_BEGIN( cfg ); 141 APP_CONFIG_BEGIN( cfg );
142 int ModeCount = cfg->readNumEntry("ModeCount", 0); 142 int ModeCount = cfg->readNumEntry("ModeCount", 0);
143 int Mode = cfg->readNumEntry("Mode", 0); 143 int Mode = cfg->readNumEntry("Mode", 0);
144 int SchemeCount = cfg->readNumEntry("SchemeCount", 0); 144 int SchemeCount = cfg->readNumEntry("SchemeCount", 0);
145 int Scheme = cfg->readNumEntry("Scheme", 0); 145 int Scheme = cfg->readNumEntry("Scheme", 0);
146 146
147 /* 147 /*
148 if (SchemeCount == 0 || Scheme == -1) { 148 if (SchemeCount == 0 || Scheme == -1) {
149 QMessageBox::warning(this, tr("Configuration Error"), 149 QMessageBox::warning(this, tr("Configuration Error"),
150 tr("There are no schemes defined,\n" 150 tr("There are no schemes defined,\n"
151 "or no scheme is selected.")); 151 "or no scheme is selected."));
152 APP_CONFIG_END( cfg ); 152 APP_CONFIG_END( cfg );
153 return 0; 153 return 0;
154 } 154 }
155 */ 155 */
156 156
157 connect(modesPopup, SIGNAL(activated(int)), this, SLOT(schemeChecked(int))); 157 connect(modesPopup, SIGNAL(activated(int)), this, SLOT(schemeChecked(int)));
158 modeID.resize(ModeCount > 0 ? ModeCount : 0); 158 modeID.resize(ModeCount > 0 ? ModeCount : 0);
159 159
160 if (!schemesPopup->isEmpty()) 160 if (!schemesPopup->isEmpty())
161 schemesPopup->clear(); 161 schemesPopup->clear();
162 162
163 SAVE_CONFIG_GROUP( cfg, oldgroup ); 163 SAVE_CONFIG_GROUP( cfg, oldgroup );
164 164
165 QString ModeGroup; 165 QString ModeGroup;
166 QString ModeName; 166 QString ModeName;
167 167
168 for (int m = 0; m < ModeCount; m++) { 168 for (int m = 0; m < ModeCount; m++) {
169 ModeGroup.sprintf("Mode %d", m); 169 ModeGroup.sprintf("Mode %d", m);
170 cfg->setGroup(ModeGroup); 170 cfg->setGroup(ModeGroup);
171 171
172 ModeName = cfg->readEntry("Description", ModeGroup); 172 ModeName = cfg->readEntry("Description", ModeGroup);
173 173
174 QPopupMenu *p = new QPopupMenu; 174 QPopupMenu *p = new QPopupMenu;
175 p->setCheckable(TRUE); 175 p->setCheckable(TRUE);
176 connect(p, SIGNAL(activated(int)), this, SLOT(schemeChecked(int))); 176 connect(p, SIGNAL(activated(int)), this, SLOT(schemeChecked(int)));
177 schemesPopup->append(p); 177 schemesPopup->append(p);
178 178
179 modeID[m] = modesPopup->insertItem(ModeName, schemesPopup->at(m)); 179 modeID[m] = modesPopup->insertItem(ModeName, schemesPopup->at(m));
180 modesPopup->setItemEnabled(modeID[m], FALSE); 180 modesPopup->setItemEnabled(modeID[m], FALSE);
181 modesPopup->setItemChecked(modeID[m], m == Mode); 181 modesPopup->setItemChecked(modeID[m], m == Mode);
182 } 182 }
183 183
184 schemeID.resize(SchemeCount); 184 schemeID.resize(SchemeCount);
185 schemeMode.resize(SchemeCount); 185 schemeMode.resize(SchemeCount);
186 186
187 QString SchemeGroup; 187 QString SchemeGroup;
188 QString SchemeName; 188 QString SchemeName;
189 int SchemeMode; 189 int SchemeMode;
190 190
191 for (int i = 0; i < SchemeCount; i++) { 191 for (int i = 0; i < SchemeCount; i++) {
192 SchemeGroup.sprintf("Scheme %d", i); 192 SchemeGroup.sprintf("Scheme %d", i);
193 cfg->setGroup(SchemeGroup); 193 cfg->setGroup(SchemeGroup);
194 194
195 SchemeName = cfg->readEntry("Description", SchemeGroup); 195 SchemeName = cfg->readEntry("Description", SchemeGroup);
196 SchemeMode = cfg->readNumEntry("Mode", -1); 196 SchemeMode = cfg->readNumEntry("Mode", -1);
197 197
198 schemeMode[i] = SchemeMode; 198 schemeMode[i] = SchemeMode;
199 if (SchemeMode == -1) { 199 if (SchemeMode == -1) {
200 schemeID[i] = modesPopup->insertItem(SchemeName); 200 schemeID[i] = modesPopup->insertItem(SchemeName);
201 modesPopup->setItemChecked(schemeID[i], i == Scheme); 201 modesPopup->setItemChecked(schemeID[i], i == Scheme);
202 } else { 202 } else {
203 schemeID[i] = schemesPopup->at(SchemeMode)->insertItem(SchemeName); 203 schemeID[i] = schemesPopup->at(SchemeMode)->insertItem(SchemeName);
204 schemesPopup->at(SchemeMode)-> 204 schemesPopup->at(SchemeMode)->
205 setItemChecked(schemeID[i], i == Scheme); 205 setItemChecked(schemeID[i], i == Scheme);
206 modesPopup->setItemEnabled(modeID[SchemeMode], TRUE); 206 modesPopup->setItemEnabled(modeID[SchemeMode], TRUE);
207 } 207 }
208 } 208 }
209 209
210 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 210 RESTORE_CONFIG_GROUP( cfg, oldgroup );
211 211
212 APP_CONFIG_END( cfg ); 212 APP_CONFIG_END( cfg );
213 return SchemeCount; 213 return SchemeCount;
214} 214}
215 215
216void Kpacman::quitKpacman() 216void Kpacman::quitKpacman()
217{ 217{
218 APP_QUIT(); 218 APP_QUIT();
219} 219}
220 220
221void Kpacman::newKpacman() 221void Kpacman::newKpacman()
222{ 222{
223 if (!gamePopup->isItemEnabled(hofID)) 223 if (!gamePopup->isItemEnabled(hofID))
224 gamePopup->setItemEnabled(hofID, TRUE); 224 gamePopup->setItemEnabled(hofID, TRUE);
225 225
226 if (gamePopup->isItemChecked(hofID)) 226 if (gamePopup->isItemChecked(hofID))
227 toggleHallOfFame(); 227 toggleHallOfFame();
228 228
229 if (gamePopup->isItemChecked(pauseID)) 229 if (gamePopup->isItemChecked(pauseID))