mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-18 20:04:31 +01:00
Remove a few uses of std::bind
This commit is contained in:
1 parent
2bc181104b
commit
f14a38db52
3 files changed
+24
-27
No files matched your search
+5
-5
@@ -266,16 +266,16 @@ public:
|
||||
// Call this from UI thread
|
||||
EventReturn Dispatch(EventParams &e);
|
||||
|
||||
// This is suggested for use in most cases. Autobinds, allowing for neat syntax.
|
||||
// This is now the suggested default way to bind a handler - just used a lambda, and if necessary call other functions.
|
||||
void Add(std::function<EventReturn(EventParams &)> func);
|
||||
|
||||
// The old way of doing things.
|
||||
template<class T>
|
||||
T *Handle(T *thiz, EventReturn (T::* theCallback)(EventParams &e)) {
|
||||
T *Handle(T *thiz, EventReturn (T::* theCallback)(EventParams &)) {
|
||||
Add(std::bind(theCallback, thiz, std::placeholders::_1));
|
||||
return thiz;
|
||||
}
|
||||
|
||||
// Sometimes you have an already-bound function<>, just use this then.
|
||||
void Add(std::function<EventReturn(EventParams&)> func);
|
||||
|
||||
private:
|
||||
std::vector<HandlerRegistration> handlers_;
|
||||
DISALLOW_COPY_AND_ASSIGN(Event);
|
||||
|
||||
+19
-20
@@ -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());
|
||||
|
||||
@@ -44,8 +44,6 @@ public:
|
||||
|
||||
protected:
|
||||
void CreateViews() override;
|
||||
void CallbackDeleteSaveData(bool yes);
|
||||
void CallbackDeleteGame(bool yes);
|
||||
|
||||
private:
|
||||
UI::Choice *AddOtherChoice(UI::Choice *choice);
|
||||
|
||||
Reference in new issue
Block a user