From: Emmanuel Granatello Date: Mon, 1 Mar 2010 11:33:50 +0000 (+0100) Subject: Best Score X-Git-Url: http://git.maemo.org/git/?p=qmemory;a=commitdiff_plain;h=50f4640feaa00a0dd06dfe60d826e0a3276449dd Best Score Inserita la funzionalità di best score utilizzando i QSetting --- diff --git a/mainwindow.cpp b/mainwindow.cpp index a508562..70fd57c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -3,12 +3,14 @@ #include #include #include +#include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { - + bestScore=0; + readSettings(); ui->setupUi(this); statusLed = new QLed(ui->verticalLayoutWidget); ui->horizontalLayout_4->insertWidget(0,statusLed); @@ -58,8 +60,20 @@ MainWindow::MainWindow(QWidget *parent) : //showMaximized(); } void MainWindow::sbagliato(int score){ - QString sscore("Score "); + + if(bestScore<= score){ + bestScore=score; + writeSettings(); + QString sscore("This is Best Score "); + sscore.append(QString::number(score)); + QMessageBox::warning(this, tr("End Game"),sscore,QMessageBox::Escape); + //tread.genera(); + exit(0); + } + QString sscore("Your Score: "); sscore.append(QString::number(score)); + sscore.append("\n Best score: "); + sscore.append(QString::number(bestScore)); QMessageBox::warning(this, tr("End Game"),sscore,QMessageBox::Escape); //tread.genera(); exit(0); @@ -206,4 +220,17 @@ void MainWindow::changeEvent(QEvent *e) break; } } +void MainWindow::writeSettings() +{ + QSettings settings("Emmynet Inc.", "QMemory"); + settings.setValue("bestscore",bestScore); + +} + +void MainWindow::readSettings() +{ + QSettings settings("Emmynet Inc.", "QMemory"); + bestScore=(settings.value("bestscore").toInt()); + +} diff --git a/mainwindow.h b/mainwindow.h index e1ab34a..41c929b 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -35,6 +35,11 @@ signals: protected: void changeEvent(QEvent *e); +private: + void writeSettings(); + void readSettings(); + + int bestScore; Ui::MainWindow *ui; QList sequenza; TestThread tread; diff --git a/moc_mainwindow.cpp b/moc_mainwindow.cpp index 162f4d6..5d1d827 100644 --- a/moc_mainwindow.cpp +++ b/moc_mainwindow.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** Meta object code from reading C++ file 'mainwindow.h' ** -** Created: Fri Feb 26 16:31:33 2010 +** Created: Mon Mar 1 12:31:40 2010 ** by: The Qt Meta Object Compiler version 62 (Qt 4.6.1) ** ** WARNING! All changes made in this file will be lost! diff --git a/moc_mainwindow.o b/moc_mainwindow.o new file mode 100644 index 0000000..0f7a29a Binary files /dev/null and b/moc_mainwindow.o differ