mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-13 11:40:38 +02:00
simplify
This commit is contained in:
parent
e61dc2ec23
commit
077ec65bf6
@ -140,7 +140,7 @@ public:
|
|||||||
void setCampaignBonus(int bonusId) const override;
|
void setCampaignBonus(int bonusId) const override;
|
||||||
void setMapInfo(std::shared_ptr<CMapInfo> to, std::shared_ptr<CMapGenOptions> mapGenOpts = {}) const override;
|
void setMapInfo(std::shared_ptr<CMapInfo> to, std::shared_ptr<CMapGenOptions> mapGenOpts = {}) const override;
|
||||||
void setPlayer(PlayerColor color) 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 setDifficulty(int to) const override;
|
||||||
void setTurnLength(int npos) const override;
|
void setTurnLength(int npos) const override;
|
||||||
void sendMessage(const std::string & txt) const override;
|
void sendMessage(const std::string & txt) const override;
|
||||||
|
@ -660,58 +660,8 @@ int OptionsTab::SelectionWindow::getElement(const Point & cursorPosition)
|
|||||||
return x + y * elementsPerLine;
|
return x + y * elementsPerLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsTab::SelectionWindow::clickReleased(const Point & cursorPosition) {
|
void OptionsTab::SelectionWindow::setElement(int elem, bool apply)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
int elem = getElement(cursorPosition);
|
|
||||||
|
|
||||||
PlayerSettings set = PlayerSettings();
|
PlayerSettings set = PlayerSettings();
|
||||||
if(type == SelType::TOWN)
|
if(type == SelType::TOWN)
|
||||||
{
|
{
|
||||||
@ -728,8 +678,11 @@ void OptionsTab::SelectionWindow::showPopupWindow(const Point & cursorPosition)
|
|||||||
}
|
}
|
||||||
if(set.castle != PlayerSettings::NONE)
|
if(set.castle != PlayerSettings::NONE)
|
||||||
{
|
{
|
||||||
CPlayerSettingsHelper helper = CPlayerSettingsHelper(set, SelType::TOWN);
|
if(!apply)
|
||||||
GH.windows().createAndPushWindow<CPlayerOptionTooltipBox>(helper);
|
{
|
||||||
|
CPlayerSettingsHelper helper = CPlayerSettingsHelper(set, SelType::TOWN);
|
||||||
|
GH.windows().createAndPushWindow<CPlayerOptionTooltipBox>(helper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(type == SelType::HERO)
|
if(type == SelType::HERO)
|
||||||
@ -747,8 +700,11 @@ void OptionsTab::SelectionWindow::showPopupWindow(const Point & cursorPosition)
|
|||||||
}
|
}
|
||||||
if(set.hero != PlayerSettings::NONE)
|
if(set.hero != PlayerSettings::NONE)
|
||||||
{
|
{
|
||||||
CPlayerSettingsHelper helper = CPlayerSettingsHelper(set, SelType::HERO);
|
if(!apply)
|
||||||
GH.windows().createAndPushWindow<CPlayerOptionTooltipBox>(helper);
|
{
|
||||||
|
CPlayerSettingsHelper helper = CPlayerSettingsHelper(set, SelType::HERO);
|
||||||
|
GH.windows().createAndPushWindow<CPlayerOptionTooltipBox>(helper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(type == SelType::BONUS)
|
if(type == SelType::BONUS)
|
||||||
@ -758,10 +714,30 @@ void OptionsTab::SelectionWindow::showPopupWindow(const Point & cursorPosition)
|
|||||||
set.bonus = static_cast<PlayerSettings::Ebonus>(elem-1);
|
set.bonus = static_cast<PlayerSettings::Ebonus>(elem-1);
|
||||||
if(set.bonus != PlayerSettings::NONE)
|
if(set.bonus != PlayerSettings::NONE)
|
||||||
{
|
{
|
||||||
CPlayerSettingsHelper helper = CPlayerSettingsHelper(set, SelType::BONUS);
|
if(!apply)
|
||||||
GH.windows().createAndPushWindow<CPlayerOptionTooltipBox>(helper);
|
{
|
||||||
|
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)
|
OptionsTab::SelectedBox::SelectedBox(Point position, PlayerSettings & settings, SelType type)
|
||||||
|
@ -138,6 +138,7 @@ public:
|
|||||||
void recreate();
|
void recreate();
|
||||||
void setSelection();
|
void setSelection();
|
||||||
int getElement(const Point & cursorPosition);
|
int getElement(const Point & cursorPosition);
|
||||||
|
void setElement(int element);
|
||||||
|
|
||||||
void clickReleased(const Point & cursorPosition) override;
|
void clickReleased(const Point & cursorPosition) override;
|
||||||
void showPopupWindow(const Point & cursorPosition) override;
|
void showPopupWindow(const Point & cursorPosition) override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user