]> git.mxchange.org Git - flightgear.git/commitdiff
Splash-screen feedback on scenery download.
authorJames Turner <zakalawe@mac.com>
Mon, 30 Sep 2013 15:13:04 +0000 (16:13 +0100)
committerJames Turner <zakalawe@mac.com>
Mon, 30 Sep 2013 15:36:13 +0000 (16:36 +0100)
src/Scenery/tilemgr.cxx
src/Scenery/tilemgr.hxx
src/Viewer/splash.cxx

index 7aba0f11c665f0515497fac75d61970e59d5b6b6..8216c0a8621f9999d672ce8d20bc0156f60c4d08 100644 (file)
@@ -242,7 +242,7 @@ void FGTileMgr::schedule_needed(const SGBucket& curr_bucket, double vis)
  * Update the various queues maintained by the tilemagr (private
  * internal function, do not call directly.)
  */
-void FGTileMgr::update_queues()
+void FGTileMgr::update_queues(bool& isDownloadingScenery)
 {
     osg::FrameStamp* framestamp
         = globals->get_renderer()->getViewer()->getFrameStamp();
@@ -265,22 +265,22 @@ void FGTileMgr::update_queues()
             // based on current visibilty
             e->prep_ssg_node(vis);
             
-            bool nonExpiredOrCurrent = !e->is_expired(current_time) || e->is_current_view();
-            if ( !e->is_loaded() &&
-                !isTileDirSyncing(e->tileFileName) &&
-                nonExpiredOrCurrent)
-            {                
-                // schedule tile for loading with osg pager
-                _pager->queueRequest(e->tileFileName,
-                                     e->getNode(),
-                                     e->get_priority(),
-                                     framestamp,
-                                     e->getDatabaseRequest(),
-                                     _options.get());
-                loading++;
-            }
-        } else
-        {
+            if (!e->is_loaded()) {
+                bool nonExpiredOrCurrent = !e->is_expired(current_time) || e->is_current_view();
+                bool downloading = isTileDirSyncing(e->tileFileName);
+                isDownloadingScenery |= downloading;
+                if ( !downloading && nonExpiredOrCurrent) {
+                    // schedule tile for loading with osg pager
+                    _pager->queueRequest(e->tileFileName,
+                                         e->getNode(),
+                                         e->get_priority(),
+                                         framestamp,
+                                         e->getDatabaseRequest(),
+                                         _options.get());
+                    loading++;
+                }
+            } // of tile not loaded case
+        } else {
             SG_LOG(SG_TERRAIN, SG_ALERT, "Warning: empty tile in cache!");
         }
         tile_cache.next();
@@ -321,7 +321,8 @@ void FGTileMgr::update(double)
     double vis = _visibilityMeters->getDoubleValue();
     schedule_tiles_at(globals->get_view_position(), vis);
 
-    update_queues();
+    bool waitingOnTerrasync = false;
+    update_queues(waitingOnTerrasync);
 
     // scenery loading check, triggers after each sim (tile manager) reinit
     if (!_scenery_loaded->getBoolValue())
@@ -330,6 +331,7 @@ void FGTileMgr::update(double)
         bool positionFinalized = fgGetBool("sim/position-finalized");
         bool sceneryOverride = _scenery_override->getBoolValue();
         
+        
     // we are done if final position is set and the scenery & FDM are done.
     // scenery-override can ignore the last two, but not position finalization.
         if (positionFinalized && (sceneryOverride || (isSceneryLoaded() && fdmInited)))
@@ -339,7 +341,14 @@ void FGTileMgr::update(double)
         }
         else
         {
-            fgSplashProgress(positionFinalized ? "loading-scenery" : "finalize-position");
+            if (!positionFinalized) {
+                fgSplashProgress("finalize-position");
+            } else if (waitingOnTerrasync) {
+                fgSplashProgress("downloading-scenery");
+            } else {
+                fgSplashProgress("loading-scenery");
+            }
+            
             // be nice to loader threads while waiting for initial scenery, reduce to 20fps
             SGTimeStamp::sleepForMSec(50);
         }
index c95f915a05cd89d4f1803a44f06b81715bd2d228..2c676f73ee8c06c73d6f945466db826fa3ea1d42 100644 (file)
@@ -81,7 +81,7 @@ private:
     simgear::SGTerraSync* _terra_sync;
 
     // update various queues internal queues
-    void update_queues();
+    void update_queues(bool& isDownloadingScenery);
 
     // schedule tiles for the viewer bucket
     void schedule_tiles_at(const SGGeod& location, double rangeM);
index fb79955189b6f0ed43f5defbcb9a7416a425ce1b..8b881d4385613f9f41cbc2f66e5625b7a7f29610 100644 (file)
@@ -402,11 +402,22 @@ void fgSplashProgress( const char *identifier ) {
       text = globals->get_locale()->getLocalizedString(id.c_str(),
                                                        "sys", "<incomplete language resource>");
   }
-
-  if (!strcmp(fgGetString("/sim/startup/splash-progress-text"), text)) {
-    return;
-  }
+    
+    if (!strcmp(fgGetString("/sim/startup/splash-progress-text"), text)) {
+        return;
+    }
+    
+    if (!strcmp(identifier,"downloading-scenery")) {
+        std::ostringstream oss;
+        unsigned int kbytesPerSec = fgGetInt("/sim/terrasync/transfer-rate-bytes-sec") / 1024;
+        oss << text;
+        if (kbytesPerSec > 0) {
+            oss << " - " << kbytesPerSec << " KBytes/sec";
+        }
+        fgSetString("/sim/startup/splash-progress-text", oss.str());
+    } else {
+        SG_LOG( SG_VIEW, SG_INFO, "Splash screen progress " << identifier );
+        fgSetString("/sim/startup/splash-progress-text", text);
+    }
   
-  SG_LOG( SG_VIEW, SG_INFO, "Splash screen progress " << identifier );
-  fgSetString("/sim/startup/splash-progress-text", text);
 }