#include #include #include #include #include #include #include #include
#include #include using namespace std; namespace Form { //////////////////////////////// Simple Form //////////////////////////////// string Button::serialize() { try { fifo_json button; button["text"] = text; if (!image.empty()) { fifo_json imageObj; imageObj["type"] = image.find("textures/") == 0 ? "path" : "url"; imageObj["data"] = image; button["image"] = imageObj; } return button.dump(); } catch (const fifo_json::exception&) { logger.error("Fail to generate Button in Simple Form serialize!"); return ""; } } SimpleForm& SimpleForm::setTitle(const string& title) { this->title = title; return *this; } SimpleForm& SimpleForm::setContent(const string& content) { this->content = content; return *this; } SimpleForm& SimpleForm::addButton(string text, string image, Button::ButtonCallback callback) { return append(Button(text, image, callback)); } SimpleForm& SimpleForm::append(const Button& element) { elements.emplace_back(make_shared