mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
Multiple improvements to the progress bar to reduce startup times and increase consistency.
Also changed from SDL_GetTicks64() to SDL_GetTicks() in SystemData as the 64-bit function doesn't work with older SDL releases.
This commit is contained in:
parent
2546756fa1
commit
e9b1718fca
|
@ -535,8 +535,8 @@ bool SystemData::loadConfig()
|
|||
return true;
|
||||
}
|
||||
|
||||
uint64_t lastTime {0};
|
||||
uint64_t accumulator {0};
|
||||
unsigned int lastTime {0};
|
||||
unsigned int accumulator {0};
|
||||
|
||||
for (pugi::xml_node system {systemList.child("system")}; system;
|
||||
system = system.next_sibling("system")) {
|
||||
|
@ -552,17 +552,18 @@ bool SystemData::loadConfig()
|
|||
path = system.child("path").text().get();
|
||||
|
||||
if (splashScreen) {
|
||||
const uint64_t curTime {SDL_GetTicks64()};
|
||||
const unsigned int curTime {SDL_GetTicks()};
|
||||
accumulator += curTime - lastTime;
|
||||
lastTime = curTime;
|
||||
++parsedSystems;
|
||||
// This prevents Renderer::swapBuffers() from being called excessively which
|
||||
// could lead to significantly longer application startup times.
|
||||
if (accumulator > 15) {
|
||||
if (accumulator > 40) {
|
||||
accumulator = 0;
|
||||
const float progress {glm::mix(0.0f, 0.5f, parsedSystems / systemCount)};
|
||||
Window::getInstance()->renderSplashScreen(Window::SplashScreenState::SCANNING,
|
||||
progress);
|
||||
lastTime += SDL_GetTicks() - curTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -768,8 +769,12 @@ bool SystemData::loadConfig()
|
|||
}
|
||||
}
|
||||
|
||||
if (splashScreen)
|
||||
Window::getInstance()->renderSplashScreen(Window::SplashScreenState::SCANNING, 0.5f);
|
||||
if (splashScreen) {
|
||||
if (sSystemVector.size() > 0)
|
||||
Window::getInstance()->renderSplashScreen(Window::SplashScreenState::SCANNING, 0.5f);
|
||||
else
|
||||
Window::getInstance()->renderSplashScreen(Window::SplashScreenState::SCANNING, 1.0f);
|
||||
}
|
||||
|
||||
LOG(LogInfo) << "Parsed configuration for " << systemCount << " system"
|
||||
<< (systemCount == 1 ? ", loaded " : "s, loaded ") << sSystemVector.size()
|
||||
|
|
|
@ -681,7 +681,9 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
window->pushGui(ViewController::getInstance());
|
||||
window->renderSplashScreen(Window::SplashScreenState::SCANNING, 0.0f);
|
||||
|
||||
if (Settings::getInstance()->getBool("SplashScreen"))
|
||||
window->renderSplashScreen(Window::SplashScreenState::SCANNING, 0.0f);
|
||||
|
||||
InputManager::getInstance().parseEvent(event);
|
||||
if (event.type == SDL_QUIT)
|
||||
|
|
|
@ -1108,23 +1108,41 @@ void ViewController::preload()
|
|||
if (!SystemData::sSystemVector.empty())
|
||||
getSystemListView();
|
||||
|
||||
const bool splashScreen {Settings::getInstance()->getBool("SplashScreen")};
|
||||
float loadedSystems {0.0f};
|
||||
unsigned int lastTime {0};
|
||||
unsigned int accumulator {0};
|
||||
|
||||
for (auto it = SystemData::sSystemVector.cbegin(); // Line break.
|
||||
it != SystemData::sSystemVector.cend(); ++it) {
|
||||
const std::string entryType {(*it)->isCustomCollection() ? "custom collection" : "system"};
|
||||
LOG(LogDebug) << "ViewController::preload(): Populating gamelist for " << entryType << " \""
|
||||
<< (*it)->getName() << "\"";
|
||||
if (Settings::getInstance()->getBool("SplashScreen")) {
|
||||
if (splashScreen) {
|
||||
const unsigned int curTime {SDL_GetTicks()};
|
||||
accumulator += curTime - lastTime;
|
||||
lastTime = curTime;
|
||||
++loadedSystems;
|
||||
const float progress {
|
||||
glm::mix(0.5f, 1.0f, loadedSystems / static_cast<float>(systemCount))};
|
||||
mWindow->renderSplashScreen(Window::SplashScreenState::POPULATING, progress);
|
||||
// This prevents Renderer::swapBuffers() from being called excessively which
|
||||
// could lead to significantly longer application startup times.
|
||||
if (accumulator > 20) {
|
||||
accumulator = 0;
|
||||
const float progress {
|
||||
glm::mix(0.5f, 1.0f, loadedSystems / static_cast<float>(systemCount))};
|
||||
mWindow->renderSplashScreen(Window::SplashScreenState::POPULATING, progress);
|
||||
lastTime += SDL_GetTicks() - curTime;
|
||||
}
|
||||
}
|
||||
(*it)->getIndex()->resetFilters();
|
||||
getGamelistView(*it)->preloadGamelist();
|
||||
}
|
||||
|
||||
if (splashScreen && SystemData::sSystemVector.size() > 0)
|
||||
Window::getInstance()->renderSplashScreen(Window::SplashScreenState::POPULATING, 1.0f);
|
||||
|
||||
// Short delay so that the full progress bar is always visible before proceeding.
|
||||
SDL_Delay(100);
|
||||
|
||||
if (SystemData::sSystemVector.size() > 0)
|
||||
ThemeData::setThemeTransitions();
|
||||
|
||||
|
|
Loading…
Reference in a new issue