CMessage.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. #include "stdafx.h"
  2. #include "CMessage.h"
  3. #include "SDL_ttf.h"
  4. #include "hch/CDefHandler.h"
  5. #include "CGameInfo.h"
  6. #include "SDL_Extensions.h"
  7. #include "hch/CLodHandler.h"
  8. #include <boost/algorithm/string.hpp>
  9. #include <boost/algorithm/string/replace.hpp>
  10. #include "CPlayerInterface.h"
  11. #include "hch/CDefHandler.h"
  12. #include "CGameInfo.h"
  13. #include "SDL_Extensions.h"
  14. #include <sstream>
  15. #include "hch/CGeneralTextHandler.h"
  16. #include "client/Graphics.h"
  17. #include "CAdvmapInterface.h"
  18. SDL_Color tytulowy, tlo, zwykly ;
  19. extern SDL_Surface * screen;
  20. extern TTF_Font * TNRB16, *TNR, *GEOR13;
  21. using namespace NMessage;
  22. const int COMPONENT_TO_SUBTITLE = 5;
  23. const int BETWEEN_COMPS_ROWS = 10;
  24. const int BEFORE_COMPONENTS = 30;
  25. template <typename T, typename U> std::pair<T,U> max(const std::pair<T,U> &x, const std::pair<T,U> &y)
  26. {
  27. std::pair<T,U> ret;
  28. ret.first = std::max(x.first,y.first);
  29. ret.second = std::max(x.second,y.second);
  30. return ret;
  31. }
  32. namespace NMessage
  33. {
  34. CDefHandler * ok, *cancel;
  35. std::vector<std::vector<SDL_Surface*> > piecesOfBox; //in colors of all players
  36. SDL_Surface * background = NULL;
  37. }
  38. void CMessage::init()
  39. {
  40. {
  41. for (int i=0;i<PLAYER_LIMIT;i++)
  42. {
  43. CDefHandler * bluePieces = CDefHandler::giveDef("DIALGBOX.DEF");
  44. std::vector<SDL_Surface *> n;
  45. piecesOfBox.push_back(n);
  46. if (i==1)
  47. {
  48. for (size_t j=0;j<bluePieces->ourImages.size();++j)
  49. {
  50. piecesOfBox[i].push_back(bluePieces->ourImages[j].bitmap);
  51. }
  52. }
  53. for (size_t j=0;j<bluePieces->ourImages.size();++j)
  54. {
  55. graphics->blueToPlayersAdv(bluePieces->ourImages[j].bitmap,i);
  56. piecesOfBox[i].push_back(bluePieces->ourImages[j].bitmap);
  57. }
  58. }
  59. NMessage::background = BitmapHandler::loadBitmap("DIBOXBCK.BMP");
  60. SDL_SetColorKey(background,SDL_SRCCOLORKEY,SDL_MapRGB(background->format,0,255,255));
  61. }
  62. ok = CDefHandler::giveDef("IOKAY.DEF");
  63. cancel = CDefHandler::giveDef("ICANCEL.DEF");
  64. }
  65. void CMessage::dispose()
  66. {
  67. for (int i=0;i<PLAYER_LIMIT;i++)
  68. {
  69. for (size_t j=0; j<piecesOfBox[i].size(); ++j)
  70. {
  71. SDL_FreeSurface(piecesOfBox[i][j]);
  72. }
  73. }
  74. SDL_FreeSurface(background);
  75. delete ok;
  76. delete cancel;
  77. }
  78. SDL_Surface * CMessage::drawBox1(int w, int h, int playerColor) //draws box for window
  79. {
  80. //prepare surface
  81. SDL_Surface * ret = SDL_CreateRGBSurface(screen->flags, w, h, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, screen->format->Amask);
  82. for (int i=0; i<h; i+=background->h)//background
  83. {
  84. for (int j=0; j<w; j+=background->w-1)
  85. {
  86. SDL_BlitSurface(background,&genRect(background->h,background->w-1,1,0),ret,&genRect(h,w,j,i)); //FIXME taking address of temporary
  87. }
  88. }
  89. drawBorder(playerColor, ret, w, h);
  90. return ret;
  91. }
  92. std::vector<std::string> * CMessage::breakText(std::string text, size_t line, bool userBreak, bool ifor) //TODO userBreak -- use me
  93. {
  94. std::vector<std::string> * ret = new std::vector<std::string>();
  95. while (text.length()>line)
  96. {
  97. int whereCut = -1, braces=0;
  98. bool pom = true, opened=false;
  99. for (size_t i=0; i<line+braces; i++)
  100. {
  101. if (text[i]==10) //end of line sign
  102. {
  103. whereCut=i+1;
  104. pom=false;
  105. break;
  106. }
  107. else if (ifor && ((text[i]=='{') || (text[i]=='}'))) // ignore braces
  108. {
  109. if (text[i]=='{')
  110. opened=true;
  111. else
  112. opened=false;
  113. braces++;
  114. }
  115. }
  116. for (int i=line+braces; i>0&&pom; i--)
  117. {
  118. if (text[i]==' ')
  119. {
  120. whereCut = i;
  121. break;
  122. }
  123. else if (opened && text[i]=='{')
  124. opened = false;
  125. else if (text[i]=='}')
  126. opened = true;
  127. }
  128. ret->push_back(text.substr(0,whereCut));
  129. text.erase(0,whereCut);
  130. boost::algorithm::trim_left_if(text,boost::algorithm::is_any_of(" "));
  131. if (opened)
  132. {
  133. (*(ret->end()-1))+='}';
  134. text.insert(0,"{");
  135. }
  136. }
  137. for (size_t i=0;i<text.length();i++)
  138. {
  139. if (text[i]==10) //end of line sign
  140. {
  141. ret->push_back(text.substr(0,i));
  142. text.erase(0,i);
  143. i=0;
  144. }
  145. }
  146. if (text.length() > 0)
  147. ret->push_back(text);
  148. for (size_t i=0; i<ret->size(); i++)
  149. {
  150. boost::algorithm::trim((*ret)[i]);
  151. }
  152. return ret;
  153. }
  154. std::pair<int,int> CMessage::getMaxSizes(std::vector<std::vector<SDL_Surface*> > * txtg)
  155. {
  156. std::pair<int,int> ret;
  157. ret.first = -1;
  158. ret.second=0;
  159. for (size_t i=0; i<txtg->size();i++) //szukamy najszerszej linii i lacznej wysokosci
  160. {
  161. int lw=0;
  162. for (size_t j=0;j<(*txtg)[i].size();j++)
  163. {
  164. lw+=(*txtg)[i][j]->w;
  165. ret.second+=(*txtg)[i][j]->h;
  166. }
  167. if(!(*txtg)[i].size())
  168. ret.second+=19;
  169. if (ret.first<lw)
  170. ret.first=lw;
  171. }
  172. return ret;
  173. }
  174. SDL_Surface * CMessage::blitTextOnSur(std::vector<std::vector<SDL_Surface*> > * txtg, int & curh, SDL_Surface * ret, int xCenterPos)
  175. {
  176. for (size_t i=0; i<txtg->size();i++)
  177. {
  178. int lw=0; //line width
  179. for (size_t j=0;j<(*txtg)[i].size();j++)
  180. lw+=(*txtg)[i][j]->w;
  181. int pw = (xCenterPos < 0) ? ret->w/2 : xCenterPos;
  182. pw -= lw/2; //x coord for the start of the text
  183. int tw = pw;
  184. for (size_t j=0;j<(*txtg)[i].size();j++) //blit text
  185. {
  186. blitAt((*txtg)[i][j],tw,curh+i*19,ret);
  187. tw+=(*txtg)[i][j]->w;
  188. SDL_FreeSurface((*txtg)[i][j]);
  189. (*txtg)[i][j] = NULL;
  190. }
  191. }
  192. curh+=txtg->size()*19;
  193. return ret;
  194. }
  195. std::vector<std::vector<SDL_Surface*> > * CMessage::drawText(std::vector<std::string> * brtext, TTF_Font *font)
  196. {
  197. if(!font) font = TNRB16;
  198. std::vector<std::vector<SDL_Surface*> > * txtg = new std::vector<std::vector<SDL_Surface*> >();
  199. txtg->resize(brtext->size());
  200. for (size_t i=0; i<brtext->size();i++) //foreach line
  201. {
  202. while((*brtext)[i].length()) //jesli zostalo cos
  203. {
  204. size_t z=0; bool br=true;
  205. while( ((*brtext)[i][z]) != ('{') )
  206. {
  207. if (z >= (((*brtext)[i].length())-1))
  208. {
  209. br=false;
  210. break;
  211. }
  212. z++;
  213. }
  214. if (!br)
  215. z++;
  216. if (z)
  217. (*txtg)[i].push_back(TTF_RenderText_Blended(font,(*brtext)[i].substr(0,z).c_str(),zwykly));
  218. (*brtext)[i].erase(0,z);
  219. z=0;
  220. if ( ((*brtext)[i].length()==0) || ((*brtext)[i][z]!='{') )
  221. {
  222. continue;
  223. }
  224. while( ((*brtext)[i][++z]) != ('}') )
  225. {}
  226. //tyemp = (*brtext)[i].substr(1,z-1); //od 1 bo pomijamy otwierajaca klamre
  227. (*txtg)[i].push_back(TTF_RenderText_Blended(font,(*brtext)[i].substr(1,z-1).c_str(),tytulowy));
  228. (*brtext)[i].erase(0,z+1); //z+1 bo dajemy zamykajaca klamre
  229. } //ends while((*brtext)[i].length())
  230. } //ends for(int i=0; i<brtext->size();i++)
  231. return txtg;
  232. }
  233. CSimpleWindow * CMessage::genWindow(std::string text, int player, int Lmar, int Rmar, int Tmar, int Bmar)
  234. {
  235. CSimpleWindow * ret = new CSimpleWindow();
  236. std::vector<std::string> * brtext = breakText(text,32,true,true);
  237. std::vector<std::vector<SDL_Surface*> > * txtg = drawText(brtext);
  238. std::pair<int,int> txts = getMaxSizes(txtg);
  239. ret->bitmap = drawBox1(txts.first+Lmar+Rmar,txts.second+Tmar+Bmar,0);
  240. ret->pos.h=ret->bitmap->h;
  241. ret->pos.w=ret->bitmap->w;
  242. int curh = ret->bitmap->h/2 - (19*txtg->size())/2;
  243. blitTextOnSur(txtg,curh,ret->bitmap);
  244. delete brtext;
  245. delete txtg;
  246. return ret;
  247. }
  248. SDL_Surface * CMessage::drawBoxTextBitmapSub( int player, std::string text, SDL_Surface* bitmap, std::string sub, int charperline/*=30*/, int imgToBmp/*=55*/ )
  249. {
  250. int curh;
  251. std::vector<std::string> * tekst = breakText(text,charperline);
  252. std::vector<std::vector<SDL_Surface*> > * txtg = drawText(tekst);
  253. std::pair<int,int> txts = getMaxSizes(txtg), boxs;
  254. boxs.first = std::max(txts.first,bitmap->w) // text/bitmap max width
  255. + 50; //side margins
  256. boxs.second =
  257. (curh=45) //top margin
  258. + txts.second //text total height
  259. + imgToBmp //text <=> img
  260. + bitmap->h
  261. + 5 // to sibtitle
  262. + (*txtg)[0][0]->h
  263. + 30;
  264. SDL_Surface *ret = drawBox1(boxs.first,boxs.second,player);
  265. blitTextOnSur(txtg,curh,ret);
  266. curh += imgToBmp;
  267. blitAt(bitmap,(ret->w/2)-(bitmap->w/2),curh,ret);
  268. curh += bitmap->h + 5;
  269. CSDL_Ext::printAtMiddle(sub,ret->w/2,curh+10,GEOR13,zwykly,ret);
  270. delete tekst;
  271. delete txtg;
  272. return ret;
  273. }
  274. void CMessage::drawIWindow(CInfoWindow * ret, std::string text, int player, int charperline)
  275. {
  276. SDL_Surface * _or = NULL;
  277. if(dynamic_cast<CSelWindow*>(ret)) //it's selection window, so we'll blit "or" between components
  278. _or = TTF_RenderText_Blended(GEOR13,CGI->generaltexth->allTexts[4].c_str(),zwykly);
  279. std::vector<std::string> * brtext = breakText(text,charperline,true,true); //text
  280. std::vector<std::vector<SDL_Surface*> > * txtg = drawText(brtext);
  281. std::pair<int,int> txts = getMaxSizes(txtg);
  282. ComponentsToBlit comps(ret->components,500,_or);
  283. if(ret->buttons.size())
  284. txts.second += 20 + //before button
  285. ok->ourImages[0].bitmap->h; //button
  286. if (ret->components.size())
  287. {
  288. txts.second += 30 + comps.h; //space to first component
  289. }
  290. amax(txts.first,comps.w);
  291. ret->bitmap = drawBox1(txts.first+70,txts.second+70,0);
  292. ret->pos.h=ret->bitmap->h;
  293. ret->pos.w=ret->bitmap->w;
  294. ret->pos.x=screen->w/2-(ret->pos.w/2);
  295. ret->pos.y=screen->h/2-(ret->pos.h/2);
  296. int curh = 30; //gorny margines
  297. blitTextOnSur(txtg,curh,ret->bitmap);
  298. if (ret->components.size())
  299. {
  300. curh += BEFORE_COMPONENTS;
  301. comps.blitCompsOnSur(_or, 10, curh, ret->bitmap);
  302. }
  303. if(ret->buttons.size())
  304. {
  305. curh += 20; //to buttton
  306. int bw = 20*(ret->buttons.size()-1); //total width of buttons - start with distance between them
  307. for(size_t i=0; i<ret->buttons.size(); i++) //and add buttons width
  308. bw+=ret->buttons[i]->imgs[0][0]->w;
  309. bw = (ret->bitmap->w/2) - (bw/2);
  310. for(size_t i=0; i<ret->buttons.size(); i++)
  311. {
  312. ret->buttons[i]->pos.x = bw + ret->pos.x;
  313. ret->buttons[i]->pos.y = curh + ret->pos.y;
  314. bw += ret->buttons[i]->imgs[0][0]->w + 20;
  315. }
  316. }
  317. for(size_t i=0; i<ret->components.size(); i++)
  318. {
  319. ret->components[i]->pos.x += ret->pos.x;
  320. ret->components[i]->pos.y += ret->pos.y;
  321. }
  322. delete brtext;
  323. delete txtg;
  324. if(_or)
  325. SDL_FreeSurface(_or);
  326. }
  327. SDL_Surface * CMessage::genMessage
  328. (std::string title, std::string text, EWindowType type, std::vector<CDefHandler*> *addPics, void * cb)
  329. {
  330. //max x 320 okolo 30 znakow
  331. std::vector<std::string> * tekst;
  332. if (text.length() < 30) //nie trzeba polamac
  333. {
  334. tekst = new std::vector<std::string>();
  335. tekst->push_back(text);
  336. }
  337. else tekst = breakText(text);
  338. int ww, hh; //wymiary boksa
  339. if (319>30+13*text.length())
  340. ww = 30+13*text.length();
  341. else ww = 319;
  342. if (title.length())
  343. hh=110+(21*tekst->size());
  344. else hh=60+(21*tekst->size());
  345. if (type==yesOrNO) //make place for buttons
  346. {
  347. if (ww<200) ww=200;
  348. hh+=70;
  349. }
  350. SDL_Surface * ret = drawBox1(ww,hh,0);
  351. //prepare title text
  352. if (title.length())
  353. {
  354. SDL_Surface * titleText = TTF_RenderText_Blended(TNRB16,title.c_str(),tytulowy);
  355. //draw title
  356. SDL_Rect tytul = genRect(titleText->h,titleText->w,((ret->w/2)-(titleText->w/2)),37);
  357. SDL_BlitSurface(titleText,NULL,ret,&tytul);
  358. SDL_FreeSurface(titleText);
  359. }
  360. //draw text
  361. for (size_t i=0; i<tekst->size(); i++)
  362. {
  363. int by = 37+i*21;
  364. if (title.length()) by+=40;
  365. SDL_Surface * tresc = TTF_RenderText_Blended(TNRB16,(*tekst)[i].c_str(),zwykly);
  366. SDL_Rect trescRect = genRect(tresc->h,tresc->w,((ret->w/2)-(tresc->w/2)),by);
  367. SDL_BlitSurface(tresc,NULL,ret,&trescRect);
  368. SDL_FreeSurface(tresc);
  369. }
  370. if (type==yesOrNO) // add buttons
  371. {
  372. int by = 77+tekst->size()*21;
  373. if (title.length()) by+=40;
  374. int hwo = (*addPics)[0]->ourImages[0].bitmap->w, hwc=(*addPics)[0]->ourImages[0].bitmap->w;
  375. //ok
  376. SDL_Rect trescRect = genRect((*addPics)[0]->ourImages[0].bitmap->h,hwo,((ret->w/2)-hwo-10),by);
  377. SDL_BlitSurface((*addPics)[0]->ourImages[0].bitmap,NULL,ret,&trescRect);
  378. ((std::vector<SDL_Rect>*)(cb))->push_back(trescRect);
  379. //cancel
  380. trescRect = genRect((*addPics)[1]->ourImages[0].bitmap->h,hwc,((ret->w/2)+10),by);
  381. SDL_BlitSurface((*addPics)[1]->ourImages[0].bitmap,NULL,ret,&trescRect);
  382. ((std::vector<SDL_Rect>*)(cb))->push_back(trescRect);
  383. }
  384. delete tekst;
  385. return ret;
  386. }
  387. void CMessage::drawBorder(int playerColor, SDL_Surface * ret, int w, int h, int x, int y)
  388. {
  389. //obwodka I-szego rzedu pozioma
  390. for (int i=0; i<w-piecesOfBox[playerColor][6]->w; i+=piecesOfBox[playerColor][6]->w)
  391. {
  392. SDL_BlitSurface
  393. (piecesOfBox[playerColor][6],NULL,ret,&genRect(piecesOfBox[playerColor][6]->h,piecesOfBox[playerColor][6]->w,x+i,y+0));
  394. SDL_BlitSurface
  395. (piecesOfBox[playerColor][7],NULL,ret,&genRect(piecesOfBox[playerColor][7]->h,piecesOfBox[playerColor][7]->w,x+i,y+h-piecesOfBox[playerColor][7]->h));
  396. }
  397. //obwodka I-szego rzedu pionowa
  398. for (int i=0; i<h-piecesOfBox[playerColor][4]->h; i+=piecesOfBox[playerColor][4]->h)
  399. {
  400. SDL_BlitSurface
  401. (piecesOfBox[playerColor][4],NULL,ret,&genRect(piecesOfBox[playerColor][4]->h,piecesOfBox[playerColor][4]->w,x+0,y+i));
  402. SDL_BlitSurface
  403. (piecesOfBox[playerColor][5],NULL,ret,&genRect(piecesOfBox[playerColor][5]->h,piecesOfBox[playerColor][5]->w,x+w-piecesOfBox[playerColor][5]->w,y+i));
  404. }
  405. //corners
  406. SDL_BlitSurface
  407. (piecesOfBox[playerColor][0],NULL,ret,&genRect(piecesOfBox[playerColor][0]->h,piecesOfBox[playerColor][0]->w,x+0,y+0));
  408. SDL_BlitSurface
  409. (piecesOfBox[playerColor][1],NULL,ret,&genRect(piecesOfBox[playerColor][1]->h,piecesOfBox[playerColor][1]->w,x+w-piecesOfBox[playerColor][1]->w,y+0));
  410. SDL_BlitSurface
  411. (piecesOfBox[playerColor][2],NULL,ret,&genRect(piecesOfBox[playerColor][2]->h,piecesOfBox[playerColor][2]->w,x+0,y+h-piecesOfBox[playerColor][2]->h));
  412. SDL_BlitSurface
  413. (piecesOfBox[playerColor][3],NULL,ret,&genRect(piecesOfBox[playerColor][3]->h,piecesOfBox[playerColor][3]->w,x+w-piecesOfBox[playerColor][3]->w,y+h-piecesOfBox[playerColor][3]->h));
  414. }
  415. ComponentResolved::ComponentResolved()
  416. {
  417. comp = NULL;
  418. img = NULL;
  419. txt = NULL;
  420. }
  421. ComponentResolved::ComponentResolved( SComponent *Comp )
  422. {
  423. comp = Comp;
  424. img = comp->getImg();
  425. std::vector<std::string> * brtext = CMessage::breakText(comp->subtitle,11,true,true); //text
  426. txt = CMessage::drawText(brtext,GEOR13);
  427. delete brtext;
  428. comp->pos.w = img->w;
  429. comp->pos.h = img->h + COMPONENT_TO_SUBTITLE + CMessage::getMaxSizes(txt).second;
  430. }
  431. ComponentResolved::~ComponentResolved()
  432. {
  433. for(size_t i = 0; i < txt->size(); i++)
  434. for(size_t j = 0; j < (*txt)[i].size(); j++)
  435. if((*txt)[i][j])
  436. SDL_FreeSurface((*txt)[i][j]);
  437. delete txt;
  438. }
  439. ComponentsToBlit::~ComponentsToBlit()
  440. {
  441. for(size_t i=0; i<comps.size(); i++)
  442. for(size_t j = 0; j < comps[i].size(); j++)
  443. delete comps[i][j];
  444. }
  445. ComponentsToBlit::ComponentsToBlit(std::vector<SComponent*> & SComps, int maxw, SDL_Surface* _or)
  446. {
  447. w = h = 0;
  448. if(!SComps.size())
  449. return;
  450. comps.resize(1);
  451. int curw = 0;
  452. int curr = 0;
  453. for(size_t i=0;i<SComps.size();i++)
  454. {
  455. int toadd = (SComps[i]->getImg()->w + 12 + (_or ? _or->w : 0));
  456. if (curw + toadd > maxw)
  457. {
  458. amax(w,curw);
  459. curw = SComps[i]->getImg()->w;
  460. comps.resize(curr+1);
  461. }
  462. else
  463. {
  464. curw += toadd;
  465. }
  466. comps[curr].push_back(new ComponentResolved(SComps[i]));
  467. }
  468. for(size_t i=0;i<comps.size();i++)
  469. {
  470. int maxh = 0;
  471. for(size_t j=0;j<comps.size();j++)
  472. amax(maxh,comps[i][j]->comp->pos.h);
  473. h += maxh + BETWEEN_COMPS_ROWS;
  474. }
  475. }
  476. void ComponentsToBlit::blitCompsOnSur( SDL_Surface * _or, int inter, int &curh, SDL_Surface *ret )
  477. {
  478. for (size_t i=0;i<comps.size();i++)
  479. {
  480. int totalw=0, maxh=0;
  481. for(size_t j=0;j<(comps)[i].size();j++)
  482. {
  483. ComponentResolved *cur = (comps)[i][j];
  484. totalw += cur->comp->pos.w;
  485. amax(maxh,cur->comp->pos.h);
  486. }
  487. if(_or)
  488. {
  489. totalw += (inter*2+_or->w) * ((comps)[i].size() - 1);
  490. }
  491. else
  492. {
  493. totalw += (inter) * ((comps)[i].size() - 1);
  494. }
  495. curh+=maxh/2;
  496. int curw = (ret->w/2)-(totalw/2);
  497. for(size_t j=0;j<(comps)[i].size();j++)
  498. {
  499. ComponentResolved *cur = (comps)[i][j];
  500. //blit img
  501. int hlp = curh-(cur->comp->pos.h)/2;
  502. blitAt(cur->img,curw,hlp,ret);
  503. cur->comp->pos.x = curw;
  504. cur->comp->pos.y = hlp;
  505. //blit subtitle
  506. hlp += cur->img->h + COMPONENT_TO_SUBTITLE;
  507. CMessage::blitTextOnSur(cur->txt, hlp, ret, cur->comp->pos.x + cur->comp->pos.w/2 );
  508. //if there is subsequent component blit "or"
  509. curw += cur->img->w;
  510. if(j<((comps)[i].size()-1))
  511. {
  512. if(_or)
  513. {
  514. curw+=inter;
  515. blitAt(_or,curw,curh-(_or->h/2),ret);
  516. curw+=_or->w;
  517. }
  518. curw+=inter;
  519. }
  520. }
  521. curh+=maxh/2;
  522. }
  523. }