mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-18 04:45:39 +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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t lastTime {0};
|
unsigned int lastTime {0};
|
||||||
uint64_t accumulator {0};
|
unsigned int accumulator {0};
|
||||||
|
|
||||||
for (pugi::xml_node system {systemList.child("system")}; system;
|
for (pugi::xml_node system {systemList.child("system")}; system;
|
||||||
system = system.next_sibling("system")) {
|
system = system.next_sibling("system")) {
|
||||||
|
@ -552,17 +552,18 @@ bool SystemData::loadConfig()
|
||||||
path = system.child("path").text().get();
|
path = system.child("path").text().get();
|
||||||
|
|
||||||
if (splashScreen) {
|
if (splashScreen) {
|
||||||
const uint64_t curTime {SDL_GetTicks64()};
|
const unsigned int curTime {SDL_GetTicks()};
|
||||||
accumulator += curTime - lastTime;
|
accumulator += curTime - lastTime;
|
||||||
lastTime = curTime;
|
lastTime = curTime;
|
||||||
++parsedSystems;
|
++parsedSystems;
|
||||||
// This prevents Renderer::swapBuffers() from being called excessively which
|
// This prevents Renderer::swapBuffers() from being called excessively which
|
||||||
// could lead to significantly longer application startup times.
|
// could lead to significantly longer application startup times.
|
||||||
if (accumulator > 15) {
|
if (accumulator > 40) {
|
||||||
accumulator = 0;
|
accumulator = 0;
|
||||||
const float progress {glm::mix(0.0f, 0.5f, parsedSystems / systemCount)};
|
const float progress {glm::mix(0.0f, 0.5f, parsedSystems / systemCount)};
|
||||||
Window::getInstance()->renderSplashScreen(Window::SplashScreenState::SCANNING,
|
Window::getInstance()->renderSplashScreen(Window::SplashScreenState::SCANNING,
|
||||||
progress);
|
progress);
|
||||||
|
lastTime += SDL_GetTicks() - curTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -768,8 +769,12 @@ bool SystemData::loadConfig()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (splashScreen)
|
if (splashScreen) {
|
||||||
Window::getInstance()->renderSplashScreen(Window::SplashScreenState::SCANNING, 0.5f);
|
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"
|
LOG(LogInfo) << "Parsed configuration for " << systemCount << " system"
|
||||||
<< (systemCount == 1 ? ", loaded " : "s, loaded ") << sSystemVector.size()
|
<< (systemCount == 1 ? ", loaded " : "s, loaded ") << sSystemVector.size()
|
||||||
|
|
|
@ -681,7 +681,9 @@ int main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
window->pushGui(ViewController::getInstance());
|
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);
|
InputManager::getInstance().parseEvent(event);
|
||||||
if (event.type == SDL_QUIT)
|
if (event.type == SDL_QUIT)
|
||||||
|
|
|
@ -1108,23 +1108,41 @@ void ViewController::preload()
|
||||||
if (!SystemData::sSystemVector.empty())
|
if (!SystemData::sSystemVector.empty())
|
||||||
getSystemListView();
|
getSystemListView();
|
||||||
|
|
||||||
|
const bool splashScreen {Settings::getInstance()->getBool("SplashScreen")};
|
||||||
float loadedSystems {0.0f};
|
float loadedSystems {0.0f};
|
||||||
|
unsigned int lastTime {0};
|
||||||
|
unsigned int accumulator {0};
|
||||||
|
|
||||||
for (auto it = SystemData::sSystemVector.cbegin(); // Line break.
|
for (auto it = SystemData::sSystemVector.cbegin(); // Line break.
|
||||||
it != SystemData::sSystemVector.cend(); ++it) {
|
it != SystemData::sSystemVector.cend(); ++it) {
|
||||||
const std::string entryType {(*it)->isCustomCollection() ? "custom collection" : "system"};
|
const std::string entryType {(*it)->isCustomCollection() ? "custom collection" : "system"};
|
||||||
LOG(LogDebug) << "ViewController::preload(): Populating gamelist for " << entryType << " \""
|
LOG(LogDebug) << "ViewController::preload(): Populating gamelist for " << entryType << " \""
|
||||||
<< (*it)->getName() << "\"";
|
<< (*it)->getName() << "\"";
|
||||||
if (Settings::getInstance()->getBool("SplashScreen")) {
|
if (splashScreen) {
|
||||||
|
const unsigned int curTime {SDL_GetTicks()};
|
||||||
|
accumulator += curTime - lastTime;
|
||||||
|
lastTime = curTime;
|
||||||
++loadedSystems;
|
++loadedSystems;
|
||||||
const float progress {
|
// This prevents Renderer::swapBuffers() from being called excessively which
|
||||||
glm::mix(0.5f, 1.0f, loadedSystems / static_cast<float>(systemCount))};
|
// could lead to significantly longer application startup times.
|
||||||
mWindow->renderSplashScreen(Window::SplashScreenState::POPULATING, progress);
|
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();
|
(*it)->getIndex()->resetFilters();
|
||||||
getGamelistView(*it)->preloadGamelist();
|
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)
|
if (SystemData::sSystemVector.size() > 0)
|
||||||
ThemeData::setThemeTransitions();
|
ThemeData::setThemeTransitions();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue