CComponent.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. /*
  2. * CComponent.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 "CComponent.h"
  12. #include "CArtifactHolder.h"
  13. #include "Images.h"
  14. #include <vcmi/spells/Service.h>
  15. #include <vcmi/spells/Spell.h>
  16. #include "../gui/CGuiHandler.h"
  17. #include "../gui/CursorHandler.h"
  18. #include "../gui/TextAlignment.h"
  19. #include "../gui/Shortcut.h"
  20. #include "../render/Canvas.h"
  21. #include "../render/IFont.h"
  22. #include "../render/Graphics.h"
  23. #include "../windows/CMessage.h"
  24. #include "../windows/InfoWindows.h"
  25. #include "../widgets/TextControls.h"
  26. #include "../CGameInfo.h"
  27. #include "../../lib/ArtifactUtils.h"
  28. #include "../../lib/CTownHandler.h"
  29. #include "../../lib/CHeroHandler.h"
  30. #include "../../lib/networkPacks/Component.h"
  31. #include "../../lib/spells/CSpellHandler.h"
  32. #include "../../lib/CCreatureHandler.h"
  33. #include "../../lib/CSkillHandler.h"
  34. #include "../../lib/CGeneralTextHandler.h"
  35. #include "../../lib/CArtHandler.h"
  36. #include "../../lib/CArtifactInstance.h"
  37. CComponent::CComponent(ComponentType Type, ComponentSubType Subtype, std::optional<int32_t> Val, ESize imageSize, EFonts font)
  38. {
  39. init(Type, Subtype, Val, imageSize, font, "");
  40. }
  41. CComponent::CComponent(ComponentType Type, ComponentSubType Subtype, const std::string & Val, ESize imageSize, EFonts font)
  42. {
  43. init(Type, Subtype, std::nullopt, imageSize, font, Val);
  44. }
  45. CComponent::CComponent(const Component & c, ESize imageSize, EFonts font)
  46. {
  47. init(c.type, c.subType, c.value, imageSize, font, "");
  48. }
  49. void CComponent::init(ComponentType Type, ComponentSubType Subtype, std::optional<int32_t> Val, ESize imageSize, EFonts fnt, const std::string & ValText)
  50. {
  51. OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
  52. addUsedEvents(SHOW_POPUP);
  53. data.type = Type;
  54. data.subType = Subtype;
  55. data.value = Val;
  56. customSubtitle = ValText;
  57. size = imageSize;
  58. font = fnt;
  59. assert(size < sizeInvalid);
  60. setSurface(getFileName()[size], (int)getIndex());
  61. pos.w = image->pos.w;
  62. pos.h = image->pos.h;
  63. if (imageSize < small)
  64. font = FONT_TINY; //for tiny images - tiny font
  65. pos.h += 4; //distance between text and image
  66. // WARNING: too low values will lead to bad line-breaks in CPlayerOptionTooltipBox - check right-click on starting town in pregame
  67. int max = 80;
  68. if (size < large)
  69. max = 72;
  70. if (size < medium)
  71. max = 60;
  72. if (size < small)
  73. max = 55;
  74. if(Type == ComponentType::RESOURCE && !ValText.empty())
  75. max = 80;
  76. std::vector<std::string> textLines = CMessage::breakText(getSubtitle(), std::max<int>(max, pos.w), font);
  77. for(auto & line : textLines)
  78. {
  79. int height = static_cast<int>(graphics->fonts[font]->getLineHeight());
  80. auto label = std::make_shared<CLabel>(pos.w/2, pos.h + height/2, font, ETextAlignment::CENTER, Colors::WHITE, line);
  81. pos.h += height;
  82. if(label->pos.w > pos.w)
  83. {
  84. pos.x -= (label->pos.w - pos.w)/2;
  85. pos.w = label->pos.w;
  86. }
  87. lines.push_back(label);
  88. }
  89. }
  90. std::vector<AnimationPath> CComponent::getFileName() const
  91. {
  92. static const std::array<std::string, 4> primSkillsArr = {"PSKIL32", "PSKIL32", "PSKIL42", "PSKILL"};
  93. static const std::array<std::string, 4> secSkillsArr = {"SECSK32", "SECSK32", "SECSKILL", "SECSK82"};
  94. static const std::array<std::string, 4> resourceArr = {"SMALRES", "RESOURCE", "RESOURCE", "RESOUR82"};
  95. static const std::array<std::string, 4> creatureArr = {"CPRSMALL", "CPRSMALL", "CPRSMALL", "TWCRPORT"};
  96. static const std::array<std::string, 4> artifactArr = {"Artifact", "Artifact", "Artifact", "Artifact"};
  97. static const std::array<std::string, 4> spellsArr = {"SpellInt", "SpellInt", "SpellInt", "SPELLSCR"};
  98. static const std::array<std::string, 4> moraleArr = {"IMRL22", "IMRL30", "IMRL42", "imrl82"};
  99. static const std::array<std::string, 4> luckArr = {"ILCK22", "ILCK30", "ILCK42", "ilck82"};
  100. static const std::array<std::string, 4> heroArr = {"PortraitsSmall", "PortraitsSmall", "PortraitsSmall", "PortraitsLarge"};
  101. static const std::array<std::string, 4> flagArr = {"CREST58", "CREST58", "CREST58", "CREST58"};
  102. auto gen = [](const std::array<std::string, 4> & arr) -> std::vector<AnimationPath>
  103. {
  104. return { AnimationPath::builtin(arr[0]), AnimationPath::builtin(arr[1]), AnimationPath::builtin(arr[2]), AnimationPath::builtin(arr[3]) };
  105. };
  106. switch(data.type)
  107. {
  108. case ComponentType::PRIM_SKILL:
  109. case ComponentType::EXPERIENCE:
  110. case ComponentType::MANA:
  111. case ComponentType::LEVEL:
  112. return gen(primSkillsArr);
  113. case ComponentType::NONE:
  114. case ComponentType::SEC_SKILL:
  115. return gen(secSkillsArr);
  116. case ComponentType::RESOURCE:
  117. case ComponentType::RESOURCE_PER_DAY:
  118. return gen(resourceArr);
  119. case ComponentType::CREATURE:
  120. return gen(creatureArr);
  121. case ComponentType::ARTIFACT:
  122. return gen(artifactArr);
  123. case ComponentType::SPELL_SCROLL:
  124. case ComponentType::SPELL:
  125. return gen(spellsArr);
  126. case ComponentType::MORALE:
  127. return gen(moraleArr);
  128. case ComponentType::LUCK:
  129. return gen(luckArr);
  130. case ComponentType::BUILDING:
  131. return std::vector<AnimationPath>(4, (*CGI->townh)[data.subType.as<BuildingTypeUniqueID>().getFaction()]->town->clientInfo.buildingsIcons);
  132. case ComponentType::HERO_PORTRAIT:
  133. return gen(heroArr);
  134. case ComponentType::FLAG:
  135. return gen(flagArr);
  136. default:
  137. assert(0);
  138. return {};
  139. }
  140. }
  141. size_t CComponent::getIndex() const
  142. {
  143. switch(data.type)
  144. {
  145. case ComponentType::NONE:
  146. return 0;
  147. case ComponentType::PRIM_SKILL:
  148. return data.subType.getNum();
  149. case ComponentType::EXPERIENCE:
  150. case ComponentType::LEVEL:
  151. return 4; // for whatever reason, in H3 experience icon is located in primary skills icons
  152. case ComponentType::MANA:
  153. return 5; // for whatever reason, in H3 mana points icon is located in primary skills icons
  154. case ComponentType::SEC_SKILL:
  155. return data.subType.getNum() * 3 + 3 + data.value.value_or(0) - 1;
  156. case ComponentType::RESOURCE:
  157. case ComponentType::RESOURCE_PER_DAY:
  158. return data.subType.getNum();
  159. case ComponentType::CREATURE:
  160. return CGI->creatures()->getById(data.subType.as<CreatureID>())->getIconIndex();
  161. case ComponentType::ARTIFACT:
  162. return CGI->artifacts()->getById(data.subType.as<ArtifactID>())->getIconIndex();
  163. case ComponentType::SPELL_SCROLL:
  164. case ComponentType::SPELL:
  165. return (size < large) ? data.subType.getNum() + 1 : data.subType.getNum();
  166. case ComponentType::MORALE:
  167. return data.value.value_or(0) + 3;
  168. case ComponentType::LUCK:
  169. return data.value.value_or(0) + 3;
  170. case ComponentType::BUILDING:
  171. return data.subType.as<BuildingTypeUniqueID>().getBuilding();
  172. case ComponentType::HERO_PORTRAIT:
  173. return CGI->heroTypes()->getById(data.subType.as<HeroTypeID>())->getIconIndex();
  174. case ComponentType::FLAG:
  175. return data.subType.getNum();
  176. default:
  177. assert(0);
  178. return 0;
  179. }
  180. }
  181. std::string CComponent::getDescription() const
  182. {
  183. switch(data.type)
  184. {
  185. case ComponentType::PRIM_SKILL:
  186. return CGI->generaltexth->arraytxt[2+data.subType.getNum()];
  187. case ComponentType::EXPERIENCE:
  188. case ComponentType::LEVEL:
  189. return CGI->generaltexth->allTexts[241];
  190. case ComponentType::MANA:
  191. return CGI->generaltexth->allTexts[149];
  192. case ComponentType::SEC_SKILL:
  193. return CGI->skillh->getByIndex(data.subType.getNum())->getDescriptionTranslated(data.value.value_or(0));
  194. case ComponentType::RESOURCE:
  195. case ComponentType::RESOURCE_PER_DAY:
  196. return CGI->generaltexth->allTexts[242];
  197. case ComponentType::NONE:
  198. case ComponentType::CREATURE:
  199. return "";
  200. case ComponentType::ARTIFACT:
  201. return VLC->artifacts()->getById(data.subType.as<ArtifactID>())->getDescriptionTranslated();
  202. case ComponentType::SPELL_SCROLL:
  203. {
  204. auto description = VLC->arth->objects[ArtifactID::SPELL_SCROLL]->getDescriptionTranslated();
  205. ArtifactUtils::insertScrrollSpellName(description, data.subType.as<SpellID>());
  206. return description;
  207. }
  208. case ComponentType::SPELL:
  209. return VLC->spells()->getById(data.subType.as<SpellID>())->getDescriptionTranslated(data.value.value_or(0));
  210. case ComponentType::MORALE:
  211. return CGI->generaltexth->heroscrn[ 4 - (data.value.value_or(0)>0) + (data.value.value_or(0)<0)];
  212. case ComponentType::LUCK:
  213. return CGI->generaltexth->heroscrn[ 7 - (data.value.value_or(0)>0) + (data.value.value_or(0)<0)];
  214. case ComponentType::BUILDING:
  215. {
  216. auto index = data.subType.as<BuildingTypeUniqueID>();
  217. return (*CGI->townh)[index.getFaction()]->town->buildings[index.getBuilding()]->getDescriptionTranslated();
  218. }
  219. case ComponentType::HERO_PORTRAIT:
  220. return "";
  221. case ComponentType::FLAG:
  222. return "";
  223. default:
  224. assert(0);
  225. return "";
  226. }
  227. }
  228. std::string CComponent::getSubtitle() const
  229. {
  230. if (!customSubtitle.empty())
  231. return customSubtitle;
  232. switch(data.type)
  233. {
  234. case ComponentType::PRIM_SKILL:
  235. if (data.value)
  236. return boost::str(boost::format("%+d %s") % data.value.value_or(0) % CGI->generaltexth->primarySkillNames[data.subType.getNum()]);
  237. else
  238. return CGI->generaltexth->primarySkillNames[data.subType.getNum()];
  239. case ComponentType::EXPERIENCE:
  240. return std::to_string(data.value.value_or(0));
  241. case ComponentType::LEVEL:
  242. {
  243. std::string level = CGI->generaltexth->allTexts[442];
  244. boost::replace_first(level, "1", std::to_string(data.value.value_or(0)));
  245. return level;
  246. }
  247. case ComponentType::MANA:
  248. return boost::str(boost::format("%+d %s") % data.value.value_or(0) % CGI->generaltexth->allTexts[387]);
  249. case ComponentType::SEC_SKILL:
  250. return CGI->generaltexth->levels[data.value.value_or(0)-1] + "\n" + CGI->skillh->getById(data.subType.as<SecondarySkill>())->getNameTranslated();
  251. case ComponentType::RESOURCE:
  252. return std::to_string(data.value.value_or(0));
  253. case ComponentType::RESOURCE_PER_DAY:
  254. return boost::str(boost::format(CGI->generaltexth->allTexts[3]) % data.value.value_or(0));
  255. case ComponentType::CREATURE:
  256. {
  257. auto creature = CGI->creh->getById(data.subType.as<CreatureID>());
  258. if(data.value)
  259. return std::to_string(*data.value) + " " + (*data.value > 1 ? creature->getNamePluralTranslated() : creature->getNameSingularTranslated());
  260. else
  261. return creature->getNamePluralTranslated();
  262. }
  263. case ComponentType::ARTIFACT:
  264. return CGI->artifacts()->getById(data.subType.as<ArtifactID>())->getNameTranslated();
  265. case ComponentType::SPELL_SCROLL:
  266. case ComponentType::SPELL:
  267. return CGI->spells()->getById(data.subType.as<SpellID>())->getNameTranslated();
  268. case ComponentType::NONE:
  269. case ComponentType::MORALE:
  270. case ComponentType::LUCK:
  271. case ComponentType::HERO_PORTRAIT:
  272. return "";
  273. case ComponentType::BUILDING:
  274. {
  275. auto index = data.subType.as<BuildingTypeUniqueID>();
  276. auto building = (*CGI->townh)[index.getFaction()]->town->buildings[index.getBuilding()];
  277. if(!building)
  278. {
  279. logGlobal->error("Town of faction %s has no building #%d", (*CGI->townh)[index.getFaction()]->town->faction->getNameTranslated(), index.getBuilding().getNum());
  280. return (boost::format("Missing building #%d") % index.getBuilding().getNum()).str();
  281. }
  282. return building->getNameTranslated();
  283. }
  284. case ComponentType::FLAG:
  285. return CGI->generaltexth->capColors[data.subType.as<PlayerColor>().getNum()];
  286. default:
  287. assert(0);
  288. return "";
  289. }
  290. }
  291. void CComponent::setSurface(const AnimationPath & defName, int imgPos)
  292. {
  293. OBJECT_CONSTRUCTION_CUSTOM_CAPTURING(255-DISPOSE);
  294. image = std::make_shared<CAnimImage>(defName, imgPos);
  295. }
  296. void CComponent::showPopupWindow(const Point & cursorPosition)
  297. {
  298. if(!getDescription().empty())
  299. CRClickPopup::createAndPush(getDescription());
  300. }
  301. void CSelectableComponent::clickPressed(const Point & cursorPosition)
  302. {
  303. if(onSelect)
  304. onSelect();
  305. }
  306. void CSelectableComponent::clickDouble(const Point & cursorPosition)
  307. {
  308. if(onChoose)
  309. onChoose();
  310. }
  311. void CSelectableComponent::init()
  312. {
  313. selected = false;
  314. }
  315. CSelectableComponent::CSelectableComponent(const Component &c, std::function<void()> OnSelect):
  316. CComponent(c),onSelect(OnSelect)
  317. {
  318. setRedrawParent(true);
  319. addUsedEvents(LCLICK | DOUBLECLICK | KEYBOARD);
  320. init();
  321. }
  322. CSelectableComponent::CSelectableComponent(ComponentType Type, ComponentSubType Sub, int Val, ESize imageSize, std::function<void()> OnSelect):
  323. CComponent(Type,Sub,Val, imageSize),onSelect(OnSelect)
  324. {
  325. setRedrawParent(true);
  326. addUsedEvents(LCLICK | DOUBLECLICK | KEYBOARD);
  327. init();
  328. }
  329. void CSelectableComponent::select(bool on)
  330. {
  331. if(on != selected)
  332. {
  333. selected = on;
  334. redraw();
  335. }
  336. }
  337. void CSelectableComponent::showAll(Canvas & to)
  338. {
  339. CComponent::showAll(to);
  340. if(selected)
  341. {
  342. to.drawBorder(Rect::createAround(image->pos, 1), Colors::BRIGHT_YELLOW);
  343. }
  344. }
  345. void CComponentBox::selectionChanged(std::shared_ptr<CSelectableComponent> newSelection)
  346. {
  347. if (newSelection == selected)
  348. return;
  349. if (selected)
  350. selected->select(false);
  351. selected = newSelection;
  352. if (onSelect)
  353. onSelect(selectedIndex());
  354. if (selected)
  355. selected->select(true);
  356. }
  357. int CComponentBox::selectedIndex()
  358. {
  359. if (selected)
  360. return static_cast<int>(std::find(components.begin(), components.end(), selected) - components.begin());
  361. return -1;
  362. }
  363. Point CComponentBox::getOrTextPos(CComponent *left, CComponent *right)
  364. {
  365. int leftSubtitle = ( left->pos.w - left->image->pos.w) / 2;
  366. int rightSubtitle = (right->pos.w - right->image->pos.w) / 2;
  367. int fullDistance = getDistance(left, right) + leftSubtitle + rightSubtitle;
  368. return Point(fullDistance/2 - leftSubtitle, (left->image->pos.h + right->image->pos.h) / 4);
  369. }
  370. int CComponentBox::getDistance(CComponent *left, CComponent *right)
  371. {
  372. int leftSubtitle = ( left->pos.w - left->image->pos.w) / 2;
  373. int rightSubtitle = (right->pos.w - right->image->pos.w) / 2;
  374. int subtitlesOffset = leftSubtitle + rightSubtitle;
  375. return std::max(betweenSubtitlesMin, betweenImagesMin - subtitlesOffset);
  376. }
  377. void CComponentBox::placeComponents(bool selectable)
  378. {
  379. OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
  380. if (components.empty())
  381. return;
  382. //prepare components
  383. for(auto & comp : components)
  384. {
  385. addChild(comp.get());
  386. comp->recActions = defActions; //FIXME: for some reason, received component might have recActions set to 0
  387. comp->moveTo(Point(pos.x, pos.y));
  388. }
  389. struct RowData
  390. {
  391. size_t comps;
  392. int width;
  393. int height;
  394. RowData (size_t Comps, int Width, int Height):
  395. comps(Comps), width (Width), height (Height){};
  396. };
  397. std::vector<RowData> rows;
  398. rows.push_back (RowData (0,0,0));
  399. //split components in rows
  400. std::shared_ptr<CComponent> prevComp;
  401. for(std::shared_ptr<CComponent> comp : components)
  402. {
  403. //make sure that components are smaller than our width
  404. //assert(pos.w == 0 || pos.w < comp->pos.w);
  405. const int distance = prevComp ? getDistance(prevComp.get(), comp.get()) : 0;
  406. //start next row
  407. if ((pos.w != 0 && rows.back().width + comp->pos.w + distance > pos.w) // row is full
  408. || rows.back().comps >= componentsInRow)
  409. {
  410. prevComp = nullptr;
  411. rows.push_back (RowData (0,0,0));
  412. }
  413. if (prevComp)
  414. rows.back().width += distance;
  415. rows.back().comps++;
  416. rows.back().width += comp->pos.w;
  417. vstd::amax(rows.back().height, comp->pos.h);
  418. prevComp = comp;
  419. }
  420. if (pos.w == 0)
  421. {
  422. for(auto & row : rows)
  423. vstd::amax(pos.w, row.width);
  424. }
  425. int height = ((int)rows.size() - 1) * betweenRows;
  426. for(auto & row : rows)
  427. height += row.height;
  428. //assert(pos.h == 0 || pos.h < height);
  429. if (pos.h == 0)
  430. pos.h = height;
  431. auto iter = components.begin();
  432. int currentY = (pos.h - height) / 2;
  433. //move components to their positions
  434. for (auto & rows_row : rows)
  435. {
  436. // amount of free space we may add on each side of every component
  437. int freeSpace = (pos.w - rows_row.width) / ((int)rows_row.comps * 2);
  438. prevComp = nullptr;
  439. int currentX = 0;
  440. for (size_t col = 0; col < rows_row.comps; col++)
  441. {
  442. currentX += freeSpace;
  443. if (prevComp)
  444. {
  445. if (selectable)
  446. {
  447. Point orPos = Point(currentX - freeSpace, currentY) + getOrTextPos(prevComp.get(), iter->get());
  448. orLabels.push_back(std::make_shared<CLabel>(orPos.x, orPos.y, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, CGI->generaltexth->allTexts[4]));
  449. }
  450. currentX += getDistance(prevComp.get(), iter->get());
  451. }
  452. (*iter)->moveBy(Point(currentX, currentY));
  453. currentX += (*iter)->pos.w;
  454. currentX += freeSpace;
  455. prevComp = *(iter++);
  456. }
  457. currentY += rows_row.height + betweenRows;
  458. }
  459. }
  460. CComponentBox::CComponentBox(std::vector<std::shared_ptr<CComponent>> _components, Rect position):
  461. CComponentBox(_components, position, defaultBetweenImagesMin, defaultBetweenSubtitlesMin, defaultBetweenRows, defaultComponentsInRow)
  462. {
  463. }
  464. CComponentBox::CComponentBox(std::vector<std::shared_ptr<CComponent>> _components, Rect position, int betweenImagesMin, int betweenSubtitlesMin, int betweenRows, int componentsInRow):
  465. components(_components),
  466. betweenImagesMin(betweenImagesMin),
  467. betweenSubtitlesMin(betweenSubtitlesMin),
  468. betweenRows(betweenRows),
  469. componentsInRow(componentsInRow)
  470. {
  471. setRedrawParent(true);
  472. pos = position + pos.topLeft();
  473. placeComponents(false);
  474. }
  475. CComponentBox::CComponentBox(std::vector<std::shared_ptr<CSelectableComponent>> _components, Rect position, std::function<void(int newID)> _onSelect):
  476. CComponentBox(_components, position, _onSelect, defaultBetweenImagesMin, defaultBetweenSubtitlesMin, defaultBetweenRows, defaultComponentsInRow)
  477. {
  478. }
  479. CComponentBox::CComponentBox(std::vector<std::shared_ptr<CSelectableComponent>> _components, Rect position, std::function<void(int newID)> _onSelect, int betweenImagesMin, int betweenSubtitlesMin, int betweenRows, int componentsInRow):
  480. components(_components.begin(), _components.end()),
  481. onSelect(_onSelect),
  482. betweenImagesMin(betweenImagesMin),
  483. betweenSubtitlesMin(betweenSubtitlesMin),
  484. betweenRows(betweenRows),
  485. componentsInRow(componentsInRow)
  486. {
  487. setRedrawParent(true);
  488. pos = position + pos.topLeft();
  489. placeComponents(true);
  490. assert(!components.empty());
  491. auto key = EShortcut::SELECT_INDEX_1;
  492. for(auto & comp : _components)
  493. {
  494. comp->onSelect = std::bind(&CComponentBox::selectionChanged, this, comp);
  495. comp->assignedKey = key;
  496. key = vstd::next(key, 1);
  497. }
  498. selectionChanged(_components.front());
  499. }