1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00
This commit is contained in:
Michael 2023-08-12 18:20:44 +02:00 committed by GitHub
parent c40c747ccf
commit 481cd89dc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View File

@ -448,14 +448,37 @@ void OptionsTab::SelectionWindow::apply()
{
close();
CSH->setPlayerOption(LobbyChangePlayerOption::TOWN, 1, color);
setSelection();
}
}
void OptionsTab::SelectionWindow::setSelection()
{
int selectedFractionPos = -1;
for(int i = 0; i<factions.size(); i++)
if(factions[i] == selectedFraction)
selectedFractionPos = i;
int initialFractionPos = -1;
for(int i = 0; i<factions.size(); i++)
if(factions[i] == initialFraction)
initialFractionPos = i;
int deltatown = selectedFractionPos - initialFractionPos;
if(deltatown != 0)
for(int i = 0; i<abs(deltatown); i++)
CSH->setPlayerOption(LobbyChangePlayerOption::TOWN, deltatown > 0 ? 1 : -1, color);
}
void OptionsTab::SelectionWindow::redraw()
{
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
components.clear();
GH.windows().totalRedraw();
genContentTitle();
genContentCastles();
genContentHeroes();

View File

@ -123,6 +123,7 @@ public:
void apply();
void redraw();
void setSelection();
FactionID getElementCastle(const Point & cursorPosition);
HeroTypeID getElementHero(const Point & cursorPosition);
int getElementBonus(const Point & cursorPosition);