void KBlocksWin::levelChanged() { //Scene reads the difficulty level for us if (mGameCount == 1) { singleGame(); } else { pveStepGame(); } mpGameView->setFocus(Qt::MouseFocusReason); }
void KBlocksWin::setupGUILayout() { QAction *action; action = KStandardGameAction::gameNew(this, SLOT(singleGame()), actionCollection()); action->setText(i18n("Single Game")); actionCollection()->addAction(QStringLiteral("newGame"), action); action = new QAction(this); action->setText(i18n("Human vs AI")); actionCollection()->addAction(QStringLiteral("pve_step"), action); connect(action, &QAction::triggered, this, &KBlocksWin::pveStepGame); m_pauseAction = KStandardGameAction::pause(this, SLOT(pauseGame()), actionCollection()); actionCollection()->addAction(QStringLiteral("pauseGame"), m_pauseAction); m_pauseAction->setEnabled(false); action = KStandardGameAction::highscores(this, SLOT(showHighscore()), actionCollection()); actionCollection()->addAction(QStringLiteral("showHighscores"), action); action = KStandardGameAction::quit(this, SLOT(close()), actionCollection()); actionCollection()->addAction(QStringLiteral("quit"), action); KStandardAction::preferences(this, SLOT(configureSettings()), actionCollection()); KToggleAction *soundAction = new KToggleAction(i18n("&Play sounds"), this); soundAction->setChecked(Settings::sounds()); actionCollection()->addAction(QStringLiteral("sounds"), soundAction); connect(soundAction, &KToggleAction::triggered, this, &KBlocksWin::setSoundsEnabled); // TODO mScore = new QLabel(i18n("Points: 0 - Lines: 0 - Level: 0")); statusBar()->addPermanentWidget(mScore); connect(mpGameScene, &KBlocksScene::scoreChanged, this, &KBlocksWin::onScoreChanged); connect(mpGameScene, &KBlocksScene::isHighscore, this, &KBlocksWin::onIsHighscore); Kg::difficulty()->addStandardLevelRange( KgDifficultyLevel::Easy, KgDifficultyLevel::Hard ); KgDifficultyGUI::init(this); connect(Kg::difficulty(), &KgDifficulty::currentLevelChanged, this, &KBlocksWin::levelChanged); setupGUI(); }
void KBlocksWin::setupGUILayout() { QAction *action; action = KStandardGameAction::gameNew(this, SLOT(singleGame()), actionCollection()); action->setText(i18n("Single Game")); actionCollection()->addAction( QLatin1String( "newGame" ), action); action = new KAction(this); action->setText(i18n("Human vs AI")); actionCollection()->addAction( QLatin1String( "pve_step" ), action); connect(action, SIGNAL(triggered(bool)), this, SLOT(pveStepGame())); m_pauseAction = KStandardGameAction::pause(this, SLOT(pauseGame()), actionCollection()); actionCollection()->addAction( QLatin1String( "pauseGame" ), m_pauseAction); action = KStandardGameAction::highscores(this, SLOT(showHighscore()), actionCollection()); actionCollection()->addAction( QLatin1String( "showHighscores" ), action); action = KStandardGameAction::quit(this, SLOT(close()), actionCollection()); actionCollection()->addAction( QLatin1String( "quit" ), action); KStandardAction::preferences(this, SLOT(configureSettings()), actionCollection()); KAction* soundAction = new KToggleAction(i18n("&Play sounds"), this); soundAction->setChecked(Settings::sounds()); actionCollection()->addAction( QLatin1String( "sounds" ), soundAction); connect(soundAction, SIGNAL(triggered(bool)), this, SLOT(setSoundsEnabled(bool))); // TODO statusBar()->insertItem( i18n("Points: 0 - Lines: 0 - Level: 0"), 0 ); connect(mpGameScene, SIGNAL(scoreChanged(int,int,int,int)), this, SLOT(onScoreChanged(int,int,int,int))); connect(mpGameScene, SIGNAL(isHighscore(int,int,int)), this, SLOT(onIsHighscore(int,int,int))); Kg::difficulty()->addStandardLevelRange( KgDifficultyLevel::Easy, KgDifficultyLevel::Hard ); KgDifficultyGUI::init(this); connect(Kg::difficulty(), SIGNAL(currentLevelChanged(const KgDifficultyLevel*)), SLOT(levelChanged())); setupGUI(); }