12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #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<Entity*>(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<Entity*>(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;
- }
|