Graphics.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. #include "StdInc.h"
  2. #include "Graphics.h"
  3. #include "../lib/filesystem/Filesystem.h"
  4. #include "../lib/filesystem/CBinaryReader.h"
  5. #include "CDefHandler.h"
  6. #include "gui/SDL_Extensions.h"
  7. #include "gui/CAnimation.h"
  8. #include <SDL_ttf.h>
  9. #include "../lib/CThreadHelper.h"
  10. #include "CGameInfo.h"
  11. #include "../lib/VCMI_Lib.h"
  12. #include "../CCallback.h"
  13. #include "../lib/CHeroHandler.h"
  14. #include "../lib/CTownHandler.h"
  15. #include "../lib/CGeneralTextHandler.h"
  16. #include "../lib/CCreatureHandler.h"
  17. #include "CBitmapHandler.h"
  18. #include "../lib/spells/CSpellHandler.h"
  19. #include "../lib/CGameState.h"
  20. #include "../lib/JsonNode.h"
  21. #include "../lib/vcmi_endian.h"
  22. #include "../lib/CStopWatch.h"
  23. #include "../lib/mapObjects/CObjectClassesHandler.h"
  24. #include "../lib/mapObjects/CObjectHandler.h"
  25. using namespace CSDL_Ext;
  26. #ifdef min
  27. #undef min
  28. #endif
  29. #ifdef max
  30. #undef max
  31. #endif
  32. /*
  33. * Graphics.cpp, part of VCMI engine
  34. *
  35. * Authors: listed in file AUTHORS in main folder
  36. *
  37. * License: GNU General Public License v2.0 or later
  38. * Full text of license available in license.txt file, in main folder
  39. *
  40. */
  41. Graphics * graphics = nullptr;
  42. void Graphics::loadPaletteAndColors()
  43. {
  44. auto textFile = CResourceHandler::get()->load(ResourceID("DATA/PLAYERS.PAL"))->readAll();
  45. std::string pals((char*)textFile.first.get(), textFile.second);
  46. playerColorPalette = new SDL_Color[256];
  47. neutralColor = new SDL_Color;
  48. playerColors = new SDL_Color[PlayerColor::PLAYER_LIMIT_I];
  49. int startPoint = 24; //beginning byte; used to read
  50. for(int i=0; i<256; ++i)
  51. {
  52. SDL_Color col;
  53. col.r = pals[startPoint++];
  54. col.g = pals[startPoint++];
  55. col.b = pals[startPoint++];
  56. col.a = SDL_ALPHA_OPAQUE;
  57. startPoint++;
  58. playerColorPalette[i] = col;
  59. }
  60. neutralColorPalette = new SDL_Color[32];
  61. auto stream = CResourceHandler::get()->load(ResourceID("config/NEUTRAL.PAL"));
  62. CBinaryReader reader(stream.get());
  63. for(int i=0; i<32; ++i)
  64. {
  65. neutralColorPalette[i].r = reader.readUInt8();
  66. neutralColorPalette[i].g = reader.readUInt8();
  67. neutralColorPalette[i].b = reader.readUInt8();
  68. reader.readUInt8(); // this is "flags" entry, not alpha
  69. neutralColorPalette[i].a = SDL_ALPHA_OPAQUE;
  70. }
  71. //colors initialization
  72. SDL_Color colors[] = {
  73. {0xff,0, 0, SDL_ALPHA_OPAQUE},
  74. {0x31,0x52,0xff,SDL_ALPHA_OPAQUE},
  75. {0x9c,0x73,0x52,SDL_ALPHA_OPAQUE},
  76. {0x42,0x94,0x29,SDL_ALPHA_OPAQUE},
  77. {0xff,0x84,0, SDL_ALPHA_OPAQUE},
  78. {0x8c,0x29,0xa5,SDL_ALPHA_OPAQUE},
  79. {0x09,0x9c,0xa5,SDL_ALPHA_OPAQUE},
  80. {0xc6,0x7b,0x8c,SDL_ALPHA_OPAQUE}};
  81. for(int i=0;i<8;i++)
  82. {
  83. playerColors[i] = colors[i];
  84. }
  85. //gray
  86. neutralColor->r = 0x84;
  87. neutralColor->g = 0x84;
  88. neutralColor->b = 0x84;
  89. neutralColor->a = SDL_ALPHA_OPAQUE;
  90. }
  91. void Graphics::initializeBattleGraphics()
  92. {
  93. const JsonNode config(ResourceID("config/battles_graphics.json"));
  94. // Reserve enough space for the terrains
  95. int idx = config["backgrounds"].Vector().size();
  96. battleBacks.resize(idx+1); // 1 to idx, 0 is unused
  97. idx = 1;
  98. for(const JsonNode &t : config["backgrounds"].Vector()) {
  99. battleBacks[idx].push_back(t.String());
  100. idx++;
  101. }
  102. //initialization of AC->def name mapping
  103. for(const JsonNode &ac : config["ac_mapping"].Vector()) {
  104. int ACid = ac["id"].Float();
  105. std::vector< std::string > toAdd;
  106. for(const JsonNode &defname : ac["defnames"].Vector()) {
  107. toAdd.push_back(defname.String());
  108. }
  109. battleACToDef[ACid] = toAdd;
  110. }
  111. }
  112. Graphics::Graphics()
  113. {
  114. #if 0
  115. #define GET_DATA(TYPE,DESTINATION,FUNCTION_TO_GET) \
  116. (std::bind(&setData<TYPE>,&DESTINATION,FUNCTION_TO_GET))
  117. #define GET_DEF_ESS(DESTINATION, DEF_NAME) \
  118. (GET_DATA \
  119. (CDefEssential*,DESTINATION,\
  120. std::function<CDefEssential*()>(std::bind(CDefHandler::giveDefEss,DEF_NAME))))
  121. std::vector<Task> tasks; //preparing list of graphics to load
  122. tasks += std::bind(&Graphics::loadFonts,this);
  123. tasks += std::bind(&Graphics::loadPaletteAndColors,this);
  124. tasks += std::bind(&Graphics::loadHeroFlags,this);
  125. tasks += std::bind(&Graphics::initializeBattleGraphics,this);
  126. tasks += std::bind(&Graphics::loadErmuToPicture,this);
  127. tasks += std::bind(&Graphics::initializeImageLists,this);
  128. CThreadHelper th(&tasks,std::max((ui32)1,boost::thread::hardware_concurrency()));
  129. th.run();
  130. #else
  131. loadFonts();
  132. loadPaletteAndColors();
  133. loadHeroFlags();
  134. initializeBattleGraphics();
  135. loadErmuToPicture();
  136. initializeImageLists();
  137. #endif
  138. //(!) do not load any CAnimation here
  139. }
  140. void Graphics::load()
  141. {
  142. heroMoveArrows = std::make_shared<CAnimation>("ADAG");
  143. heroMoveArrows->preload();
  144. loadHeroAnims();//todo: remove
  145. loadHeroAnimations();
  146. loadHeroFlagAnimations();
  147. }
  148. void Graphics::loadHeroAnims()
  149. {
  150. //first - group number to be rotated1, second - group number after rotation1
  151. std::vector<std::pair<int,int> > rotations =
  152. {
  153. {6,10}, {7,11}, {8,12}, {1,13},
  154. {2,14}, {3,15}
  155. };
  156. for(auto & elem : CGI->heroh->classes.heroClasses)
  157. {
  158. for (auto & templ : VLC->objtypeh->getHandlerFor(Obj::HERO, elem->id)->getTemplates())
  159. {
  160. if (!heroAnims.count(templ.animationFile))
  161. heroAnims[templ.animationFile] = loadHeroAnim(templ.animationFile, rotations);
  162. }
  163. }
  164. boatAnims.push_back(loadHeroAnim("AB01_.DEF", rotations));
  165. boatAnims.push_back(loadHeroAnim("AB02_.DEF", rotations));
  166. boatAnims.push_back(loadHeroAnim("AB03_.DEF", rotations));
  167. }
  168. void Graphics::loadHeroAnimations()
  169. {
  170. for(auto & elem : CGI->heroh->classes.heroClasses)
  171. {
  172. for (auto & templ : VLC->objtypeh->getHandlerFor(Obj::HERO, elem->id)->getTemplates())
  173. {
  174. if (!heroAnimations.count(templ.animationFile))
  175. heroAnimations[templ.animationFile] = loadHeroAnimation(templ.animationFile);
  176. }
  177. }
  178. boatAnimations[0] = loadHeroAnimation("AB01_.DEF");
  179. boatAnimations[1] = loadHeroAnimation("AB02_.DEF");
  180. boatAnimations[2] = loadHeroAnimation("AB03_.DEF");
  181. mapObjectAnimations["AB01_.DEF"] = boatAnimations[0];
  182. mapObjectAnimations["AB02_.DEF"] = boatAnimations[1];
  183. mapObjectAnimations["AB03_.DEF"] = boatAnimations[2];
  184. }
  185. void Graphics::loadHeroFlagAnimations()
  186. {
  187. static const std::vector<std::string> HERO_FLAG_ANIMATIONS =
  188. {
  189. "AF00", "AF01","AF02","AF03",
  190. "AF04", "AF05","AF06","AF07"
  191. };
  192. static const std::vector< std::vector<std::string> > BOAT_FLAG_ANIMATIONS =
  193. {
  194. {
  195. "ABF01L", "ABF01G", "ABF01R", "ABF01D",
  196. "ABF01B", "ABF01P", "ABF01W", "ABF01K"
  197. },
  198. {
  199. "ABF02L", "ABF02G", "ABF02R", "ABF02D",
  200. "ABF02B", "ABF02P", "ABF02W", "ABF02K"
  201. },
  202. {
  203. "ABF03L", "ABF03G", "ABF03R", "ABF03D",
  204. "ABF03B", "ABF03P", "ABF03W", "ABF03K"
  205. }
  206. };
  207. for(const auto & name : HERO_FLAG_ANIMATIONS)
  208. heroFlagAnimations.push_back(loadHeroFlagAnimation(name));
  209. for(int i = 0; i < BOAT_FLAG_ANIMATIONS.size(); i++)
  210. for(const auto & name : BOAT_FLAG_ANIMATIONS[i])
  211. boatFlagAnimations[i].push_back(loadHeroFlagAnimation(name));
  212. }
  213. std::shared_ptr<CAnimation> Graphics::loadHeroFlagAnimation(const std::string & name)
  214. {
  215. //first - group number to be rotated, second - group number after rotation
  216. static const std::vector<std::pair<int,int> > rotations =
  217. {
  218. {6,10}, {7,11}, {8,12}, {1,13},
  219. {2,14}, {3,15}
  220. };
  221. std::shared_ptr<CAnimation> anim = std::make_shared<CAnimation>(name);
  222. anim->preload();
  223. for(const auto & rotation : rotations)
  224. {
  225. const int sourceGroup = rotation.first;
  226. const int targetGroup = rotation.second;
  227. for(size_t frame = 0; frame < anim->size(sourceGroup); ++frame)
  228. {
  229. anim->duplicateImage(sourceGroup, frame, targetGroup);
  230. IImage * image = anim->getImage(frame, targetGroup);
  231. image->verticalFlip();
  232. }
  233. }
  234. return anim;
  235. }
  236. CDefEssential * Graphics::loadHeroAnim( const std::string &name, const std::vector<std::pair<int,int> > &rotations)
  237. {
  238. CDefEssential *anim = CDefHandler::giveDefEss(name);
  239. int pom = 0; //how many groups has been rotated
  240. for(int o=7; pom<6; ++o)
  241. {
  242. for(int p=0;p<6;p++)
  243. {
  244. if(anim->ourImages[o].groupNumber == rotations[p].first)
  245. {
  246. for(int e=0; e<8; ++e)
  247. {
  248. Cimage nci;
  249. nci.bitmap = CSDL_Ext::verticalFlip(anim->ourImages[o+e].bitmap);
  250. nci.groupNumber = rotations[p].second;
  251. nci.imName = std::string();
  252. anim->ourImages.push_back(nci);
  253. if(pom>2) //we need only one frame for groups 13/14/15
  254. break;
  255. }
  256. if(pom<3) //there are eight frames of animtion of groups 6/7/8 so for speed we'll skip them
  257. o+=8;
  258. else //there is only one frame of 1/2/3
  259. o+=1;
  260. ++pom;
  261. if(p==2 && pom<4) //group1 starts at index 1
  262. o = 1;
  263. }
  264. }
  265. }
  266. for(auto & elem : anim->ourImages)
  267. {
  268. CSDL_Ext::alphaTransform(elem.bitmap);
  269. }
  270. return anim;
  271. }
  272. std::shared_ptr<CAnimation> Graphics::loadHeroAnimation(const std::string &name)
  273. {
  274. //first - group number to be rotated, second - group number after rotation
  275. static const std::vector<std::pair<int,int> > rotations =
  276. {
  277. {6,10}, {7,11}, {8,12}, {1,13},
  278. {2,14}, {3,15}
  279. };
  280. std::shared_ptr<CAnimation> anim = std::make_shared<CAnimation>(name);
  281. anim->preload();
  282. for(const auto & rotation : rotations)
  283. {
  284. const int sourceGroup = rotation.first;
  285. const int targetGroup = rotation.second;
  286. for(size_t frame = 0; frame < anim->size(sourceGroup); ++frame)
  287. {
  288. anim->duplicateImage(sourceGroup, frame, targetGroup);
  289. IImage * image = anim->getImage(frame, targetGroup);
  290. image->verticalFlip();
  291. }
  292. }
  293. //todo: apply following commented out optimizations or merge with loadHeroFlagAnimation
  294. // int pom = 0; //how many groups has been rotated
  295. // for(int o = 7; pom < 6; ++o)
  296. // {
  297. // for(int p = 0; p<6; p++)
  298. // {
  299. // IImage frame = anim->getImage()
  300. // if(anim->ourImages[o].groupNumber == rotations[p].first)
  301. // {
  302. // for(int e=0; e<8; ++e)
  303. // {
  304. // Cimage nci;
  305. // nci.bitmap = CSDL_Ext::verticalFlip(anim->ourImages[o+e].bitmap);
  306. // nci.groupNumber = rotations[p].second;
  307. // nci.imName = std::string();
  308. // anim->ourImages.push_back(nci);
  309. // if(pom>2) //we need only one frame for groups 13/14/15
  310. // break;
  311. // }
  312. // if(pom<3) //there are eight frames of animtion of groups 6/7/8 so for speed we'll skip them
  313. // o+=8;
  314. // else //there is only one frame of 1/2/3
  315. // o+=1;
  316. // ++pom;
  317. // if(p==2 && pom<4) //group1 starts at index 1
  318. // o = 1;
  319. // }
  320. // }
  321. // }
  322. return anim;
  323. }
  324. void Graphics::loadHeroFlagsDetail(std::pair<std::vector<CDefEssential *> Graphics::*, std::vector<const char *> > &pr)
  325. {
  326. for(int i=0;i<8;i++)
  327. (this->*pr.first).push_back(CDefHandler::giveDefEss(pr.second[i]));
  328. //first - group number to be rotated1, second - group number after rotation1
  329. std::vector<std::pair<int,int> > rotations =
  330. {
  331. {6,10}, {7,11}, {8,12}
  332. };
  333. for(int q=0; q<8; ++q)
  334. {
  335. std::vector<Cimage> &curImgs = (this->*pr.first)[q]->ourImages;
  336. for(size_t o=0; o<curImgs.size(); ++o)
  337. {
  338. for(auto & rotation : rotations)
  339. {
  340. if(curImgs[o].groupNumber==rotation.first)
  341. {
  342. for(int e=0; e<8; ++e)
  343. {
  344. Cimage nci;
  345. nci.bitmap = CSDL_Ext::verticalFlip(curImgs[o+e].bitmap);
  346. nci.groupNumber = rotation.second;
  347. nci.imName = std::string();
  348. curImgs.push_back(nci);
  349. }
  350. o+=8;
  351. }
  352. }
  353. }
  354. for(size_t o=0; o<curImgs.size(); ++o)
  355. {
  356. if(curImgs[o].groupNumber==1 || curImgs[o].groupNumber==2 || curImgs[o].groupNumber==3)
  357. {
  358. for(int e=0; e<8; ++e)
  359. {
  360. Cimage nci;
  361. nci.bitmap = CSDL_Ext::verticalFlip(curImgs[o+e].bitmap);
  362. nci.groupNumber = 12 + curImgs[o].groupNumber;
  363. nci.imName = std::string();
  364. curImgs.push_back(nci);
  365. }
  366. o+=8;
  367. }
  368. }
  369. for(auto & curImg : curImgs)
  370. {
  371. CSDL_Ext::setDefaultColorKey(curImg.bitmap);
  372. SDL_SetSurfaceBlendMode(curImg.bitmap,SDL_BLENDMODE_NONE);
  373. }
  374. }
  375. }
  376. void Graphics::loadHeroFlags()
  377. {
  378. CStopWatch th;
  379. std::pair<std::vector<CDefEssential *> Graphics::*, std::vector<const char *> > pr[4] =
  380. {
  381. {
  382. &Graphics::flags1,
  383. {"ABF01L.DEF","ABF01G.DEF","ABF01R.DEF","ABF01D.DEF","ABF01B.DEF",
  384. "ABF01P.DEF","ABF01W.DEF","ABF01K.DEF"}
  385. },
  386. {
  387. &Graphics::flags2,
  388. {"ABF02L.DEF","ABF02G.DEF","ABF02R.DEF","ABF02D.DEF","ABF02B.DEF",
  389. "ABF02P.DEF","ABF02W.DEF","ABF02K.DEF"}
  390. },
  391. {
  392. &Graphics::flags3,
  393. {"ABF03L.DEF","ABF03G.DEF","ABF03R.DEF","ABF03D.DEF","ABF03B.DEF",
  394. "ABF03P.DEF","ABF03W.DEF","ABF03K.DEF"}
  395. },
  396. {
  397. &Graphics::flags4,
  398. {"AF00.DEF","AF01.DEF","AF02.DEF","AF03.DEF","AF04.DEF",
  399. "AF05.DEF","AF06.DEF","AF07.DEF"}
  400. }
  401. };
  402. for(auto p: pr)
  403. {
  404. loadHeroFlagsDetail(p);
  405. }
  406. logGlobal->infoStream() << "Loading and transforming heroes' flags: "<<th.getDiff();
  407. }
  408. void Graphics::blueToPlayersAdv(SDL_Surface * sur, PlayerColor player)
  409. {
  410. if(sur->format->palette)
  411. {
  412. SDL_Color *palette = nullptr;
  413. if(player < PlayerColor::PLAYER_LIMIT)
  414. {
  415. palette = playerColorPalette + 32*player.getNum();
  416. }
  417. else if(player == PlayerColor::NEUTRAL)
  418. {
  419. palette = neutralColorPalette;
  420. }
  421. else
  422. {
  423. logGlobal->errorStream() << "Wrong player id in blueToPlayersAdv (" << player << ")!";
  424. return;
  425. }
  426. SDL_SetColors(sur, palette, 224, 32);
  427. }
  428. else
  429. {
  430. //TODO: implement. H3 method works only for images with palettes.
  431. // Add some kind of player-colored overlay?
  432. // Or keep palette approach here and replace only colors of specific value(s)
  433. // Or just wait for OpenGL support?
  434. logGlobal->warnStream() << "Image must have palette to be player-colored!";
  435. }
  436. }
  437. void Graphics::loadFonts()
  438. {
  439. const JsonNode config(ResourceID("config/fonts.json"));
  440. const JsonVector & bmpConf = config["bitmap"].Vector();
  441. const JsonNode & ttfConf = config["trueType"];
  442. const JsonNode & hanConf = config["bitmapHan"];
  443. assert(bmpConf.size() == FONTS_NUMBER);
  444. for (size_t i=0; i<FONTS_NUMBER; i++)
  445. {
  446. std::string filename = bmpConf[i].String();
  447. if (!hanConf[filename].isNull())
  448. fonts[i] = new CBitmapHanFont(hanConf[filename]);
  449. else if (!ttfConf[filename].isNull()) // no ttf override
  450. fonts[i] = new CTrueTypeFont(ttfConf[filename]);
  451. else
  452. fonts[i] = new CBitmapFont(filename);
  453. }
  454. }
  455. CDefEssential * Graphics::getDef( const CGObjectInstance * obj )
  456. {
  457. if (obj->appearance.animationFile.empty())
  458. {
  459. logGlobal->warnStream() << boost::format("Def name for obj %d (%d,%d) is empty!") % obj->id % obj->ID % obj->subID;
  460. return nullptr;
  461. }
  462. return advmapobjGraphics[obj->appearance.animationFile];
  463. }
  464. CDefEssential * Graphics::getDef( const ObjectTemplate & info )
  465. {
  466. if (info.animationFile.empty())
  467. {
  468. logGlobal->warnStream() << boost::format("Def name for obj (%d,%d) is empty!") % info.id % info.subid;
  469. return nullptr;
  470. }
  471. return advmapobjGraphics[info.animationFile];
  472. }
  473. std::shared_ptr<CAnimation> Graphics::getAnimation(const CGObjectInstance* obj)
  474. {
  475. return getAnimation(obj->appearance);
  476. }
  477. std::shared_ptr<CAnimation> Graphics::getAnimation(const ObjectTemplate & info)
  478. {
  479. //the only(?) invisible object
  480. if(info.id == Obj::EVENT)
  481. {
  482. return std::shared_ptr<CAnimation>();
  483. }
  484. if(info.animationFile.empty())
  485. {
  486. logGlobal->warnStream() << boost::format("Def name for obj (%d,%d) is empty!") % info.id % info.subid;
  487. return std::shared_ptr<CAnimation>();
  488. }
  489. std::shared_ptr<CAnimation> ret = mapObjectAnimations[info.animationFile];
  490. //already loaded
  491. if(ret)
  492. {
  493. ret->preload();
  494. return ret;
  495. }
  496. ret = std::make_shared<CAnimation>(info.animationFile);
  497. mapObjectAnimations[info.animationFile] = ret;
  498. ret->preload();
  499. return ret;
  500. }
  501. void Graphics::loadErmuToPicture()
  502. {
  503. //loading ERMU to picture
  504. const JsonNode config(ResourceID("config/ERMU_to_picture.json"));
  505. int etp_idx = 0;
  506. for(const JsonNode &etp : config["ERMU_to_picture"].Vector()) {
  507. int idx = 0;
  508. for(const JsonNode &n : etp.Vector()) {
  509. ERMUtoPicture[idx][etp_idx] = n.String();
  510. idx ++;
  511. }
  512. assert (idx == ARRAY_COUNT(ERMUtoPicture));
  513. etp_idx ++;
  514. }
  515. assert (etp_idx == 44);
  516. }
  517. void Graphics::addImageListEntry(size_t index, std::string listName, std::string imageName)
  518. {
  519. if (!imageName.empty())
  520. {
  521. JsonNode entry;
  522. entry["frame"].Float() = index;
  523. entry["file"].String() = imageName;
  524. imageLists["SPRITES/" + listName]["images"].Vector().push_back(entry);
  525. }
  526. }
  527. void Graphics::initializeImageLists()
  528. {
  529. for(const CCreature * creature : CGI->creh->creatures)
  530. {
  531. addImageListEntry(creature->iconIndex, "CPRSMALL", creature->smallIconName);
  532. addImageListEntry(creature->iconIndex, "TWCRPORT", creature->largeIconName);
  533. }
  534. for(const CHero * hero : CGI->heroh->heroes)
  535. {
  536. addImageListEntry(hero->imageIndex, "UN32", hero->iconSpecSmall);
  537. addImageListEntry(hero->imageIndex, "UN44", hero->iconSpecLarge);
  538. addImageListEntry(hero->imageIndex, "PORTRAITSLARGE", hero->portraitLarge);
  539. addImageListEntry(hero->imageIndex, "PORTRAITSSMALL", hero->portraitSmall);
  540. }
  541. for(const CArtifact * art : CGI->arth->artifacts)
  542. {
  543. addImageListEntry(art->iconIndex, "ARTIFACT", art->image);
  544. addImageListEntry(art->iconIndex, "ARTIFACTLARGE", art->large);
  545. }
  546. for(const CFaction * faction : CGI->townh->factions)
  547. {
  548. if (faction->town)
  549. {
  550. auto & info = faction->town->clientInfo;
  551. addImageListEntry(info.icons[0][0], "ITPT", info.iconLarge[0][0]);
  552. addImageListEntry(info.icons[0][1], "ITPT", info.iconLarge[0][1]);
  553. addImageListEntry(info.icons[1][0], "ITPT", info.iconLarge[1][0]);
  554. addImageListEntry(info.icons[1][1], "ITPT", info.iconLarge[1][1]);
  555. addImageListEntry(info.icons[0][0] + 2, "ITPA", info.iconSmall[0][0]);
  556. addImageListEntry(info.icons[0][1] + 2, "ITPA", info.iconSmall[0][1]);
  557. addImageListEntry(info.icons[1][0] + 2, "ITPA", info.iconSmall[1][0]);
  558. addImageListEntry(info.icons[1][1] + 2, "ITPA", info.iconSmall[1][1]);
  559. }
  560. }
  561. for(const CSpell * spell : CGI->spellh->objects)
  562. {
  563. addImageListEntry(spell->id, "SPELLS", spell->iconBook);
  564. addImageListEntry(spell->id+1, "SPELLINT", spell->iconEffect);
  565. addImageListEntry(spell->id, "SPELLBON", spell->iconScenarioBonus);
  566. addImageListEntry(spell->id, "SPELLSCR", spell->iconScroll);
  567. }
  568. }