1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

Queries refactoring

* Moved SUMMON_BOAT special case to mechanics
* Partially moved Town portal logic to mechanics class
* Added generic query reply to CCallback
* Redesigned Queries so that base API do not depends on CGameHandler
* Got rid of CGameHandler::castSpellRequest
* Removed CGameHandler::castSpell
* Added new Query type for town portal dialog (not used yet)
This commit is contained in:
AlexVinS
2017-06-06 07:53:51 +03:00
parent f463dc2fa3
commit 3d1a84875e
32 changed files with 729 additions and 295 deletions

View File

@@ -1191,6 +1191,39 @@ void CPlayerInterface::showTeleportDialog(TeleportChannelID channel, TTeleportEx
cb->selectionMade(choosenExit, askID);
}
void CPlayerInterface::showMapObjectSelectDialog(QueryID askID, const Component & icon, const MetaString & title, const MetaString & description, const std::vector<ObjectInstanceID> & objects)
{
EVENT_HANDLER_CALLED_BY_CLIENT;
auto selectCallback = [=](int selection)
{
JsonNode reply(JsonNode::DATA_INTEGER);
reply.Integer() = selection;
cb->sendQueryReply(reply, askID);
};
auto cancelCallback = [=]()
{
JsonNode reply(JsonNode::DATA_NULL);
cb->sendQueryReply(reply, askID);
};
CComponent * localIcon = new CComponent(icon);
const std::string localTitle = title.toString();
const std::string localDescription = description.toString();
std::vector<int> tempList;
tempList.reserve(objects.size());
for(auto item : objects)
tempList.push_back(item.getNum());
CObjectListWindow * wnd = new CObjectListWindow(tempList, localIcon, localTitle, localDescription, selectCallback);
wnd->onExit = cancelCallback;
GH.pushInt(wnd);
}
void CPlayerInterface::tileRevealed(const std::unordered_set<int3, ShashInt3> &pos)
{
EVENT_HANDLER_CALLED_BY_CLIENT;