Level collection selection cont. & styling.
authorMarja Hassinen <marja2@Vahvero.(none)>
Sat, 2 Jan 2010 18:21:14 +0000 (20:21 +0200)
committerMarja Hassinen <marja2@Vahvero.(none)>
Sat, 2 Jan 2010 18:21:14 +0000 (20:21 +0200)
data/intro01.leg
data/intro02.leg
src/collections.ui
src/game.cpp
src/game.h

index 4d45ced..068fd9e 100644 (file)
@@ -1 +1 @@
-Build a pipe from the start <img src="IMGDIR/5_180.png" width="30" height="30"><br>to the end <img src="IMGDIR/6_0.png" width="30" height="30">.
\ No newline at end of file
+Build a pipe from the start <img src="IMGDIR/5_180.png" width="50" height="50"><br>to the end <img src="IMGDIR/6_0.png" width="50" height="50">.
\ No newline at end of file
index 15729de..fb89e1d 100644 (file)
@@ -1 +1 @@
-You must use all pre-placed pipes.<br> For pieces with two pipes, <img src="IMGDIR/3_0.png" width="30" height="30"> and <img src="IMGDIR/4_0.png" width="30" height="30">,<br>both pipes must be used.
+You must use all pre-placed pipes.<br> For pieces with two pipes, <img src="IMGDIR/3_0.png" width="50" height="50"> and <img src="IMGDIR/4_0.png" width="50" height="50">,<br>both pipes must be used.
index 00dca22..e7a23ec 100644 (file)
@@ -28,7 +28,7 @@
   </property>
   <layout class="QVBoxLayout" name="verticalLayout">
    <item>
-    <widget class="QLabel" name="startTitle">
+    <widget class="QLabel" name="title">
      <property name="font">
       <font>
        <family>Sans Serif</family>
@@ -36,7 +36,7 @@
       </font>
      </property>
      <property name="text">
-      <string/>
+      <string>Choose a level collection:</string>
      </property>
      <property name="textFormat">
       <enum>Qt::RichText</enum>
index 0aad055..fddf831 100644 (file)
@@ -468,6 +468,11 @@ void GameController::computeFlow()
         return;
     }
 
+    if (flowDir == DirPassed) {
+        flowTimer.stop();
+        emit levelPassed(flowScore);
+    }
+
     if (flowDir == DirNone) {
         // This square contained no pipe or an incompatible pipe. Get
         // some more time, so that the user sees the failure before we
@@ -479,15 +484,15 @@ void GameController::computeFlow()
     flowScore += 10;
 
     if (flowDir == DirDone) {
+        // Again, give the user some time...
         if (flowPreplaced < neededFlow) {
             flowDir = DirFailed;
             // TODO: indicate which pipes were missing
-            flowTimer.setInterval(1000);
-        }
-        else {
-            flowTimer.stop();
-            emit levelPassed(flowScore);
         }
+        else
+            flowDir = DirPassed;
+
+        flowTimer.setInterval(1000);
         return;
     }
 
@@ -555,10 +560,15 @@ LevelSwitcher::LevelSwitcher(GameController* gameController,
 void LevelSwitcher::chooseLevelCollection()
 {
     levelList->clear();
+    bool first = true;
     foreach (const QString& collection, levelCollections) {
         QListWidgetItem *newItem = new QListWidgetItem();
         newItem->setText(collection);
         levelList->addItem(newItem); // transfers ownership
+        if (first) {
+            levelList->setCurrentItem(newItem);
+            first = false;
+        }
     }
     levelWidget->show();
 }
@@ -604,6 +614,10 @@ void LevelSwitcher::initiateLevel()
 
     QString introText = gameData.readLine();
     introText.replace("IMGDIR", IMGDIR);
+
+    // The start button might be connected to "chooseLevelCollection"
+    startButton->disconnect();
+    connect(startButton, SIGNAL(clicked()), this, SLOT(onStartClicked()));
     startLabel->setText(introText);
     startWidget->show();
 }
@@ -621,7 +635,8 @@ void LevelSwitcher::onLevelPassed(int score)
     else {
         startTitle->setText(QString("All levels passed. Score: ") + QString::number(score));
         startLabel->setText("Start a new game?");
-        // TODO: go to the level set selection screen
+        startButton->disconnect();
+        connect(startButton, SIGNAL(clicked()), this, SLOT(chooseLevelCollection()));
         level = 0;
         startWidget->show();
     }
index 88540a1..e253ee0 100644 (file)
@@ -51,7 +51,8 @@ enum Direction
     DirRight,
     DirDown,
     DirDone,
-    DirFailed
+    DirFailed,
+    DirPassed
 };
 
 typedef struct Piece
@@ -240,10 +241,10 @@ private slots:
     void onStartClicked();
     void onLevelPassed(int score);
     void onLevelFailed();
+    void chooseLevelCollection();
 
 private:
     void initiateLevel();
-    void chooseLevelCollection();
 
     GameController* gameController; // Not owned
     QWidget* levelWidget; // Not owned