| 16 | static bool s_guiFrameActive; |
| 17 | |
| 18 | bool init(void* window, void* context, s32 uiScale) |
| 19 | { |
| 20 | s_uiScale = uiScale; |
| 21 | |
| 22 | // Setup Dear ImGui context |
| 23 | IMGUI_CHECKVERSION(); |
| 24 | ImGui::CreateContext(); |
| 25 | ImGuiIO& io = ImGui::GetIO(); |
| 26 | //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls |
| 27 | //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls |
| 28 | |
| 29 | // Setup Dear ImGui style |
| 30 | ImGui::StyleColorsDark(); |
| 31 | |
| 32 | // Setup Platform/Renderer bindings |
| 33 | ImGui_ImplSDL2_InitForOpenGL((SDL_Window *)window, context); |
| 34 | ImGui_ImplOpenGL3_Init(glsl_version); |
| 35 | |
| 36 | // Set the default font (13 px) |
| 37 | // TODO: Allow scaled UI, so loading a different font for larger scales. |
| 38 | if (s_uiScale <= 100) |
| 39 | { |
| 40 | io.Fonts->AddFontDefault(); |
| 41 | } |
| 42 | else |
| 43 | { |
| 44 | char fp[TFE_MAX_PATH]; |
| 45 | sprintf(fp, "Fonts/DroidSansMono.ttf"); |
| 46 | TFE_Paths::mapSystemPath(fp); |
| 47 | io.Fonts->AddFontFromFileTTF(fp, f32(13 * s_uiScale / 100)); |
| 48 | } |
| 49 | |
| 50 | TFE_Markdown::init(f32(16 * s_uiScale / 100)); |
| 51 | |
| 52 | // Initialize file dialogs. |
| 53 | if (!pfd::settings::available()) |
| 54 | { |
| 55 | // TODO: Log error |
| 56 | return false; |
| 57 | } |
| 58 | |
| 59 | return true; |
| 60 | } |
| 61 | |
| 62 | void shutdown() |
| 63 | { |
no test coverage detected