From a304e9b4206f9c528968315024e704291bbb1eaa Mon Sep 17 00:00:00 2001 From: shenweip Date: Thu, 3 Oct 2013 20:44:16 +0800 Subject: [PATCH] Make a distinction between savedata and installdata. --- UI/GameInfoCache.cpp | 34 +++++++++++++++++++++++++++++++++- UI/GameInfoCache.h | 4 +++- UI/GameScreen.cpp | 5 +++++ UI/GameScreen.h | 1 + 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/UI/GameInfoCache.cpp b/UI/GameInfoCache.cpp index 0681ba4318..5a90236ae0 100644 --- a/UI/GameInfoCache.cpp +++ b/UI/GameInfoCache.cpp @@ -91,6 +91,7 @@ u64 GameInfo::GetSaveDataSizeInBytes() { std::vector saveDataDir = GetSaveDataDirectories(); u64 totalSize = 0; + u64 filesSizeInDir = 0; for (size_t j = 0; j < saveDataDir.size(); j++) { std::vector fileInfo; getFilesInDir(saveDataDir[j].c_str(), &fileInfo); @@ -99,8 +100,38 @@ u64 GameInfo::GetSaveDataSizeInBytes() { FileInfo finfo; getFileInfo(fileInfo[i].fullName.c_str(), &finfo); if (!finfo.isDirectory) - totalSize += finfo.size; + filesSizeInDir += finfo.size; } + if (filesSizeInDir < 0xA00000) { + //Generally the savedata size in a dir shouldn't be more than 10MB. + totalSize += filesSizeInDir; + } + filesSizeInDir = 0; + } + return totalSize; +} + +u64 GameInfo::GetInstallDataSizeInBytes() { + std::vector saveDataDir = GetSaveDataDirectories(); + + u64 totalSize = 0; + u64 filesSizeInDir = 0; + for (size_t j = 0; j < saveDataDir.size(); j++) { + std::vector fileInfo; + getFilesInDir(saveDataDir[j].c_str(), &fileInfo); + // Note: getFileInDir does not fill in fileSize properly. + for (size_t i = 0; i < fileInfo.size(); i++) { + FileInfo finfo; + getFileInfo(fileInfo[i].fullName.c_str(), &finfo); + if (!finfo.isDirectory) + filesSizeInDir += finfo.size; + } + if (filesSizeInDir >= 0xA00000) { + // Generally the savedata size in a dir shouldn't be more than 10MB. + // This is probably GameInstall data. + totalSize += filesSizeInDir; + } + filesSizeInDir = 0; } return totalSize; } @@ -311,6 +342,7 @@ public: if (info_->wantBG) { info_->gameSize = info_->GetGameSizeInBytes(); info_->saveDataSize = info_->GetSaveDataSizeInBytes(); + info_->installDataSize = info_->GetInstallDataSizeInBytes(); } } diff --git a/UI/GameInfoCache.h b/UI/GameInfoCache.h index b4f47b2039..0d4be8c5b3 100644 --- a/UI/GameInfoCache.h +++ b/UI/GameInfoCache.h @@ -35,13 +35,14 @@ class GameInfo { public: GameInfo() : fileType(FILETYPE_UNKNOWN), paramSFOLoaded(false), iconTexture(NULL), pic0Texture(NULL), pic1Texture(NULL), - wantBG(false), gameSize(0), saveDataSize(0) {} + wantBG(false), gameSize(0), saveDataSize(0), installDataSize(0) {} bool DeleteGame(); // Better be sure what you're doing when calling this. bool DeleteAllSaveData(); u64 GetGameSizeInBytes(); u64 GetSaveDataSizeInBytes(); + u64 GetInstallDataSizeInBytes(); void LoadParamSFO(); @@ -82,6 +83,7 @@ public: u64 gameSize; u64 saveDataSize; + u64 installDataSize; }; class GameInfoCache { diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index d36b5ed442..b2d256338a 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -56,6 +56,7 @@ void GameScreen::CreateViews() { tvTitle_ = leftColumn->Add(new TextView(info->title, ALIGN_LEFT, 1.0f, new AnchorLayoutParams(10, 200, NONE, NONE))); tvGameSize_ = leftColumn->Add(new TextView("...", ALIGN_LEFT, 1.0f, new AnchorLayoutParams(10, 250, NONE, NONE))); tvSaveDataSize_ = leftColumn->Add(new TextView("...", ALIGN_LEFT, 1.0f, new AnchorLayoutParams(10, 290, NONE, NONE))); + tvInstallDataSize_ = leftColumn->Add(new TextView("", ALIGN_LEFT, 1.0f, new AnchorLayoutParams(10, 330, NONE, NONE))); } ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins)); @@ -128,6 +129,10 @@ void GameScreen::update(InputState &input) { tvGameSize_->SetText(temp); sprintf(temp, "%s: %1.2f %s", ga->T("SaveData"), (float) (info->saveDataSize) / 1024.f / 1024.f, ga->T("MB")); tvSaveDataSize_->SetText(temp); + if (info->installDataSize > 0) { + sprintf(temp, "%s: %1.2f %s", ga->T("InstallData"), (float) (info->installDataSize) / 1024.f / 1024.f, ga->T("MB")); + tvInstallDataSize_->SetText(temp); + } } } diff --git a/UI/GameScreen.h b/UI/GameScreen.h index 8df9d70621..dbecc2712c 100644 --- a/UI/GameScreen.h +++ b/UI/GameScreen.h @@ -56,4 +56,5 @@ private: UI::TextView *tvTitle_; UI::TextView *tvGameSize_; UI::TextView *tvSaveDataSize_; + UI::TextView *tvInstallDataSize_; };