CBonusSelection.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. /*
  2. * CBonusSelection.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 "CBonusSelection.h"
  12. #include <vcmi/spells/Spell.h>
  13. #include <vcmi/spells/Service.h>
  14. #include "CSelectionBase.h"
  15. #include "ExtraOptionsTab.h"
  16. #include "../CGameInfo.h"
  17. #include "../CPlayerInterface.h"
  18. #include "../CServerHandler.h"
  19. #include "../mainmenu/CMainMenu.h"
  20. #include "../mainmenu/CPrologEpilogVideo.h"
  21. #include "../media/IMusicPlayer.h"
  22. #include "../widgets/CComponent.h"
  23. #include "../widgets/Buttons.h"
  24. #include "../widgets/MiscWidgets.h"
  25. #include "../widgets/ObjectLists.h"
  26. #include "../widgets/TextControls.h"
  27. #include "../windows/GUIClasses.h"
  28. #include "../windows/InfoWindows.h"
  29. #include "../render/IImage.h"
  30. #include "../render/IRenderHandler.h"
  31. #include "../render/CAnimation.h"
  32. #include "../render/Graphics.h"
  33. #include "../gui/CGuiHandler.h"
  34. #include "../gui/Shortcut.h"
  35. #include "../gui/WindowHandler.h"
  36. #include "../../lib/CConfigHandler.h"
  37. #include "../../lib/CCreatureHandler.h"
  38. #include "../../lib/CHeroHandler.h"
  39. #include "../../lib/CSkillHandler.h"
  40. #include "../../lib/StartInfo.h"
  41. #include "../../lib/entities/building/CBuilding.h"
  42. #include "../../lib/entities/building/CBuildingHandler.h"
  43. #include "../../lib/entities/faction/CFaction.h"
  44. #include "../../lib/entities/faction/CTown.h"
  45. #include "../../lib/entities/faction/CTownHandler.h"
  46. #include "../../lib/filesystem/Filesystem.h"
  47. #include "../../lib/texts/CGeneralTextHandler.h"
  48. #include "../../lib/campaign/CampaignState.h"
  49. #include "../../lib/mapping/CMapService.h"
  50. #include "../../lib/mapping/CMapInfo.h"
  51. #include "../../lib/mapObjects/CGHeroInstance.h"
  52. std::shared_ptr<CampaignState> CBonusSelection::getCampaign()
  53. {
  54. return CSH->si->campState;
  55. }
  56. CBonusSelection::CBonusSelection()
  57. : CWindowObject(BORDERED)
  58. {
  59. OBJECT_CONSTRUCTION;
  60. setBackground(getCampaign()->getRegions().getBackgroundName());
  61. panelBackground = std::make_shared<CPicture>(ImagePath::builtin("CAMPBRF.BMP"), 456, 6);
  62. const auto & playVideo = [this]()
  63. {
  64. GH.windows().createAndPushWindow<CPrologEpilogVideo>(
  65. getCampaign()->scenario(CSH->campaignMap).prolog,
  66. [this]() { redraw(); } );
  67. };
  68. buttonStart = std::make_shared<CButton>(
  69. Point(475, 536), AnimationPath::builtin("CBBEGIB.DEF"), CButton::tooltip(), std::bind(&CBonusSelection::startMap, this), EShortcut::GLOBAL_ACCEPT
  70. );
  71. buttonRestart = std::make_shared<CButton>(Point(475, 536), AnimationPath::builtin("CBRESTB.DEF"), CButton::tooltip(), std::bind(&CBonusSelection::restartMap, this), EShortcut::GLOBAL_ACCEPT);
  72. buttonVideo = std::make_shared<CButton>(Point(705, 214), AnimationPath::builtin("CBVIDEB.DEF"), CButton::tooltip(), playVideo, EShortcut::LOBBY_REPLAY_VIDEO);
  73. buttonBack = std::make_shared<CButton>(Point(624, 536), AnimationPath::builtin("CBCANCB.DEF"), CButton::tooltip(), std::bind(&CBonusSelection::goBack, this), EShortcut::GLOBAL_CANCEL);
  74. campaignName = std::make_shared<CLabel>(481, 28, FONT_BIG, ETextAlignment::TOPLEFT, Colors::YELLOW, CSH->si->getCampaignName());
  75. iconsMapSizes = std::make_shared<CAnimImage>(AnimationPath::builtin("SCNRMPSZ"), 4, 0, 735, 26);
  76. labelCampaignDescription = std::make_shared<CLabel>(481, 63, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[38]);
  77. campaignDescription = std::make_shared<CTextBox>(getCampaign()->getDescriptionTranslated(), Rect(480, 86, 286, 117), 1);
  78. mapName = std::make_shared<CLabel>(481, 219, FONT_BIG, ETextAlignment::TOPLEFT, Colors::YELLOW, CSH->mi->getNameTranslated());
  79. labelMapDescription = std::make_shared<CLabel>(481, 253, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[496]);
  80. mapDescription = std::make_shared<CTextBox>("", Rect(480, 278, 292, 108), 1);
  81. labelChooseBonus = std::make_shared<CLabel>(475, 432, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[71]);
  82. groupBonuses = std::make_shared<CToggleGroup>(std::bind(&IServerAPI::setCampaignBonus, CSH, _1));
  83. flagbox = std::make_shared<CFlagBox>(Rect(486, 407, 335, 23));
  84. std::vector<std::string> difficulty;
  85. std::string difficultyString = CGI->generaltexth->allTexts[492];
  86. boost::split(difficulty, difficultyString, boost::is_any_of(" "));
  87. labelDifficulty = std::make_shared<CLabel>(724, settings["general"]["enableUiEnhancements"].Bool() ? 457 : 432, FONT_MEDIUM, ETextAlignment::TOPCENTER, Colors::WHITE, difficulty.back());
  88. for(size_t b = 0; b < difficultyIcons.size(); ++b)
  89. {
  90. difficultyIcons[b] = std::make_shared<CAnimImage>(AnimationPath::builtinTODO("GSPBUT" + std::to_string(b + 3) + ".DEF"), 0, 0, 709, settings["general"]["enableUiEnhancements"].Bool() ? 480 : 455);
  91. }
  92. if(getCampaign()->playerSelectedDifficulty())
  93. {
  94. Point posLeft = settings["general"]["enableUiEnhancements"].Bool() ? Point(693, 495) : Point(694, 508);
  95. Point posRight = settings["general"]["enableUiEnhancements"].Bool() ? Point(739, 495) : Point(738, 508);
  96. buttonDifficultyLeft = std::make_shared<CButton>(posLeft, AnimationPath::builtin("SCNRBLF.DEF"), CButton::tooltip(), std::bind(&CBonusSelection::decreaseDifficulty, this), EShortcut::MOVE_LEFT);
  97. buttonDifficultyRight = std::make_shared<CButton>(posRight, AnimationPath::builtin("SCNRBRT.DEF"), CButton::tooltip(), std::bind(&CBonusSelection::increaseDifficulty, this), EShortcut::MOVE_RIGHT);
  98. }
  99. for(auto scenarioID : getCampaign()->allScenarios())
  100. {
  101. if(getCampaign()->isAvailable(scenarioID))
  102. regions.push_back(std::make_shared<CRegion>(scenarioID, true, true, getCampaign()->getRegions()));
  103. else if(getCampaign()->isConquered(scenarioID)) //display as striped
  104. regions.push_back(std::make_shared<CRegion>(scenarioID, false, false, getCampaign()->getRegions()));
  105. }
  106. if (!getCampaign()->getMusic().empty())
  107. CCS->musich->playMusic( getCampaign()->getMusic(), true, false);
  108. if(CSH->getState() != EClientState::GAMEPLAY && settings["general"]["enableUiEnhancements"].Bool())
  109. {
  110. tabExtraOptions = std::make_shared<ExtraOptionsTab>();
  111. tabExtraOptions->recActions = UPDATE | SHOWALL | LCLICK | RCLICK_POPUP;
  112. tabExtraOptions->recreate(true);
  113. tabExtraOptions->setEnabled(false);
  114. buttonExtraOptions = std::make_shared<CButton>(Point(643, 431), AnimationPath::builtin("GSPBUT2.DEF"), CGI->generaltexth->zelp[46], [this]{ tabExtraOptions->setEnabled(!tabExtraOptions->isActive()); GH.windows().totalRedraw(); }, EShortcut::LOBBY_EXTRA_OPTIONS);
  115. buttonExtraOptions->setTextOverlay(CGI->generaltexth->translate("vcmi.optionsTab.extraOptions.hover"), FONT_SMALL, Colors::WHITE);
  116. }
  117. }
  118. void CBonusSelection::createBonusesIcons()
  119. {
  120. OBJECT_CONSTRUCTION;
  121. const CampaignScenario & scenario = getCampaign()->scenario(CSH->campaignMap);
  122. const std::vector<CampaignBonus> & bonDescs = scenario.travelOptions.bonusesToChoose;
  123. groupBonuses = std::make_shared<CToggleGroup>(std::bind(&IServerAPI::setCampaignBonus, CSH, _1));
  124. constexpr std::array bonusPics =
  125. {
  126. "SPELLBON.DEF", // Spell
  127. "TWCRPORT.DEF", // Monster
  128. "", // Building - BO*.BMP
  129. "ARTIFBON.DEF", // Artifact
  130. "SPELLBON.DEF", // Spell scroll
  131. "PSKILBON.DEF", // Primary skill
  132. "SSKILBON.DEF", // Secondary skill
  133. "BORES.DEF", // Resource
  134. "PORTRAITSLARGE", // Hero HPL*.BMP
  135. "PORTRAITSLARGE"
  136. // Player - CREST58.DEF
  137. };
  138. for(int i = 0; i < bonDescs.size(); i++)
  139. {
  140. int bonusType = static_cast<size_t>(bonDescs[i].type);
  141. std::string picName = bonusPics[bonusType];
  142. size_t picNumber = bonDescs[i].info2;
  143. MetaString desc;
  144. switch(bonDescs[i].type)
  145. {
  146. case CampaignBonusType::SPELL:
  147. desc.appendLocalString(EMetaText::GENERAL_TXT, 715);
  148. desc.replaceName(SpellID(bonDescs[i].info2));
  149. break;
  150. case CampaignBonusType::MONSTER:
  151. picNumber = bonDescs[i].info2 + 2;
  152. desc.appendLocalString(EMetaText::GENERAL_TXT, 717);
  153. desc.replaceNumber(bonDescs[i].info3);
  154. desc.replaceNamePlural(bonDescs[i].info2);
  155. break;
  156. case CampaignBonusType::BUILDING:
  157. {
  158. FactionID faction;
  159. for(auto & elem : CSH->si->playerInfos)
  160. {
  161. if(elem.second.isControlledByHuman())
  162. {
  163. faction = elem.second.castle;
  164. break;
  165. }
  166. }
  167. assert(faction != -1);
  168. BuildingID buildID;
  169. if(getCampaign()->formatVCMI())
  170. buildID = BuildingID(bonDescs[i].info1);
  171. else
  172. buildID = CBuildingHandler::campToERMU(bonDescs[i].info1, faction, std::set<BuildingID>());
  173. picName = graphics->ERMUtoPicture[faction][buildID];
  174. picNumber = -1;
  175. if(vstd::contains((*CGI->townh)[faction]->town->buildings, buildID))
  176. desc.appendTextID((*CGI->townh)[faction]->town->buildings.find(buildID)->second->getNameTextID());
  177. break;
  178. }
  179. case CampaignBonusType::ARTIFACT:
  180. desc.appendLocalString(EMetaText::GENERAL_TXT, 715);
  181. desc.replaceName(ArtifactID(bonDescs[i].info2));
  182. break;
  183. case CampaignBonusType::SPELL_SCROLL:
  184. desc.appendLocalString(EMetaText::GENERAL_TXT, 716);
  185. desc.replaceName(SpellID(bonDescs[i].info2));
  186. break;
  187. case CampaignBonusType::PRIMARY_SKILL:
  188. {
  189. int leadingSkill = -1;
  190. std::vector<std::pair<int, int>> toPrint; //primary skills to be listed <num, val>
  191. const ui8 * ptr = reinterpret_cast<const ui8 *>(&bonDescs[i].info2);
  192. for(int g = 0; g < GameConstants::PRIMARY_SKILLS; ++g)
  193. {
  194. if(leadingSkill == -1 || ptr[g] > ptr[leadingSkill])
  195. {
  196. leadingSkill = g;
  197. }
  198. if(ptr[g] != 0)
  199. {
  200. toPrint.push_back(std::make_pair(g, ptr[g]));
  201. }
  202. }
  203. picNumber = leadingSkill;
  204. desc.appendLocalString(EMetaText::GENERAL_TXT, 715);
  205. std::string substitute; //text to be printed instead of %s
  206. for(int v = 0; v < toPrint.size(); ++v)
  207. {
  208. substitute += std::to_string(toPrint[v].second);
  209. substitute += " " + CGI->generaltexth->primarySkillNames[toPrint[v].first];
  210. if(v != toPrint.size() - 1)
  211. {
  212. substitute += ", ";
  213. }
  214. }
  215. desc.replaceRawString(substitute);
  216. break;
  217. }
  218. case CampaignBonusType::SECONDARY_SKILL:
  219. desc.appendLocalString(EMetaText::GENERAL_TXT, 718);
  220. desc.replaceTextID(TextIdentifier("core", "skilllev", bonDescs[i].info3 - 1).get());
  221. desc.replaceName(SecondarySkill(bonDescs[i].info2));
  222. picNumber = bonDescs[i].info2 * 3 + bonDescs[i].info3 - 1;
  223. break;
  224. case CampaignBonusType::RESOURCE:
  225. {
  226. desc.appendLocalString(EMetaText::GENERAL_TXT, 717);
  227. switch(bonDescs[i].info1)
  228. {
  229. case 0xFD: //wood + ore
  230. {
  231. desc.replaceLocalString(EMetaText::GENERAL_TXT, 721);
  232. picNumber = 7;
  233. break;
  234. }
  235. case 0xFE: //wood + ore
  236. {
  237. desc.replaceLocalString(EMetaText::GENERAL_TXT, 722);
  238. picNumber = 8;
  239. break;
  240. }
  241. default:
  242. {
  243. desc.replaceName(GameResID(bonDescs[i].info1));
  244. picNumber = bonDescs[i].info1;
  245. }
  246. }
  247. desc.replaceNumber(bonDescs[i].info2);
  248. break;
  249. }
  250. case CampaignBonusType::HEROES_FROM_PREVIOUS_SCENARIO:
  251. {
  252. auto superhero = getCampaign()->strongestHero(static_cast<CampaignScenarioID>(bonDescs[i].info2), PlayerColor(bonDescs[i].info1));
  253. if(!superhero)
  254. logGlobal->warn("No superhero! How could it be transferred?");
  255. picNumber = superhero ? superhero->getIconIndex() : 0;
  256. desc.appendLocalString(EMetaText::GENERAL_TXT, 719);
  257. desc.replaceRawString(getCampaign()->scenario(static_cast<CampaignScenarioID>(bonDescs[i].info2)).scenarioName.toString());
  258. break;
  259. }
  260. case CampaignBonusType::HERO:
  261. if(bonDescs[i].info2 == 0xFFFF)
  262. {
  263. desc.appendLocalString(EMetaText::GENERAL_TXT, 720); // Start with random hero
  264. picNumber = -1;
  265. picName = "CBONN1A3.BMP";
  266. }
  267. else
  268. {
  269. desc.appendLocalString(EMetaText::GENERAL_TXT, 715); // Start with %s
  270. desc.replaceTextID(CGI->heroh->objects[bonDescs[i].info2]->getNameTextID());
  271. }
  272. break;
  273. }
  274. std::shared_ptr<CToggleButton> bonusButton = std::make_shared<CToggleButton>(Point(475 + i * 68, 455), AnimationPath::builtin("campaignBonusSelection"), CButton::tooltip(desc.toString(), desc.toString()));
  275. if(picNumber != -1)
  276. bonusButton->setOverlay(std::make_shared<CAnimImage>(AnimationPath::builtin(picName), picNumber));
  277. else
  278. bonusButton->setOverlay(std::make_shared<CPicture>(ImagePath::builtin(picName)));
  279. if(CSH->campaignBonus == i)
  280. bonusButton->setBorderColor(Colors::BRIGHT_YELLOW);
  281. groupBonuses->addToggle(i, bonusButton);
  282. }
  283. if(getCampaign()->getBonusID(CSH->campaignMap))
  284. groupBonuses->setSelected(*getCampaign()->getBonusID(CSH->campaignMap));
  285. }
  286. void CBonusSelection::updateAfterStateChange()
  287. {
  288. if(CSH->getState() != EClientState::GAMEPLAY)
  289. {
  290. buttonRestart->disable();
  291. buttonVideo->disable();
  292. buttonStart->enable();
  293. buttonBack->block(!getCampaign()->conqueredScenarios().empty());
  294. }
  295. else
  296. {
  297. buttonStart->disable();
  298. buttonRestart->enable();
  299. buttonVideo->enable();
  300. buttonBack->block(false);
  301. if(buttonDifficultyLeft)
  302. buttonDifficultyLeft->disable();
  303. if(buttonDifficultyRight)
  304. buttonDifficultyRight->disable();
  305. }
  306. if(CSH->campaignBonus == -1)
  307. {
  308. buttonStart->block(getCampaign()->scenario(CSH->campaignMap).travelOptions.bonusesToChoose.size());
  309. }
  310. else
  311. {
  312. buttonStart->block(false);
  313. }
  314. for(auto region : regions)
  315. region->updateState();
  316. if(!CSH->mi)
  317. return;
  318. iconsMapSizes->setFrame(CSH->mi->getMapSizeIconId());
  319. mapName->setText(CSH->mi->getNameTranslated());
  320. mapDescription->setText(CSH->mi->getDescriptionTranslated());
  321. for(size_t i = 0; i < difficultyIcons.size(); i++)
  322. {
  323. if(i == CSH->si->difficulty)
  324. difficultyIcons[i]->enable();
  325. else
  326. difficultyIcons[i]->disable();
  327. }
  328. flagbox->recreate();
  329. createBonusesIcons();
  330. }
  331. void CBonusSelection::goBack()
  332. {
  333. if(CSH->getState() != EClientState::GAMEPLAY)
  334. {
  335. GH.windows().popWindows(2);
  336. }
  337. else
  338. {
  339. close();
  340. }
  341. // TODO: we can actually only pop bonus selection interface for custom campaigns
  342. // Though this would require clearing CLobbyScreen::bonusSel pointer when poping this interface
  343. /*
  344. else
  345. {
  346. close();
  347. CSH->state = EClientState::LOBBY;
  348. }
  349. */
  350. }
  351. void CBonusSelection::startMap()
  352. {
  353. if (!CSH->validateGameStart())
  354. return;
  355. auto showPrologVideo = [=]()
  356. {
  357. auto exitCb = [=]()
  358. {
  359. logGlobal->info("Starting scenario %d", static_cast<int>(CSH->campaignMap));
  360. CSH->sendStartGame();
  361. };
  362. const CampaignScenario & scenario = getCampaign()->scenario(CSH->campaignMap);
  363. if(scenario.prolog.hasPrologEpilog)
  364. {
  365. GH.windows().createAndPushWindow<CPrologEpilogVideo>(scenario.prolog, exitCb);
  366. }
  367. else
  368. {
  369. exitCb();
  370. }
  371. };
  372. //block buttons immediately
  373. buttonStart->block(true);
  374. buttonRestart->block(true);
  375. buttonVideo->block(true);
  376. buttonBack->block(true);
  377. if(LOCPLINT) // we're currently ingame, so ask for starting new map and end game
  378. {
  379. close();
  380. LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[67], [=]()
  381. {
  382. showPrologVideo();
  383. }, 0);
  384. }
  385. else
  386. {
  387. showPrologVideo();
  388. }
  389. }
  390. void CBonusSelection::restartMap()
  391. {
  392. close();
  393. LOCPLINT->showYesNoDialog(
  394. CGI->generaltexth->allTexts[67],
  395. [=]()
  396. {
  397. GH.dispatchMainThread(
  398. []()
  399. {
  400. CSH->sendRestartGame();
  401. }
  402. );
  403. },
  404. 0
  405. );
  406. }
  407. void CBonusSelection::increaseDifficulty()
  408. {
  409. CSH->setDifficulty(CSH->si->difficulty + 1);
  410. }
  411. void CBonusSelection::decreaseDifficulty()
  412. {
  413. // avoid negative overflow (0 - 1 = 255)
  414. if (CSH->si->difficulty > 0)
  415. CSH->setDifficulty(CSH->si->difficulty - 1);
  416. }
  417. CBonusSelection::CRegion::CRegion(CampaignScenarioID id, bool accessible, bool selectable, const CampaignRegions & campDsc)
  418. : CIntObject(LCLICK | SHOW_POPUP), idOfMapAndRegion(id), accessible(accessible), selectable(selectable)
  419. {
  420. OBJECT_CONSTRUCTION;
  421. pos += campDsc.getPosition(id);
  422. auto color = CSH->si->campState->scenario(idOfMapAndRegion).regionColor;
  423. graphicsNotSelected = std::make_shared<CPicture>(campDsc.getAvailableName(id, color));
  424. graphicsNotSelected->disable();
  425. graphicsSelected = std::make_shared<CPicture>(campDsc.getSelectedName(id, color));
  426. graphicsSelected->disable();
  427. graphicsStriped = std::make_shared<CPicture>(campDsc.getConqueredName(id, color));
  428. graphicsStriped->disable();
  429. pos.w = graphicsNotSelected->pos.w;
  430. pos.h = graphicsNotSelected->pos.h;
  431. }
  432. void CBonusSelection::CRegion::updateState()
  433. {
  434. if(!accessible)
  435. {
  436. graphicsNotSelected->disable();
  437. graphicsSelected->disable();
  438. graphicsStriped->enable();
  439. }
  440. else if(CSH->campaignMap == idOfMapAndRegion)
  441. {
  442. graphicsNotSelected->disable();
  443. graphicsSelected->enable();
  444. graphicsStriped->disable();
  445. }
  446. else
  447. {
  448. graphicsNotSelected->enable();
  449. graphicsSelected->disable();
  450. graphicsStriped->disable();
  451. }
  452. }
  453. void CBonusSelection::CRegion::clickReleased(const Point & cursorPosition)
  454. {
  455. if(selectable && !graphicsNotSelected->getSurface()->isTransparent(cursorPosition - pos.topLeft()))
  456. {
  457. CSH->setCampaignMap(idOfMapAndRegion);
  458. }
  459. }
  460. void CBonusSelection::CRegion::showPopupWindow(const Point & cursorPosition)
  461. {
  462. // FIXME: For some reason "down" is only ever contain indeterminate_value
  463. auto & text = CSH->si->campState->scenario(idOfMapAndRegion).regionText;
  464. if(!graphicsNotSelected->getSurface()->isTransparent(cursorPosition - pos.topLeft()) && !text.empty())
  465. {
  466. CRClickPopup::createAndPush(text.toString());
  467. }
  468. }