1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00
This commit is contained in:
Michael 2023-08-17 18:15:42 +02:00 committed by GitHub
parent e61dc2ec23
commit 077ec65bf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 58 deletions

View File

@ -140,7 +140,7 @@ public:
void setCampaignBonus(int bonusId) const override;
void setMapInfo(std::shared_ptr<CMapInfo> to, std::shared_ptr<CMapGenOptions> mapGenOpts = {}) const override;
void setPlayer(PlayerColor color) const override;
void setPlayerOption(ui8 what, si16 value, PlayerColor player) const override;
void setPlayerOption(ui8 what, int32_t value, PlayerColor player) const override;
void setDifficulty(int to) const override;
void setTurnLength(int npos) const override;
void sendMessage(const std::string & txt) const override;

View File

@ -660,58 +660,8 @@ int OptionsTab::SelectionWindow::getElement(const Point & cursorPosition)
return x + y * elementsPerLine;
}
void OptionsTab::SelectionWindow::clickReleased(const Point & cursorPosition) {
int elem = getElement(cursorPosition);
PlayerSettings set = PlayerSettings();
if(type == SelType::TOWN)
{
if(elem > 0)
{
elem--;
if(elem >= factions.size())
return;
set.castle = factions[elem];
}
else
{
set.castle = PlayerSettings::RANDOM;
}
if(set.castle != PlayerSettings::NONE)
selectedFaction = set.castle;
}
if(type == SelType::HERO)
{
if(elem > 0)
{
elem--;
if(elem >= heroes.size())
return;
set.hero = heroes[elem];
}
else
{
set.hero = PlayerSettings::RANDOM;
}
if(set.hero != PlayerSettings::NONE)
selectedHero = set.hero;
}
if(type == SelType::BONUS)
{
if(elem >= allowedBonus.size())
return;
set.bonus = static_cast<PlayerSettings::Ebonus>(allowedBonus[elem]);
if(set.bonus != PlayerSettings::NONE)
selectedBonus = set.bonus;
}
apply();
}
void OptionsTab::SelectionWindow::showPopupWindow(const Point & cursorPosition)
void OptionsTab::SelectionWindow::setElement(int elem, bool apply)
{
int elem = getElement(cursorPosition);
PlayerSettings set = PlayerSettings();
if(type == SelType::TOWN)
{
@ -728,8 +678,11 @@ void OptionsTab::SelectionWindow::showPopupWindow(const Point & cursorPosition)
}
if(set.castle != PlayerSettings::NONE)
{
CPlayerSettingsHelper helper = CPlayerSettingsHelper(set, SelType::TOWN);
GH.windows().createAndPushWindow<CPlayerOptionTooltipBox>(helper);
if(!apply)
{
CPlayerSettingsHelper helper = CPlayerSettingsHelper(set, SelType::TOWN);
GH.windows().createAndPushWindow<CPlayerOptionTooltipBox>(helper);
}
}
}
if(type == SelType::HERO)
@ -747,8 +700,11 @@ void OptionsTab::SelectionWindow::showPopupWindow(const Point & cursorPosition)
}
if(set.hero != PlayerSettings::NONE)
{
CPlayerSettingsHelper helper = CPlayerSettingsHelper(set, SelType::HERO);
GH.windows().createAndPushWindow<CPlayerOptionTooltipBox>(helper);
if(!apply)
{
CPlayerSettingsHelper helper = CPlayerSettingsHelper(set, SelType::HERO);
GH.windows().createAndPushWindow<CPlayerOptionTooltipBox>(helper);
}
}
}
if(type == SelType::BONUS)
@ -758,10 +714,30 @@ void OptionsTab::SelectionWindow::showPopupWindow(const Point & cursorPosition)
set.bonus = static_cast<PlayerSettings::Ebonus>(elem-1);
if(set.bonus != PlayerSettings::NONE)
{
CPlayerSettingsHelper helper = CPlayerSettingsHelper(set, SelType::BONUS);
GH.windows().createAndPushWindow<CPlayerOptionTooltipBox>(helper);
if(!apply)
{
CPlayerSettingsHelper helper = CPlayerSettingsHelper(set, SelType::BONUS);
GH.windows().createAndPushWindow<CPlayerOptionTooltipBox>(helper);
}
}
}
if(apply)
apply();
}
void OptionsTab::SelectionWindow::clickReleased(const Point & cursorPosition)
{
int elem = getElement(cursorPosition);
setElement(elem, true);
}
void OptionsTab::SelectionWindow::showPopupWindow(const Point & cursorPosition)
{
int elem = getElement(cursorPosition);
setElement(elem, false);
}
OptionsTab::SelectedBox::SelectedBox(Point position, PlayerSettings & settings, SelType type)

View File

@ -138,6 +138,7 @@ public:
void recreate();
void setSelection();
int getElement(const Point & cursorPosition);
void setElement(int element);
void clickReleased(const Point & cursorPosition) override;
void showPopupWindow(const Point & cursorPosition) override;