#include "UIDialog.h" #include "Game.h" #include "NetworkMessage.h" #include "Quest.h" UIDialog::UIDialog( Framework::Text id, int playerId, Framework::XML::Element* uiml) : ReferenceCounter(), id(id), playerId(playerId), uiml(uiml) {} UIDialog::~UIDialog() { uiml->release(); } void UIDialog::api(Framework::StreamReader* zRequest, NetworkMessage* zResponse) {} bool UIDialog::open() const { Entity* zEntity = Game::INSTANCE->zEntity(playerId); if (zEntity) { Game::INSTANCE->zQuestManager()->processEvent(new QuestEventOpenDialog( dynamic_cast(zEntity->getThis()), id)); NetworkMessage* msg = new NetworkMessage(); msg->openDialog(id, uiml->toString()); Game::INSTANCE->sendMessage(msg, zEntity); return 1; } return 0; } bool UIDialog::update() const { Entity* zEntity = Game::INSTANCE->zEntity(playerId); if (zEntity) { Game::INSTANCE->zQuestManager()->processEvent(new QuestEventOpenDialog( dynamic_cast(zEntity->getThis()), id)); NetworkMessage* msg = new NetworkMessage(); msg->updateDialog(id, uiml->toString()); Game::INSTANCE->sendMessage(msg, zEntity); return 1; } return 0; } const Framework::Text& UIDialog::getId() const { return id; } int UIDialog::getPlayerId() const { return playerId; }