Fix loading bar going out of bounds ()

The actual reason lies in the loader implementation, which for some reason can sometimes count up the `m_refreshedModCount` twice for some mods which are disabled.

This small change checks the actual loaded mod count instead of relying on an incorrect `LoaderImpl` member and fixes issue .
This commit is contained in:
Oleksandr Nemesh 2024-04-12 22:45:08 +03:00 committed by GitHub
parent 6516adb557
commit e50c3abff4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -146,13 +146,27 @@ struct CustomLoadingLayer : Modify<CustomLoadingLayer, LoadingLayer> {
LoaderImpl::get()->updateResources(true);
this->continueLoadAssets();
}
int getLoadedMods() {
auto allMods = Loader::get()->getAllMods();
return std::count_if(allMods.begin(), allMods.end(), [&](auto& item) {
return item->isEnabled();
});
}
int getEnabledMods() {
auto allMods = Loader::get()->getAllMods();
return std::count_if(allMods.begin(), allMods.end(), [&](auto& item) {
return item->shouldLoad();
});
}
int getCurrentStep() {
return m_fields->m_geodeLoadStep + m_loadStep + 1 + LoaderImpl::get()->m_refreshedModCount;
return m_fields->m_geodeLoadStep + m_loadStep + getLoadedMods();
}
int getTotalStep() {
return 18 + m_fields->m_totalMods;
return 3 + 14 + getEnabledMods();
}
void updateLoadingBar() {