fgpanel: fixed some error handling/setup issues
- Provide error message when fgdata path is missing. - Exit game mode when closing/aborting program (show mouse cursor etc). - Support absolute paths for "--panel" parameter. - Don't crash when a font is missing.
This commit is contained in:
parent
dbda2fb95d
commit
be720b424a
3 changed files with 20 additions and 0 deletions
|
@ -56,6 +56,8 @@ FGGLApplication::FGGLApplication( const char * aName, int argc, char ** argv ) :
|
|||
|
||||
FGGLApplication::~FGGLApplication()
|
||||
{
|
||||
if (gameMode)
|
||||
glutLeaveGameMode();
|
||||
}
|
||||
|
||||
void FGGLApplication::DisplayCallback()
|
||||
|
|
|
@ -90,6 +90,15 @@ FGPanelApplication::FGPanelApplication( int argc, char ** argv ) :
|
|||
throw exception();
|
||||
}
|
||||
|
||||
// see if we got a valid fgdata path
|
||||
SGPath BaseCheck(ApplicationProperties::root);
|
||||
BaseCheck.append("version");
|
||||
if (!BaseCheck.exists())
|
||||
{
|
||||
cerr << "Missing base package. Use --fg-root=path_to_fgdata" << endl;
|
||||
throw exception();
|
||||
}
|
||||
|
||||
try {
|
||||
SGPath tpath = ApplicationProperties::GetRootPath( panelFilename.c_str() );
|
||||
readProperties( tpath.str(), ApplicationProperties::Properties );
|
||||
|
@ -284,8 +293,12 @@ double ApplicationProperties::getDouble( const char * name, double def )
|
|||
if( n == NULL ) return def;
|
||||
return n->getDoubleValue();
|
||||
}
|
||||
|
||||
SGPath ApplicationProperties::GetRootPath( const char * sub )
|
||||
{
|
||||
SGPath subpath( sub );
|
||||
if ( subpath.isAbsolute() )
|
||||
return subpath;
|
||||
SGPath path( ApplicationProperties::root );
|
||||
if( sub != NULL )
|
||||
path.append( sub );
|
||||
|
|
|
@ -804,6 +804,11 @@ FGTextLayer::draw ()
|
|||
transform();
|
||||
|
||||
text_renderer.setFont(ApplicationProperties::fontCache.getTexFont(_font_name.c_str()));
|
||||
if (!text_renderer.getFont())
|
||||
{
|
||||
SG_LOG( SG_COCKPIT, SG_ALERT, "Missing font file: " << _font_name );
|
||||
return;
|
||||
}
|
||||
|
||||
text_renderer.setPointSize(_pointSize);
|
||||
text_renderer.begin();
|
||||
|
|
Loading…
Reference in a new issue