#include "qw_dialoguefactory.h" #include "qw_levelbuilder.h" QWDialogueFactory::QWDialogueFactory(QWLevelBuilder *b) : builder(b) {} std::shared_ptr QWDialogueFactory::createTextDialogue(const QJsonObject &json_object) { std::unique_ptr new_dialogue; qDebug() << " Found QWTextDialogue. " << json_object["id"].toString() << "."; Q_ASSERT(json_object.contains("text")); QStringList text; const QJsonArray text_pages = json_object["text"].toArray(); for (auto const &page : text_pages) text << page.toString(); // add events on leave or something new_dialogue = std::make_unique(text); return std::shared_ptr{std::move(new_dialogue)}; } std::shared_ptr QWDialogueFactory::createWidgetDialogue(const QJsonObject &json_object) { std::unique_ptr new_dialogue; qDebug() << " Found QWWidgetDialogue. " << json_object["id"].toString() << "."; Q_ASSERT(json_object.contains("qml_filename")); new_dialogue = std::make_unique(json_object["qml_filename"].toString()); return std::shared_ptr{std::move(new_dialogue)}; }