mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-25 12:55:00 +00:00
GUI: Speed up GUI loading by caching game sizes (#2130)
* Add show game size toggle * Fix (#7) * Fix I removed the gameSizeCheckBox from the 'Emulator' group and put it in 'GUI settings' hLayoutTrophy which contains the Trophy information was inside the GUIMusicLayout, so I fixed that too. * TR * Use cached sizes if the feature is enabled --------- Co-authored-by: DanielSvoboda <daniel.svoboda@hotmail.com>
This commit is contained in:
parent
c6ab149c56
commit
4f2f9494b0
34 changed files with 239 additions and 68 deletions
|
@ -62,11 +62,46 @@ public:
|
|||
QDir dir(dirPath);
|
||||
QDirIterator it(dir.absolutePath(), QDirIterator::Subdirectories);
|
||||
qint64 total = 0;
|
||||
|
||||
if (!Config::GetLoadGameSizeEnabled()) {
|
||||
game.size = FormatSize(0).toStdString();
|
||||
return;
|
||||
}
|
||||
|
||||
// Cache path
|
||||
QFile size_cache_file(Common::FS::GetUserPath(Common::FS::PathType::MetaDataDir) /
|
||||
game.serial / "size_cache.txt");
|
||||
QFileInfo cacheInfo(size_cache_file);
|
||||
QFileInfo dirInfo(dirPath);
|
||||
|
||||
// Check if cache file exists and is valid
|
||||
if (size_cache_file.exists() && cacheInfo.lastModified() >= dirInfo.lastModified()) {
|
||||
if (size_cache_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&size_cache_file);
|
||||
QString cachedSize = in.readLine();
|
||||
size_cache_file.close();
|
||||
|
||||
if (!cachedSize.isEmpty()) {
|
||||
game.size = cachedSize.toStdString();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Cache is invalid or does not exist; calculate size
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
total += it.fileInfo().size();
|
||||
}
|
||||
|
||||
game.size = FormatSize(total).toStdString();
|
||||
|
||||
// Save new cache
|
||||
if (size_cache_file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
QTextStream out(&size_cache_file);
|
||||
out << QString::fromStdString(game.size) << "\n";
|
||||
size_cache_file.close();
|
||||
}
|
||||
}
|
||||
|
||||
static QString GetRegion(char region) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue