1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

TOWN_PORTAL callback is too specific to ba part on spellwindow class

This commit is contained in:
AlexVinS
2015-01-30 10:24:30 +03:00
parent 33f22bf2fc
commit 66ca4bc0c2
2 changed files with 9 additions and 11 deletions

View File

@@ -593,12 +593,6 @@ Uint8 CSpellWindow::pagesWithinCurrentTab()
return battleSpellsOnly ? sitesPerTabBattle[selectedTab] : sitesPerTabAdv[selectedTab];
}
void CSpellWindow::teleportTo( int town, const CGHeroInstance * hero )
{
const CGTownInstance * dest = LOCPLINT->cb->getTown(ObjectInstanceID(town));
LOCPLINT->cb->castSpell(hero, SpellID::TOWN_PORTAL, dest->visitablePos());
}
CSpellWindow::SpellArea::SpellArea(SDL_Rect pos, CSpellWindow * owner)
{
this->pos = pos;
@@ -755,13 +749,20 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
availableTowns.push_back(t->id.getNum());//add to the list
}
}
auto castTownPortal = [h](int townId)
{
const CGTownInstance * dest = LOCPLINT->cb->getTown(ObjectInstanceID(townId));
LOCPLINT->cb->castSpell(h, SpellID::TOWN_PORTAL, dest->visitablePos());
};
if (availableTowns.empty())
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[124]);
else
GH.pushInt (new CObjectListWindow(availableTowns,
new CAnimImage("SPELLSCR",mySpell),
CGI->generaltexth->jktexts[40], CGI->generaltexth->jktexts[41],
std::bind (&CSpellWindow::teleportTo, owner, _1, h)));
castTownPortal));
}
return;
}
@@ -780,8 +781,7 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
if(sp->getTargetType() == CSpell::LOCATION)
{
adventureInt->enterCastingMode(sp);
return;
adventureInt->enterCastingMode(sp);
}
else if(sp->getTargetType() == CSpell::NO_TARGET)
{

View File

@@ -112,6 +112,4 @@ public:
void deactivate();
void showAll(SDL_Surface * to);
void show(SDL_Surface * to);
void teleportTo(int town, const CGHeroInstance * hero);
};