diff --git a/client/lobby/RandomMapTab.cpp b/client/lobby/RandomMapTab.cpp index cd87598b2..dd8b4fca5 100644 --- a/client/lobby/RandomMapTab.cpp +++ b/client/lobby/RandomMapTab.cpp @@ -139,13 +139,13 @@ RandomMapTab::RandomMapTab() groupMonsterStrength->pos.y += 485; groupMonsterStrength->pos.x += BTNS_GROUP_LEFT_MARGIN; const std::vector monsterStrengthBtns = {"RANWEAK", "RANNORM", "RANSTRG"}; - addButtonsWithRandToGroup(groupMonsterStrength.get(), monsterStrengthBtns, 0, 2, WIDE_BTN_WIDTH, 248, 251); + addButtonsWithRandToGroup(groupMonsterStrength.get(), monsterStrengthBtns, 2, 4, WIDE_BTN_WIDTH, 248, 251, EMonsterStrength::RANDOM, false); groupMonsterStrength->addCallback([&](int btnId) { if(btnId < 0) mapGenOptions->setMonsterStrength(EMonsterStrength::RANDOM); else - mapGenOptions->setMonsterStrength(static_cast(btnId + EMonsterStrength::GLOBAL_WEAK)); //value 2 to 4 + mapGenOptions->setMonsterStrength(static_cast(btnId)); //value 2 to 4 updateMapInfoByHost(); }); @@ -212,25 +212,25 @@ void RandomMapTab::setMapGenOptions(std::shared_ptr opts) groupMonsterStrength->setSelected(opts->getMonsterStrength()); } -void RandomMapTab::addButtonsWithRandToGroup(CToggleGroup * group, const std::vector & defs, int nStart, int nEnd, int btnWidth, int helpStartIndex, int helpRandIndex) const +void RandomMapTab::addButtonsWithRandToGroup(CToggleGroup * group, const std::vector & defs, int nStart, int nEnd, int btnWidth, int helpStartIndex, int helpRandIndex, int randIndex, bool animIdfromBtnId) const { - addButtonsToGroup(group, defs, nStart, nEnd, btnWidth, helpStartIndex); + addButtonsToGroup(group, defs, nStart, nEnd, btnWidth, helpStartIndex, animIdfromBtnId); // Buttons are relative to button group, TODO better solution? SObjectConstruction obj__i(group); const std::string RANDOM_DEF = "RANRAND"; - group->addToggle(CMapGenOptions::RANDOM_SIZE, std::make_shared(Point(256, 0), RANDOM_DEF, CGI->generaltexth->zelp[helpRandIndex])); - group->setSelected(CMapGenOptions::RANDOM_SIZE); + group->addToggle(randIndex, std::make_shared(Point(256, 0), RANDOM_DEF, CGI->generaltexth->zelp[helpRandIndex])); + group->setSelected(randIndex); } -void RandomMapTab::addButtonsToGroup(CToggleGroup * group, const std::vector & defs, int nStart, int nEnd, int btnWidth, int helpStartIndex) const +void RandomMapTab::addButtonsToGroup(CToggleGroup * group, const std::vector & defs, int nStart, int nEnd, int btnWidth, int helpStartIndex, bool animIdfromBtnId) const { // Buttons are relative to button group, TODO better solution? SObjectConstruction obj__i(group); int cnt = nEnd - nStart + 1; for(int i = 0; i < cnt; ++i) { - auto button = std::make_shared(Point(i * btnWidth, 0), defs[i + nStart], CGI->generaltexth->zelp[helpStartIndex + i]); + auto button = std::make_shared(Point(i * btnWidth, 0), animIdfromBtnId ? defs[i + nStart] : defs[i], CGI->generaltexth->zelp[helpStartIndex + i]); // For blocked state we should use pressed image actually button->setImageOrder(0, 1, 1, 3); group->addToggle(i + nStart, button); diff --git a/client/lobby/RandomMapTab.h b/client/lobby/RandomMapTab.h index 5297f472a..6d89d2146 100644 --- a/client/lobby/RandomMapTab.h +++ b/client/lobby/RandomMapTab.h @@ -29,8 +29,8 @@ public: CFunctionList, std::shared_ptr)> mapInfoChanged; private: - void addButtonsWithRandToGroup(CToggleGroup * group, const std::vector & defs, int startIndex, int endIndex, int btnWidth, int helpStartIndex, int helpRandIndex) const; - void addButtonsToGroup(CToggleGroup * group, const std::vector & defs, int startIndex, int endIndex, int btnWidth, int helpStartIndex) const; + void addButtonsWithRandToGroup(CToggleGroup * group, const std::vector & defs, int startIndex, int endIndex, int btnWidth, int helpStartIndex, int helpRandIndex, int randIndex = -1, bool animIdfromBtnId = true) const; + void addButtonsToGroup(CToggleGroup * group, const std::vector & defs, int startIndex, int endIndex, int btnWidth, int helpStartIndex, bool animIdfromBtnId = true) const; void deactivateButtonsFrom(CToggleGroup * group, int startId); void validatePlayersCnt(int playersCnt); void validateCompOnlyPlayersCnt(int compOnlyPlayersCnt);