Choose a random splash texture
Signed-off-by: onox <denkpadje@gmail.com>
This commit is contained in:
parent
7aaa0772df
commit
e3c8ecc25a
1 changed files with 28 additions and 12 deletions
|
@ -184,22 +184,36 @@ char *genNameString()
|
||||||
|
|
||||||
static osg::Node* fgCreateSplashCamera()
|
static osg::Node* fgCreateSplashCamera()
|
||||||
{
|
{
|
||||||
const char* splash_texture = fgGetString("/sim/startup/splash-texture");
|
|
||||||
SGSharedPtr<SGPropertyNode> style = fgGetNode("/sim/gui/style[0]", true);
|
|
||||||
|
|
||||||
char *namestring = genNameString();
|
char *namestring = genNameString();
|
||||||
fgSetString("/sim/startup/program-name", namestring);
|
fgSetString("/sim/startup/program-name", namestring);
|
||||||
delete[] namestring;
|
delete[] namestring;
|
||||||
|
|
||||||
SGPath tpath;
|
simgear::PropertyList textures = fgGetNode("/sim/startup", true)->getChildren("splash-texture");
|
||||||
if (splash_texture && strcmp(splash_texture, "")) {
|
std::vector<SGPath> useable_textures;
|
||||||
tpath = globals->resolve_maybe_aircraft_path(splash_texture);
|
SGPath tpath;
|
||||||
if (tpath.isNull())
|
|
||||||
{
|
// Build a list of textures that are usable; those whose path can be resolved
|
||||||
SG_LOG( SG_VIEW, SG_ALERT, "Cannot find splash screen file '" << splash_texture
|
for (simgear::PropertyList::iterator it = textures.begin(); it != textures.end(); it++) {
|
||||||
<< "'. Using default." );
|
std::string value = (*it)->getStringValue();
|
||||||
}
|
if (!value.empty()) {
|
||||||
}
|
tpath = globals->resolve_maybe_aircraft_path(value);
|
||||||
|
if (!tpath.isNull()) {
|
||||||
|
useable_textures.push_back(tpath);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SG_LOG(SG_VIEW, SG_ALERT, "Cannot find splash screen file '" << value << "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Seed the RNG in order to get randomness
|
||||||
|
sg_srandom_time();
|
||||||
|
|
||||||
|
if (!useable_textures.empty()) {
|
||||||
|
// Select a random useable texture
|
||||||
|
const int index = (int)(sg_random() * useable_textures.size());
|
||||||
|
tpath = useable_textures[index];
|
||||||
|
}
|
||||||
|
|
||||||
if (tpath.isNull()) {
|
if (tpath.isNull()) {
|
||||||
// no splash screen specified - select random image
|
// no splash screen specified - select random image
|
||||||
|
@ -214,6 +228,8 @@ static osg::Node* fgCreateSplashCamera()
|
||||||
tpath.concat( ".png" );
|
tpath.concat( ".png" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SGSharedPtr<SGPropertyNode> style = fgGetNode("/sim/gui/style[0]", true);
|
||||||
|
|
||||||
osg::Texture2D* splashTexture = new osg::Texture2D;
|
osg::Texture2D* splashTexture = new osg::Texture2D;
|
||||||
splashTexture->setImage(osgDB::readImageFile(tpath.c_str()));
|
splashTexture->setImage(osgDB::readImageFile(tpath.c_str()));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue