MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / init

Function init

TheForceEngine/TFE_FrontEndUI/frontEndUi.cpp:323–388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321 }
322
323 void init()
324 {
325 TFE_System::logWrite(LOG_MSG, "Startup", "TFE_FrontEndUI::init");
326 s_appState = APP_STATE_MENU;
327 s_menuRetState = APP_STATE_MENU;
328 s_subUI = FEUI_NONE;
329 s_relativeMode = false;
330 s_drawNoGameDataMsg = false;
331 char fontpath[TFE_MAX_PATH];
332
333 sprintf(fontpath, "%s", "Fonts/DroidSansMono.ttf");
334 TFE_Paths::mapSystemPath(fontpath);
335
336 s_uiScale = (f32)TFE_Ui::getUiScale() * 0.01f;
337
338 ImGuiIO& io = ImGui::GetIO();
339 s_menuFont = io.Fonts->AddFontFromFileTTF(fontpath, floorf(32*s_uiScale + 0.5f));
340 s_versionFont = io.Fonts->AddFontFromFileTTF(fontpath, floorf(16*s_uiScale + 0.5f));
341 s_titleFont = io.Fonts->AddFontFromFileTTF(fontpath, floorf(48*s_uiScale + 0.5f));
342 s_dialogFont = io.Fonts->AddFontFromFileTTF(fontpath, floorf(20*s_uiScale + 0.5f));
343
344 if (!loadGpuImage("UI_Images/TFE_TitleLogo.png", &s_logoGpuImage))
345 {
346 TFE_System::logWrite(LOG_ERROR, "SystemUI", "Cannot load TFE logo: \"UI_Images/TFE_TitleLogo.png\"");
347 }
348 if (!loadGpuImage("UI_Images/TFE_TitleText.png", &s_titleGpuImage))
349 {
350 TFE_System::logWrite(LOG_ERROR, "SystemUI", "Cannot load TFE Title: \"UI_Images/TFE_TitleText.png\"");
351 }
352 if (!loadGpuImage("UI_Images/Gradient.png", &s_gradientImage))
353 {
354 TFE_System::logWrite(LOG_ERROR, "SystemUI", "Cannot load TFE Title: \"UI_Images/Gradient.png\"");
355 }
356
357 bool buttonsLoaded = true;
358 buttonsLoaded &= loadGpuImage("UI_Images/TFE_StartNormal.png", &s_buttonNormal[0]);
359 buttonsLoaded &= loadGpuImage("UI_Images/TFE_StartSelected.png", &s_buttonSelected[0]);
360 buttonsLoaded &= loadGpuImage("UI_Images/TFE_LoadNormal.png", &s_buttonNormal[1]);
361 buttonsLoaded &= loadGpuImage("UI_Images/TFE_LoadSelected.png", &s_buttonSelected[1]);
362 buttonsLoaded &= loadGpuImage("UI_Images/TFE_ManualNormal.png", &s_buttonNormal[2]);
363 buttonsLoaded &= loadGpuImage("UI_Images/TFE_ManualSelected.png", &s_buttonSelected[2]);
364 buttonsLoaded &= loadGpuImage("UI_Images/TFE_CreditsNormal.png", &s_buttonNormal[3]);
365 buttonsLoaded &= loadGpuImage("UI_Images/TFE_CreditsSelected.png", &s_buttonSelected[3]);
366 buttonsLoaded &= loadGpuImage("UI_Images/TFE_SettingsNormal.png", &s_buttonNormal[4]);
367 buttonsLoaded &= loadGpuImage("UI_Images/TFE_SettingsSelected.png", &s_buttonSelected[4]);
368 buttonsLoaded &= loadGpuImage("UI_Images/TFE_ModsNormal.png", &s_buttonNormal[5]);
369 buttonsLoaded &= loadGpuImage("UI_Images/TFE_ModsSelected.png", &s_buttonSelected[5]);
370 buttonsLoaded &= loadGpuImage("UI_Images/TFE_EditorNormal.png", &s_buttonNormal[6]);
371 buttonsLoaded &= loadGpuImage("UI_Images/TFE_EditorSelected.png", &s_buttonSelected[6]);
372 buttonsLoaded &= loadGpuImage("UI_Images/TFE_ExitNormal.png", &s_buttonNormal[7]);
373 buttonsLoaded &= loadGpuImage("UI_Images/TFE_ExitSelected.png", &s_buttonSelected[7]);
374 if (!buttonsLoaded)
375 {
376 TFE_System::logWrite(LOG_ERROR, "SystemUI", "Cannot load title screen button images.");
377 }
378
379 // Setup menu item callbacks
380 s_menuItemselected[0] = menuItem_Start;

Callers 1

initConsoleFunction · 0.70

Calls 5

logWriteFunction · 0.85
getUiScaleFunction · 0.85
AddFontFromFileTTFMethod · 0.80
loadGpuImageFunction · 0.70
mapSystemPathFunction · 0.50

Tested by

no test coverage detected