Browse Source

[qcross] some gui bugfixes

master
Oliver Groß 9 years ago
parent
commit
5cb6dd6880
  1. 34
      qcross/cgamewindow.cpp

34
qcross/cgamewindow.cpp

@ -44,11 +44,13 @@ namespace qcross {
CGameWindow::CGameWindow(QWidget * parent) : QMainWindow(parent) {
m_Highscore = NULL;
m_PictureIndex = -1;
m_Picture = new CNonogram(QSize(10, 10));
m_Picture->updateNumbers();
m_Picture = NULL;
m_Field = new CCrossFieldWidget(m_Picture, this);
m_Field->setTime(42 * 60 + 23);
// CNonogram * dummyPic = new CNonogram(QSize(10, 10));
// dummyPic->updateNumbers();
m_Field = new CCrossFieldWidget(NULL, this);
// m_Field->setTime(42 * 60 + 23);
setCentralWidget(m_Field);
m_Field->showMessage(tr("Welcome to QCross!"));
@ -86,7 +88,6 @@ namespace qcross {
m_PauseGameAction = currentMenu->addAction(tr("&Pause"));
m_PauseGameAction->setEnabled(false);
m_PauseGameAction->setCheckable(true);
m_PauseGameAction->setChecked(true);
m_PauseGameAction->setShortcut(Qt::CTRL + Qt::Key_P);
connect(m_PauseGameAction, SIGNAL(toggled(bool)), this, SLOT(pauseGame(bool)));
currentMenu->addSeparator();
@ -176,7 +177,7 @@ namespace qcross {
void CGameWindow::newGame() {
bool notPaused = !m_Field->isPaused();
if (notPaused)
pauseGame(true);
m_Field->pause();
CNewGameDialog dialog;
if (dialog.exec() == QDialog::Accepted) {
@ -190,6 +191,7 @@ namespace qcross {
CNonogram * newPicture = dialog.takeNonogram();
newPicture->updateNumbers();
m_SaveGameAction->setEnabled(true);
m_PauseGameAction->setEnabled(true);
m_RestartGameAction->setEnabled(true);
@ -203,8 +205,9 @@ namespace qcross {
m_Field->resume();
m_Field->showMessage(tr("Game started!"), 1000);
}
else
pauseGame(false);
if (m_Picture && !m_PauseGameAction->isChecked())
m_Field->resume();
}
@ -213,7 +216,7 @@ namespace qcross {
return;
if (!m_Field->isPaused())
m_PauseGameAction->setChecked(true);
m_Field->pause();
QString fileName = QFileDialog::getSaveFileName(this, tr("Save current game"),
QDir::homePath(), tr("QCross Saved games (*.csg)"));
@ -231,12 +234,13 @@ namespace qcross {
else
writeSaveGame(out);
m_PauseGameAction->setChecked(false);
if(!m_PauseGameAction->isChecked())
m_Field->resume();
}
void CGameWindow::loadGame() {
if (!m_Field->isPaused())
m_PauseGameAction->setChecked(true);
m_Field->pause();
QString fileName = QFileDialog::getOpenFileName(this, tr("Open saved game"),
QDir::homePath(), tr("QCross Saved games (*.csg)"));
@ -260,6 +264,8 @@ namespace qcross {
if (readSaveGame(in)) {
m_PauseGameAction->setEnabled(true);
m_PauseGameAction->setChecked(m_Field->isPaused());
m_SaveGameAction->setEnabled(true);
}
else {
m_Field->setPicture(NULL);
@ -276,7 +282,8 @@ namespace qcross {
}
}
m_PauseGameAction->setChecked(false);
if (m_Picture && !m_PauseGameAction->isChecked())
m_Field->resume();
}
void CGameWindow::restartGame() {
@ -289,6 +296,9 @@ namespace qcross {
}
void CGameWindow::pauseGame(bool value) {
if (value == m_Field->isPaused())
return;
if (value) {
m_Field->pause();
m_Field->showMessage(tr("Game paused."));

Loading…
Cancel
Save