summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
3d0c731)
+impuzzle (0.4-1maemo0) unstable; urgency=low
+
+ * Implemented: Game state save and restore
+ * Implemented: Maemo5 style notifications
+
+ -- Timo Härkönen <timop.harkonen@gmail.com> Wed, 24 Mar 2010 17:51:13 +0200
+
impuzzle (0.3-2maemo1) unstable; urgency=low
* Added bug tracking link to control
impuzzle (0.3-2maemo1) unstable; urgency=low
* Added bug tracking link to control
Package: impuzzle
Architecture: any
Package: impuzzle
Architecture: any
-Depends: libqt4-core (>= 4.6.0), libqt4-gui (>= 4.6.0)
+Depends: libqt4-core (>= 4.6.0), libqt4-gui (>= 4.6.0), libqt4-maemo5 (>= 4.6.0)
Description: Image puzzle game
impuzzle is a picture puzzle game that let's you
use your own pictures as the game board.
\ No newline at end of file
Description: Image puzzle game
impuzzle is a picture puzzle game that let's you
use your own pictures as the game board.
\ No newline at end of file
#define RANDOM_IMAGE_TXT "Random image"
#define SELECT_IMAGE_TXT "Select image..."
#define RANDOM_IMAGE_TXT "Random image"
#define SELECT_IMAGE_TXT "Select image..."
-#define RESTORE_FILE "impuzzle.restore"
+#define RESTORE_FILE "impuzzle.dat"
#define HOME_DIRECTORY ".impuzzle"
#endif // DEFINES_H
#define HOME_DIRECTORY ".impuzzle"
#endif // DEFINES_H
#include <QDir>
#include <QTextStream>
#include <QCloseEvent>
#include <QDir>
#include <QTextStream>
#include <QCloseEvent>
+#include <QFileInfo>
+#include <QDateTime>
+
+#ifdef Q_WS_MAEMO_5
+#include <QMaemo5InformationBox>
+#endif
.arg(QDir::homePath()).arg(HOME_DIRECTORY).arg(RESTORE_FILE))) {
if(!restoreGame()) {
setPieces(ImageImporter::instance()->newPieces(Settings::instance()->image(), Settings::instance()->pieceCount()));
.arg(QDir::homePath()).arg(HOME_DIRECTORY).arg(RESTORE_FILE))) {
if(!restoreGame()) {
setPieces(ImageImporter::instance()->newPieces(Settings::instance()->image(), Settings::instance()->pieceCount()));
+ PuzzleItem::setMoveCount(0);
-bool GameView::areAllPiecesOk() const
+bool GameView::areAllPiecesOk()
{
for(int i = 0; i < pieces_.count(); ++i) {
// Skip hidden piece
{
for(int i = 0; i < pieces_.count(); ++i) {
// Skip hidden piece
// Show dialog with move count
QMessageBox::about(const_cast<GameView *>(this), tr("You won"), QString("Puzzle completed with %1 moves").arg(PuzzleItem::moveCount()));
// Show dialog with move count
QMessageBox::about(const_cast<GameView *>(this), tr("You won"), QString("Puzzle completed with %1 moves").arg(PuzzleItem::moveCount()));
qDebug() << "restore list count: " << list.count();
if(!list.isEmpty()) {
qDebug() << "restore list count: " << list.count();
if(!list.isEmpty()) {
- Settings::instance()->setPieceCount(list.at(0).toInt());
+ bool ok = false;
+ int pieces = list.at(0).toInt(&ok);
+ if(!ok) {
+ return false;
+ }
+ if(!QFile::exists(im) && im != "default") {
+ return false;
+ }
+
+ int moveCount = list.at(2).toInt(&ok);
+ if(!ok) {
+ return false;
+ }
+
+ Settings::instance()->setPieceCount(pieces);
+ PuzzleItem::setMoveCount(moveCount);
+
if(im == "default" || im.isEmpty()) {
Settings::instance()->setImage(0);
Settings::instance()->setImagePath("default");
if(im == "default" || im.isEmpty()) {
Settings::instance()->setImage(0);
Settings::instance()->setImagePath("default");
Settings::instance()->setImagePath(im);
Settings::instance()->setImage(QPixmap(im));
}
Settings::instance()->setImagePath(im);
Settings::instance()->setImage(QPixmap(im));
}
- PuzzleItem::setMoveCount(list.at(2).toInt());
setPieces(ImageImporter::instance()->newPieces(Settings::instance()->image(), Settings::instance()->pieceCount()), false);
setPieces(ImageImporter::instance()->newPieces(Settings::instance()->image(), Settings::instance()->pieceCount()), false);
if(!list.at(j + 3).isNull()) {
QStringList points = list.at(j + 3).split("#");
//if(points.count() == 2)
if(!list.at(j + 3).isNull()) {
QStringList points = list.at(j + 3).split("#");
//if(points.count() == 2)
- QPointF point(points.at(0).toInt(), points.at(1).toInt());
+ int x = points.at(0).toInt(&ok);
+ if(!ok) {
+ return false;
+ }
+
+ int y = points.at(1).toInt(&ok);
+ if(!ok) {
+ return false;
+ }
+
+ QPointF point(x, y);
- qDebug() << "Setting piece " << pieces_.at(j)->pieceNumber();
- qDebug() << "x: " << point.x() << " y: " << point.y();
+ //qDebug() << "Setting piece " << pieces_.at(j)->pieceNumber();
+ //qDebug() << "x: " << point.x() << " y: " << point.y();
pieces_.at(j)->setCurrentPlace(point);
}
pieces_.at(j)->setCurrentPlace(point);
}
+ else {
+ return false;
+ }
for(int m = 0; m < pieces_.count(); ++m) {
pieces_.at(m)->setPos(pieces_.at(m)->currentPlace());
if(pieces_.at(m)->pieceNumber() == hidden.at(2).toInt()) {
for(int m = 0; m < pieces_.count(); ++m) {
pieces_.at(m)->setPos(pieces_.at(m)->currentPlace());
if(pieces_.at(m)->pieceNumber() == hidden.at(2).toInt()) {
- qDebug() << "Hiding piece number " << hidden;
+ //qDebug() << "Hiding piece number " << hidden;
setMovingPieces();
}
else {
setMovingPieces();
}
else {
setPieces(ImageImporter::instance()->newPieces(Settings::instance()->image(), Settings::instance()->pieceCount()));
file.close();
file.remove();
setPieces(ImageImporter::instance()->newPieces(Settings::instance()->image(), Settings::instance()->pieceCount()));
file.close();
file.remove();
+ QFileInfo fileInfo(file);
+
+ QDateTime created = fileInfo.created();
+ QString infoTxt = QString("Restored game state from %1")
+ .arg(created.toString(Qt::TextDate));
+
+#ifdef Q_WS_MAEMO_5
+ QMaemo5InformationBox::information(this, infoTxt);
+#endif
+
file.close();
file.remove();
file.close();
file.remove();
QTextStream out(&file);
out << Settings::instance()->pieceCount();
QTextStream out(&file);
out << Settings::instance()->pieceCount();
if(Settings::instance()->imagePath().isEmpty()) {
if(Settings::instance()->imagePath().isEmpty()) {
+ out << QString("default");
}
else {
out << Settings::instance()->imagePath();
}
}
else {
out << Settings::instance()->imagePath();
}
out << PuzzleItem::moveCount();
out << PuzzleItem::moveCount();
// piece positions
int number = 0;
// piece positions
int number = 0;
for(int i = 0; i < pieces_.count(); ++i) {
if(pieces_.at(i)->pieceNumber() == number + 1) {
out << pieces_.at(i)->currentPlace().x();
for(int i = 0; i < pieces_.count(); ++i) {
if(pieces_.at(i)->pieceNumber() == number + 1) {
out << pieces_.at(i)->currentPlace().x();
out << pieces_.at(i)->currentPlace().y();
out << pieces_.at(i)->currentPlace().y();
pieces_.at(i)->pieceNumber();
if(!pieces_.at(i)->isVisible()) {
hiddenNo = number + 1;
pieces_.at(i)->pieceNumber();
if(!pieces_.at(i)->isVisible()) {
hiddenNo = number + 1;
QList<PuzzleItem *> pieces() const;
QPointF emptyPlace();
void setEmptyPlace(const QPointF &place);
QList<PuzzleItem *> pieces() const;
QPointF emptyPlace();
void setEmptyPlace(const QPointF &place);
- bool areAllPiecesOk() const;
void setMovingPieces();
public slots:
void setMovingPieces();
public slots:
bool restoreGame();
bool saveGame();
bool restoreGame();
bool saveGame();
+signals:
+ void gameWon();
+
protected:
void closeEvent(QCloseEvent *event);
protected:
void closeEvent(QCloseEvent *event);
settingsDialog_ = new SettingsDialog(this);
setWindowTitle(tr("ImPuzzle"));
settingsDialog_ = new SettingsDialog(this);
setWindowTitle(tr("ImPuzzle"));
+
+ connect(GameView::instance(), SIGNAL(gameWon()), this, SLOT(gameEnded()));
}
void MainWindow::createMenu()
}
void MainWindow::createMenu()
saveAction_ = new QAction(tr("Save game"), this);
connect(saveAction_, SIGNAL(triggered()), GameView::instance(), SLOT(saveGame()));
saveAction_ = new QAction(tr("Save game"), this);
connect(saveAction_, SIGNAL(triggered()), GameView::instance(), SLOT(saveGame()));
+ saveAction_->setDisabled(true);
}
void MainWindow::importClicked()
}
void MainWindow::importClicked()
settingsDialog_->exec();
GameView::instance()->setPieces(ImageImporter::instance()->newPieces(Settings::instance()->image(), Settings::instance()->pieceCount()));
settingsDialog_->exec();
GameView::instance()->setPieces(ImageImporter::instance()->newPieces(Settings::instance()->image(), Settings::instance()->pieceCount()));
+ saveAction_->setEnabled(true);
}
void MainWindow::settingsClicked()
{
}
}
void MainWindow::settingsClicked()
{
}
+
+void MainWindow::gameEnded()
+{
+ if(saveAction_->isEnabled()) {
+ saveAction_->setDisabled(true);
+ }
+}
void newGameClicked();
void importClicked();
void settingsClicked();
void newGameClicked();
void importClicked();
void settingsClicked();
private:
void createActions();
private:
void createActions();
INCLUDEPATH += .
DESTDIR = ../bin
INCLUDEPATH += .
DESTDIR = ../bin
+maemo5 {
+ QT += maemo5
+}
+
# Input
HEADERS += gameview.h \
mainwindow.h \
# Input
HEADERS += gameview.h \
mainwindow.h \