CSelectionBase.cpp 17 KB

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