From 9863e31364036c05811562b0bbebdec59aa82b20 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Thu, 26 Jul 2018 20:12:30 -0300 Subject: [PATCH] Update the loading window less --- src/Profile.cpp | 3 ++- src/ScoreManager.cpp | 3 ++- src/SongCacheIndex.cpp | 13 +++++++++---- src/SongManager.cpp | 17 +++++++---------- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/Profile.cpp b/src/Profile.cpp index 0a6ede3188..b3a66632f0 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -870,9 +870,10 @@ ProfileLoadResult Profile::LoadAllFromDir( const RString &sDir, bool bRequireSig ld->SetText("Migrating replay data to new folder..."); } int replayindex = 0; + int onePercent = std::max(replays.size(), 1u); for (auto r : replays) { - if (ld && ld_timer.Ago() > ld_update) { + if (ld && replayindex%onePercent==0 && ld_timer.Ago() > ld_update) { ld_timer.Touch(); ld->SetProgress(replayindex); ++replayindex; diff --git a/src/ScoreManager.cpp b/src/ScoreManager.cpp index 8196cbfe7a..63b417c5f6 100644 --- a/src/ScoreManager.cpp +++ b/src/ScoreManager.cpp @@ -283,9 +283,10 @@ void ScoreManager::RecalculateSSRs(LoadingWindow *ld, const string& profileID) { ld->SetText("\nUpdating Ratings"); } + int onePercent = std::max(scores.size()/100, 1u); int scoreindex = 0; for(size_t i = 0; i < scores.size(); ++i) { - if (ld && ld_timer.Ago() > ld_update) { + if (ld && scoreindex%onePercent==0 && ld_timer.Ago() > ld_update) { ld_timer.Touch(); ld->SetProgress(i); } diff --git a/src/SongCacheIndex.cpp b/src/SongCacheIndex.cpp index 65f1ed6116..4ff3ddc9bc 100644 --- a/src/SongCacheIndex.cpp +++ b/src/SongCacheIndex.cpp @@ -12,6 +12,7 @@ #include "CommonMetrics.h" #include "Steps.h" #include "NotesLoaderSSC.h" +#include #include "NotesWriterSSC.h" #include @@ -607,10 +608,12 @@ void SongCacheIndex::LoadHyperCache(LoadingWindow * ld, map& hyp int count = db->execAndGet("SELECT COUNT(*) FROM songs"); if (ld && count > 0) { ld->SetIndeterminate(false); + ld->SetProgress(0); ld->SetTotalWork(count); } RString lastDir; int progress = 0; + int onePercent = std::max(count / 100, 1); try { SQLite::Statement query(*db, "SELECT * FROM songs"); @@ -620,11 +623,11 @@ void SongCacheIndex::LoadHyperCache(LoadingWindow * ld, map& hyp hyperCache[songID.first] = s; lastDir = songID.first; // this is a song directory. Load a new song. - if (ld) + progress++; + if (ld && progress%onePercent==0) { ld->SetProgress(progress); ld->SetText(("Loading Cache\n (" + lastDir + ")").c_str()); - progress++; } } @@ -642,10 +645,12 @@ void SongCacheIndex::LoadCache(LoadingWindow * ld, mapexecAndGet("SELECT COUNT(*) FROM songs"); if (ld && count > 0) { ld->SetIndeterminate(false); + ld->SetProgress(0); ld->SetTotalWork(count); } RString lastDir; int progress = 0; + int onePercent = std::max(count / 100, 1); try { SQLite::Statement query(*db, "SELECT * FROM songs"); @@ -655,11 +660,11 @@ void SongCacheIndex::LoadCache(LoadingWindow * ld, mapSetProgress(progress); ld->SetText(("Loading Cache\n(" + lastDir + ")").c_str()); - progress++; } } diff --git a/src/SongManager.cpp b/src/SongManager.cpp index 2b2625aaca..1025e0009e 100644 --- a/src/SongManager.cpp +++ b/src/SongManager.cpp @@ -10,6 +10,7 @@ #include "LocalizedString.h" #include "MsdFile.h" #include "NoteSkinManager.h" +#include #include "NotesLoaderDWI.h" #include "NotesLoaderSM.h" #include "NotesLoaderSSC.h" @@ -211,10 +212,11 @@ void SongManager::InitSongsFromDisk( LoadingWindow *ld ) ld->SetTotalWork( cache.size() ); ld->SetText("Loading songs from cache"); } + int onePercent = std::max(cache.size() / 100, 1u); int cacheIndex = 0; for (auto& pair : cache) { cacheIndex++; - if(ld && cacheIndex%4 ==0) + if(ld && cacheIndex%onePercent ==0) ld->SetProgress(cacheIndex); auto& pNewSong = pair.second; const RString& dir = pNewSong->GetSongDir(); @@ -288,11 +290,6 @@ void Playlist::AddChart(const string & ck) { Chart ch; ch.FromKey(ck); ch.rate = rate; - - if (!chartlist.empty()) - if (chartlist[0].stepsptr->m_StepsType != ch.stepsptr->m_StepsType) - return; - chartlist.emplace_back(ch); } @@ -593,6 +590,7 @@ void SongManager::LoadStepManiaSongDir( RString sDir, LoadingWindow *ld ) ld->SetText("Sanity checking groups"); } int groupsChecked = 0; + int onePercent = std::max(arrayGroupDirs.size()/ 100, 1u); FOREACH_CONST(RString, arrayGroupDirs, s) { RString sGroupDirName = *s; SanityCheckGroupDir(sDir + sGroupDirName); @@ -603,7 +601,7 @@ void SongManager::LoadStepManiaSongDir( RString sDir, LoadingWindow *ld ) SortRStringArray(arraySongDirs); arrayGroupSongDirs.emplace_back(arraySongDirs); songCount += arraySongDirs.size(); - if(ld != nullptr) + if(ld != nullptr && groupsChecked%onePercent ==0) ld->SetProgress(++groupsChecked); } @@ -613,11 +611,11 @@ void SongManager::LoadStepManiaSongDir( RString sDir, LoadingWindow *ld ) ld->SetTotalWork(arrayGroupDirs.size()); } int groupIndex = 0; - int songIndex = 0; + onePercent = std::max(arrayGroupDirs.size() / 100, 1u); FOREACH_CONST(RString, arrayGroupDirs, s) { RString sGroupDirName = *s; vector &arraySongDirs = arrayGroupSongDirs[groupIndex++]; - if (ld) { + if (ld && groupIndex&onePercent==0) { ld->SetProgress(groupIndex); ld->SetText("Loading Songs From Disk\n" + sGroupDirName); } @@ -625,7 +623,6 @@ void SongManager::LoadStepManiaSongDir( RString sDir, LoadingWindow *ld ) SongPointerVector& index_entry = m_mapSongGroupIndex[sGroupDirName]; RString group_base_name = Basename(sGroupDirName); for (size_t j = 0; j < arraySongDirs.size(); ++j) { - songIndex++; RString sSongDirName = arraySongDirs[j]; RString hur = sSongDirName + "/"; hur.MakeLower();