Split device polling out of renderLoading

This commit is contained in:
Benau 2022-04-01 09:59:46 +08:00
parent 1c99ba2562
commit 601511e7f4
4 changed files with 16 additions and 2 deletions

View File

@ -1531,6 +1531,14 @@ namespace GUIEngine
x = ICON_MARGIN;
}
}
#endif
} // renderLoading
// -----------------------------------------------------------------------
void flushRenderLoading(bool launching)
{
#ifndef SERVER_ONLY
// This will avoid no response in windows, also allow showing loading
// icon in apple device, because apple device only update render
// buffer if you poll the mainloop
@ -1542,7 +1550,7 @@ namespace GUIEngine
}
// If launch is finished, pause & display the story mode timers
if ( !launching)
if (!launching)
{
// For speedruns only, display the timer on loading screens
if (UserConfigParams::m_speedrun_mode)
@ -1557,7 +1565,7 @@ namespace GUIEngine
irr_driver->handleWindowResize();
}
#endif
} // renderLoading
} // flushRenderLoading
// -----------------------------------------------------------------------
@ -1571,6 +1579,7 @@ namespace GUIEngine
->beginScene(true, true, video::SColor(255,100,101,140));
renderLoading(false, true, false);
g_device->getVideoDriver()->endScene();
GUIEngine::flushRenderLoading(true/*launching*/);
}
else
{

View File

@ -248,6 +248,9 @@ namespace GUIEngine
/** \brief renders a "loading" screen */
void renderLoading(bool clearIcons = true, bool launching = false, bool update_tips = true);
/** \brief poll events during rendering to prevent unresponsive window */
void flushRenderLoading(bool launching);
/** \brief to spice up a bit the loading icon : add icons to the loading screen */
void addLoadingIcon(irr::video::ITexture* icon);

View File

@ -1874,6 +1874,7 @@ void initRest()
// Input manager set first so it recieves SDL joystick event
GUIEngine::init(device, driver, StateManager::get());
GUIEngine::renderLoading(true, true, false);
GUIEngine::flushRenderLoading(true/*launching*/);
#ifdef ANDROID
JNIEnv* env = (JNIEnv*)SDL_AndroidGetJNIEnv();

View File

@ -556,6 +556,7 @@ void RaceManager::startNextRace()
GUIEngine::clearLoadingTips();
GUIEngine::renderLoading(true/*clearIcons*/, false/*launching*/, false/*update_tips*/);
device->getVideoDriver()->endScene();
GUIEngine::flushRenderLoading(false/*launching*/);
}
m_num_finished_karts = 0;