MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / uiLoop

Function uiLoop

source/ui/mainui.cpp:367–462  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

365}
366
367bool uiLoop() {
368 // Poll and handle events (inputs, window resize, etc.)
369 // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
370 // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
371 // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
372 // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
373 SDL_Event event = {};
374 bool done = false;
375 while (SDL_WaitEventTimeout(&event, GlobalSettings::getFrameDelayMillies()))
376 {
377 GlobalSettings::updateLastFrameDelayChange();
378 ImGui_ImplSDL2_ProcessEvent(&event);
379 if (event.type == SDL_QUIT) {
380 done = true;
381 if (currentView) {
382 // :TODO: should we stop the quit action if this save fails?
383 currentView->saveChanges();
384 }
385 } else if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window)) {
386 done = true;
387 } else if (event.type >= SDL_USEREVENT) {
388 SDL_PushEvent(&event); // if we are currently launching then there is another spot where sdl polling is happening in threadedMainloop.cpp, if we drop this custom msg then another thread will be blocked forever
389 break;
390 } else if (event.type == SDL_DROPFILE) {
391 char* droppedFileOrDir = event.drop.file;
392 static BString staticFilePath;
393
394 staticFilePath = BString::copy(droppedFileOrDir);
395 runOnMainUI([]() {
396 gotoView(VIEW_INSTALL, B("Install"), staticFilePath);
397 return false;
398 });
399 SDL_free(droppedFileOrDir); // Free dropped_filedir memory
400 break;
401 }
402 }
403
404 // Start the Dear ImGui frame
405#ifdef BOXEDWINE_IMGUI_DX9
406 if (StartUpArgs::uiType == UI_TYPE_DX9) {
407 ImGui_ImplDX9_NewFrame();
408 }
409#elif defined(BOXEDWINE_OPENGL_SDL)
410 if (StartUpArgs::uiType == UI_TYPE_OPENGL) {
411#ifdef BOXEDWINE_OPENGL_IMGUI_V2
412 ImGui_ImplOpenGL2_NewFrame();
413#else
414 ImGui_ImplOpenGL3_NewFrame();
415#endif
416 }
417#endif
418 ImGui_ImplSDL2_NewFrame(window);
419 ImGui::NewFrame();
420
421 uiDraw();
422
423 // Rendering
424#ifdef BOXEDWINE_IMGUI_DX9

Callers 4

doMainLoopFunction · 0.85
doMainLoopFunction · 0.85
uiContinueFunction · 0.85
startAppMethod · 0.85

Calls 15

SDL_WaitEventTimeoutFunction · 0.85
SDL_GetWindowIDFunction · 0.85
SDL_PushEventFunction · 0.85
runOnMainUIFunction · 0.85
gotoViewFunction · 0.85
BFunction · 0.85
SDL_freeFunction · 0.85
ImGui_ImplDX9_NewFrameFunction · 0.85
ImGui_ImplSDL2_NewFrameFunction · 0.85

Tested by

no test coverage detected