diff --git a/ui/ui_screen.cpp b/ui/ui_screen.cpp index 66f6eec6bc..c13ebf5733 100644 --- a/ui/ui_screen.cpp +++ b/ui/ui_screen.cpp @@ -206,7 +206,20 @@ void PopupScreen::CreateViews() { } void MessagePopupScreen::CreatePopupContents(UI::ViewGroup *parent) { - parent->Add(new UI::TextView(message_)); + std::vector 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) { diff --git a/ui/ui_screen.h b/ui/ui_screen.h index 85cc5f7863..42362ba08a 100644 --- a/ui/ui_screen.h +++ b/ui/ui_screen.h @@ -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 callback) : PopupScreen(title) {} - UI::Event OnChoice; + MessagePopupScreen(std::string title, std::string message, std::string button1, std::string button2, std::function 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 callback_; + std::function callback_; }; // TODO: Need a way to translate OK and Cancel