Added autopause
authorHeli Hyvättinen <heli.hyvattinen@kymp.net>
Wed, 20 Jul 2011 13:16:24 +0000 (16:16 +0300)
committerHeli Hyvättinen <heli.hyvattinen@kymp.net>
Wed, 20 Jul 2011 13:16:24 +0000 (16:16 +0300)
Autopauses after 15 minutes. Restarted at start of level and returning
from pause. Timer stopped during paused.

seascene.cpp
seascene.h

index 24c4a0c..b483311 100644 (file)
@@ -82,6 +82,10 @@ SeaScene::SeaScene(QObject *parent) :
     connect(pPauseAction_,SIGNAL(toggled(bool)),this,SLOT(pause(bool)));
 
 
+    autopauseTimer.setInterval(15*60*1000);
+    connect(&autopauseTimer,SIGNAL(timeout()),this,SLOT(forcePause()));
+
+
 }
 
 void SeaScene::setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed)
@@ -208,6 +212,8 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed)
         connect(pOctopus,SIGNAL(droppingGhosts()),pShip,SLOT(dropAllGhosts()));
     }
     delete pPosition;
+
+
 }
 
 void SeaScene::setupMap(Level level)
@@ -339,6 +345,8 @@ void SeaScene::pause(bool paused)
             screenLitKeeper_.keepScreenLit(true);
             if (pPausetextItem_)
                 pPausetextItem_->hide();
+
+            autopauseTimer.start(); //Start counting towards autopause
         }
 
         else
@@ -353,6 +361,8 @@ void SeaScene::pause(bool paused)
                 qDebug() << "showing pause text";
             }
                 else qDebug() << "No pause text available";
+
+            autopauseTimer.stop(); //No need to count toward autopause when already paused
         }
 }
 
@@ -518,6 +528,7 @@ void SeaScene::restartLevel()
     setupMap(levelList_.value(currentLevel_));  //value() returns default constructor Level if index is invalid, so no risk of crash
     vibrationActivate(pVibrateAction_->isChecked());  //Vibration effects are lost without this
    // qDebug() << pVibrateAction_->isChecked();
+    autopauseTimer.start();  //reset counting towards autopause
 }
 
 
index 5fce73f..0e2a513 100644 (file)
@@ -29,6 +29,7 @@
 #include "screenlitkeeper.h"
 #include "level.h"
 #include <QAction>
+#include <QTimer>
 
 class SeaScene : public QGraphicsScene
 {
@@ -129,6 +130,7 @@ protected:
 
     bool pauseForced_;
 
+    QTimer autopauseTimer;
 
 };