Add functionality to the MessagePopupScreen class.

It can more or less replace PromptScreen in PPSSPP.
This commit is contained in:
The Dax committed 2014-09-14 19:54:25 -04:00
1 parent 6ee862b564
commit 167f2a8a2c
2 files changed
+19 -4

No files matched your search

+14 -1
View File
@@ -206,7 +206,20 @@ void PopupScreen::CreateViews() {
}
void MessagePopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
parent->Add(new UI::TextView(message_));
std::vector<std::string> messageLines;
SplitString(message_, '\n', messageLines);
for (const auto& lineOfText : messageLines)
parent->Add(new UI::TextView(lineOfText, ALIGN_LEFT | ALIGN_VCENTER, false));
}
void MessagePopupScreen::OnCompleted(DialogResult result) {
if (result == DR_OK) {
if (callback_)
callback_(true);
} else {
if (callback_)
callback_(false);
}
}
UI::EventReturn PopupScreen::OnOK(UI::EventParams &e) {
+5 -3
View File
@@ -110,8 +110,9 @@ private:
class MessagePopupScreen : public PopupScreen {
public:
MessagePopupScreen(std::string title, std::string message, std::string button1, std::string button2, std::function<void(int)> callback) : PopupScreen(title) {}
UI::Event OnChoice;
MessagePopupScreen(std::string title, std::string message, std::string button1, std::string button2, std::function<void(bool)> callback)
: PopupScreen(title, button1, button2), message_(message), callback_(callback) {}
UI::Event OnChange;
protected:
virtual bool FillVertical() const override { return false; }
@@ -119,8 +120,9 @@ protected:
virtual void CreatePopupContents(UI::ViewGroup *parent) override;
private:
void OnCompleted(DialogResult result) override;
std::string message_;
std::function<void(int)> callback_;
std::function<void(bool)> callback_;
};
// TODO: Need a way to translate OK and Cancel