CSelectionBase.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. /*
  2. * CSelectionBase.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 "CSelectionBase.h"
  12. #include "CBonusSelection.h"
  13. #include "CLobbyScreen.h"
  14. #include "OptionsTab.h"
  15. #include "RandomMapTab.h"
  16. #include "SelectionTab.h"
  17. #include "../../CCallback.h"
  18. #include "../CGameInfo.h"
  19. #include "../CPlayerInterface.h"
  20. #include "../CMusicHandler.h"
  21. #include "../CVideoHandler.h"
  22. #include "../CServerHandler.h"
  23. #include "../gui/CGuiHandler.h"
  24. #include "../gui/Shortcut.h"
  25. #include "../gui/WindowHandler.h"
  26. #include "../globalLobby/GlobalLobbyClient.h"
  27. #include "../mainmenu/CMainMenu.h"
  28. #include "../widgets/Buttons.h"
  29. #include "../widgets/CComponent.h"
  30. #include "../widgets/GraphicalPrimitiveCanvas.h"
  31. #include "../widgets/ObjectLists.h"
  32. #include "../widgets/Slider.h"
  33. #include "../widgets/TextControls.h"
  34. #include "../windows/GUIClasses.h"
  35. #include "../windows/InfoWindows.h"
  36. #include "../render/CAnimation.h"
  37. #include "../render/Graphics.h"
  38. #include "../render/IFont.h"
  39. #include "../render/IRenderHandler.h"
  40. #include "../../lib/CGeneralTextHandler.h"
  41. #include "../../lib/CHeroHandler.h"
  42. #include "../../lib/CRandomGenerator.h"
  43. #include "../../lib/CThreadHelper.h"
  44. #include "../../lib/MetaString.h"
  45. #include "../../lib/filesystem/Filesystem.h"
  46. #include "../../lib/mapping/CMapHeader.h"
  47. #include "../../lib/mapping/CMapInfo.h"
  48. #include "../../lib/networkPacks/PacksForLobby.h"
  49. ISelectionScreenInfo::ISelectionScreenInfo(ESelectionScreen ScreenType)
  50. : screenType(ScreenType)
  51. {
  52. assert(!SEL);
  53. SEL = this;
  54. }
  55. ISelectionScreenInfo::~ISelectionScreenInfo()
  56. {
  57. assert(SEL == this);
  58. SEL = nullptr;
  59. }
  60. int ISelectionScreenInfo::getCurrentDifficulty()
  61. {
  62. return getStartInfo()->difficulty;
  63. }
  64. PlayerInfo ISelectionScreenInfo::getPlayerInfo(PlayerColor color)
  65. {
  66. return getMapInfo()->mapHeader->players.at(color.getNum());
  67. }
  68. CSelectionBase::CSelectionBase(ESelectionScreen type)
  69. : CWindowObject(BORDERED | SHADOW_DISABLED), ISelectionScreenInfo(type)
  70. {
  71. OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
  72. pos.w = 762;
  73. pos.h = 584;
  74. if(screenType == ESelectionScreen::campaignList)
  75. {
  76. setBackground(ImagePath::builtin("CamCust.bmp"));
  77. }
  78. else
  79. {
  80. const JsonVector & bgNames = CMainMenuConfig::get().getConfig()["game-select"].Vector();
  81. setBackground(ImagePath::fromJson(*RandomGeneratorUtil::nextItem(bgNames, CRandomGenerator::getDefault())));
  82. }
  83. pos = background->center();
  84. card = std::make_shared<InfoCard>();
  85. buttonBack = std::make_shared<CButton>(Point(581, 535), AnimationPath::builtin("SCNRBACK.DEF"), CGI->generaltexth->zelp[105], [=](){ close();}, EShortcut::GLOBAL_CANCEL);
  86. }
  87. void CSelectionBase::toggleTab(std::shared_ptr<CIntObject> tab)
  88. {
  89. if(curTab && curTab->isActive())
  90. {
  91. curTab->deactivate();
  92. curTab->recActions = 0;
  93. }
  94. if(curTab != tab)
  95. {
  96. tab->recActions = 255 - DISPOSE;
  97. tab->activate();
  98. curTab = tab;
  99. }
  100. else
  101. {
  102. curTab.reset();
  103. }
  104. if(tabSel->showRandom && tab != tabOpt)
  105. {
  106. tabSel->curFolder = "";
  107. tabSel->showRandom = false;
  108. tabSel->filter(0, true);
  109. }
  110. GH.windows().totalRedraw();
  111. }
  112. InfoCard::InfoCard()
  113. : chatMode(ChatMode::Enabled)
  114. {
  115. OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
  116. setRedrawParent(true);
  117. pos.x += 393;
  118. pos.y += 6;
  119. labelSaveDate = std::make_shared<CLabel>(310, 38, FONT_SMALL, ETextAlignment::BOTTOMRIGHT, Colors::WHITE);
  120. labelMapSize = std::make_shared<CLabel>(333, 56, FONT_TINY, ETextAlignment::CENTER, Colors::WHITE);
  121. mapName = std::make_shared<CLabel>(26, 39, FONT_BIG, ETextAlignment::TOPLEFT, Colors::YELLOW);
  122. Rect descriptionRect(26, 149, 320, 115);
  123. mapDescription = std::make_shared<CTextBox>("", descriptionRect, 1);
  124. playerListBg = std::make_shared<CPicture>(ImagePath::builtin("CHATPLUG.bmp"), 16, 276);
  125. chat = std::make_shared<CChatBox>(Rect(18, 126, 335, 143));
  126. pvpBox = std::make_shared<PvPBox>(Rect(18, 126, 335, 262));
  127. buttonInvitePlayers = std::make_shared<CButton>(Point(20, 365), AnimationPath::builtin("pregameInvitePlayers"), CGI->generaltexth->zelp[105], [](){ CSH->getGlobalLobby().activateRoomInviteInterface(); } );
  128. buttonOpenGlobalLobby = std::make_shared<CButton>(Point(188, 365), AnimationPath::builtin("pregameReturnToLobby"), CGI->generaltexth->zelp[105], [](){ CSH->getGlobalLobby().activateInterface(); });
  129. buttonInvitePlayers->setTextOverlay (MetaString::createFromTextID("vcmi.lobby.invite.header").toString(), EFonts::FONT_SMALL, Colors::WHITE);
  130. buttonOpenGlobalLobby->setTextOverlay(MetaString::createFromTextID("vcmi.lobby.backToLobby").toString(), EFonts::FONT_SMALL, Colors::WHITE);
  131. if(SEL->screenType == ESelectionScreen::campaignList)
  132. {
  133. labelCampaignDescription = std::make_shared<CLabel>(26, 132, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[38]);
  134. }
  135. else
  136. {
  137. background = std::make_shared<CPicture>(ImagePath::builtin("GSELPOP1.bmp"), 0, 0);
  138. parent->addChild(background.get());
  139. auto it = vstd::find(parent->children, this); //our position among parent children
  140. parent->children.insert(it, background.get()); //put BG before us
  141. parent->children.pop_back();
  142. pos.w = background->pos.w;
  143. pos.h = background->pos.h;
  144. iconsMapSizes = std::make_shared<CAnimImage>(AnimationPath::builtin("SCNRMPSZ"), 4, 0, 318, 22); //let it be custom size (frame 4) by default
  145. iconDifficulty = std::make_shared<CToggleGroup>(0);
  146. {
  147. constexpr std::array difButns = {"GSPBUT3.DEF", "GSPBUT4.DEF", "GSPBUT5.DEF", "GSPBUT6.DEF", "GSPBUT7.DEF"};
  148. for(int i = 0; i < 5; i++)
  149. {
  150. auto button = std::make_shared<CToggleButton>(Point(110 + i * 32, 450), AnimationPath::builtin(difButns[i]), CGI->generaltexth->zelp[24 + i]);
  151. iconDifficulty->addToggle(i, button);
  152. if(SEL->screenType != ESelectionScreen::newGame)
  153. button->block(true);
  154. }
  155. }
  156. flagbox = std::make_shared<CFlagBox>(Rect(24, 400, 335, 23));
  157. labelMapDiff = std::make_shared<CLabel>(33, 430, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[494]);
  158. labelPlayerDifficulty = std::make_shared<CLabel>(133, 430, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[492] + ":");
  159. labelRating = std::make_shared<CLabel>(290, 430, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[218] + ":");
  160. labelScenarioName = std::make_shared<CLabel>(26, 22, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[495]);
  161. labelScenarioDescription = std::make_shared<CLabel>(26, 132, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[496]);
  162. labelVictoryCondition = std::make_shared<CLabel>(26, 283, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[497]);
  163. labelLossCondition = std::make_shared<CLabel>(26, 339, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[498]);
  164. iconsVictoryCondition = std::make_shared<CAnimImage>(AnimationPath::builtin("SCNRVICT"), 0, 0, 24, 302);
  165. iconsLossCondition = std::make_shared<CAnimImage>(AnimationPath::builtin("SCNRLOSS"), 0, 0, 24, 359);
  166. labelVictoryConditionText = std::make_shared<CLabel>(60, 307, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
  167. labelLossConditionText = std::make_shared<CLabel>(60, 366, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
  168. labelDifficulty = std::make_shared<CLabel>(62, 472, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
  169. labelDifficultyPercent = std::make_shared<CLabel>(311, 472, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
  170. labelGroupPlayers = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
  171. disableLabelRedraws();
  172. }
  173. setChat(ChatMode::Disabled);
  174. if (CSH->inLobbyRoom())
  175. setChat(ChatMode::Enabled); // FIXME: less ugly version?
  176. }
  177. void InfoCard::disableLabelRedraws()
  178. {
  179. labelSaveDate->setAutoRedraw(false);
  180. labelMapSize->setAutoRedraw(false);
  181. mapName->setAutoRedraw(false);
  182. mapDescription->label->setAutoRedraw(false);
  183. labelVictoryConditionText->setAutoRedraw(false);
  184. labelLossConditionText->setAutoRedraw(false);
  185. labelDifficulty->setAutoRedraw(false);
  186. labelDifficultyPercent->setAutoRedraw(false);
  187. }
  188. void InfoCard::changeSelection()
  189. {
  190. auto mapInfo = SEL->getMapInfo();
  191. if(!mapInfo)
  192. return;
  193. labelSaveDate->setText(mapInfo->date);
  194. mapName->setText(mapInfo->getNameTranslated());
  195. mapDescription->setText(mapInfo->getDescriptionTranslated());
  196. mapDescription->label->scrollTextTo(0, false);
  197. if(mapDescription->slider)
  198. mapDescription->slider->scrollToMin();
  199. if(SEL->screenType == ESelectionScreen::campaignList)
  200. return;
  201. const CMapHeader * header = mapInfo->mapHeader.get();
  202. labelMapSize->setText(std::to_string(header->width) + "x" + std::to_string(header->height));
  203. iconsMapSizes->setFrame(mapInfo->getMapSizeIconId());
  204. iconsVictoryCondition->setFrame(header->victoryIconIndex);
  205. labelVictoryConditionText->setText(header->victoryMessage.toString());
  206. iconsLossCondition->setFrame(header->defeatIconIndex);
  207. labelLossConditionText->setText(header->defeatMessage.toString());
  208. flagbox->recreate();
  209. labelDifficulty->setText(CGI->generaltexth->arraytxt[142 + vstd::to_underlying(mapInfo->mapHeader->difficulty)]);
  210. iconDifficulty->setSelected(SEL->getCurrentDifficulty());
  211. if(SEL->screenType == ESelectionScreen::loadGame || SEL->screenType == ESelectionScreen::saveGame)
  212. for(auto & button : iconDifficulty->buttons)
  213. button.second->setEnabled(button.first == SEL->getCurrentDifficulty());
  214. const std::array<std::string, 5> difficultyPercent = {"80%", "100%", "130%", "160%", "200%"};
  215. labelDifficultyPercent->setText(difficultyPercent[SEL->getCurrentDifficulty()]);
  216. OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
  217. // FIXME: We recreate them each time because CLabelGroup don't use smart pointers
  218. labelGroupPlayers = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
  219. if(chatMode != ChatMode::Enabled)
  220. labelGroupPlayers->disable();
  221. for(const auto & p : CSH->playerNames)
  222. {
  223. int slotsUsed = labelGroupPlayers->currentSize();
  224. Point labelPosition;
  225. if(slotsUsed < 4)
  226. labelPosition = Point(24, 285 + slotsUsed * graphics->fonts[FONT_SMALL]->getLineHeight()); // left column
  227. else
  228. labelPosition = Point(193, 285 + (slotsUsed - 4) * graphics->fonts[FONT_SMALL]->getLineHeight()); // right column
  229. labelGroupPlayers->add(labelPosition.x, labelPosition.y, p.second.name);
  230. }
  231. }
  232. void InfoCard::setChat(ChatMode setMode)
  233. {
  234. if(chatMode == setMode)
  235. return;
  236. switch(setMode)
  237. {
  238. case InfoCard::ChatMode::Enabled:
  239. if(SEL->screenType == ESelectionScreen::campaignList)
  240. {
  241. labelCampaignDescription->disable();
  242. }
  243. else
  244. {
  245. labelScenarioDescription->disable();
  246. labelVictoryCondition->disable();
  247. labelLossCondition->disable();
  248. iconsVictoryCondition->disable();
  249. labelVictoryConditionText->disable();
  250. iconsLossCondition->disable();
  251. labelLossConditionText->disable();
  252. labelGroupPlayers->enable();
  253. }
  254. if (CSH->inLobbyRoom())
  255. {
  256. buttonInvitePlayers->enable();
  257. buttonOpenGlobalLobby->enable();
  258. }
  259. mapDescription->disable();
  260. chat->enable();
  261. pvpBox->disable();
  262. playerListBg->enable();
  263. break;
  264. case InfoCard::ChatMode::Disabled:
  265. buttonInvitePlayers->disable();
  266. buttonOpenGlobalLobby->disable();
  267. mapDescription->enable();
  268. chat->disable();
  269. pvpBox->disable();
  270. playerListBg->disable();
  271. if(SEL->screenType == ESelectionScreen::campaignList)
  272. {
  273. labelCampaignDescription->enable();
  274. }
  275. else
  276. {
  277. labelScenarioDescription->enable();
  278. labelVictoryCondition->enable();
  279. labelLossCondition->enable();
  280. iconsVictoryCondition->enable();
  281. iconsLossCondition->enable();
  282. labelVictoryConditionText->enable();
  283. labelLossConditionText->enable();
  284. labelGroupPlayers->disable();
  285. }
  286. break;
  287. case InfoCard::ChatMode::PvP:
  288. buttonInvitePlayers->disable();
  289. buttonOpenGlobalLobby->disable();
  290. mapDescription->disable();
  291. chat->disable();
  292. pvpBox->enable();
  293. playerListBg->enable();
  294. if(SEL->screenType == ESelectionScreen::campaignList)
  295. {
  296. labelCampaignDescription->disable();
  297. }
  298. else
  299. {
  300. labelScenarioDescription->disable();
  301. labelVictoryCondition->disable();
  302. labelLossCondition->disable();
  303. iconsVictoryCondition->disable();
  304. iconsLossCondition->disable();
  305. labelVictoryConditionText->disable();
  306. labelLossConditionText->disable();
  307. labelGroupPlayers->disable();
  308. }
  309. break;
  310. }
  311. chatMode = setMode;
  312. GH.windows().totalRedraw();
  313. }
  314. CChatBox::CChatBox(const Rect & rect)
  315. : CIntObject(KEYBOARD | TEXTINPUT)
  316. {
  317. OBJ_CONSTRUCTION;
  318. pos += rect.topLeft();
  319. setRedrawParent(true);
  320. const int height = static_cast<int>(graphics->fonts[FONT_SMALL]->getLineHeight());
  321. Rect textInputArea(1, rect.h - height, rect.w - 1, height);
  322. Rect chatHistoryArea(3, 1, rect.w - 3, rect.h - height - 1);
  323. inputBackground = std::make_shared<TransparentFilledRectangle>(textInputArea, ColorRGBA(0,0,0,192));
  324. inputBox = std::make_shared<CTextInput>(textInputArea, EFonts::FONT_SMALL, nullptr, ETextAlignment::TOPLEFT, true);
  325. inputBox->removeUsedEvents(KEYBOARD);
  326. chatHistory = std::make_shared<CTextBox>("", chatHistoryArea, 1);
  327. chatHistory->label->color = Colors::GREEN;
  328. }
  329. bool CChatBox::captureThisKey(EShortcut key)
  330. {
  331. return !inputBox->getText().empty() && key == EShortcut::GLOBAL_ACCEPT;
  332. }
  333. void CChatBox::keyPressed(EShortcut key)
  334. {
  335. if(key == EShortcut::GLOBAL_ACCEPT && inputBox->getText().size())
  336. {
  337. CSH->sendMessage(inputBox->getText());
  338. inputBox->setText("");
  339. }
  340. else
  341. inputBox->keyPressed(key);
  342. }
  343. void CChatBox::addNewMessage(const std::string & text)
  344. {
  345. CCS->soundh->playSound(AudioPath::builtin("CHAT"));
  346. chatHistory->setText(chatHistory->label->getText() + text + "\n");
  347. if(chatHistory->slider)
  348. chatHistory->slider->scrollToMax();
  349. }
  350. PvPBox::PvPBox(const Rect & rect)
  351. {
  352. OBJ_CONSTRUCTION;
  353. pos += rect.topLeft();
  354. setRedrawParent(true);
  355. buttonFlipCoin = std::make_shared<CButton>(Point(17, 160), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("flip coin"), [](){
  356. LobbyPvPAction lpa;
  357. lpa.action = LobbyPvPAction::COIN;
  358. CSH->sendLobbyPack(lpa);
  359. }, EShortcut::NONE);
  360. buttonFlipCoin->setTextOverlay("Flip coin2", EFonts::FONT_SMALL, Colors::WHITE);
  361. buttonRandomTown = std::make_shared<CButton>(Point(17, 184), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("random town"), [](){
  362. LobbyPvPAction lpa;
  363. lpa.action = LobbyPvPAction::RANDOM_TOWN;
  364. CSH->sendLobbyPack(lpa);
  365. }, EShortcut::NONE);
  366. buttonRandomTown->setTextOverlay("random town", EFonts::FONT_SMALL, Colors::WHITE);
  367. buttonRandomTownVs = std::make_shared<CButton>(Point(17, 208), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("random town vs"), [](){
  368. LobbyPvPAction lpa;
  369. lpa.action = LobbyPvPAction::RANDOM_TOWN_VS;
  370. CSH->sendLobbyPack(lpa);
  371. }, EShortcut::NONE);
  372. buttonRandomTownVs->setTextOverlay("random town vs", EFonts::FONT_SMALL, Colors::WHITE);
  373. }
  374. CFlagBox::CFlagBox(const Rect & rect)
  375. : CIntObject(SHOW_POPUP)
  376. {
  377. pos += rect.topLeft();
  378. pos.w = rect.w;
  379. pos.h = rect.h;
  380. OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
  381. labelAllies = std::make_shared<CLabel>(0, 0, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[390] + ":");
  382. labelEnemies = std::make_shared<CLabel>(133, 0, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[391] + ":");
  383. iconsTeamFlags = GH.renderHandler().loadAnimation(AnimationPath::builtin("ITGFLAGS.DEF"));
  384. iconsTeamFlags->preload();
  385. }
  386. void CFlagBox::recreate()
  387. {
  388. flagsAllies.clear();
  389. flagsEnemies.clear();
  390. OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
  391. const int alliesX = 5 + (int)labelAllies->getWidth();
  392. const int enemiesX = 5 + 133 + (int)labelEnemies->getWidth();
  393. for(auto i = CSH->si->playerInfos.cbegin(); i != CSH->si->playerInfos.cend(); i++)
  394. {
  395. auto flag = std::make_shared<CAnimImage>(iconsTeamFlags, i->first.getNum(), 0);
  396. if(i->first == CSH->myFirstColor() || CSH->getPlayerTeamId(i->first) == CSH->getPlayerTeamId(CSH->myFirstColor()))
  397. {
  398. flag->moveTo(Point(pos.x + alliesX + (int)flagsAllies.size()*flag->pos.w, pos.y));
  399. flagsAllies.push_back(flag);
  400. }
  401. else
  402. {
  403. flag->moveTo(Point(pos.x + enemiesX + (int)flagsEnemies.size()*flag->pos.w, pos.y));
  404. flagsEnemies.push_back(flag);
  405. }
  406. }
  407. }
  408. void CFlagBox::showPopupWindow(const Point & cursorPosition)
  409. {
  410. if(SEL->getMapInfo())
  411. GH.windows().createAndPushWindow<CFlagBoxTooltipBox>(iconsTeamFlags);
  412. }
  413. CFlagBox::CFlagBoxTooltipBox::CFlagBoxTooltipBox(std::shared_ptr<CAnimation> icons)
  414. : CWindowObject(BORDERED | RCLICK_POPUP | SHADOW_DISABLED, ImagePath::builtin("DIBOXBCK"))
  415. {
  416. OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
  417. labelTeamAlignment = std::make_shared<CLabel>(128, 30, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[657]);
  418. labelGroupTeams = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
  419. std::vector<std::set<PlayerColor>> teams(PlayerColor::PLAYER_LIMIT_I);
  420. for(PlayerColor j(0); j < PlayerColor::PLAYER_LIMIT; j++)
  421. {
  422. if(SEL->getPlayerInfo(j).canHumanPlay || SEL->getPlayerInfo(j).canComputerPlay)
  423. {
  424. teams[SEL->getPlayerInfo(j).team].insert(j);
  425. }
  426. }
  427. auto curIdx = 0;
  428. for(const auto & team : teams)
  429. {
  430. if(team.empty())
  431. continue;
  432. labelGroupTeams->add(128, 65 + 50 * curIdx, boost::str(boost::format(CGI->generaltexth->allTexts[656]) % (curIdx + 1)));
  433. int curx = 128 - 9 * team.size();
  434. for(const auto & player : team)
  435. {
  436. iconsFlags.push_back(std::make_shared<CAnimImage>(icons, player, 0, curx, 75 + 50 * curIdx));
  437. curx += 18;
  438. }
  439. ++curIdx;
  440. }
  441. pos.w = 256;
  442. pos.h = 90 + 50 * curIdx;
  443. background->scaleTo(Point(pos.w, pos.h));
  444. center();
  445. }