splash screen: use language resource for translation
Also pimp the progress spinner.
This commit is contained in:
parent
db3c70e235
commit
88592bfe71
4 changed files with 56 additions and 23 deletions
|
@ -161,6 +161,10 @@ FGLocale::selectLanguage(const char *language)
|
|||
}
|
||||
|
||||
_currentLocale = locale;
|
||||
|
||||
// load resource for system messages (translations for fgfs internal messages)
|
||||
loadResource("sys");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -98,9 +98,9 @@ static void fgLoadInitialScenery()
|
|||
}
|
||||
else
|
||||
{
|
||||
fgSplashProgress("loading scenery");
|
||||
// be nice to loader threads while waiting for initial scenery, reduce to 2fps
|
||||
SGTimeStamp::sleepForMSec(500);
|
||||
fgSplashProgress("loading-scenery");
|
||||
// be nice to loader threads while waiting for initial scenery, reduce to 20fps
|
||||
SGTimeStamp::sleepForMSec(50);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -183,7 +183,6 @@ static void fgIdleFunction ( void ) {
|
|||
// our initializations out of the idle callback so that we can get a
|
||||
// splash screen up and running right away.
|
||||
static int idle_state = 0;
|
||||
static int spin_count = 0;
|
||||
|
||||
static osg::ref_ptr<GeneralInitOperation> genOp;
|
||||
if ( idle_state == 0 ) {
|
||||
|
@ -212,17 +211,17 @@ static void fgIdleFunction ( void ) {
|
|||
if (!guiFinishInit())
|
||||
return;
|
||||
idle_state++;
|
||||
fgSplashProgress("loading aircraft list");
|
||||
fgSplashProgress("loading-aircraft-list");
|
||||
|
||||
} else if ( idle_state == 2 ) {
|
||||
idle_state++;
|
||||
fgSplashProgress("loading navigation data");
|
||||
fgSplashProgress("loading-nav-data");
|
||||
|
||||
} else if ( idle_state == 3 ) {
|
||||
idle_state++;
|
||||
fgInitNav();
|
||||
|
||||
fgSplashProgress("initializing scenery system");
|
||||
fgSplashProgress("init-scenery");
|
||||
|
||||
} else if ( idle_state == 4 ) {
|
||||
idle_state+=2;
|
||||
|
@ -264,11 +263,11 @@ static void fgIdleFunction ( void ) {
|
|||
globals->get_scenery()->bind();
|
||||
globals->set_tile_mgr( new FGTileMgr );
|
||||
|
||||
fgSplashProgress("loading aircraft");
|
||||
fgSplashProgress("loading-aircraft");
|
||||
|
||||
} else if ( idle_state == 6 ) {
|
||||
idle_state++;
|
||||
fgSplashProgress("creating subsystems");
|
||||
fgSplashProgress("creating-subsystems");
|
||||
|
||||
} else if ( idle_state == 7 ) {
|
||||
idle_state++;
|
||||
|
@ -276,7 +275,7 @@ static void fgIdleFunction ( void ) {
|
|||
st.stamp();
|
||||
fgCreateSubsystems();
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "Creating subsystems took:" << st.elapsedMSec());
|
||||
fgSplashProgress("binding subsystems");
|
||||
fgSplashProgress("binding-subsystems");
|
||||
|
||||
} else if ( idle_state == 8 ) {
|
||||
idle_state++;
|
||||
|
@ -285,16 +284,14 @@ static void fgIdleFunction ( void ) {
|
|||
globals->get_subsystem_mgr()->bind();
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "Binding subsystems took:" << st.elapsedMSec());
|
||||
|
||||
fgSplashProgress("initing subsystems");
|
||||
fgSplashProgress("init-subsystems");
|
||||
} else if ( idle_state == 9 ) {
|
||||
SGSubsystem::InitStatus status = globals->get_subsystem_mgr()->incrementalInit();
|
||||
if ( status == SGSubsystem::INIT_DONE) {
|
||||
++idle_state;
|
||||
fgSplashProgress("finishing subsystem init");
|
||||
fgSplashProgress("finishing-subsystems");
|
||||
} else {
|
||||
const char* spinChars = "-\\|/";
|
||||
string msg = string("initing subsystems ") + spinChars[spin_count++ % 4];
|
||||
fgSplashProgress(msg.c_str());
|
||||
fgSplashProgress("init-subsystems");
|
||||
}
|
||||
|
||||
} else if ( idle_state == 10 ) {
|
||||
|
@ -329,7 +326,7 @@ static void fgIdleFunction ( void ) {
|
|||
"No METAR available to pick active runway" );
|
||||
}
|
||||
|
||||
fgSplashProgress("initializing graphics engine");
|
||||
fgSplashProgress("init-graphics");
|
||||
|
||||
} else if ( idle_state == 900 ) {
|
||||
idle_state = 1000;
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include <Main/globals.hxx>
|
||||
#include <Main/fg_props.hxx>
|
||||
#include <Main/fg_os.hxx>
|
||||
#include <Main/locale.hxx>
|
||||
#include "splash.hxx"
|
||||
#include "renderer.hxx"
|
||||
|
||||
|
@ -307,10 +308,21 @@ static osg::Node* fgCreateSplashCamera()
|
|||
text->setPosition(osg::Vec3(0, -0.92, 0));
|
||||
text->setAlignment(osgText::Text::CENTER_CENTER);
|
||||
SGPropertyNode* prop = fgGetNode("/sim/startup/splash-progress-text", true);
|
||||
prop->setStringValue("initializing");
|
||||
prop->setStringValue("");
|
||||
text->setUpdateCallback(new FGSplashTextUpdateCallback(prop));
|
||||
geode->addDrawable(text);
|
||||
|
||||
osgText::Text* spinnertext = new osgText::Text;
|
||||
spinnertext->setFont(globals->get_fontcache()->getfntpath(fn.c_str()).str());
|
||||
spinnertext->setCharacterSize(0.06);
|
||||
spinnertext->setColor(osg::Vec4(1, 1, 1, 1));
|
||||
spinnertext->setPosition(osg::Vec3(0, -0.97, 0));
|
||||
spinnertext->setAlignment(osgText::Text::CENTER_CENTER);
|
||||
prop = fgGetNode("/sim/startup/splash-progress-spinner", true);
|
||||
prop->setStringValue("");
|
||||
spinnertext->setUpdateCallback(new FGSplashTextUpdateCallback(prop));
|
||||
geode->addDrawable(spinnertext);
|
||||
|
||||
text = new osgText::Text;
|
||||
text->setFont(globals->get_fontcache()->getfntpath(fn.c_str()).str());
|
||||
text->setCharacterSize(0.08);
|
||||
|
@ -332,6 +344,8 @@ static osg::Node* fgCreateSplashCamera()
|
|||
text->setUpdateCallback(new FGSplashTextUpdateCallback(prop));
|
||||
geode->addDrawable(text);
|
||||
|
||||
fgSplashProgress("init");
|
||||
|
||||
return camera;
|
||||
}
|
||||
|
||||
|
@ -370,11 +384,28 @@ void fgSplashInit () {
|
|||
globals->get_renderer()->splashinit();
|
||||
}
|
||||
|
||||
void fgSplashProgress ( const char *text ) {
|
||||
void fgSplashProgress( const char *identifier ) {
|
||||
const char* spinChars = "-\\|/";
|
||||
static int spin_count = 0;
|
||||
string spin_status = string("");
|
||||
|
||||
if (identifier[0] != 0)
|
||||
spin_status += spinChars[spin_count++ % 4];
|
||||
|
||||
fgSetString("/sim/startup/splash-progress-spinner", spin_status);
|
||||
|
||||
const char* text = "";
|
||||
if (identifier[0] != 0)
|
||||
{
|
||||
string id = string("splash/") + identifier;
|
||||
text = globals->get_locale()->getLocalizedString(id.c_str(),
|
||||
"sys", "<incomplete language resource>");
|
||||
}
|
||||
|
||||
if (!strcmp(fgGetString("/sim/startup/splash-progress-text"), text)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SG_LOG( SG_VIEW, SG_INFO, "Splash screen progress " << text );
|
||||
SG_LOG( SG_VIEW, SG_INFO, "Splash screen progress " << identifier );
|
||||
fgSetString("/sim/startup/splash-progress-text", text);
|
||||
}
|
||||
|
|
|
@ -31,13 +31,14 @@
|
|||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
// Initialize the splash screen
|
||||
/** Initialize the splash screen */
|
||||
void fgSplashInit ();
|
||||
|
||||
// Set progress information
|
||||
void fgSplashProgress ( const char *text );
|
||||
/** Set progress information.
|
||||
* "identifier" references an element of the language resource. */
|
||||
void fgSplashProgress ( const char *identifier );
|
||||
|
||||
// Retrieve the splash screen node ...
|
||||
/** Retrieve the splash screen node */
|
||||
osg::Node* fgCreateSplashNode();
|
||||
|
||||
#endif // _SPLASH_HXX
|
||||
|
|
Loading…
Reference in a new issue