Only show button to delete savedata if there is savedata to delete

This commit is contained in:
Henrik Rydgard 2014-07-21 20:59:03 +02:00
parent 8b38df9205
commit a3563c920d
2 changed files with 12 additions and 5 deletions

View File

@ -94,7 +94,7 @@ std::vector<std::string> GameInfo::GetSaveDataDirectories() {
getFilesInDir(memc.c_str(), &dirs);
std::vector<std::string> directories;
if (id.empty()) {
if (id.size() < 5) {
return directories;
}
for (size_t i = 0; i < dirs.size(); i++) {

View File

@ -83,7 +83,10 @@ void GameScreen::CreateViews() {
Choice *play = new Choice(ga->T("Play"));
rightColumnItems->Add(play)->OnClick.Handle(this, &GameScreen::OnPlay);
rightColumnItems->Add(new Choice(ga->T("Game Settings")))->OnClick.Handle(this, &GameScreen::OnGameSettings);
rightColumnItems->Add(new Choice(ga->T("Delete Save Data")))->OnClick.Handle(this, &GameScreen::OnDeleteSaveData);
std::vector<std::string> saveDirs = info->GetSaveDataDirectories();
if (saveDirs.size()) {
rightColumnItems->Add(new Choice(ga->T("Delete Save Data")))->OnClick.Handle(this, &GameScreen::OnDeleteSaveData);
}
rightColumnItems->Add(new Choice(ga->T("Delete Game")))->OnClick.Handle(this, &GameScreen::OnDeleteGame);
if (host->CanCreateShortcut()) {
rightColumnItems->Add(new Choice(ga->T("Create Shortcut")))->OnClick.Handle(this, &GameScreen::OnCreateShortcut);
@ -176,9 +179,13 @@ UI::EventReturn GameScreen::OnDeleteSaveData(UI::EventParams &e) {
I18NCategory *ga = GetI18NCategory("Game");
GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE);
if (info) {
screenManager()->push(
new PromptScreen(d->T("DeleteConfirmAll", "Do you really want to delete all\nyour save data for this game?"), ga->T("ConfirmDelete"), d->T("Cancel"),
std::bind(&GameScreen::CallbackDeleteSaveData, this, placeholder::_1)));
// Check that there's any savedata to delete
std::vector<std::string> saveDirs = info->GetSaveDataDirectories();
if (saveDirs.size()) {
screenManager()->push(
new PromptScreen(d->T("DeleteConfirmAll", "Do you really want to delete all\nyour save data for this game?"), ga->T("ConfirmDelete"), d->T("Cancel"),
std::bind(&GameScreen::CallbackDeleteSaveData, this, placeholder::_1)));
}
}
RecreateViews();