diff --git a/client/windows/CCastleInterface.cpp b/client/windows/CCastleInterface.cpp index 9439ebf1e..50be7f9ce 100644 --- a/client/windows/CCastleInterface.cpp +++ b/client/windows/CCastleInterface.cpp @@ -863,6 +863,7 @@ void CCastleBuildings::enterCastleGate() return;//only visiting hero can use castle gates } std::vector availableTowns; + std::vector> images; std::vector Towns = LOCPLINT->localState->getOwnedTowns(); for(auto & Town : Towns) { @@ -872,23 +873,19 @@ void CCastleBuildings::enterCastleGate() t->hasBuilt(BuildingSubID::CASTLE_GATE)) //and the town has a castle gate { availableTowns.push_back(t->id.getNum());//add to the list + if(settings["general"]["enableUiEnhancements"].Bool()) + { + std::shared_ptr a = GH.renderHandler().loadAnimation(AnimationPath::builtin("ITPA")); + a->preload(); + images.push_back(a->getImage(t->town->clientInfo.icons[t->hasFort()][false] + 2)->scaleFast(Point(35, 23))); + } } } - std::vector> images; - for(auto & t : Towns) - { - if(!settings["general"]["enableUiEnhancements"].Bool()) - break; - std::shared_ptr a = GH.renderHandler().loadAnimation(AnimationPath::builtin("ITPA")); - a->preload(); - images.push_back(a->getImage(t->town->clientInfo.icons[t->hasFort()][false] + 2)->scaleFast(Point(35, 23))); - } - auto gateIcon = std::make_shared(town->town->clientInfo.buildingsIcons, BuildingID::CASTLE_GATE);//will be deleted by selection window auto wnd = std::make_shared(availableTowns, gateIcon, CGI->generaltexth->jktexts[40], CGI->generaltexth->jktexts[41], std::bind (&CCastleInterface::castleTeleport, LOCPLINT->castleInt, _1), 0, images); - wnd->onPopup = [Towns](int index) { CRClickPopup::createAndPush(Towns[index], GH.getCursorPosition()); }; + wnd->onPopup = [availableTowns](int index) { CRClickPopup::createAndPush(LOCPLINT->cb->getObjInstance(ObjectInstanceID(availableTowns[index])), GH.getCursorPosition()); }; GH.windows().pushWindow(wnd); }