Commit fb10761b authored by Stefan Majewsky's avatar Stefan Majewsky

Make piece shadow creation feel more responsive.

svn path=/trunk/KDE/kdegames/palapeli/; revision=1111399
parent 1052758a
......@@ -201,8 +201,7 @@ void Palapeli::Piece::doMove()
if (scene)
{
scene->validatePiecePosition(this);
//TODO: savegame is updated multiple times at once when multiple pieces are moved
scene->updateSavegame();
scene->invalidateSavegame();
}
}
......
......@@ -42,8 +42,12 @@ Palapeli::Scene::Scene(QObject* parent)
: QGraphicsScene(parent)
, m_constrained(false)
, m_constraintVisualizer(new Palapeli::ConstraintVisualizer(this))
, m_savegameTimer(new QTimer(this))
, m_loadingPuzzle(false)
{
m_savegameTimer->setInterval(500); //write savegame twice per second at most
m_savegameTimer->setSingleShot(true);
connect(m_savegameTimer, SIGNAL(timeout()), this, SLOT(updateSavegame()));
connect(&m_metadataLoader, SIGNAL(finished()), this, SLOT(continueLoading()));
}
......@@ -332,10 +336,16 @@ void Palapeli::Scene::pieceMoved()
mergeCandidates << piece;
}
searchConnections(mergeCandidates);
updateSavegame();
invalidateSavegame();
emit reportProgress(m_atomicPieceCount, m_pieces.count());
}
void Palapeli::Scene::invalidateSavegame()
{
if (!m_savegameTimer->isActive())
m_savegameTimer->start();
}
void Palapeli::Scene::updateSavegame()
{
//save piece positions
......
......@@ -48,7 +48,7 @@ namespace Palapeli
void loadPuzzle(const QModelIndex& index);
void restartPuzzle();
void setConstrained(bool constrained);
void updateSavegame();
void invalidateSavegame();
Q_SIGNALS:
void constrainedChanged(bool constrained);
void puzzleStarted();
......@@ -57,6 +57,7 @@ namespace Palapeli
private Q_SLOTS:
void pieceMoved();
void pieceInstanceTransaction(const QList<Palapeli::Piece*>& deletedPieces, const QList<Palapeli::Piece*>& createdPieces);
void updateSavegame();
void playVictoryAnimation();
void playVictoryAnimation2();
void playVictoryAnimation3();
......@@ -77,6 +78,7 @@ namespace Palapeli
QString m_identifier;
QPointer<Palapeli::Puzzle> m_puzzle;
QList<Palapeli::Piece*> m_pieces;
QTimer* m_savegameTimer;
int m_atomicPieceCount;
//some stuff needed for loading puzzles
bool m_loadingPuzzle;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment