diff --git a/es-app/src/SystemData.cpp b/es-app/src/SystemData.cpp index 6c0cfd334..69fb4184a 100644 --- a/es-app/src/SystemData.cpp +++ b/es-app/src/SystemData.cpp @@ -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() diff --git a/es-app/src/main.cpp b/es-app/src/main.cpp index 79d627fe0..3ff2ababc 100644 --- a/es-app/src/main.cpp +++ b/es-app/src/main.cpp @@ -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) diff --git a/es-app/src/views/ViewController.cpp b/es-app/src/views/ViewController.cpp index a55392a2a..857a24e8d 100644 --- a/es-app/src/views/ViewController.cpp +++ b/es-app/src/views/ViewController.cpp @@ -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(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(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();