Remove a few uses of std::bind

This commit is contained in:
Henrik Rydgård committed 2025-05-28 11:05:35 +02:00
1 parent 2bc181104b
commit f14a38db52
3 files changed
+24 -27

No files matched your search

+19 -20
View File
@@ -538,24 +538,23 @@ UI::EventReturn GameScreen::OnDeleteSaveData(UI::EventParams &e) {
if (info->saveDataSize) {
const bool trashAvailable = System_GetPropertyBool(SYSPROP_HAS_TRASH_BIN);
auto di = GetI18NCategory(I18NCat::DIALOG);
Path gamePath = gamePath_;
screenManager()->push(
new PromptScreen(gamePath_, di->T("DeleteConfirmAll", "Do you really want to delete all\nyour save data for this game?"), trashAvailable ? di->T("Move to trash") : di->T("Delete"), di->T("Cancel"),
std::bind(&GameScreen::CallbackDeleteSaveData, this, std::placeholders::_1)));
[gamePath](bool yes) {
if (yes) {
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(NULL, gamePath, GameInfoFlags::PARAM_SFO);
info->DeleteAllSaveData();
info->saveDataSize = 0;
info->installDataSize = 0;
}
}));
}
}
RecreateViews();
return UI::EVENT_DONE;
}
void GameScreen::CallbackDeleteSaveData(bool yes) {
if (yes) {
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(NULL, gamePath_, GameInfoFlags::PARAM_SFO);
info->DeleteAllSaveData();
info->saveDataSize = 0;
info->installDataSize = 0;
}
}
UI::EventReturn GameScreen::OnDeleteGame(UI::EventParams &e) {
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(NULL, gamePath_, GameInfoFlags::PARAM_SFO);
if (info->Ready(GameInfoFlags::PARAM_SFO)) {
@@ -564,22 +563,22 @@ UI::EventReturn GameScreen::OnDeleteGame(UI::EventParams &e) {
prompt = di->T("DeleteConfirmGame", "Do you really want to delete this game\nfrom your device? You can't undo this.");
prompt += "\n\n" + gamePath_.ToVisualString(g_Config.memStickDirectory.c_str());
const bool trashAvailable = System_GetPropertyBool(SYSPROP_HAS_TRASH_BIN);
Path gamePath = gamePath_;
ScreenManager *sm = screenManager();
screenManager()->push(
new PromptScreen(gamePath_, prompt, trashAvailable ? di->T("Move to trash") : di->T("Delete"), di->T("Cancel"),
std::bind(&GameScreen::CallbackDeleteGame, this, std::placeholders::_1)));
[sm, gamePath](bool yes) {
if (yes) {
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(NULL, gamePath, GameInfoFlags::PARAM_SFO);
info->Delete();
g_gameInfoCache->Clear();
sm->switchScreen(new MainScreen());
}
}));
}
return UI::EVENT_DONE;
}
void GameScreen::CallbackDeleteGame(bool yes) {
if (yes) {
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(NULL, gamePath_, GameInfoFlags::PARAM_SFO);
info->Delete();
g_gameInfoCache->Clear();
screenManager()->switchScreen(new MainScreen());
}
}
UI::EventReturn GameScreen::OnRemoveFromRecent(UI::EventParams &e) {
g_recentFiles.Remove(gamePath_.ToString());
screenManager()->switchScreen(new MainScreen());