| 276 | } |
| 277 | |
| 278 | bool idUserInterfaceLocal::InitFromFile( const char *qpath, bool rebuild, bool cache ) { |
| 279 | |
| 280 | if ( !( qpath && *qpath ) ) { |
| 281 | // FIXME: Memory leak!! |
| 282 | return false; |
| 283 | } |
| 284 | |
| 285 | loading = true; |
| 286 | |
| 287 | if ( rebuild ) { |
| 288 | delete desktop; |
| 289 | desktop = new idWindow( this ); |
| 290 | } else if ( desktop == NULL ) { |
| 291 | desktop = new idWindow( this ); |
| 292 | } |
| 293 | |
| 294 | source = qpath; |
| 295 | state.Set( "text", "Test Text!" ); |
| 296 | |
| 297 | idParser src( LEXFL_NOFATALERRORS | LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT ); |
| 298 | |
| 299 | //Load the timestamp so reload guis will work correctly |
| 300 | fileSystem->ReadFile(qpath, NULL, &timeStamp); |
| 301 | |
| 302 | src.LoadFile( qpath ); |
| 303 | |
| 304 | if ( src.IsLoaded() ) { |
| 305 | idToken token; |
| 306 | while( src.ReadToken( &token ) ) { |
| 307 | if ( idStr::Icmp( token, "windowDef" ) == 0 ) { |
| 308 | desktop->SetDC( &uiManagerLocal.dc ); |
| 309 | if ( desktop->Parse( &src, rebuild ) ) { |
| 310 | desktop->SetFlag( WIN_DESKTOP ); |
| 311 | desktop->FixupParms(); |
| 312 | } |
| 313 | continue; |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | state.Set( "name", qpath ); |
| 318 | } else { |
| 319 | desktop->SetDC( &uiManagerLocal.dc ); |
| 320 | desktop->SetFlag( WIN_DESKTOP ); |
| 321 | desktop->name = "Desktop"; |
| 322 | desktop->text = va( "Invalid GUI: %s", qpath ); |
| 323 | desktop->rect = idRectangle( 0.0f, 0.0f, 640.0f, 480.0f ); |
| 324 | desktop->drawRect = desktop->rect; |
| 325 | desktop->foreColor = idVec4( 1.0f, 1.0f, 1.0f, 1.0f ); |
| 326 | desktop->backColor = idVec4( 0.0f, 0.0f, 0.0f, 1.0f ); |
| 327 | desktop->SetupFromState(); |
| 328 | common->Warning( "Couldn't load gui: '%s'", qpath ); |
| 329 | loading = false; |
| 330 | return false; |
| 331 | } |
| 332 | |
| 333 | interactive = desktop->Interactive(); |
| 334 | |
| 335 | if ( uiManagerLocal.guis.Find( this ) == NULL ) { |
no test coverage detected