From: Heli Hyvättinen Date: Mon, 26 Sep 2011 18:24:09 +0000 (+0300) Subject: Vibration should now only be tried if the app has the resource X-Git-Tag: v0.4.0~13^2~2 X-Git-Url: https://vcs.maemo.org/git/?a=commitdiff_plain;h=9a5e199d08b9b6eb93602af4122927cd41a2a991;p=ghostsoverboard Vibration should now only be tried if the app has the resource However, vibration does not work at all (since the beta 2 firmware). --- diff --git a/seascene.cpp b/seascene.cpp index 395e723..d473538 100644 --- a/seascene.cpp +++ b/seascene.cpp @@ -86,6 +86,8 @@ SeaScene::SeaScene(QObject *parent) : connect(this,SIGNAL(allGhostsPicked()),this,SLOT(nextLevel()),Qt::QueuedConnection); + + pVibrateAction_ = new QAction(tr("Vibration effects"),this); pVibrateAction_->setCheckable(true); connect(pVibrateAction_,SIGNAL(toggled(bool)),this,SLOT(vibrationActivate(bool))); @@ -102,6 +104,7 @@ SeaScene::SeaScene(QObject *parent) : autopauseTimer.setInterval(15*60*1000); connect(&autopauseTimer,SIGNAL(timeout()),this,SLOT(turnPauseOn())); + vibrationAllowed_ = false; pResourceSet_ = new ResourcePolicy::ResourceSet("game",this); ResourcePolicy::VibraResource * pVibraResource = new ResourcePolicy::VibraResource(); pVibraResource->setOptional(false); //The only resource of the set, so no sense for it to be optional @@ -241,6 +244,10 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed) connect(pShip,SIGNAL(pickingGhost(QGraphicsItem*)),this, SLOT(removeGhost(QGraphicsItem*)) ); connect(pShip,SIGNAL(droppingGhosts(int)),this,SLOT(ghostsDropped(int))); connect(this,SIGNAL(vibrationActivated(bool)),pShip,SLOT(setVibrationActivate(bool))); + if (vibrationAllowed_) + pShip->allowVibration(); //Vibration is disallowed by default so only allowing needs to be done explicitly + connect(pResourceSet_,SIGNAL(resourcesGranted(const QList< ResourcePolicy::ResourceType >)),pShip,SLOT(allowVibration())); + connect(pResourceSet_,SIGNAL(lostResources()),pShip,SLOT(disallowVibration())); pShip->startMoving(); movingItems_.append(pShip); connect(this,SIGNAL(pauseOn()),pShip,SLOT(stopMoving())); @@ -633,6 +640,7 @@ void SeaScene::restartLevel() vibrationActivate(pVibrateAction_->isChecked()); //Vibration effects are lost without this // qDebug() << pVibrateAction_->isChecked(); + autopauseTimer.start(); //reset counting towards autopause @@ -818,10 +826,12 @@ void SeaScene::createLevelCompletedItems() void SeaScene::resourcesAvailable() { qDebug() << "Resources available"; + vibrationAllowed_ = true; } void SeaScene::resourcesLost() { qDebug() << "Resources lost"; + vibrationAllowed_ = false; } diff --git a/seascene.h b/seascene.h index 715dfe3..6f77229 100644 --- a/seascene.h +++ b/seascene.h @@ -47,6 +47,7 @@ signals: void pauseOff(); void vibrationActivated(bool on); + public slots: /*! Places all needed items for a level to (re)start. @@ -159,6 +160,7 @@ protected: int levelScore_; ResourcePolicy::ResourceSet * pResourceSet_; + bool vibrationAllowed_; }; diff --git a/ship.cpp b/ship.cpp index 8afc2d2..6c92db0 100644 --- a/ship.cpp +++ b/ship.cpp @@ -38,6 +38,7 @@ Ship::Ship(QList pixmapList, QGraphicsItem *parent) : shipImages_ = pixmapList; ghostsAboard_ = 0; vibrationActive_ = false; + vibrationAllowed_ = false; } bool Ship::handleCollisions() @@ -98,7 +99,7 @@ void Ship::dropAllGhosts() //vibrate - if (vibrationActive_) + if (vibrationActive_ && vibrationAllowed_) { // This is for fremantle @@ -129,3 +130,13 @@ void Ship::setVibrationActivate(bool on) { vibrationActive_ = on; } + +void Ship::allowVibration() +{ + vibrationAllowed_ = true; +} + +void Ship::disallowVibration() +{ + vibrationAllowed_ = false; +} diff --git a/ship.h b/ship.h index 77cd334..6aa2cc6 100644 --- a/ship.h +++ b/ship.h @@ -48,6 +48,10 @@ public slots: void setVibrationActivate(bool on); + void allowVibration(); + + void disallowVibration(); + protected: protected: @@ -61,6 +65,8 @@ protected: bool vibrationActive_; + bool vibrationAllowed_; + };