1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Merge pull request #358 from Chocimier/altar

Fixed bugs in Altar
This commit is contained in:
ArseniyShestakov 2017-08-05 02:25:41 +03:00 committed by GitHub
commit 4388e12a3a
2 changed files with 23 additions and 2 deletions

View File

@ -575,8 +575,10 @@ void CTradeWindow::showAll(SDL_Surface * to)
if(readyToTrade)
{
hLeft->showAllAt(pos.topLeft() + selectionOffset(true), selectionSubtitle(true), to);
hRight->showAllAt(pos.topLeft() + selectionOffset(false), selectionSubtitle(false), to);
if(hLeft)
hLeft->showAllAt(pos.topLeft() + selectionOffset(true), selectionSubtitle(true), to);
if(hRight)
hRight->showAllAt(pos.topLeft() + selectionOffset(false), selectionSubtitle(false), to);
}
}
@ -1314,10 +1316,28 @@ void CAltarWindow::selectionChanged(bool side)
slider->block(!slider->getAmount());
slider->moveTo(sacrificedUnits[hLeft->serial]);
max->block(!slider->getAmount());
selectOppositeItem(side);
readyToTrade = true;
redraw();
}
void CAltarWindow::selectOppositeItem(bool side)
{
bool oppositeSide = !side;
int pos = vstd::find_pos(items[side], side ? hLeft : hRight);
int oppositePos = vstd::find_pos(items[oppositeSide], oppositeSide ? hLeft : hRight);
if(pos >= 0 && pos != oppositePos)
{
if(oppositeSide)
hLeft = items[oppositeSide][pos];
else
hRight = items[oppositeSide][pos];
selectionChanged(oppositeSide);
}
}
void CAltarWindow::mimicCres()
{
std::vector<Rect> positions;

View File

@ -141,6 +141,7 @@ public:
void selectionChanged(bool side) override; //true == left
void selectOppositeItem(bool side);
void SacrificeAll();
void SacrificeBackpack();