MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / InitFromFile

Method InitFromFile

neo/ui/UserInterface.cpp:278–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

276}
277
278bool 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 ) {

Callers 3

TouchMethod · 0.45
ReloadMethod · 0.45
FindGuiMethod · 0.45

Calls 15

vaFunction · 0.85
ReadFileMethod · 0.80
SetDCMethod · 0.80
SetupFromStateMethod · 0.80
InteractiveMethod · 0.80
idRectangleClass · 0.70
idVec4Class · 0.50
SetMethod · 0.45
LoadFileMethod · 0.45
IsLoadedMethod · 0.45
ReadTokenMethod · 0.45
ParseMethod · 0.45

Tested by

no test coverage detected