123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- #include "QuestRequirement.h"
- #include <Fenster.h>
- #include "Quest.h"
- QuestRequirement::QuestRequirement()
- : ReferenceCounter()
- {}
- void QuestRequirement::api(Framework::StreamReader* message,
- Framework::XML::Element* zParent,
- QuestStorage* zStorage)
- {}
- void QuestRequirement::setRequirementId(Framework::Text id)
- {
- this->id = id;
- }
- const Framework::Text& QuestRequirement::getRequirementId() const
- {
- return id;
- }
- void QuestRequirement::setDescription(Framework::Text description)
- {
- this->description = description;
- }
- const Framework::Text& QuestRequirement::getDescription() const
- {
- return description;
- }
- QuestRequirementOpenDialog::QuestRequirementOpenDialog()
- : QuestRequirement()
- {}
- void QuestRequirementOpenDialog::processEvent(
- QuestEvent* zEvent, QuestStorage* zStorage)
- {
- QuestRequirementStorage* zRequirementStorage
- = zStorage->zStorage(getRequirementId());
- QuestEventOpenDialog* event = dynamic_cast<QuestEventOpenDialog*>(zEvent);
- if (event)
- {
- if (event->getDialogId() == dialogId)
- {
- zRequirementStorage->setFullfilled(true);
- }
- }
- }
- void QuestRequirementOpenDialog::addRequirementUIML(QuestStorage* zStorage,
- Framework::XML::Element* zParent,
- Framework::Text onClickPrefix)
- {
- Framework::XML::Element* container = new Framework::XML::Element(
- "<frame width=\"100%\" height=\"50\" display=\"row\" gap=\"10\"/>");
- container->setAttribute("style",
- Framework::Text() += (Framework::Fenster::Style::Sichtbar
- | Framework::Fenster::Style::Erlaubt));
- container->setAttribute(
- "id", Framework::Text("requirement_") += getRequirementId());
- // TODO: add icon of dialog
- auto text
- = new Framework::XML::Element("<text width=\"auto\" height=\"auto\"/>");
- text->setAttribute("id",
- Framework::Text("requirement_description_") += getRequirementId());
- text->setText(description);
- container->addChild(text);
- auto status = new Framework::XML::Element(
- "<text margin-top=\"10\" width=\"auto\" height=\"auto\"/>");
- status->setAttribute("align-top", text->getAttributeValue("id"));
- status->setAttribute("align-x", text->getAttributeValue("id"));
- if (zStorage->zStorage(getRequirementId())->isFullfilled())
- {
- status->setText("Completed");
- status->setAttribute("text-color", "0xFF00FF00");
- }
- else
- {
- status->setText("Not completed");
- status->setAttribute("text-color", "0xFFFF0000");
- }
- container->addChild(status);
- zParent->addChild(container);
- }
- void QuestRequirementOpenDialog::setDialogId(Framework::Text dialogId)
- {
- this->dialogId = dialogId;
- }
- const Framework::Text& QuestRequirementOpenDialog::getDialogId() const
- {
- return dialogId;
- }
- QuestRequirementOpenDialogType::QuestRequirementOpenDialogType()
- : QuestRequirementFactoryBase()
- {}
- QuestRequirementOpenDialog* QuestRequirementOpenDialogType::createValue(
- Framework::JSON::JSONObject* zJson) const
- {
- return new QuestRequirementOpenDialog();
- }
- void QuestRequirementOpenDialogType::fromJson(
- QuestRequirementOpenDialog* zResult,
- Framework::JSON::JSONObject* zJson) const
- {
- zResult->setDialogId(zJson->zValue("dialogId")->asString()->getString());
- QuestRequirementFactoryBase::fromJson(zResult, zJson);
- }
- void QuestRequirementOpenDialogType::toJson(QuestRequirementOpenDialog* zObject,
- Framework::JSON::JSONObject* zResult) const
- {
- zResult->addValue(
- "dialogId", new Framework::JSON::JSONString(zObject->dialogId));
- QuestRequirementFactoryBase::toJson(zObject, zResult);
- }
- JSONObjectValidationBuilder* QuestRequirementOpenDialogType::addToValidator(
- JSONObjectValidationBuilder* builder) const
- {
- return QuestRequirementFactoryBase::addToValidator(
- builder->withRequiredString("id")
- ->finishString()
- ->withRequiredString("description")
- ->finishString()
- ->withRequiredString("dialogId")
- ->finishString());
- }
- Framework::Text QuestRequirementOpenDialogType::getTypeToken() const
- {
- return "open_dialog";
- }
|