#include "QuestDialog.h" #include "Game.h" QuestDialog::QuestDialog(int playerId) : UIDialog("quests", playerId, 0) { QuestManager* zManager = Game::INSTANCE->zQuestManager(); Framework::Text uiml = ""; uiml.append() << ""; QuestParty* party = zManager->zParty(playerId); int index = 0; for (QuestCollection* questCollection : zManager->questCollections) { if (questCollection->isVisible(party, zManager)) { uiml.append() << "getName() << "\">" << questCollection->getName() << ""; } } uiml.append() << ""; this->uiml = new Framework::XML::Element(uiml); } void QuestDialog::api( Framework::StreamReader* zRequest, NetworkMessage* zResponse) { char typ; zRequest->lese(&typ, 1); switch (typ) { case 0: // onSelect Message of listView { int selection; zRequest->lese((char*)&selection, 4); auto questGraph = this->uiml->selectChildsByName("questGraph"); questGraph.selectChildren().remove(); auto listItems = uiml->selectChildsByName("listView").selectChildren(); listItems.removeAttribute("selected"); listItems .whereAttributeEquals( "id", Framework::Text("quest_collection_") + selection) .forEach([this, &questGraph]( Framework::XML::Element* zElement) { zElement->setAttribute("selected", ""); auto collectionName = zElement->getAttributeValue("collectionName"); QuestManager* zManager = Game::INSTANCE->zQuestManager(); auto questCollection = zManager->zCollection(collectionName); QuestParty* zParty = zManager->zParty(getPlayerId()); for (Quest* quest : questCollection->quests) { if (quest->isVisible(zParty, zManager)) { questGraph.addChild(getQuestGraphItem(quest, zParty)); } } }); update(); break; } } } Framework::XML::Element* QuestDialog::getQuestGraphItem( Quest* zQuest, QuestParty* zParty) { Framework::Text requirements = ""; int index = 0; int currentGroup = 0; for (Framework::Text* requiredQuest : zQuest->requiredQuestsIds) { int group = zQuest->requiredQuestsGroups.get(index); if (index != 0) { if (group != currentGroup) { requirements += "||"; currentGroup = group; } else { requirements += "&&"; } } else { currentGroup = group; } requirements += *requiredQuest; index++; } if (!zQuest->isActive(zParty)) { Framework::Text result = "questId << "\" name=\"Unknown Quest\" image=\"" << zQuest->imagePath << "\" description=\"You have to finish other quests befor this " "quest will be available.\" finished=\"false\" mainQuest=\"" << zQuest->mainQuest << "\" requirements=\"" << requirements << "\" width=\"" << (zQuest->mainQuest ? "50" : "30") << "\" height=\"" << (zQuest->mainQuest ? "50" : "30") << "\"/>"; return new Framework::XML::Element(result); } else { QuestStorage* zStorage = zParty->zQuestStorage(zQuest->questId); Framework::Text result = "questId << "\" name=\"" << zQuest->questName + "\" image=\"" << zQuest->imagePath << "\" description=\"" << zQuest->description << "\" finished=\"" << zStorage->isQuestFinished() << "\" mainQuest=\"" << zQuest->mainQuest << "\" requirements=\"" << requirements << "\" width=\"" << (zQuest->mainQuest ? "50" : "30") << "\" height=\"" << (zQuest->mainQuest ? "50" : "30") << "\"/>"; return new Framework::XML::Element(result); } }