[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [gcompris] src/activities/balancebox: balancebox, fix unhidden overlay
From:       Holger Kaelberer <holger.k () elberer ! de>
Date:       2015-10-31 17:36:16
Message-ID: E1Zsa4e-0007k8-2Q () scm ! kde ! org
[Download RAW message or body]

Git commit c5fbffcee69a14e8cc842e4ec6a33a96d7f16d0f by Holger Kaelberer.
Committed on 31/10/2015 at 17:36.
Pushed by hkaelberer into branch 'master'.

balancebox, fix unhidden overlay

- hide loading overlay before returning from initMap if
  pendingObjects == 0 (thanks JonnyJ for reporting)

- always hide loading overlay onStop

- fix corner case for >1 empty level at the end of the user level:
  following use-case: start new level in editor -> change
  something, don't save -> click next -> click "yes" continue -> new
  empty level is started -> iterate -> >1 empty levels in the users file

M  +22   -16   src/activities/balancebox/balancebox.js
M  +4    -2    src/activities/balancebox/editor/BalanceboxEditor.qml
M  +0    -1    src/activities/balancebox/editor/editor_worker.js

http://commits.kde.org/gcompris/c5fbffcee69a14e8cc842e4ec6a33a96d7f16d0f

diff --git a/src/activities/balancebox/balancebox.js \
b/src/activities/balancebox/balancebox.js index 5cd1703..08754de 100644
--- a/src/activities/balancebox/balancebox.js
+++ b/src/activities/balancebox/balancebox.js
@@ -24,7 +24,6 @@
   - add rectangular fixture for goal
   - editor: add 'clear' button
   - editor: allow going back: level 1 -> last level
-  - add sound effects
   - add new item: unordered contact, that has to be collected but in an
     arbitrary order
 */
@@ -131,16 +130,16 @@ function reconfigureScene()
     pixelsPerMeter = (items.mapWrapper.length / boardSizeBase) * boardSizePix / \
boardSizeM;  vFactor = pixelsPerMeter / box2dPpm;
 
-    console.log("Starting: mode=" + items.mode
-            + " pixelsPerM=" + items.world.pixelsPerMeter
-            + " timeStep=" + items.world.timeStep
-            + " posIterations=" + items.world.positionIterations
-            + " velIterations=" + items.world.velocityIterations
-            + " boardSizePix" + boardSizePix  + " (real " + items.mapWrapper.length \
                + ")"
-            + " pixelsPerMeter=" + pixelsPerMeter
-            + " vFactor=" + vFactor
-            + " dpi=" + items.dpi
-            + " nativeOrientation=" + \
GCompris.ApplicationInfo.getNativeOrientation()); +//    console.log("Starting: \
mode=" + items.mode +//            + " pixelsPerM=" + items.world.pixelsPerMeter
+//            + " timeStep=" + items.world.timeStep
+//            + " posIterations=" + items.world.positionIterations
+//            + " velIterations=" + items.world.velocityIterations
+//            + " boardSizePix" + boardSizePix  + " (real " + \
items.mapWrapper.length + ")" +//            + " pixelsPerMeter=" + pixelsPerMeter
+//            + " vFactor=" + vFactor
+//            + " dpi=" + items.dpi
+//            + " nativeOrientation=" + \
GCompris.ApplicationInfo.getNativeOrientation());  }
 
 function sinDeg(num)
@@ -154,11 +153,10 @@ function moveBall()
     var dvx = ((m*g*dt) * sinDeg(items.tilt.yRotation)) / m;
     var dvy = ((m*g*dt) * sinDeg(items.tilt.xRotation)) / m;
 
-/*    console.log("moving ball: dv: " + items.ball.body.linearVelocity.x
-            + "/" + items.ball.body.linearVelocity.y 
-            +  " -> " + (items.ball.body.linearVelocity.x+dvx) 
-            + "/" + (items.ball.body.linearVelocity.y+dvy));
-  */
+//    console.log("moving ball: dv: " + items.ball.body.linearVelocity.x
+//            + "/" + items.ball.body.linearVelocity.y
+//            +  " -> " + (items.ball.body.linearVelocity.x+dvx)
+//            + "/" + (items.ball.body.linearVelocity.y+dvy));
     
     items.ball.body.linearVelocity.x += dvx * vFactor;
     items.ball.body.linearVelocity.y += dvy * vFactor;
@@ -217,6 +215,8 @@ function stop() {
     // unlock screen orientation
     if (GCompris.ApplicationInfo.isMobile)
         GCompris.ApplicationInfo.setRequestedOrientation(-1);
+    // make sure loading overlay is really stopped
+    items.loading.stop();
 }
 
 function createObject(component, properties)
@@ -379,6 +379,12 @@ function initMap()
     }
     if (goalUnlocked && goal)  // if we have no contacts at all
         goal.imageSource = baseUrl + "/door.svg";
+
+    if (pendingObjects === 0) {
+        // don't have any pending objects (e.g. empty map!): stop overlay
+        items.timer.start();
+        items.loading.stop();
+    }
 }
 
 function addBallContact(item)
diff --git a/src/activities/balancebox/editor/BalanceboxEditor.qml \
b/src/activities/balancebox/editor/BalanceboxEditor.qml index 0992ab8..c738fdb 100644
--- a/src/activities/balancebox/editor/BalanceboxEditor.qml
+++ b/src/activities/balancebox/editor/BalanceboxEditor.qml
@@ -651,8 +651,10 @@ Item {
         }
         onNextLevelClicked: {
             if (Activity.levelChanged)
-                Activity.warnUnsavedChanges(Activity.nextLevel,
-                                            function() {});
+                Activity.warnUnsavedChanges(function() {
+                    Activity.levelChanged = false; // mark unchanged early to make \
check in nextLevel() work +                    Activity.nextLevel();
+                }, function() {});
             else
                 Activity.nextLevel();
         }
diff --git a/src/activities/balancebox/editor/editor_worker.js \
b/src/activities/balancebox/editor/editor_worker.js index c1ffd7a..6d06b14 100644
--- a/src/activities/balancebox/editor/editor_worker.js
+++ b/src/activities/balancebox/editor/editor_worker.js
@@ -22,7 +22,6 @@
 Qt.include("../balancebox_common.js")
 
 WorkerScript.onMessage = function(msg) {
-    console.debug("XXX worker started");
     var maxContactValue = 1;
     msg.lastBallIndex = -1;
     msg.lastGoalIndex = -1;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic