40 lines
1.2 KiB
C++
40 lines
1.2 KiB
C++
|
#include "qw_dialoguefactory.h"
|
||
|
#include "qw_levelbuilder.h"
|
||
|
|
||
|
QWDialogueFactory::QWDialogueFactory(QWLevelBuilder *b) :
|
||
|
builder(b)
|
||
|
{}
|
||
|
|
||
|
std::shared_ptr<QWTextDialogue> QWDialogueFactory::createTextDialogue(const QJsonObject &json_object)
|
||
|
{
|
||
|
std::unique_ptr<QWTextDialogue> 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<QWTextDialogue>(text);
|
||
|
|
||
|
return std::shared_ptr<QWTextDialogue>{std::move(new_dialogue)};
|
||
|
}
|
||
|
|
||
|
std::shared_ptr<QWWidgetDialogue> QWDialogueFactory::createWidgetDialogue(const QJsonObject &json_object)
|
||
|
{
|
||
|
std::unique_ptr<QWWidgetDialogue> new_dialogue;
|
||
|
|
||
|
qDebug() << " Found QWWidgetDialogue. " << json_object["id"].toString() << ".";
|
||
|
|
||
|
Q_ASSERT(json_object.contains("qml_filename"));
|
||
|
|
||
|
new_dialogue = std::make_unique<QWWidgetDialogue>(json_object["qml_filename"].toString());
|
||
|
|
||
|
return std::shared_ptr<QWWidgetDialogue>{std::move(new_dialogue)};
|
||
|
}
|