1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Merge pull request #3583 from Laserlicht/town_portal

town portal dialog adjustments
This commit is contained in:
Ivan Savenko
2024-02-01 11:30:51 +02:00
committed by GitHub
4 changed files with 78 additions and 14 deletions

View File

@@ -34,6 +34,7 @@
#include "../render/Canvas.h"
#include "../render/IImage.h"
#include "../render/IRenderHandler.h"
#include "../render/CAnimation.h"
#include "../render/ColorFilter.h"
#include "../adventureMap/AdventureMapInterface.h"
#include "../adventureMap/CList.h"
@@ -872,7 +873,7 @@ void CCastleBuildings::enterCastleGate()
return;//only visiting hero can use castle gates
}
std::vector <int> availableTowns;
std::vector <const CGTownInstance*> Towns = LOCPLINT->cb->getTownsInfo(true);
std::vector <const CGTownInstance*> Towns = LOCPLINT->localState->getOwnedTowns();
for(auto & Town : Towns)
{
const CGTownInstance *t = Town;
@@ -883,9 +884,22 @@ void CCastleBuildings::enterCastleGate()
availableTowns.push_back(t->id.getNum());//add to the list
}
}
std::vector<std::shared_ptr<IImage>> images;
for(auto & t : Towns)
{
if(!settings["general"]["enableUiEnhancements"].Bool())
break;
std::shared_ptr<CAnimation> 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<CAnimImage>(town->town->clientInfo.buildingsIcons, BuildingID::CASTLE_GATE);//will be deleted by selection window
GH.windows().createAndPushWindow<CObjectListWindow>(availableTowns, gateIcon, CGI->generaltexth->jktexts[40],
CGI->generaltexth->jktexts[41], std::bind (&CCastleInterface::castleTeleport, LOCPLINT->castleInt, _1));
auto wnd = std::make_shared<CObjectListWindow>(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()); };
GH.windows().pushWindow(wnd);
}
void CCastleBuildings::enterDwelling(int level)