The systems are now counted upfront for accurate progress bar positioning if there's a custom es_systems.xml file in use.

This commit is contained in:
Leon Styhre 2023-01-23 23:38:25 +01:00
parent 90851befc5
commit fc282f559c
2 changed files with 32 additions and 12 deletions

View file

@ -1300,6 +1300,8 @@ void CollectionSystemsManager::removeCollectionsFromDisplayedSystems()
// Remove all custom collections in bundle.
// This should not delete the objects from memory!
if (mCustomCollectionsBundle == nullptr)
return;
FileData* customRoot {mCustomCollectionsBundle->getRootFolder()};
std::vector<FileData*> mChildren {customRoot->getChildren()};
for (auto it = mChildren.cbegin(); it != mChildren.cend(); ++it) {

View file

@ -460,9 +460,34 @@ bool SystemData::loadConfig()
const std::vector<std::string>& configPaths {getConfigPath(true)};
const std::string& rompath {FileData::getROMDirectory()};
bool onlyProcessCustomFile {false};
const bool splashScreen {Settings::getInstance()->getBool("SplashScreen")};
float systemCount {0.0f};
float loadedSystems {0.0f};
// This is only done to get the total system count, for calculating the progress bar position.
for (auto& configPath : configPaths) {
pugi::xml_document doc;
#if defined(_WIN64)
const pugi::xml_parse_result& res {
doc.load_file(Utils::String::stringToWideString(configPath).c_str())};
#else
const pugi::xml_parse_result& res {doc.load_file(configPath.c_str())};
#endif
if (!res)
break;
const pugi::xml_node& systemList {doc.child("systemList")};
if (!systemList)
continue;
for (pugi::xml_node system {systemList.child("system")}; system;
system = system.next_sibling("system")) {
++systemCount;
}
if (doc.child("loadExclusive"))
break;
}
for (auto& configPath : configPaths) {
// If the loadExclusive tag is present in the custom es_systems.xml file, then skip
// processing of the bundled configuration file.
@ -510,17 +535,9 @@ bool SystemData::loadConfig()
return true;
}
const bool splashScreen {Settings::getInstance()->getBool("SplashScreen")};
float systemCount {0.0f};
float loadedSystems {0.0f};
uint64_t lastTime {0};
uint64_t accumulator {0};
for (pugi::xml_node system {systemList.child("system")}; system;
system = system.next_sibling("system")) {
++systemCount;
}
for (pugi::xml_node system {systemList.child("system")}; system;
system = system.next_sibling("system")) {
std::string name;
@ -749,10 +766,11 @@ bool SystemData::loadConfig()
sSystemVector.emplace_back(newSys);
}
}
if (splashScreen)
Window::getInstance()->renderSplashScreen(Window::SplashScreenState::SCANNING, 0.5f);
}
if (splashScreen)
Window::getInstance()->renderSplashScreen(Window::SplashScreenState::SCANNING, 0.5f);
// Sort systems by sortName, which will normally be the same as the full name.
std::sort(std::begin(sSystemVector), std::end(sSystemVector), [](SystemData* a, SystemData* b) {
return Utils::String::toUpper(a->getSortName()) < Utils::String::toUpper(b->getSortName());
@ -818,7 +836,7 @@ std::vector<std::string> SystemData::getConfigPath(bool legacyWarning)
}
}
std::string path = customSystemsDirectory + "/es_systems.xml";
std::string path {customSystemsDirectory + "/es_systems.xml"};
if (Utils::FileSystem::exists(path)) {
LOG(LogInfo) << "Found custom systems configuration file";