-rw-r--r-- | noncore/games/kpacman/referee.cpp | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/noncore/games/kpacman/referee.cpp b/noncore/games/kpacman/referee.cpp index 81f331b..6d8f3fb 100644 --- a/noncore/games/kpacman/referee.cpp +++ b/noncore/games/kpacman/referee.cpp @@ -601,273 +601,259 @@ void Referee::confTiming(bool defGroup) dyingPostAnimationMS = cfg->readNumEntry("DyingPostAnimationMS", 500); if (defGroup || cfg->hasKey("IntroAnimationMS")) introAnimationMS = cfg->readNumEntry("IntroAnimationMS", 800); if (defGroup || cfg->hasKey("IntroPostAnimationMS")) introPostAnimationMS = cfg->readNumEntry("IntroPostAnimationMS", 1000); if (defGroup || cfg->hasKey("LevelUpPreAnimationMS")) levelUpPreAnimationMS = cfg->readNumEntry("LevelUpPreAnimationMS", 2000); if (defGroup || cfg->hasKey("LevelUpAnimationMS")) levelUpAnimationMS = cfg->readNumEntry("LevelUpAnimationMS", 2000); if (defGroup || cfg->hasKey("EnergizerAnimationMS")) energizerAnimationMS = cfg->readNumEntry("EnergizerAnimationMS", 200); APP_CONFIG_END( cfg ); } void Referee::confScoring(bool defGroup) { APP_CONFIG_BEGIN( cfg ); if (defGroup || cfg->hasKey("PointScore")) pointScore = cfg->readNumEntry("PointScore", 10); if (defGroup || cfg->hasKey("EnergizerScore")) energizerScore = cfg->readNumEntry("EnergizerScore", 50); if (defGroup || cfg->hasKey("FruitScore")) fillArray(fruitScore, cfg->readEntry("FruitScore", "100,300,500,,700,,1000,,2000,,3000,,5000"), maxLevel+1); if (defGroup || cfg->hasKey("MonsterScore")) fillArray(monsterScore, cfg->readEntry("MonsterScore", "200,400,800,1600"), 4); if (defGroup || cfg->hasKey("ExtraLifeScore")) fillArray(extraLifeScore, cfg->readEntry("ExtraLifeScore", "10000"), -1); APP_CONFIG_END( cfg ); } void Referee::confScheme() { APP_CONFIG_BEGIN( cfg ); SAVE_CONFIG_GROUP( cfg, oldgroup ); QString newgroup; // if not set, read mode and scheme from the configfile if (mode == -1 && scheme == -1) { scheme = cfg->readNumEntry("Scheme", -1); mode = cfg->readNumEntry("Mode", -1); // if mode is not set in the defGroup-group, lookup the scheme group if (scheme != -1 || mode == -1) { newgroup.sprintf("Scheme %d", scheme); cfg->setGroup(newgroup); mode = cfg->readNumEntry("Mode", -1); RESTORE_CONFIG_GROUP( cfg, oldgroup ); } } confLevels(); if (mode != -1) { newgroup.sprintf("Mode %d", mode); cfg->setGroup(newgroup); confLevels(FALSE); } if (scheme != -1) { newgroup.sprintf("Scheme %d", scheme); cfg->setGroup(newgroup); confLevels(FALSE); } RESTORE_CONFIG_GROUP( cfg, oldgroup ); confMisc(); confTiming(); confScoring(); if (mode != -1) { newgroup.sprintf("Mode %d", mode); cfg->setGroup(newgroup); confMisc(FALSE); confTiming(FALSE); confScoring(FALSE); } if (scheme != -1) { newgroup.sprintf("Scheme %d", scheme); cfg->setGroup(newgroup); confMisc(FALSE); confTiming(FALSE); confScoring(FALSE); } fillMapName(); RESTORE_CONFIG_GROUP( cfg, oldgroup ); APP_CONFIG_END( cfg ); } void Referee::setScheme(int Scheme, int Mode, Bitfont *font) { mode = Mode; scheme = Scheme; confScheme(); pix->setScheme(scheme, mode, font); pacman->setMaxPixmaps(pix->maxPixmaps(PacmanPix)); fruit->setMaxPixmaps(pix->maxPixmaps(FruitPix)); for (Monster *m = monsters->first(); m != 0; m = monsters->next()) if (m) m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix)); for (Energizer *e = energizers->first(); e != 0; e = energizers->next()) if (e) e->setMaxPixmaps(pix->maxPixmaps(EnergizerPix)); if (gameState.testBit(Introducing)) for (int i = 0; i < (gameState.testBit(Init) ? timerCount : 15); i++) introPaint(i); setFixedSize(pix->levelPix().size()); repaint(); } 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_Down || - key == Key_Right || - key == Key_Left )) + + if ( !gameState.testBit(Playing) && ( key == Key_Up || key == Key_Down || key == Key_Left || key == Key_Right ) ) play(); - // "Space" => pause - //else if ( key == Key_Space || key == Key_F3 ) - // pause(); - // "Menu" => hall of fame - //else if ( key == Key_F11 || key == Key_F4 ) - // toggleHallOfFame(); -#endif if (gameState.testBit(Paused) || gameState.testBit(HallOfFame) || gameState.testBit(Demonstration) || gameState.testBit(Dying) || gameState.testBit(Ready) || gameState.testBit(LevelDone) || !gameState.testBit(Playing)) return; if (key == UpKey) pacman->setDirection(N); else if (key == DownKey) pacman->setDirection(S); else if (key == RightKey) pacman->setDirection(E); else if (key == LeftKey) pacman->setDirection(W); #ifdef CHEATS else if (key == Key_L) { printf("levelUp()\n"); levelUp(); } else if (key == Key_F) { printf("fruit->move(TRUE)\n"); fruit->move(TRUE); repaint(FALSE); } else if (key == Key_E) { printf("setLifes(++lifes)\n"); emit setLifes(++lifes); } #endif else { k->ignore(); return; } k->accept(); } void Referee::score(int p) { if (!gameState.testBit(Playing)) return; if ((points += p) < 0) points = 0; emit setPoints(points); if (points >= nextExtraLifeScore) { emit setLifes(++lifes); if (extraLifeScoreIndex < (int) extraLifeScore.size()-1) extraLifeScoreIndex++; if (extraLifeScore[extraLifeScoreIndex] < 0) nextExtraLifeScore = extraLifeScore[extraLifeScoreIndex] * -1; else nextExtraLifeScore += extraLifeScore[extraLifeScoreIndex]; } } void Referee::eaten() { if (gameState.testBit(Ready)) return; stop(); if (monstersEaten < 4) monstersEaten++; gameState.setBit(Scoring); score(monsterScore[monstersEaten-1]); repaint(pix->rect(pix->rect(pacman->position(), MonsterPix), pix->rect(pacman->position(), MonsterScorePix, monstersEaten-1))); if (--timerCount > 0) QTimer::singleShot( monsterScoreDurMS, this, SLOT(eaten())); else { for (Monster *m = monsters->first(); m != 0; m = monsters->next()) if (m && m->direction() == X && !gameState.testBit(Introducing)) m->setDirection(N); if (monstersEaten != 4 || !gameState.testBit(Introducing)) QTimer::singleShot( monsterScoreDurMS, this, SLOT(start())); } } void Referee::toggleHallOfFame() { gameState.toggleBit(HallOfFame); } void Referee::hallOfFame() { if (gameState.testBit(HallOfFame)) // If the HallOfFame is switched on manually, toggle the toggleHallOfFame(); // bit twice. emit setLevel(0); // Clear status display for hall of fame emit setScore(level, 0); emit forcedHallOfFame(TRUE); } void Referee::pause() { static int pausedTimer = 0; if (!gameState.testBit(Paused)) { pausedTimer = gameTimer; stop(); stopEnergizer(); gameState.setBit(Paused); repaint(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, tr("PAUSED")), FALSE); } else { gameState.clearBit(Paused); repaint(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, tr("PAUSED")), FALSE); if (pausedTimer) { pausedTimer = 0; start(); } } emit togglePaused(); } void Referee::intro() { stop(); stopEnergizer(); bool paused = gameState.testBit(Paused); gameState.fill(FALSE); gameState.setBit(Introducing); gameState.setBit(Init); if (paused) gameState.setBit(Paused); level = 0; emit setLevel(level); |