From: James Turner Date: Mon, 30 Sep 2013 15:13:04 +0000 (+0100) Subject: Splash-screen feedback on scenery download. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ad4834c651e52d5c9c79c604a1b2916afb2e0c34;p=flightgear.git Splash-screen feedback on scenery download. --- diff --git a/src/Scenery/tilemgr.cxx b/src/Scenery/tilemgr.cxx index 7aba0f11c..8216c0a86 100644 --- a/src/Scenery/tilemgr.cxx +++ b/src/Scenery/tilemgr.cxx @@ -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); } diff --git a/src/Scenery/tilemgr.hxx b/src/Scenery/tilemgr.hxx index c95f915a0..2c676f73e 100644 --- a/src/Scenery/tilemgr.hxx +++ b/src/Scenery/tilemgr.hxx @@ -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); diff --git a/src/Viewer/splash.cxx b/src/Viewer/splash.cxx index fb7995518..8b881d438 100644 --- a/src/Viewer/splash.cxx +++ b/src/Viewer/splash.cxx @@ -402,11 +402,22 @@ void fgSplashProgress( const char *identifier ) { text = globals->get_locale()->getLocalizedString(id.c_str(), "sys", ""); } - - 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); }