-rw-r--r-- | noncore/games/kpacman/score.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/games/kpacman/score.cpp b/noncore/games/kpacman/score.cpp index b3ff3d9..e91771b 100644 --- a/noncore/games/kpacman/score.cpp +++ b/noncore/games/kpacman/score.cpp | |||
@@ -1,399 +1,399 @@ | |||
1 | 1 | ||
2 | #include "portable.h" | 2 | #include "portable.h" |
3 | 3 | ||
4 | #if defined( KDE2_PORT ) | 4 | #if defined( KDE2_PORT ) |
5 | #include <score.h> | 5 | #include <score.h> |
6 | #include <score.moc> | 6 | #include <score.moc> |
7 | 7 | ||
8 | #include <kaccel.h> | 8 | #include <kaccel.h> |
9 | #include <kapp.h> | 9 | #include <kapp.h> |
10 | #include <kconfig.h> | 10 | #include <kconfig.h> |
11 | #include <kstddirs.h> | 11 | #include <kstddirs.h> |
12 | #include <kmessagebox.h> | 12 | #include <kmessagebox.h> |
13 | #elif defined( QPE_PORT ) | 13 | #elif defined( QPE_PORT ) |
14 | #include <qaccel.h> | 14 | #include <qaccel.h> |
15 | #include "config.h" | 15 | #include <qpe/config.h> |
16 | #include "score.h" | 16 | #include "score.h" |
17 | #endif | 17 | #endif |
18 | 18 | ||
19 | #include <stdlib.h> | 19 | #include <stdlib.h> |
20 | #include <ctype.h> | 20 | #include <ctype.h> |
21 | 21 | ||
22 | #include <qpixmap.h> | 22 | #include <qpixmap.h> |
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qdstream.h> | 24 | #include <qdstream.h> |
25 | #include <qkeycode.h> | 25 | #include <qkeycode.h> |
26 | #include <qtimer.h> | 26 | #include <qtimer.h> |
27 | #include <qfileinfo.h> | 27 | #include <qfileinfo.h> |
28 | 28 | ||
29 | #include "bitfont.h" | 29 | #include "bitfont.h" |
30 | 30 | ||
31 | Score::Score(QWidget *parent, const char *name, int Scheme, int Mode, Bitfont *font) : QWidget(parent, name) | 31 | Score::Score(QWidget *parent, const char *name, int Scheme, int Mode, Bitfont *font) : QWidget(parent, name) |
32 | { | 32 | { |
33 | setFocusPolicy(QWidget::StrongFocus); | 33 | setFocusPolicy(QWidget::StrongFocus); |
34 | 34 | ||
35 | paused = FALSE; | 35 | paused = FALSE; |
36 | 36 | ||
37 | lastScore = -1; | 37 | lastScore = -1; |
38 | lastPlayer = -1; | 38 | lastPlayer = -1; |
39 | 39 | ||
40 | cursorBlinkTimer = 0; | 40 | cursorBlinkTimer = 0; |
41 | cursorBlinkMS = -1; | 41 | cursorBlinkMS = -1; |
42 | cursor.x = -1; | 42 | cursor.x = -1; |
43 | cursor.y = -1; | 43 | cursor.y = -1; |
44 | cursor.on = FALSE; | 44 | cursor.on = FALSE; |
45 | cursor.chr = QChar('?'); | 45 | cursor.chr = QChar('?'); |
46 | 46 | ||
47 | initKeys(); | 47 | initKeys(); |
48 | 48 | ||
49 | scheme = Scheme; | 49 | scheme = Scheme; |
50 | mode = Mode; | 50 | mode = Mode; |
51 | confScheme(); | 51 | confScheme(); |
52 | 52 | ||
53 | bitfont = font; | 53 | bitfont = font; |
54 | 54 | ||
55 | highscoreFile.setName(locateHighscoreFilePath().filePath()); | 55 | highscoreFile.setName(locateHighscoreFilePath().filePath()); |
56 | read(); | 56 | read(); |
57 | 57 | ||
58 | for (int p = 0; p < maxPlayer; p++) { | 58 | for (int p = 0; p < maxPlayer; p++) { |
59 | playerScore[p] = 0; | 59 | playerScore[p] = 0; |
60 | playerName[p] = getenv("LOGNAME"); | 60 | playerName[p] = getenv("LOGNAME"); |
61 | if (playerName[p].length() < minPlayerNameLength) | 61 | if (playerName[p].length() < minPlayerNameLength) |
62 | playerName[p].setExpand(minPlayerNameLength-1, ' '); | 62 | playerName[p].setExpand(minPlayerNameLength-1, ' '); |
63 | 63 | ||
64 | for (uint i = 0; i < playerName[p].length(); i++) | 64 | for (uint i = 0; i < playerName[p].length(); i++) |
65 | if (playerName[p].at(i) < bitfont->firstChar() || | 65 | if (playerName[p].at(i) < bitfont->firstChar() || |
66 | playerName[p].at(i) > bitfont->lastChar()) | 66 | playerName[p].at(i) > bitfont->lastChar()) |
67 | playerName[p].at(i) = playerName[p].at(i).upper(); | 67 | playerName[p].at(i) = playerName[p].at(i).upper(); |
68 | } | 68 | } |
69 | } | 69 | } |
70 | 70 | ||
71 | Score::~Score() | 71 | Score::~Score() |
72 | { | 72 | { |
73 | // write(); | 73 | // write(); |
74 | } | 74 | } |
75 | 75 | ||
76 | void Score::paintEvent( QPaintEvent *e) | 76 | void Score::paintEvent( QPaintEvent *e) |
77 | { | 77 | { |
78 | if (rect(1, 0, tr(" 1UP ")).intersects(e->rect())) { | 78 | if (rect(1, 0, tr(" 1UP ")).intersects(e->rect())) { |
79 | QPixmap pix; | 79 | QPixmap pix; |
80 | QColor fg = BLACK; | 80 | QColor fg = BLACK; |
81 | if (cursor.on || paused || lastPlayer != 0) | 81 | if (cursor.on || paused || lastPlayer != 0) |
82 | fg = WHITE; | 82 | fg = WHITE; |
83 | pix = bitfont->text(tr(" 1UP "), fg, BLACK); | 83 | pix = bitfont->text(tr(" 1UP "), fg, BLACK); |
84 | bitBlt(this, x(1), y(0), &pix); | 84 | bitBlt(this, x(1), y(0), &pix); |
85 | } | 85 | } |
86 | 86 | ||
87 | if (rect(8, 0, tr(" HIGH SCORE ")).intersects(e->rect())) { | 87 | if (rect(8, 0, tr(" HIGH SCORE ")).intersects(e->rect())) { |
88 | QPixmap pix = bitfont->text(tr(" HIGH SCORE "), WHITE, BLACK); | 88 | QPixmap pix = bitfont->text(tr(" HIGH SCORE "), WHITE, BLACK); |
89 | bitBlt(this, x(8), y(0), &pix); | 89 | bitBlt(this, x(8), y(0), &pix); |
90 | } | 90 | } |
91 | 91 | ||
92 | if (maxPlayer > 1 && rect(21, 0, tr(" 2UP ")).intersects(e->rect())) { | 92 | if (maxPlayer > 1 && rect(21, 0, tr(" 2UP ")).intersects(e->rect())) { |
93 | QPixmap pix; | 93 | QPixmap pix; |
94 | QColor fg = BLACK; | 94 | QColor fg = BLACK; |
95 | if (cursor.on || paused || lastPlayer != 1) | 95 | if (cursor.on || paused || lastPlayer != 1) |
96 | fg = WHITE; | 96 | fg = WHITE; |
97 | pix = bitfont->text(tr(" 2UP "), fg, BLACK); | 97 | pix = bitfont->text(tr(" 2UP "), fg, BLACK); |
98 | bitBlt(this, x(21), y(0), &pix); | 98 | bitBlt(this, x(21), y(0), &pix); |
99 | } | 99 | } |
100 | 100 | ||
101 | QString s; | 101 | QString s; |
102 | 102 | ||
103 | s.sprintf("%6d0", playerScore[0]/10); | 103 | s.sprintf("%6d0", playerScore[0]/10); |
104 | if (rect(0, 1, s).intersects(e->rect())) { | 104 | if (rect(0, 1, s).intersects(e->rect())) { |
105 | QPixmap pix = bitfont->text(s, WHITE, BLACK); | 105 | QPixmap pix = bitfont->text(s, WHITE, BLACK); |
106 | bitBlt(this, x(0), y(1), &pix); | 106 | bitBlt(this, x(0), y(1), &pix); |
107 | } | 107 | } |
108 | 108 | ||
109 | s.sprintf("%8d0", HighScore/10); | 109 | s.sprintf("%8d0", HighScore/10); |
110 | if (rect(8, 1, s).intersects(e->rect())) { | 110 | if (rect(8, 1, s).intersects(e->rect())) { |
111 | QPixmap pix = bitfont->text(s, WHITE, BLACK); | 111 | QPixmap pix = bitfont->text(s, WHITE, BLACK); |
112 | bitBlt(this, x(8), y(1), &pix); | 112 | bitBlt(this, x(8), y(1), &pix); |
113 | } | 113 | } |
114 | 114 | ||
115 | if (lastScore >= 0) { | 115 | if (lastScore >= 0) { |
116 | if (rect(1, 4*1.25, tr(" CONGRATULATIONS ")).intersects(e->rect())) { | 116 | if (rect(1, 4*1.25, tr(" CONGRATULATIONS ")).intersects(e->rect())) { |
117 | QPixmap pix = bitfont->text(tr(" CONGRATULATIONS "), YELLOW, BLACK); | 117 | QPixmap pix = bitfont->text(tr(" CONGRATULATIONS "), YELLOW, BLACK); |
118 | bitBlt(this, x(1), y(4*1.25), &pix); | 118 | bitBlt(this, x(1), y(4*1.25), &pix); |
119 | } | 119 | } |
120 | if (rect(1, 6*1.25, tr(" YOU HAVE ARCHIEVED ")).intersects(e->rect())) { | 120 | if (rect(1, 6*1.25, tr(" YOU HAVE ARCHIEVED ")).intersects(e->rect())) { |
121 | QPixmap pix = bitfont->text(tr(" YOU HAVE ARCHIEVED "), CYAN, BLACK); | 121 | QPixmap pix = bitfont->text(tr(" YOU HAVE ARCHIEVED "), CYAN, BLACK); |
122 | bitBlt(this, x(1), y(6*1.25), &pix); | 122 | bitBlt(this, x(1), y(6*1.25), &pix); |
123 | } | 123 | } |
124 | if (rect(1, 7*1.25, tr(" A SCORE IN THE TOP 10. ")).intersects(e->rect())) { | 124 | if (rect(1, 7*1.25, tr(" A SCORE IN THE TOP 10. ")).intersects(e->rect())) { |
125 | QPixmap pix = bitfont->text(tr(" A SCORE IN THE TOP 10. "), CYAN, BLACK); | 125 | QPixmap pix = bitfont->text(tr(" A SCORE IN THE TOP 10. "), CYAN, BLACK); |
126 | bitBlt(this, x(1), y(7*1.25), &pix); | 126 | bitBlt(this, x(1), y(7*1.25), &pix); |
127 | } | 127 | } |
128 | if (rect(1, 8*1.25, tr(" ")).intersects(e->rect())) { | 128 | if (rect(1, 8*1.25, tr(" ")).intersects(e->rect())) { |
129 | QPixmap pix = bitfont->text(tr(" "), CYAN, BLACK); | 129 | QPixmap pix = bitfont->text(tr(" "), CYAN, BLACK); |
130 | bitBlt(this, x(1), y(8*1.25), &pix); | 130 | bitBlt(this, x(1), y(8*1.25), &pix); |
131 | } | 131 | } |
132 | } | 132 | } |
133 | 133 | ||
134 | if (rect(1, 9.5*1.25, tr("RNK SCORE NAME DATE")).intersects(e->rect())) { | 134 | if (rect(1, 9.5*1.25, tr("RNK SCORE NAME DATE")).intersects(e->rect())) { |
135 | QPixmap pix = bitfont->text(tr("RNK SCORE NAME DATE"), WHITE, BLACK); | 135 | QPixmap pix = bitfont->text(tr("RNK SCORE NAME DATE"), WHITE, BLACK); |
136 | bitBlt(this, x(1), y(9.5*1.25), &pix); | 136 | bitBlt(this, x(1), y(9.5*1.25), &pix); |
137 | } | 137 | } |
138 | 138 | ||
139 | for (int i = 0; i < 10; i++) { | 139 | for (int i = 0; i < 10; i++) { |
140 | s.sprintf("%2d%9d %-3.3s %-8.8s", | 140 | s.sprintf("%2d%9d %-3.3s %-8.8s", |
141 | i+1, hallOfFame[i].points, hallOfFame[i].name.utf8().data(), | 141 | i+1, hallOfFame[i].points, hallOfFame[i].name.utf8().data(), |
142 | formatDate(hallOfFame[i].moment.date()).data()); | 142 | formatDate(hallOfFame[i].moment.date()).data()); |
143 | if (rect(1, (11+i)*1.25, s).intersects(e->rect())) { | 143 | if (rect(1, (11+i)*1.25, s).intersects(e->rect())) { |
144 | QPixmap pix = bitfont->text(s, (i == lastScore) ? YELLOW : WHITE, BLACK); | 144 | QPixmap pix = bitfont->text(s, (i == lastScore) ? YELLOW : WHITE, BLACK); |
145 | bitBlt(this, x(1), y((11+i)*1.25), &pix); | 145 | bitBlt(this, x(1), y((11+i)*1.25), &pix); |
146 | } | 146 | } |
147 | } | 147 | } |
148 | 148 | ||
149 | if (cursor.x != -1 && cursor.y != -1 && cursor.on) { | 149 | if (cursor.x != -1 && cursor.y != -1 && cursor.on) { |
150 | if (rect(cursor.x, (cursor.y*1.25), cursor.chr).intersects(e->rect())) { | 150 | if (rect(cursor.x, (cursor.y*1.25), cursor.chr).intersects(e->rect())) { |
151 | QPixmap pix = bitfont->text(cursor.chr, BLACK, YELLOW); | 151 | QPixmap pix = bitfont->text(cursor.chr, BLACK, YELLOW); |
152 | bitBlt(this, x(cursor.x), y(cursor.y*1.25), &pix); | 152 | bitBlt(this, x(cursor.x), y(cursor.y*1.25), &pix); |
153 | } | 153 | } |
154 | } | 154 | } |
155 | 155 | ||
156 | if (paused) { | 156 | if (paused) { |
157 | 157 | ||
158 | QPixmap pix = bitfont->text(tr("PAUSED"), RED, BLACK); | 158 | QPixmap pix = bitfont->text(tr("PAUSED"), RED, BLACK); |
159 | QRect r = bitfont->rect(tr("PAUSED")); | 159 | QRect r = bitfont->rect(tr("PAUSED")); |
160 | r.moveCenter(QPoint(this->width()/2, this->height()/2)); | 160 | r.moveCenter(QPoint(this->width()/2, this->height()/2)); |
161 | 161 | ||
162 | bitBlt(this, r.x(), r.y(), &pix); | 162 | bitBlt(this, r.x(), r.y(), &pix); |
163 | } | 163 | } |
164 | } | 164 | } |
165 | 165 | ||
166 | void Score::timerEvent(QTimerEvent*) | 166 | void Score::timerEvent(QTimerEvent*) |
167 | { | 167 | { |
168 | cursor.on = !cursor.on; | 168 | cursor.on = !cursor.on; |
169 | 169 | ||
170 | if (paused) | 170 | if (paused) |
171 | return; | 171 | return; |
172 | 172 | ||
173 | if (cursor.x != -1 && cursor.y != -1) | 173 | if (cursor.x != -1 && cursor.y != -1) |
174 | repaint(rect(cursor.x, cursor.y*1.25, cursor.chr), FALSE); | 174 | repaint(rect(cursor.x, cursor.y*1.25, cursor.chr), FALSE); |
175 | scrollRepeat = FALSE; | 175 | scrollRepeat = FALSE; |
176 | 176 | ||
177 | if (lastPlayer == 0) | 177 | if (lastPlayer == 0) |
178 | repaint(rect(1, 0, tr(" 1UP ")), FALSE); | 178 | repaint(rect(1, 0, tr(" 1UP ")), FALSE); |
179 | 179 | ||
180 | if (lastPlayer == 1) | 180 | if (lastPlayer == 1) |
181 | repaint(rect(21, 0, tr(" 2UP ")), FALSE); | 181 | repaint(rect(21, 0, tr(" 2UP ")), FALSE); |
182 | } | 182 | } |
183 | 183 | ||
184 | void Score::keyPressEvent(QKeyEvent *k) | 184 | void Score::keyPressEvent(QKeyEvent *k) |
185 | { | 185 | { |
186 | if (lastScore < 0 || lastPlayer < 0 || lastPlayer >= maxPlayer || paused) { | 186 | if (lastScore < 0 || lastPlayer < 0 || lastPlayer >= maxPlayer || paused) { |
187 | k->ignore(); | 187 | k->ignore(); |
188 | return; | 188 | return; |
189 | } | 189 | } |
190 | 190 | ||
191 | int x = cursor.x; | 191 | int x = cursor.x; |
192 | int y = cursor.y; | 192 | int y = cursor.y; |
193 | 193 | ||
194 | uint key = k->key(); | 194 | uint key = k->key(); |
195 | 195 | ||
196 | if (scrollRepeat && (key == UpKey || key == Key_Up || key == DownKey || key == Key_Down)) { | 196 | if (scrollRepeat && (key == UpKey || key == Key_Up || key == DownKey || key == Key_Down)) { |
197 | k->ignore(); | 197 | k->ignore(); |
198 | return; | 198 | return; |
199 | } | 199 | } |
200 | 200 | ||
201 | if (key != Key_Return) { | 201 | if (key != Key_Return) { |
202 | if (key == RightKey || key == Key_Right) | 202 | if (key == RightKey || key == Key_Right) |
203 | if (++cursor.x > 16) | 203 | if (++cursor.x > 16) |
204 | cursor.x = 14; | 204 | cursor.x = 14; |
205 | if (key == LeftKey || key == Key_Left) | 205 | if (key == LeftKey || key == Key_Left) |
206 | if (--cursor.x < 14) | 206 | if (--cursor.x < 14) |
207 | cursor.x = 16; | 207 | cursor.x = 16; |
208 | if (key == UpKey || key == Key_Up) | 208 | if (key == UpKey || key == Key_Up) |
209 | if (cursor.chr.unicode() < bitfont->lastChar()) | 209 | if (cursor.chr.unicode() < bitfont->lastChar()) |
210 | cursor.chr = cursor.chr.unicode()+1; | 210 | cursor.chr = cursor.chr.unicode()+1; |
211 | else | 211 | else |
212 | cursor.chr = bitfont->firstChar(); | 212 | cursor.chr = bitfont->firstChar(); |
213 | if (key == DownKey || key == Key_Down) | 213 | if (key == DownKey || key == Key_Down) |
214 | if (cursor.chr.unicode() > bitfont->firstChar()) | 214 | if (cursor.chr.unicode() > bitfont->firstChar()) |
215 | cursor.chr = cursor.chr.unicode()-1; | 215 | cursor.chr = cursor.chr.unicode()-1; |
216 | else | 216 | else |
217 | cursor.chr = bitfont->lastChar(); | 217 | cursor.chr = bitfont->lastChar(); |
218 | 218 | ||
219 | if (cursor.x == x && cursor.y == y && | 219 | if (cursor.x == x && cursor.y == y && |
220 | cursor.chr == hallOfFame[lastScore].name.at(cursor.x-14)) { | 220 | cursor.chr == hallOfFame[lastScore].name.at(cursor.x-14)) { |
221 | uint ascii = k->ascii(); | 221 | uint ascii = k->ascii(); |
222 | 222 | ||
223 | if (ascii < bitfont->firstChar() || ascii > bitfont->lastChar()) | 223 | if (ascii < bitfont->firstChar() || ascii > bitfont->lastChar()) |
224 | ascii = toupper(ascii); | 224 | ascii = toupper(ascii); |
225 | 225 | ||
226 | if (ascii >= bitfont->firstChar() && ascii <= bitfont->lastChar()) { | 226 | if (ascii >= bitfont->firstChar() && ascii <= bitfont->lastChar()) { |
227 | cursor.chr = ascii; | 227 | cursor.chr = ascii; |
228 | hallOfFame[lastScore].name.at(cursor.x-14) = cursor.chr; | 228 | hallOfFame[lastScore].name.at(cursor.x-14) = cursor.chr; |
229 | if (++cursor.x > 16) | 229 | if (++cursor.x > 16) |
230 | cursor.x = 14; | 230 | cursor.x = 14; |
231 | } | 231 | } |
232 | } | 232 | } |
233 | } | 233 | } |
234 | 234 | ||
235 | if (key == Key_Return) { | 235 | if (key == Key_Return) { |
236 | playerName[lastPlayer] = hallOfFame[lastScore].name; | 236 | playerName[lastPlayer] = hallOfFame[lastScore].name; |
237 | write(); | 237 | write(); |
238 | read(); | 238 | read(); |
239 | lastScore = -1; | 239 | lastScore = -1; |
240 | cursor.x = -1; | 240 | cursor.x = -1; |
241 | cursor.y = -1; | 241 | cursor.y = -1; |
242 | // killTimers(); | 242 | // killTimers(); |
243 | emit toggleNew(); | 243 | emit toggleNew(); |
244 | end(); | 244 | end(); |
245 | } | 245 | } |
246 | 246 | ||
247 | if (x != cursor.x || y != cursor.y) { | 247 | if (x != cursor.x || y != cursor.y) { |
248 | if (cursor.x != -1) | 248 | if (cursor.x != -1) |
249 | cursor.chr = hallOfFame[lastScore].name.at(cursor.x-14); | 249 | cursor.chr = hallOfFame[lastScore].name.at(cursor.x-14); |
250 | scrollRepeat = FALSE; | 250 | scrollRepeat = FALSE; |
251 | repaint(rect(x, y*1.25, cursor.chr), FALSE); | 251 | repaint(rect(x, y*1.25, cursor.chr), FALSE); |
252 | } else | 252 | } else |
253 | hallOfFame[lastScore].name.at(cursor.x-14) = cursor.chr; | 253 | hallOfFame[lastScore].name.at(cursor.x-14) = cursor.chr; |
254 | 254 | ||
255 | if (key == UpKey || key == Key_Up || key == DownKey || key == Key_Down) | 255 | if (key == UpKey || key == Key_Up || key == DownKey || key == Key_Down) |
256 | scrollRepeat = TRUE; | 256 | scrollRepeat = TRUE; |
257 | else | 257 | else |
258 | repaint(rect(cursor.x, cursor.y*1.25, cursor.chr), FALSE); | 258 | repaint(rect(cursor.x, cursor.y*1.25, cursor.chr), FALSE); |
259 | } | 259 | } |
260 | 260 | ||
261 | void Score::initKeys() | 261 | void Score::initKeys() |
262 | { | 262 | { |
263 | APP_CONFIG_BEGIN( cfg ); | 263 | APP_CONFIG_BEGIN( cfg ); |
264 | QString up("Up"); | 264 | QString up("Up"); |
265 | up = cfg->readEntry("upKey", (const char*) up); | 265 | up = cfg->readEntry("upKey", (const char*) up); |
266 | UpKey = KAccel::stringToKey(up); | 266 | UpKey = KAccel::stringToKey(up); |
267 | 267 | ||
268 | QString down("Down"); | 268 | QString down("Down"); |
269 | down = cfg->readEntry("downKey", (const char*) down); | 269 | down = cfg->readEntry("downKey", (const char*) down); |
270 | DownKey = KAccel::stringToKey(down); | 270 | DownKey = KAccel::stringToKey(down); |
271 | 271 | ||
272 | QString left("Left"); | 272 | QString left("Left"); |
273 | left = cfg->readEntry("leftKey", (const char*) left); | 273 | left = cfg->readEntry("leftKey", (const char*) left); |
274 | LeftKey = KAccel::stringToKey(left); | 274 | LeftKey = KAccel::stringToKey(left); |
275 | 275 | ||
276 | QString right("Right"); | 276 | QString right("Right"); |
277 | right = cfg->readEntry("rightKey", (const char*) right); | 277 | right = cfg->readEntry("rightKey", (const char*) right); |
278 | RightKey = KAccel::stringToKey(right); | 278 | RightKey = KAccel::stringToKey(right); |
279 | APP_CONFIG_END( cfg ); | 279 | APP_CONFIG_END( cfg ); |
280 | } | 280 | } |
281 | 281 | ||
282 | void Score::confTiming(bool defGroup) | 282 | void Score::confTiming(bool defGroup) |
283 | { | 283 | { |
284 | APP_CONFIG_BEGIN( cfg ); | 284 | APP_CONFIG_BEGIN( cfg ); |
285 | if (defGroup || cfg->hasKey("CursorBlinkMS")) | 285 | if (defGroup || cfg->hasKey("CursorBlinkMS")) |
286 | cursorBlinkMS = cfg->readNumEntry("CursorBlinkMS", 250); | 286 | cursorBlinkMS = cfg->readNumEntry("CursorBlinkMS", 250); |
287 | if (defGroup || cfg->hasKey("HallOfFameMS")) | 287 | if (defGroup || cfg->hasKey("HallOfFameMS")) |
288 | hallOfFameMS = cfg->readNumEntry("HallOfFameMS", 7000); | 288 | hallOfFameMS = cfg->readNumEntry("HallOfFameMS", 7000); |
289 | if (defGroup || cfg->hasKey("AfterPauseMS")) | 289 | if (defGroup || cfg->hasKey("AfterPauseMS")) |
290 | afterPauseMS = cfg->readNumEntry("AfterPauseMS", 1000); | 290 | afterPauseMS = cfg->readNumEntry("AfterPauseMS", 1000); |
291 | APP_CONFIG_END( cfg ); | 291 | APP_CONFIG_END( cfg ); |
292 | } | 292 | } |
293 | 293 | ||
294 | void Score::confScheme() | 294 | void Score::confScheme() |
295 | { | 295 | { |
296 | APP_CONFIG_BEGIN( cfg ); | 296 | APP_CONFIG_BEGIN( cfg ); |
297 | SAVE_CONFIG_GROUP( cfg, oldgroup ); | 297 | SAVE_CONFIG_GROUP( cfg, oldgroup ); |
298 | QString newgroup; | 298 | QString newgroup; |
299 | 299 | ||
300 | // if not set, read mode and scheme from the configfile | 300 | // if not set, read mode and scheme from the configfile |
301 | if (mode == -1 && scheme == -1) { | 301 | if (mode == -1 && scheme == -1) { |
302 | scheme = cfg->readNumEntry("Scheme", -1); | 302 | scheme = cfg->readNumEntry("Scheme", -1); |
303 | mode = cfg->readNumEntry("Mode", -1); | 303 | mode = cfg->readNumEntry("Mode", -1); |
304 | 304 | ||
305 | // if mode is not set in the defGroup-group, lookup the scheme group | 305 | // if mode is not set in the defGroup-group, lookup the scheme group |
306 | if (scheme != -1 || mode == -1) { | 306 | if (scheme != -1 || mode == -1) { |
307 | newgroup.sprintf("Scheme %d", scheme); | 307 | newgroup.sprintf("Scheme %d", scheme); |
308 | cfg->setGroup(newgroup); | 308 | cfg->setGroup(newgroup); |
309 | 309 | ||
310 | mode = cfg->readNumEntry("Mode", -1); | 310 | mode = cfg->readNumEntry("Mode", -1); |
311 | RESTORE_CONFIG_GROUP( cfg, oldgroup ); | 311 | RESTORE_CONFIG_GROUP( cfg, oldgroup ); |
312 | } | 312 | } |
313 | } | 313 | } |
314 | 314 | ||
315 | int oldCursorBlinkMS = cursorBlinkMS; | 315 | int oldCursorBlinkMS = cursorBlinkMS; |
316 | 316 | ||
317 | confTiming(); | 317 | confTiming(); |
318 | 318 | ||
319 | if (mode != -1) { | 319 | if (mode != -1) { |
320 | newgroup.sprintf("Mode %d", mode); | 320 | newgroup.sprintf("Mode %d", mode); |
321 | cfg->setGroup(newgroup); | 321 | cfg->setGroup(newgroup); |
322 | 322 | ||
323 | confTiming(FALSE); | 323 | confTiming(FALSE); |
324 | } | 324 | } |
325 | 325 | ||
326 | if (scheme != -1) { | 326 | if (scheme != -1) { |
327 | newgroup.sprintf("Scheme %d", scheme); | 327 | newgroup.sprintf("Scheme %d", scheme); |
328 | cfg->setGroup(newgroup); | 328 | cfg->setGroup(newgroup); |
329 | 329 | ||
330 | confTiming(FALSE); | 330 | confTiming(FALSE); |
331 | } | 331 | } |
332 | 332 | ||
333 | if (cursorBlinkMS != oldCursorBlinkMS) { | 333 | if (cursorBlinkMS != oldCursorBlinkMS) { |
334 | if (cursorBlinkTimer) | 334 | if (cursorBlinkTimer) |
335 | killTimer(cursorBlinkTimer); | 335 | killTimer(cursorBlinkTimer); |
336 | cursorBlinkTimer = startTimer(cursorBlinkMS); | 336 | cursorBlinkTimer = startTimer(cursorBlinkMS); |
337 | } | 337 | } |
338 | 338 | ||
339 | RESTORE_CONFIG_GROUP( cfg, oldgroup ); | 339 | RESTORE_CONFIG_GROUP( cfg, oldgroup ); |
340 | APP_CONFIG_END( cfg ); | 340 | APP_CONFIG_END( cfg ); |
341 | } | 341 | } |
342 | 342 | ||
343 | void Score::setScheme(int Scheme, int Mode, Bitfont *font) | 343 | void Score::setScheme(int Scheme, int Mode, Bitfont *font) |
344 | { | 344 | { |
345 | mode = Mode; | 345 | mode = Mode; |
346 | scheme = Scheme; | 346 | scheme = Scheme; |
347 | 347 | ||
348 | confScheme(); | 348 | confScheme(); |
349 | 349 | ||
350 | bitfont = font; | 350 | bitfont = font; |
351 | 351 | ||
352 | for (int p = 0; p < maxPlayer; p++) | 352 | for (int p = 0; p < maxPlayer; p++) |
353 | for (uint i = 0; i < playerName[p].length(); i++) | 353 | for (uint i = 0; i < playerName[p].length(); i++) |
354 | if (playerName[p].at(i) < bitfont->firstChar() || | 354 | if (playerName[p].at(i) < bitfont->firstChar() || |
355 | playerName[p].at(i) > bitfont->lastChar()) | 355 | playerName[p].at(i) > bitfont->lastChar()) |
356 | playerName[p].at(i) = playerName[p].at(i).upper(); | 356 | playerName[p].at(i) = playerName[p].at(i).upper(); |
357 | 357 | ||
358 | for (int i = 0; i < 10; i++) | 358 | for (int i = 0; i < 10; i++) |
359 | for (uint j = 0; j < hallOfFame[i].name.length(); j++) | 359 | for (uint j = 0; j < hallOfFame[i].name.length(); j++) |
360 | if (hallOfFame[i].name.at(j) < bitfont->firstChar() || | 360 | if (hallOfFame[i].name.at(j) < bitfont->firstChar() || |
361 | hallOfFame[i].name.at(j) > bitfont->lastChar()) | 361 | hallOfFame[i].name.at(j) > bitfont->lastChar()) |
362 | hallOfFame[i].name.at(j) = hallOfFame[i].name.at(j).upper(); | 362 | hallOfFame[i].name.at(j) = hallOfFame[i].name.at(j).upper(); |
363 | 363 | ||
364 | if (cursor.chr.unicode() < bitfont->firstChar() || | 364 | if (cursor.chr.unicode() < bitfont->firstChar() || |
365 | cursor.chr.unicode() > bitfont->lastChar()) | 365 | cursor.chr.unicode() > bitfont->lastChar()) |
366 | cursor.chr = cursor.chr.upper(); | 366 | cursor.chr = cursor.chr.upper(); |
367 | } | 367 | } |
368 | 368 | ||
369 | void Score::set(int score) | 369 | void Score::set(int score) |
370 | { | 370 | { |
371 | set(score, 0); | 371 | set(score, 0); |
372 | } | 372 | } |
373 | 373 | ||
374 | void Score::set(int score, int player) | 374 | void Score::set(int score, int player) |
375 | { | 375 | { |
376 | if (player < 0 || player >= maxPlayer) | 376 | if (player < 0 || player >= maxPlayer) |
377 | return; | 377 | return; |
378 | 378 | ||
379 | lastPlayer = player; | 379 | lastPlayer = player; |
380 | playerScore[lastPlayer] = score; | 380 | playerScore[lastPlayer] = score; |
381 | 381 | ||
382 | QString s; | 382 | QString s; |
383 | 383 | ||
384 | s.sprintf("%6d0", playerScore[lastPlayer]/10); | 384 | s.sprintf("%6d0", playerScore[lastPlayer]/10); |
385 | repaint(rect(0, 1, s), FALSE); | 385 | repaint(rect(0, 1, s), FALSE); |
386 | 386 | ||
387 | if (score > HighScore) { | 387 | if (score > HighScore) { |
388 | HighScore = score; | 388 | HighScore = score; |
389 | s.sprintf("%8d0", HighScore/10); | 389 | s.sprintf("%8d0", HighScore/10); |
390 | repaint(rect(8, 1, s), FALSE); | 390 | repaint(rect(8, 1, s), FALSE); |
391 | } | 391 | } |
392 | } | 392 | } |
393 | 393 | ||
394 | /* | 394 | /* |
395 | * Set the score for player after the game if over. If the score is in the | 395 | * Set the score for player after the game if over. If the score is in the |
396 | * high scores then the hall of fame is updated (shifted) and the scoreboard | 396 | * high scores then the hall of fame is updated (shifted) and the scoreboard |
397 | * is shown. | 397 | * is shown. |
398 | */ | 398 | */ |
399 | 399 | ||