mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 21:39:52 +00:00
Add onFinish callback to screens, hook up for UIScreen::OnBack
This commit is contained in:
parent
0c397c3e68
commit
c53bf92350
@ -170,7 +170,7 @@ void ScreenManager::RecreateAllViews() {
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenManager::finishDialog(const Screen *dialog, DialogResult result) {
|
||||
void ScreenManager::finishDialog(Screen *dialog, DialogResult result) {
|
||||
if (stack_.empty()) {
|
||||
ELOG("Must be in a dialog to finishDialog");
|
||||
return;
|
||||
@ -179,6 +179,7 @@ void ScreenManager::finishDialog(const Screen *dialog, DialogResult result) {
|
||||
ELOG("Wrong dialog being finished!");
|
||||
return;
|
||||
}
|
||||
dialog->onFinish(result);
|
||||
dialogFinished_ = dialog;
|
||||
dialogResult_ = result;
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ enum DialogResult {
|
||||
DR_CANCEL,
|
||||
DR_YES,
|
||||
DR_NO,
|
||||
DR_BACK,
|
||||
};
|
||||
|
||||
class ScreenManager;
|
||||
@ -43,6 +44,7 @@ public:
|
||||
screenManager_ = 0;
|
||||
}
|
||||
|
||||
virtual void onFinish(DialogResult reason) {}
|
||||
virtual void update(InputState &input) {}
|
||||
virtual void render() {}
|
||||
virtual void deviceLost() {}
|
||||
@ -99,7 +101,7 @@ public:
|
||||
void RecreateAllViews();
|
||||
|
||||
// Pops the dialog away.
|
||||
void finishDialog(const Screen *dialog, DialogResult result = DR_OK);
|
||||
void finishDialog(Screen *dialog, DialogResult result = DR_OK);
|
||||
|
||||
// Instant touch, separate from the update() mechanism.
|
||||
void touch(const TouchInput &touch);
|
||||
|
@ -55,7 +55,7 @@ void UIScreen::key(const KeyInput &key) {
|
||||
|
||||
void UIDialogScreen::key(const KeyInput &key) {
|
||||
if ((key.flags & KEY_DOWN) && UI::IsEscapeKeyCode(key.keyCode)) {
|
||||
screenManager()->finishDialog(this, DR_CANCEL);
|
||||
screenManager()->finishDialog(this, DR_BACK);
|
||||
} else {
|
||||
UIScreen::key(key);
|
||||
}
|
||||
@ -96,7 +96,7 @@ void UIScreen::axis(const AxisInput &axis) {
|
||||
}
|
||||
|
||||
UI::EventReturn UIScreen::OnBack(UI::EventParams &e) {
|
||||
screenManager()->finishDialog(this, DR_OK);
|
||||
screenManager()->finishDialog(this, DR_BACK);
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ void PopupScreen::touch(const TouchInput &touch) {
|
||||
}
|
||||
|
||||
if (!box_->GetBounds().Contains(touch.x, touch.y))
|
||||
screenManager()->finishDialog(this, DR_CANCEL);
|
||||
screenManager()->finishDialog(this, DR_BACK);
|
||||
|
||||
UIDialogScreen::touch(touch);
|
||||
}
|
||||
@ -183,7 +183,7 @@ void ListPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
UI::EventReturn ListPopupScreen::OnListChoice(UI::EventParams &e) {
|
||||
adaptor_.SetSelected(e.a);
|
||||
if (callback_)
|
||||
callback_(adaptor_.GetSelected());
|
||||
callback_(adaptor_.GetSelected());
|
||||
screenManager()->finishDialog(this, DR_OK);
|
||||
OnCompleted(DR_OK);
|
||||
OnChoice.Dispatch(e);
|
||||
|
Loading…
Reference in New Issue
Block a user