RandomMapTab.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. /*
  2. * RandomMapTab.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "RandomMapTab.h"
  12. #include "CSelectionBase.h"
  13. #include "CLobbyScreen.h"
  14. #include "SelectionTab.h"
  15. #include "../CGameInfo.h"
  16. #include "../CServerHandler.h"
  17. #include "../gui/CGuiHandler.h"
  18. #include "../gui/MouseButton.h"
  19. #include "../gui/WindowHandler.h"
  20. #include "../widgets/CComponent.h"
  21. #include "../widgets/ComboBox.h"
  22. #include "../widgets/Buttons.h"
  23. #include "../widgets/MiscWidgets.h"
  24. #include "../widgets/ObjectLists.h"
  25. #include "../widgets/Slider.h"
  26. #include "../widgets/TextControls.h"
  27. #include "../windows/GUIClasses.h"
  28. #include "../windows/InfoWindows.h"
  29. #include "../../lib/CGeneralTextHandler.h"
  30. #include "../../lib/mapping/CMapInfo.h"
  31. #include "../../lib/mapping/CMapHeader.h"
  32. #include "../../lib/mapping/MapFormat.h"
  33. #include "../../lib/rmg/CMapGenOptions.h"
  34. #include "../../lib/rmg/CRmgTemplateStorage.h"
  35. #include "../../lib/filesystem/Filesystem.h"
  36. #include "../../lib/RoadHandler.h"
  37. RandomMapTab::RandomMapTab():
  38. InterfaceObjectConfigurable()
  39. {
  40. recActions = 0;
  41. mapGenOptions = std::make_shared<CMapGenOptions>();
  42. addCallback("toggleMapSize", [&](int btnId)
  43. {
  44. auto mapSizeVal = getPossibleMapSizes();
  45. mapGenOptions->setWidth(mapSizeVal[btnId]);
  46. mapGenOptions->setHeight(mapSizeVal[btnId]);
  47. if(mapGenOptions->getMapTemplate())
  48. if(!mapGenOptions->getMapTemplate()->matchesSize(int3{mapGenOptions->getWidth(), mapGenOptions->getHeight(), 1 + mapGenOptions->getHasTwoLevels()}))
  49. setTemplate(nullptr);
  50. updateMapInfoByHost();
  51. });
  52. addCallback("toggleTwoLevels", [&](bool on)
  53. {
  54. mapGenOptions->setHasTwoLevels(on);
  55. if(mapGenOptions->getMapTemplate())
  56. if(!mapGenOptions->getMapTemplate()->matchesSize(int3{mapGenOptions->getWidth(), mapGenOptions->getHeight(), 1 + mapGenOptions->getHasTwoLevels()}))
  57. setTemplate(nullptr);
  58. updateMapInfoByHost();
  59. });
  60. addCallback("setPlayersCount", [&](int btnId)
  61. {
  62. mapGenOptions->setHumanOrCpuPlayerCount(btnId);
  63. setMapGenOptions(mapGenOptions);
  64. updateMapInfoByHost();
  65. });
  66. addCallback("setTeamsCount", [&](int btnId)
  67. {
  68. mapGenOptions->setTeamCount(btnId);
  69. updateMapInfoByHost();
  70. });
  71. addCallback("setCompOnlyPlayers", [&](int btnId)
  72. {
  73. mapGenOptions->setCompOnlyPlayerCount(btnId);
  74. setMapGenOptions(mapGenOptions);
  75. updateMapInfoByHost();
  76. });
  77. addCallback("setCompOnlyTeams", [&](int btnId)
  78. {
  79. mapGenOptions->setCompOnlyTeamCount(btnId);
  80. updateMapInfoByHost();
  81. });
  82. addCallback("setWaterContent", [&](int btnId)
  83. {
  84. mapGenOptions->setWaterContent(static_cast<EWaterContent::EWaterContent>(btnId));
  85. updateMapInfoByHost();
  86. });
  87. addCallback("setMonsterStrength", [&](int btnId)
  88. {
  89. if(btnId < 0)
  90. mapGenOptions->setMonsterStrength(EMonsterStrength::RANDOM);
  91. else
  92. mapGenOptions->setMonsterStrength(static_cast<EMonsterStrength::EMonsterStrength>(btnId)); //value 2 to 4
  93. updateMapInfoByHost();
  94. });
  95. //new callbacks available only from mod
  96. addCallback("teamAlignments", [&](int)
  97. {
  98. GH.windows().createAndPushWindow<TeamAlignments>(*this);
  99. });
  100. for(auto road : VLC->roadTypeHandler->objects)
  101. {
  102. std::string cbRoadType = "selectRoad_" + road->getJsonKey();
  103. addCallback(cbRoadType, [&, road](bool on)
  104. {
  105. mapGenOptions->setRoadEnabled(road->getId(), on);
  106. updateMapInfoByHost();
  107. });
  108. }
  109. const JsonNode config(JsonPath::builtin("config/widgets/randomMapTab.json"));
  110. build(config);
  111. if(auto w = widget<CButton>("buttonShowRandomMaps"))
  112. {
  113. w->addCallback([&]()
  114. {
  115. (static_cast<CLobbyScreen *>(parent))->toggleTab((static_cast<CLobbyScreen *>(parent))->tabSel);
  116. (static_cast<CLobbyScreen *>(parent))->tabSel->showRandom = true;
  117. (static_cast<CLobbyScreen *>(parent))->tabSel->filter(0, true);
  118. });
  119. }
  120. //set combo box callbacks
  121. if(auto w = widget<ComboBox>("templateList"))
  122. {
  123. w->onConstructItems = [](std::vector<const void *> & curItems){
  124. auto templates = VLC->tplh->getTemplates();
  125. boost::range::sort(templates, [](const CRmgTemplate * a, const CRmgTemplate * b){
  126. return a->getName() < b->getName();
  127. });
  128. curItems.push_back(nullptr); //default template
  129. for(auto & t : templates)
  130. curItems.push_back(t);
  131. };
  132. w->onSetItem = [&](const void * item){
  133. this->setTemplate(reinterpret_cast<const CRmgTemplate *>(item));
  134. };
  135. w->getItemText = [this](int idx, const void * item){
  136. if(item)
  137. return reinterpret_cast<const CRmgTemplate *>(item)->getName();
  138. if(idx == 0)
  139. return readText(variables["randomTemplate"]);
  140. return std::string("");
  141. };
  142. }
  143. updateMapInfoByHost();
  144. }
  145. void RandomMapTab::updateMapInfoByHost()
  146. {
  147. if(CSH->isGuest())
  148. return;
  149. // Generate header info
  150. mapInfo = std::make_shared<CMapInfo>();
  151. mapInfo->isRandomMap = true;
  152. mapInfo->mapHeader = std::make_unique<CMapHeader>();
  153. mapInfo->mapHeader->version = EMapFormat::VCMI;
  154. mapInfo->mapHeader->name.appendLocalString(EMetaText::GENERAL_TXT, 740);
  155. mapInfo->mapHeader->description.appendLocalString(EMetaText::GENERAL_TXT, 741);
  156. const auto * temp = mapGenOptions->getMapTemplate();
  157. if (temp)
  158. {
  159. auto randomTemplateDescription = temp->getDescription();
  160. if (!randomTemplateDescription.empty())
  161. {
  162. auto description = std::string("\n\n") + randomTemplateDescription;
  163. mapInfo->mapHeader->description.appendRawString(description);
  164. }
  165. }
  166. mapInfo->mapHeader->difficulty = EMapDifficulty::NORMAL;
  167. mapInfo->mapHeader->height = mapGenOptions->getHeight();
  168. mapInfo->mapHeader->width = mapGenOptions->getWidth();
  169. mapInfo->mapHeader->twoLevel = mapGenOptions->getHasTwoLevels();
  170. // Generate player information
  171. int playersToGen = mapGenOptions->getMaxPlayersCount();
  172. mapInfo->mapHeader->howManyTeams = playersToGen;
  173. //TODO: Assign all human-controlled colors in first place
  174. for(int i = 0; i < PlayerColor::PLAYER_LIMIT_I; ++i)
  175. {
  176. mapInfo->mapHeader->players[i].canComputerPlay = false;
  177. mapInfo->mapHeader->players[i].canHumanPlay = false;
  178. }
  179. std::vector<PlayerColor> availableColors;
  180. for (ui8 color = 0; color < PlayerColor::PLAYER_LIMIT_I; color++)
  181. {
  182. availableColors.push_back(PlayerColor(color));
  183. }
  184. //First restore known players
  185. for (auto& player : mapGenOptions->getPlayersSettings())
  186. {
  187. PlayerInfo playerInfo;
  188. playerInfo.isFactionRandom = (player.second.getStartingTown() == FactionID::RANDOM);
  189. playerInfo.canComputerPlay = (player.second.getPlayerType() != EPlayerType::HUMAN);
  190. playerInfo.canHumanPlay = (player.second.getPlayerType() != EPlayerType::COMP_ONLY);
  191. auto team = player.second.getTeam();
  192. playerInfo.team = team;
  193. playerInfo.hasMainTown = true;
  194. playerInfo.generateHeroAtMainTown = true;
  195. mapInfo->mapHeader->players[player.first] = playerInfo;
  196. vstd::erase(availableColors, player.first);
  197. }
  198. mapInfoChanged(mapInfo, mapGenOptions);
  199. }
  200. void RandomMapTab::setMapGenOptions(std::shared_ptr<CMapGenOptions> opts)
  201. {
  202. mapGenOptions = opts;
  203. //Prepare allowed options - add all, then erase the ones above the limit
  204. for(int i = 0; i <= PlayerColor::PLAYER_LIMIT_I; ++i)
  205. {
  206. playerCountAllowed.insert(i);
  207. compCountAllowed.insert(i);
  208. if (i >= 2)
  209. {
  210. playerTeamsAllowed.insert(i);
  211. }
  212. if (i >= 1)
  213. {
  214. compTeamsAllowed.insert(i);
  215. }
  216. }
  217. std::set<int> humanCountAllowed;
  218. auto * tmpl = mapGenOptions->getMapTemplate();
  219. if(tmpl)
  220. {
  221. playerCountAllowed = tmpl->getPlayers().getNumbers();
  222. humanCountAllowed = tmpl->getHumanPlayers().getNumbers(); // Unused now?
  223. }
  224. si8 playerLimit = opts->getMaxPlayersCount();
  225. si8 humanOrCpuPlayerCount = opts->getHumanOrCpuPlayerCount();
  226. si8 compOnlyPlayersCount = opts->getCompOnlyPlayerCount();
  227. if(humanOrCpuPlayerCount != CMapGenOptions::RANDOM_SIZE)
  228. {
  229. vstd::erase_if(compCountAllowed, [playerLimit, humanOrCpuPlayerCount](int el)
  230. {
  231. return (playerLimit - humanOrCpuPlayerCount) < el;
  232. });
  233. vstd::erase_if(playerTeamsAllowed, [humanOrCpuPlayerCount](int el)
  234. {
  235. return humanOrCpuPlayerCount <= el;
  236. });
  237. }
  238. else // Random
  239. {
  240. vstd::erase_if(compCountAllowed, [playerLimit](int el)
  241. {
  242. return (playerLimit - 1) < el; // Must leave at least 1 human player
  243. });
  244. vstd::erase_if(playerTeamsAllowed, [playerLimit](int el)
  245. {
  246. return playerLimit <= el;
  247. });
  248. }
  249. if(!playerTeamsAllowed.count(opts->getTeamCount()))
  250. {
  251. opts->setTeamCount(CMapGenOptions::RANDOM_SIZE);
  252. }
  253. if(compOnlyPlayersCount != CMapGenOptions::RANDOM_SIZE)
  254. {
  255. // This setting doesn't impact total number of players
  256. vstd::erase_if(compTeamsAllowed, [compOnlyPlayersCount](int el)
  257. {
  258. return compOnlyPlayersCount<= el;
  259. });
  260. if(!compTeamsAllowed.count(opts->getCompOnlyTeamCount()))
  261. {
  262. opts->setCompOnlyTeamCount(CMapGenOptions::RANDOM_SIZE);
  263. }
  264. }
  265. if(auto w = widget<CToggleGroup>("groupMapSize"))
  266. {
  267. for(auto toggle : w->buttons)
  268. {
  269. if(auto button = std::dynamic_pointer_cast<CToggleButton>(toggle.second))
  270. {
  271. const auto & mapSizes = getPossibleMapSizes();
  272. int3 size( mapSizes[toggle.first], mapSizes[toggle.first], 1 + mapGenOptions->getHasTwoLevels());
  273. bool sizeAllowed = !mapGenOptions->getMapTemplate() || mapGenOptions->getMapTemplate()->matchesSize(size);
  274. button->block(!sizeAllowed);
  275. }
  276. }
  277. w->setSelected(vstd::find_pos(getPossibleMapSizes(), opts->getWidth()));
  278. }
  279. if(auto w = widget<CToggleButton>("buttonTwoLevels"))
  280. {
  281. int3 size( opts->getWidth(), opts->getWidth(), 2);
  282. bool undergoundAllowed = !mapGenOptions->getMapTemplate() || mapGenOptions->getMapTemplate()->matchesSize(size);
  283. w->setSelected(opts->getHasTwoLevels());
  284. w->block(!undergoundAllowed);
  285. }
  286. if(auto w = widget<CToggleGroup>("groupMaxPlayers"))
  287. {
  288. w->setSelected(opts->getHumanOrCpuPlayerCount());
  289. deactivateButtonsFrom(*w, playerCountAllowed);
  290. }
  291. if(auto w = widget<CToggleGroup>("groupMaxTeams"))
  292. {
  293. w->setSelected(opts->getTeamCount());
  294. deactivateButtonsFrom(*w, playerTeamsAllowed);
  295. }
  296. if(auto w = widget<CToggleGroup>("groupCompOnlyPlayers"))
  297. {
  298. w->setSelected(opts->getCompOnlyPlayerCount());
  299. deactivateButtonsFrom(*w, compCountAllowed);
  300. }
  301. if(auto w = widget<CToggleGroup>("groupCompOnlyTeams"))
  302. {
  303. w->setSelected(opts->getCompOnlyTeamCount());
  304. deactivateButtonsFrom(*w, compTeamsAllowed);
  305. }
  306. if(auto w = widget<CToggleGroup>("groupWaterContent"))
  307. {
  308. w->setSelected(opts->getWaterContent());
  309. if(opts->getMapTemplate())
  310. {
  311. std::set<int> allowedWater(opts->getMapTemplate()->getWaterContentAllowed().begin(), opts->getMapTemplate()->getWaterContentAllowed().end());
  312. deactivateButtonsFrom(*w, allowedWater);
  313. }
  314. else
  315. deactivateButtonsFrom(*w, {-1});
  316. }
  317. if(auto w = widget<CToggleGroup>("groupMonsterStrength"))
  318. w->setSelected(opts->getMonsterStrength());
  319. if(auto w = widget<CButton>("templateButton"))
  320. {
  321. if(tmpl)
  322. w->addTextOverlay(tmpl->getName(), EFonts::FONT_SMALL, Colors::WHITE);
  323. else
  324. w->addTextOverlay(readText(variables["randomTemplate"]), EFonts::FONT_SMALL, Colors::WHITE);
  325. }
  326. for(auto r : VLC->roadTypeHandler->objects)
  327. {
  328. // Workaround for vcmi-extras bug
  329. std::string jsonKey = r->getJsonKey();
  330. std::string identifier = jsonKey.substr(jsonKey.find(':')+1);
  331. if(auto w = widget<CToggleButton>(identifier))
  332. {
  333. w->setSelected(opts->isRoadEnabled(r->getId()));
  334. }
  335. }
  336. }
  337. void RandomMapTab::setTemplate(const CRmgTemplate * tmpl)
  338. {
  339. mapGenOptions->setMapTemplate(tmpl);
  340. setMapGenOptions(mapGenOptions);
  341. if(auto w = widget<CButton>("templateButton"))
  342. {
  343. if(tmpl)
  344. w->addTextOverlay(tmpl->getName(), EFonts::FONT_SMALL, Colors::WHITE);
  345. else
  346. w->addTextOverlay(readText(variables["randomTemplate"]), EFonts::FONT_SMALL, Colors::WHITE);
  347. }
  348. updateMapInfoByHost();
  349. }
  350. void RandomMapTab::deactivateButtonsFrom(CToggleGroup & group, const std::set<int> & allowed)
  351. {
  352. logGlobal->debug("Blocking buttons");
  353. for(auto toggle : group.buttons)
  354. {
  355. if(auto button = std::dynamic_pointer_cast<CToggleButton>(toggle.second))
  356. {
  357. if(allowed.count(CMapGenOptions::RANDOM_SIZE)
  358. || allowed.count(toggle.first)
  359. || toggle.first == CMapGenOptions::RANDOM_SIZE)
  360. {
  361. button->block(false);
  362. }
  363. else
  364. {
  365. button->block(true);
  366. }
  367. }
  368. }
  369. }
  370. std::vector<int> RandomMapTab::getPossibleMapSizes()
  371. {
  372. return {CMapHeader::MAP_SIZE_SMALL, CMapHeader::MAP_SIZE_MIDDLE, CMapHeader::MAP_SIZE_LARGE, CMapHeader::MAP_SIZE_XLARGE, CMapHeader::MAP_SIZE_HUGE, CMapHeader::MAP_SIZE_XHUGE, CMapHeader::MAP_SIZE_GIANT};
  373. }
  374. void TeamAlignmentsWidget::checkTeamCount()
  375. {
  376. //Do not allow to select one team only
  377. std::set<TeamID> teams;
  378. for (int plId = 0; plId < players.size(); ++plId)
  379. {
  380. teams.insert(TeamID(players[plId]->getSelected()));
  381. }
  382. if (teams.size() < 2)
  383. {
  384. //Do not let player close the window
  385. buttonOk->block(true);
  386. }
  387. else
  388. {
  389. buttonOk->block(false);
  390. }
  391. }
  392. TeamAlignments::TeamAlignments(RandomMapTab & randomMapTab)
  393. : CWindowObject(BORDERED)
  394. {
  395. OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
  396. widget = std::make_shared<TeamAlignmentsWidget>(randomMapTab);
  397. pos = widget->pos;
  398. updateShadow();
  399. center();
  400. }
  401. TeamAlignmentsWidget::TeamAlignmentsWidget(RandomMapTab & randomMapTab):
  402. InterfaceObjectConfigurable()
  403. {
  404. const JsonNode config(JsonPath::builtin("config/widgets/randomMapTeamsWidget.json"));
  405. variables = config["variables"];
  406. //int totalPlayers = randomMapTab.obtainMapGenOptions().getPlayerLimit();
  407. int totalPlayers = randomMapTab.obtainMapGenOptions().getMaxPlayersCount();
  408. assert(totalPlayers <= PlayerColor::PLAYER_LIMIT_I);
  409. auto settings = randomMapTab.obtainMapGenOptions().getPlayersSettings();
  410. variables["totalPlayers"].Integer() = totalPlayers;
  411. pos.w = variables["windowSize"]["x"].Integer() + totalPlayers * variables["cellMargin"]["x"].Integer();
  412. pos.h = variables["windowSize"]["y"].Integer() + totalPlayers * variables["cellMargin"]["y"].Integer();
  413. variables["backgroundRect"]["x"].Integer() = 0;
  414. variables["backgroundRect"]["y"].Integer() = 0;
  415. variables["backgroundRect"]["w"].Integer() = pos.w;
  416. variables["backgroundRect"]["h"].Integer() = pos.h;
  417. variables["okButtonPosition"]["x"].Integer() = variables["buttonsOffset"]["ok"]["x"].Integer();
  418. variables["okButtonPosition"]["y"].Integer() = variables["buttonsOffset"]["ok"]["y"].Integer() + totalPlayers * variables["cellMargin"]["y"].Integer();
  419. variables["cancelButtonPosition"]["x"].Integer() = variables["buttonsOffset"]["cancel"]["x"].Integer();
  420. variables["cancelButtonPosition"]["y"].Integer() = variables["buttonsOffset"]["cancel"]["y"].Integer() + totalPlayers * variables["cellMargin"]["y"].Integer();
  421. addCallback("ok", [&](int)
  422. {
  423. for(int plId = 0; plId < players.size(); ++plId)
  424. {
  425. randomMapTab.obtainMapGenOptions().setPlayerTeam(PlayerColor(plId), TeamID(players[plId]->getSelected()));
  426. }
  427. randomMapTab.updateMapInfoByHost();
  428. for(auto & window : GH.windows().findWindows<TeamAlignments>())
  429. GH.windows().popWindow(window);
  430. });
  431. addCallback("cancel", [&](int)
  432. {
  433. for(auto & window : GH.windows().findWindows<TeamAlignments>())
  434. GH.windows().popWindow(window);
  435. });
  436. build(config);
  437. center(pos);
  438. OBJ_CONSTRUCTION;
  439. // Window should have X * X columns, where X is max players allowed for current settings
  440. // For random player count, X is 8
  441. if (totalPlayers > settings.size())
  442. {
  443. auto savedPlayers = randomMapTab.obtainMapGenOptions().getSavedPlayersMap();
  444. for (const auto & player : savedPlayers)
  445. {
  446. if (!vstd::contains(settings, player.first))
  447. {
  448. settings[player.first] = player.second;
  449. }
  450. }
  451. }
  452. std::vector<CMapGenOptions::CPlayerSettings> settingsVec;
  453. for (const auto & player : settings)
  454. {
  455. settingsVec.push_back(player.second);
  456. }
  457. for(int plId = 0; plId < totalPlayers; ++plId)
  458. {
  459. players.push_back(std::make_shared<CToggleGroup>([&, totalPlayers, plId](int sel)
  460. {
  461. variables["player_id"].Integer() = plId;
  462. OBJ_CONSTRUCTION_TARGETED(players[plId].get());
  463. for(int teamId = 0; teamId < totalPlayers; ++teamId)
  464. {
  465. auto button = std::dynamic_pointer_cast<CToggleButton>(players[plId]->buttons[teamId]);
  466. assert(button);
  467. if(sel == teamId)
  468. {
  469. button->addOverlay(buildWidget(variables["flagsAnimation"]));
  470. }
  471. else
  472. {
  473. button->addOverlay(nullptr);
  474. }
  475. button->addCallback([this](bool)
  476. {
  477. checkTeamCount();
  478. });
  479. }
  480. }));
  481. OBJ_CONSTRUCTION_TARGETED(players.back().get());
  482. for(int teamId = 0; teamId < totalPlayers; ++teamId)
  483. {
  484. variables["point"]["x"].Integer() = variables["cellOffset"]["x"].Integer() + plId * variables["cellMargin"]["x"].Integer();
  485. variables["point"]["y"].Integer() = variables["cellOffset"]["y"].Integer() + teamId * variables["cellMargin"]["y"].Integer();
  486. auto button = buildWidget(variables["button"]);
  487. players.back()->addToggle(teamId, std::dynamic_pointer_cast<CToggleBase>(button));
  488. }
  489. // plId is not neccessarily player color, just an index
  490. auto team = settingsVec.at(plId).getTeam();
  491. if(team == TeamID::NO_TEAM)
  492. {
  493. logGlobal->warn("Player %d (id %d) has uninitialized team", settingsVec.at(plId).getColor(), plId);
  494. players.back()->setSelected(plId);
  495. }
  496. else
  497. players.back()->setSelected(team.getNum());
  498. }
  499. buttonOk = widget<CButton>("buttonOK");
  500. buttonCancel = widget<CButton>("buttonCancel");
  501. }