void MainWindow::gameIsOver() { //create score info KScoreDialog::FieldInfo scoreInfo; scoreInfo[KScoreDialog::Score].setNum(m_gameState->points()); scoreInfo[KScoreDialog::Custom1] = m_gameState->mode() == KDiamond::UntimedGame ? i18n("Untimed") : i18n("Timed"); //report score QPointer<KScoreDialog> dialog = new KScoreDialog(KScoreDialog::Name | KScoreDialog::Score, this); dialog->addField(KScoreDialog::Custom1, i18n("Mode"), "mode"); dialog->initFromDifficulty(Kg::difficulty()); dialog->addScore(scoreInfo); delete dialog; }
void MainWindow::showHighscores() { //pause game if necessary m_gameState->setState(KDiamond::Paused); if (m_gameState->state() != KDiamond::Finished) actionCollection()->action("game_pause")->setChecked(true); //show dialog QPointer<KScoreDialog> dialog = new KScoreDialog(KScoreDialog::Name | KScoreDialog::Score, this); dialog->addField(KScoreDialog::Custom1, i18n("Mode"), "mode"); dialog->initFromDifficulty(Kg::difficulty()); dialog->exec(); delete dialog; }
void App::slotEndOfGame() { if (m_board->tilesLeft() > 0) { m_board->setGameStuckEnabled(true); } else { m_board->setGameOverEnabled(true); auto const timeString = i18nc("time string: hh:mm:ss", "%1:%2:%3", QString().sprintf("%02d", m_board->currentTime() / 3600), QString().sprintf("%02d", (m_board->currentTime() / 60) % 60), QString().sprintf("%02d", m_board->currentTime() % 60)); KScoreDialog::FieldInfo scoreInfo; scoreInfo[KScoreDialog::Score].setNum(score(m_board->xTiles(), m_board->yTiles(), m_board->currentTime(), m_board->gravityFlag())); scoreInfo[KScoreDialog::Time] = timeString; QPointer<KScoreDialog> scoreDialog = new KScoreDialog(KScoreDialog::Name | KScoreDialog::Time | KScoreDialog::Score, this); scoreDialog->addField(KScoreDialog::Custom1, i18n("Gravity"), QStringLiteral("gravity")); // FIXME: This is bad, because the translated words are stored in the highscores and thus switching the language makes ugly things (schwarzer) if (m_board->gravityFlag()) { scoreInfo[KScoreDialog::Custom1] = i18n("Yes"); } else { scoreInfo[KScoreDialog::Custom1] = i18n("No"); } auto const configGroup = QStringLiteral("%1x%2").arg(m_board->xTiles()).arg(m_board->yTiles()); scoreDialog->setConfigGroup(qMakePair(QByteArray(configGroup.toUtf8()), configGroup)); if (m_board->hasCheated()) { auto const message = i18n("\nYou could have been in the highscores\nif you did not use Undo or Hint.\nTry without them next time."); KMessageBox::information(this, message, i18n("End of Game")); } else { if (scoreDialog->addScore(scoreInfo) > 0) { auto const message = i18n("Congratulations!\nYou made it into the hall of fame."); scoreDialog->setComment(message); scoreDialog->exec(); } else { auto const message = i18nc("%1 - time string like hh:mm:ss", "You made it in %1", timeString); KMessageBox::information(this, message, i18n("End of Game")); } } delete scoreDialog; } updateItems(); }