Clone of Akilla's ac2d @ https://github.com/deregtd/AC2D

cCustomWindows.h 31KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210
  1. #pragma once
  2. class cSkillWindow : public cMovableWindow, private RenderEventAbstractor< cSkillWindow >, private ResizeEventAbstractor< cSkillWindow >
  3. {
  4. public:
  5. cSkillWindow()
  6. {
  7. m_CharInfo = NULL;
  8. m_iLastScroll = 0;
  9. m_ttList = NULL;
  10. for (int i=0; i<4; i++)
  11. {
  12. m_pbWords[i].SetSize(m_wClientArea.GetWidth()-16, 16);
  13. m_pbWords[i].SetAnchorRight(true);
  14. AddClientChild(m_pbWords[i]);
  15. m_stWords[i].SetSize(m_pbWords[i].GetWidth()-5, m_pbWords[i].GetHeight());
  16. m_stWords[i].SetPosition(5, 0);
  17. m_stWords[i].SetTextColor(0xFFFFFF);
  18. m_stWords[i].SetVisible(true);
  19. m_stWords[i].SetAnchorBottom(true);
  20. m_stWords[i].SetAnchorRight(true);
  21. m_pbWords[i].AddChild(m_stWords[i]);
  22. }
  23. m_stWords[3].SetText("Specialized");
  24. m_stWords[2].SetText("Trained");
  25. m_stWords[1].SetText("Untrained");
  26. m_stWords[0].SetText("Unusable");
  27. m_pbWords[3].SetPicture(0x06000F90);
  28. m_pbWords[2].SetPicture(0x06000F86);
  29. m_pbWords[1].SetPicture(0x06000F89);
  30. m_pbWords[0].SetPicture(0x06000F89);
  31. m_sbScroll.SetPosition(m_wClientArea.GetWidth()-16, 0);
  32. m_sbScroll.SetSize(16, m_wClientArea.GetHeight());
  33. m_sbScroll.SetAnchorBottom(true);
  34. m_sbScroll.SetAnchorLeft(false);
  35. m_sbScroll.SetAnchorRight(true);
  36. m_sbScroll.SetVisible(true);
  37. m_sbScroll.SetMin(0);
  38. m_sbScroll.SetMax(0);
  39. m_sbScroll.SetValue(0);
  40. AddClientChild(m_sbScroll);
  41. AddRenderEventHandler( *(RenderEventAbstractor< cSkillWindow > *)this );
  42. AddResizeEventHandler( *(ResizeEventAbstractor< cSkillWindow > *)this );
  43. }
  44. ~cSkillWindow()
  45. {
  46. for (int i=0; i<4; i++)
  47. {
  48. m_pbWords[i].RemoveChild(m_stWords[i]);
  49. RemoveClientChild(m_pbWords[i]);
  50. }
  51. RemoveClientChild(m_sbScroll);
  52. delete []m_ttList;
  53. int iMax = (int) m_mLines.size();
  54. for (std::map<DWORD, cPictureBox *>::iterator it = m_mLines.begin(); it != m_mLines.end(); it++)
  55. {
  56. int i = it->first;
  57. m_mLines[i]->RemoveChild(*m_mIcons[i]);
  58. m_mLines[i]->RemoveChild(*m_mNames[i]);
  59. m_mLines[i]->RemoveChild(*m_mVals[i]);
  60. RemoveClientChild(*m_mLines[i]);
  61. delete m_mIcons[i];
  62. delete m_mNames[i];
  63. delete m_mVals[i];
  64. delete m_mLines[i];
  65. }
  66. }
  67. void SetCharInfo(cCharInfo *CharInfo)
  68. {
  69. m_CharInfo = CharInfo;
  70. int iMaxSkill = m_CharInfo->GetMaxSkill();
  71. m_ttList = new eTrainingType[iMaxSkill+1];
  72. for (int i=0; i<=iMaxSkill; i++)
  73. {
  74. if (!m_CharInfo->GetSkillValid(i))
  75. continue;
  76. stInternalSkill *Sk = m_CharInfo->GetSkillInfo(i);
  77. m_ttList[i] = Sk->dwTrained;
  78. m_mLines[i] = new cPictureBox();
  79. m_mIcons[i] = new cPictureBox();
  80. m_mNames[i] = new cStaticText();
  81. m_mVals[i] = new cStaticText();
  82. m_mLines[i]->SetPicture(0x06000F98);
  83. m_mLines[i]->SetVisible(true);
  84. m_mLines[i]->SetSize(m_wClientArea.GetWidth()-16, 16);
  85. m_mLines[i]->SetPosition(0, 0);
  86. m_mLines[i]->SetAnchorRight(true);
  87. AddClientChild(*m_mLines[i]);
  88. m_mIcons[i]->SetPosition(0,0);
  89. m_mIcons[i]->SetSize(16,16);
  90. m_mIcons[i]->SetVisible(true);
  91. m_mIcons[i]->SetPicture(Sk->dwIcon);
  92. m_mLines[i]->AddChild(*m_mIcons[i]);
  93. m_mNames[i]->SetPosition(17,0);
  94. m_mNames[i]->SetSize(100,16);
  95. m_mNames[i]->SetVisible(true);
  96. m_mNames[i]->SetTextColor(0xFFFFFF);
  97. m_mNames[i]->SetText(Sk->szName);
  98. m_mLines[i]->AddChild(*m_mNames[i]);
  99. m_mVals[i]->SetPosition(m_mLines[i]->GetWidth()-30,0);
  100. m_mVals[i]->SetSize(25,16);
  101. m_mVals[i]->SetVisible(true);
  102. m_mVals[i]->SetAnchorLeft(false);
  103. m_mVals[i]->SetAnchorRight(true);
  104. m_mVals[i]->SetTextColor(0xFFFFFF);
  105. m_mVals[i]->SetTextHAlign(eRight);
  106. m_mLines[i]->AddChild(*m_mVals[i]);
  107. }
  108. FireResized();
  109. }
  110. bool ResizeEventAbstractor< cSkillWindow >::OnResize( IWindow &Window, float NewWidth, float NewHeight )
  111. {
  112. return true;
  113. }
  114. bool ResizeEventAbstractor< cSkillWindow >::OnResized( IWindow & Window )
  115. {
  116. if (!m_CharInfo)
  117. return true;
  118. int iNum = m_wClientArea.GetHeight()/16;
  119. int iSkillCount = m_CharInfo->GetSkillCount();
  120. //Adjust Scrollbar Stuff
  121. m_sbScroll.SetMax(iSkillCount + 4 - iNum);
  122. int iOffset = m_sbScroll.GetValue();
  123. //Sort Skills Alphabetically
  124. int *SkillAlphaOrder = new int[iSkillCount];//{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37 };
  125. std::string *SkillNames = new std::string[iSkillCount];
  126. int iTest = 0;
  127. for (DWORD i=0; i<=m_CharInfo->GetMaxSkill(); i++)
  128. {
  129. if (!m_CharInfo->GetSkillValid(i))
  130. continue;
  131. stInternalSkill *Sk = m_CharInfo->GetSkillInfo(i);
  132. SkillNames[iTest] = Sk->szName;
  133. SkillAlphaOrder[iTest++] = i;
  134. }
  135. for (int i=0; i<iSkillCount-1; i++)
  136. {
  137. int lowest = i;
  138. std::string lowestStr = SkillNames[i];
  139. for (int h=i+1; h<iSkillCount; h++)
  140. {
  141. if (SkillNames[h] < lowestStr)
  142. {
  143. lowestStr = SkillNames[h];
  144. lowest = h;
  145. }
  146. }
  147. if (lowest != i)
  148. {
  149. //swap
  150. std::string tp = SkillNames[i];
  151. int tpi = SkillAlphaOrder[i];
  152. SkillNames[i] = SkillNames[lowest];
  153. SkillAlphaOrder[i] = SkillAlphaOrder[lowest];
  154. SkillNames[lowest] = tp;
  155. SkillAlphaOrder[lowest] = tpi;
  156. }
  157. }
  158. //Reset display of skills...
  159. for (int i=0; i<iSkillCount; i++)
  160. m_mLines[SkillAlphaOrder[i]]->SetVisible(false);
  161. for (int i=0; i<4; i++)
  162. m_pbWords[i].SetVisible(false);
  163. int iCnt = -iOffset;
  164. for (int i=3; i>=0; i--)
  165. {
  166. if ((iCnt >= 0) && (iCnt < iNum))
  167. {
  168. m_pbWords[i].SetPosition(0, iCnt*16);
  169. m_pbWords[i].SetVisible(true);
  170. }
  171. iCnt++;
  172. for (int h=0; h<iSkillCount; h++)
  173. {
  174. int iSkill = SkillAlphaOrder[h];
  175. stInternalSkill *Sk = m_CharInfo->GetSkillInfo(iSkill);
  176. if (Sk->dwTrained == i)
  177. {
  178. if ((iCnt >= 0) && (iCnt < iNum))
  179. {
  180. m_mLines[iSkill]->SetPosition(0, iCnt*16);
  181. m_mLines[iSkill]->SetVisible(true);
  182. }
  183. iCnt++;
  184. }
  185. }
  186. }
  187. delete []SkillAlphaOrder;
  188. return true;
  189. }
  190. bool RenderEventAbstractor< cSkillWindow >::OnRender( IWindow & Window, double TimeSlice )
  191. {
  192. if (!m_CharInfo)
  193. return true;
  194. bool bNeedResize = false;
  195. if (m_iLastScroll != m_sbScroll.GetValue())
  196. {
  197. m_iLastScroll = m_sbScroll.GetValue();
  198. bNeedResize = true;
  199. }
  200. int iMaxSkill = m_CharInfo->GetMaxSkill();
  201. char textBuffer[64]; // XXX: this can be slimmed down to whatever the longest possible representation is from itoa
  202. for (int i=0; i<=iMaxSkill; i++)
  203. {
  204. if (!m_CharInfo->GetSkillValid(i))
  205. continue;
  206. stInternalSkill *Sk = m_CharInfo->GetSkillInfo(i);
  207. if (Sk->dwTrained != m_ttList[i])
  208. bNeedResize = true;
  209. m_mVals[i]->SetText(itoa(Sk->dwBuffed, textBuffer, 10));
  210. m_mVals[i]->SetTextColor((Sk->dwBase != Sk->dwBuffed) ? 0xFF6060 : 0xFFFFFF);
  211. }
  212. if (bNeedResize)
  213. Window.FireResized();
  214. return true;
  215. }
  216. private:
  217. cCharInfo *m_CharInfo;
  218. std::map<DWORD, cPictureBox *> m_mLines;
  219. std::map<DWORD, cPictureBox *> m_mIcons;
  220. std::map<DWORD, cStaticText *> m_mNames;
  221. std::map<DWORD, cStaticText *> m_mVals;
  222. cPictureBox m_pbWords[4];
  223. cStaticText m_stWords[4];
  224. eTrainingType *m_ttList;
  225. cScrollBar m_sbScroll;
  226. int m_iLastScroll;
  227. };
  228. class cStatWindow : public cMovableWindow, private RenderEventAbstractor< cStatWindow >
  229. {
  230. public:
  231. cStatWindow()
  232. {
  233. for (int i=0; i<9; i++)
  234. {
  235. m_pbLines[i].SetPicture(0x06000F98);
  236. m_pbLines[i].SetVisible(true);
  237. m_pbLines[i].SetSize(m_wClientArea.GetWidth(), 16);
  238. m_pbLines[i].SetPosition(0, 16*i);
  239. m_pbLines[i].SetAnchorRight(true);
  240. AddClientChild(m_pbLines[i]);
  241. m_pbIcons[i].SetPosition(0,0);
  242. m_pbIcons[i].SetSize(16,16);
  243. m_pbIcons[i].SetVisible(true);
  244. m_pbLines[i].AddChild(m_pbIcons[i]);
  245. m_stNames[i].SetPosition(16,0);
  246. m_stNames[i].SetSize(100,16);
  247. m_stNames[i].SetVisible(true);
  248. m_stNames[i].SetTextColor(0xFFFFFF);
  249. m_pbLines[i].AddChild(m_stNames[i]);
  250. m_stVals[i].SetPosition(m_wClientArea.GetWidth()-30,0);
  251. m_stVals[i].SetSize(25,16);
  252. m_stVals[i].SetVisible(true);
  253. m_stVals[i].SetAnchorLeft(false);
  254. m_stVals[i].SetAnchorRight(true);
  255. m_stVals[i].SetTextColor(0xFFFFFF);
  256. m_stVals[i].SetTextHAlign(eRight);
  257. m_pbLines[i].AddChild(m_stVals[i]);
  258. AddRenderEventHandler( *(RenderEventAbstractor< cStatWindow > * )this );
  259. }
  260. }
  261. ~cStatWindow()
  262. {
  263. }
  264. void SetCharInfo(cCharInfo *CharInfo)
  265. {
  266. m_CharInfo = CharInfo;
  267. for (int i=0; i<6; i++)
  268. {
  269. stStatInfo *SI = m_CharInfo->GetStat(i+1);
  270. m_pbIcons[i].SetPicture(SI->dwIcon);
  271. m_stNames[i].SetText(SI->szName);
  272. }
  273. for (int i=0; i<3; i++)
  274. {
  275. stSecStatInfo *SI = m_CharInfo->GetSecStat((i+1) << 1);
  276. m_pbIcons[i+6].SetPicture(SI->dwIcon);
  277. m_stNames[i+6].SetText(SI->szName);
  278. }
  279. }
  280. bool RenderEventAbstractor< cStatWindow >::OnRender( IWindow & Window, double TimeSlice )
  281. {
  282. char textBuffer[64]; // XXX: this can be slimmed down to whatever the longest possible representation is from itoa
  283. for (int i=0; i<6; i++)
  284. {
  285. stStatInfo *SI = m_CharInfo->GetStat(i+1);
  286. m_stVals[i].SetText(itoa(SI->dwBuffed, textBuffer, 10));
  287. m_stVals[i].SetTextColor((SI->dwBase != SI->dwBuffed) ? 0xFF6060 : 0xFFFFFF);
  288. }
  289. for (int i=0; i<3; i++)
  290. {
  291. stSecStatInfo *SI = m_CharInfo->GetSecStat((i+1) << 1);
  292. m_stVals[i+6].SetText(itoa(SI->dwBuffed, textBuffer, 10));
  293. m_stVals[i+6].SetTextColor((SI->dwBase != SI->dwBuffed) ? 0xFF6060 : 0xFFFFFF);
  294. }
  295. return true;
  296. }
  297. private:
  298. cCharInfo *m_CharInfo;
  299. cPictureBox m_pbLines[9];
  300. cPictureBox m_pbIcons[9];
  301. cStaticText m_stNames[9];
  302. cStaticText m_stVals[9];
  303. };
  304. class cSpellBar : public CWindow, private ResizeEventAbstractor< cSpellBar >, private MouseEventsAbstractor< cSpellBar >, private RenderEventAbstractor< cSpellBar >
  305. {
  306. public:
  307. cSpellBar()
  308. {
  309. m_iSelBar = 0;
  310. m_iSelIndex = 0;
  311. m_iLastCnt = 0;
  312. m_iLastScroll = 0;
  313. m_sbScroll.SetHorizontal(true);
  314. m_sbScroll.SetPosition(0, GetHeight()-16);
  315. m_sbScroll.SetSize(GetWidth(), 16);
  316. m_sbScroll.SetAnchorTop(false);
  317. m_sbScroll.SetAnchorBottom(true);
  318. m_sbScroll.SetAnchorLeft(true);
  319. m_sbScroll.SetAnchorRight(true);
  320. m_sbScroll.SetVisible(false);
  321. m_sbScroll.SetMin(0);
  322. m_sbScroll.SetValue(m_iSelIndex);
  323. AddChild(m_sbScroll);
  324. m_pbSelSpell.SetSize(32, 32);
  325. m_pbSelSpell.SetPosition(0, 16);
  326. m_pbSelSpell.SetPicture(0x060011D2);
  327. m_pbSelSpell.SetVisible(true);
  328. AddChild(m_pbSelSpell);
  329. m_pbCastSpell.SetPosition(7*48 + 10, 0);
  330. m_pbCastSpell.SetSize(GetWidth() - 7*48 - 10, 16);
  331. m_pbCastSpell.SetAnchorRight(true);
  332. m_pbCastSpell.SetVisible(true);
  333. m_pbCastSpell.SetPicture(0x06001AB2);
  334. AddChild(m_pbCastSpell);
  335. m_stCastSpell.SetPosition(0, 0);
  336. m_stCastSpell.SetSize(m_pbCastSpell.GetWidth(), m_pbCastSpell.GetHeight());
  337. m_stCastSpell.SetAnchorRight(true);
  338. m_stCastSpell.SetAnchorBottom(true);
  339. m_stCastSpell.SetTextColor(0xFFFFFFFF);
  340. m_stCastSpell.SetTextHAlign(eCenter);
  341. m_stCastSpell.SetVisible(true);
  342. m_pbCastSpell.AddChild(m_stCastSpell);
  343. char SBnames[7][4] = { "I", "II", "III", "IV", "V", "VI", "VII" };
  344. for (int i=0; i<7; i++)
  345. {
  346. m_pbSpellBarSel[i].SetPosition(i*48, 0);
  347. m_pbSpellBarSel[i].SetSize(48, 16);
  348. m_pbSpellBarSel[i].SetVisible(true);
  349. AddChild(m_pbSpellBarSel[i]);
  350. m_stSpellBarSel[i].SetPosition(0,0);
  351. m_stSpellBarSel[i].SetSize(m_pbSpellBarSel[i].GetWidth(),m_pbSpellBarSel[i].GetHeight());
  352. m_stSpellBarSel[i].SetVisible(true);
  353. m_stSpellBarSel[i].SetAnchorBottom(true);
  354. m_stSpellBarSel[i].SetAnchorRight(true);
  355. m_stSpellBarSel[i].SetTextColor(0xFFFFFF);
  356. m_stSpellBarSel[i].SetTextHAlign(eCenter);
  357. m_stSpellBarSel[i].SetText(SBnames[i]);
  358. m_stSpellBarSel[i].AddMouseEventHandler( *(MouseEventsAbstractor< cSpellBar > *)this );
  359. m_pbSpellBarSel[i].AddChild(m_stSpellBarSel[i]);
  360. }
  361. UpdateSelected();
  362. AddResizeEventHandler( *(ResizeEventAbstractor< cSpellBar > *)this );
  363. AddMouseEventHandler( *(MouseEventsAbstractor< cSpellBar > *)this );
  364. AddRenderEventHandler( *(RenderEventAbstractor< cSpellBar > *)this );
  365. // m_pbSelSpell.AddMouseEventHandler( *(MouseEventsAbstractor< cSpellBar > *)this );
  366. // m_pbCastSpell.AddMouseEventHandler( *(MouseEventsAbstractor< cSpellBar > *)this );
  367. m_stCastSpell.AddMouseEventHandler( *(MouseEventsAbstractor< cSpellBar > *)this );
  368. }
  369. ~cSpellBar()
  370. {
  371. for (std::vector<cPictureBox *>::iterator i = m_vSpellBar.begin(); i != m_vSpellBar.end(); i++)
  372. delete *i;
  373. for (std::vector<cPictureBox *>::iterator i = m_vSpellBarLevel.begin(); i != m_vSpellBarLevel.end(); i++)
  374. delete *i;
  375. }
  376. void SetCharInfo(cCharInfo *CharInfo)
  377. {
  378. m_CharInfo = CharInfo;
  379. }
  380. bool ResizeEventAbstractor< cSpellBar >::OnResize( IWindow &Window, float NewWidth, float NewHeight )
  381. {
  382. return true;
  383. }
  384. bool ResizeEventAbstractor< cSpellBar >::OnResized( IWindow & Window )
  385. {
  386. for (std::vector<cPictureBox *>::iterator i = m_vSpellBar.begin(); i != m_vSpellBar.end(); i++)
  387. delete *i;
  388. for (std::vector<cPictureBox *>::iterator i = m_vSpellBarLevel.begin(); i != m_vSpellBarLevel.end(); i++)
  389. delete *i;
  390. m_vSpellBar.clear();
  391. m_vSpellBarLevel.clear();
  392. std::list<DWORD> * SBOut = m_CharInfo->GetSpellBar(m_iSelBar);
  393. std::list<DWORD>::iterator SB = SBOut->begin();
  394. int SBCnt = m_CharInfo->GetSpellBarCount(m_iSelBar);
  395. int iScrollNum = m_sbScroll.GetValue();
  396. int iNum = GetWidth()/32;
  397. if (SBCnt - iNum > 0)
  398. {
  399. m_sbScroll.SetMax(SBCnt - iNum);
  400. m_sbScroll.SetVisible(true);
  401. }
  402. else
  403. m_sbScroll.SetVisible(false);
  404. for (int i=0; i<iScrollNum; i++)
  405. SB++;
  406. m_pbSelSpell.SetVisible(false);
  407. for (int i=0; i<iNum; i++)
  408. {
  409. cPictureBox *PBL = new cPictureBox();
  410. PBL->SetSize(32, 32);
  411. PBL->SetPosition(i*32, 16);
  412. m_vSpellBarLevel.push_back(PBL);
  413. AddChild(*PBL);
  414. cPictureBox *PB = new cPictureBox();
  415. PB->SetSize(32, 32);
  416. PB->SetPosition(0, 0);
  417. PB->SetVisible(true);
  418. m_vSpellBar.push_back(PB);
  419. PB->AddMouseEventHandler( *(MouseEventsAbstractor< cSpellBar > *)this );
  420. PBL->AddChild(*PB);
  421. //found in portal.dat, next to all the scarab texts
  422. DWORD SpellLevelPic[7] = { 0x060013F4, 0x060013F5, 0x060013F6, 0x060013F7, 0x060013F8, 0x060013F9, 0x06001F63 };
  423. if (i + iScrollNum == m_iSelIndex)
  424. {
  425. m_pbSelSpell.SetVisible(true);
  426. m_pbSelSpell.SetPosition(i*32, 16);
  427. }
  428. if (i < SBCnt)
  429. {
  430. PBL->SetVisible(true);
  431. stInternalSpell *IS = m_CharInfo->GetSpellInfo(*SB);
  432. PB->SetPicture(IS->dwIcon);
  433. PBL->SetPicture(SpellLevelPic[IS->iLevel-1]);
  434. if (IS->dwFlags & 0x10)
  435. {
  436. //red outline...
  437. }
  438. SB++;
  439. }
  440. else
  441. {
  442. PBL->SetVisible(false);
  443. }
  444. }
  445. UpdateSelected();
  446. return true;
  447. }
  448. bool UpdateSelected()
  449. {
  450. m_pbSelSpell.JumpToBack();
  451. int iCnt = 0;
  452. for (std::vector<cPictureBox *>::iterator i = m_vSpellBarLevel.begin(); i != m_vSpellBarLevel.end(); i++, iCnt++)
  453. {
  454. if (!*i)
  455. continue;
  456. if (iCnt == m_iSelIndex - m_iLastScroll)
  457. {
  458. m_pbSelSpell.SetPosition((*i)->GetLeft(), 16);
  459. std::list<DWORD> * SBOut = m_CharInfo->GetSpellBar(m_iSelBar);
  460. std::list<DWORD>::iterator SB = SBOut->begin();
  461. for (int h=0; h<iCnt+m_iLastScroll; h++)
  462. SB++;
  463. // if (*SB)
  464. if ((int) SBOut->size() > iCnt+m_iLastScroll)
  465. m_stCastSpell.SetText(std::string("Cast ") + std::string( m_CharInfo->GetSpellInfo(*SB)->szName ));
  466. }
  467. }
  468. for (int i=0; i<7; i++)
  469. {
  470. m_pbSpellBarSel[i].SetPicture((i == m_iSelBar) ? 0x06001AB2 : 0x06001AB0);
  471. }
  472. return true;
  473. }
  474. bool MouseEventsAbstractor< cSpellBar >::OnMouseDown( IWindow & Window, float X, float Y, unsigned long Button )
  475. {
  476. if (!(Button & MK_LBUTTON))
  477. return true;
  478. int iCnt = 0;
  479. for (std::vector<cPictureBox *>::iterator i = m_vSpellBar.begin(); i != m_vSpellBar.end(); i++, iCnt++)
  480. {
  481. if (&Window == *i)
  482. m_iSelIndex = iCnt + m_iLastScroll;
  483. }
  484. for (int i = 0; i<7; i++)
  485. {
  486. if (&Window == &m_stSpellBarSel[i])
  487. {
  488. if (m_iSelBar != i)
  489. {
  490. m_iSelBar = i;
  491. m_sbScroll.SetValue(0);
  492. Window.FireResized();
  493. }
  494. }
  495. }
  496. if (&Window == &m_stCastSpell)
  497. {
  498. std::list<DWORD>::iterator SB = (m_CharInfo->GetSpellBar(m_iSelBar))->begin();
  499. for (int i=0; i<m_iSelIndex; i++)
  500. SB++;
  501. m_lCastList.push_back(*SB);
  502. }
  503. UpdateSelected();
  504. return true;
  505. }
  506. bool MouseEventsAbstractor< cSpellBar >::OnDoubleClick( IWindow & Window, float X, float Y, unsigned long Button )
  507. {
  508. if (!(Button & MK_LBUTTON))
  509. return true;
  510. std::list<DWORD> *nbar = m_CharInfo->GetSpellBar(m_iSelBar);
  511. std::list<DWORD>::iterator SB = nbar->begin();
  512. for (int i=0; i<m_sbScroll.GetValue(); i++)
  513. SB++;
  514. for (std::vector<cPictureBox *>::iterator i = m_vSpellBar.begin(); i != m_vSpellBar.end(); i++)
  515. {
  516. if ((*i)->GetPicture() == 0)
  517. continue;
  518. if (&Window == *i)
  519. {
  520. //Cast This Spell...
  521. m_lCastList.push_back(*SB);
  522. }
  523. SB++;
  524. }
  525. return true;
  526. }
  527. DWORD GetNextCast()
  528. {
  529. if (m_lCastList.size())
  530. {
  531. DWORD toret = m_lCastList.front();
  532. m_lCastList.pop_front();
  533. return toret;
  534. }
  535. else
  536. return 0;
  537. }
  538. bool RenderEventAbstractor< cSpellBar >::OnRender( IWindow & Window, double TimeSlice )
  539. {
  540. int SBCnt = m_CharInfo->GetSpellBarCount(m_iSelBar);
  541. if (SBCnt != m_iLastCnt)
  542. {
  543. m_iLastCnt = SBCnt;
  544. Window.FireResized();
  545. }
  546. int ScrollCnt = (int)m_sbScroll.GetValue();
  547. if (ScrollCnt != m_iLastScroll)
  548. {
  549. m_iLastScroll = ScrollCnt;
  550. Window.FireResized();
  551. }
  552. return true;
  553. }
  554. bool MouseEventsAbstractor< cSpellBar >::OnClick( IWindow &Window, float X, float Y, unsigned long Button )
  555. {
  556. return false;
  557. }
  558. bool MouseEventsAbstractor< cSpellBar >::OnMouseWheel( IWindow &Window, float X, float Y, unsigned long Button )
  559. {
  560. return false;
  561. }
  562. bool MouseEventsAbstractor< cSpellBar >::OnMouseUp( IWindow &Window, float X, float Y, unsigned long Button )
  563. {
  564. return false;
  565. }
  566. bool MouseEventsAbstractor< cSpellBar >::OnMouseMove( IWindow &Window, float X, float Y, unsigned long Button )
  567. {
  568. return false;
  569. }
  570. bool MouseEventsAbstractor< cSpellBar >::OnMouseEnter( IWindow &Window, float X, float Y, unsigned long Button )
  571. {
  572. return false;
  573. }
  574. bool MouseEventsAbstractor< cSpellBar >::OnMouseExit( IWindow &Window, float X, float Y, unsigned long Button )
  575. {
  576. return false;
  577. }
  578. private:
  579. cCharInfo *m_CharInfo;
  580. int m_iSelBar, m_iSelIndex;
  581. std::vector<cPictureBox *> m_vSpellBar;
  582. std::vector<cPictureBox *> m_vSpellBarLevel;
  583. cPictureBox m_pbSelSpell;
  584. std::list<DWORD> m_lCastList;
  585. cScrollBar m_sbScroll;
  586. cPictureBox m_pbSpellBarSel[7];
  587. cStaticText m_stSpellBarSel[7];
  588. cPictureBox m_pbCastSpell;
  589. cStaticText m_stCastSpell;
  590. int m_iLastCnt, m_iLastScroll;
  591. };
  592. class cWindowToolbar : public CWindow, private MouseEventsAbstractor< cWindowToolbar >, private RenderEventAbstractor< cWindowToolbar >
  593. {
  594. public:
  595. cWindowToolbar()
  596. {
  597. AddMouseEventHandler( *(MouseEventsAbstractor< cWindowToolbar > *)this );
  598. AddRenderEventHandler( *(RenderEventAbstractor< cWindowToolbar > *)this );
  599. }
  600. ~cWindowToolbar()
  601. {
  602. for (std::vector<stWindowEntry>::iterator i = Windows.begin(); i != Windows.end(); i++)
  603. {
  604. i->PicBox->RemoveChild(*i->Caption);
  605. RemoveChild(*i->PicBox);
  606. delete i->PicBox;
  607. delete i->Caption;
  608. }
  609. }
  610. void AddWindow(cMovableWindow * Window)
  611. {
  612. stWindowEntry NE;
  613. NE.WindowPtr = Window;
  614. NE.Icon = Window->GetIcon();
  615. NE.Visible = Window->GetVisible();
  616. NE.Title = Window->GetTitle();
  617. NE.PicBox = new cPictureBox();
  618. NE.PicBox->SetPicture(NE.Icon);
  619. NE.PicBox->SetPosition(Windows.size() * 48, 0);
  620. NE.PicBox->SetSize(32, 32);
  621. NE.PicBox->SetVisible(true);
  622. AddChild(*NE.PicBox);
  623. NE.Caption = new cStaticText();
  624. NE.Caption->SetTextHAlign(eCenter);
  625. NE.Caption->SetTextVAlign(eBottom);
  626. NE.Caption->SetText(NE.Title);
  627. NE.Caption->SetVisible(true);
  628. NE.Caption->SetSize(32, 10);
  629. NE.Caption->SetPosition(0, 30);
  630. NE.Caption->SetTextSize(10);
  631. NE.PicBox->AddChild(*NE.Caption);
  632. NE.PicBox->AddMouseEventHandler( *(MouseEventsAbstractor< cWindowToolbar > *)this );
  633. NE.Caption->AddMouseEventHandler( *(MouseEventsAbstractor< cWindowToolbar > *)this );
  634. Windows.push_back(NE);
  635. SetSize(Windows.size() * 48 - 16, 34);
  636. }
  637. bool MouseEventsAbstractor< cWindowToolbar >::OnClick( IWindow & Window, float X, float Y, unsigned long Button )
  638. {
  639. for (std::vector<stWindowEntry>::iterator i = Windows.begin(); i != Windows.end(); i++)
  640. {
  641. if ((&Window == i->PicBox) || (&Window == i->Caption))
  642. {
  643. i->WindowPtr->SetVisible(i->Visible ^ true);
  644. }
  645. }
  646. return true;
  647. }
  648. bool MouseEventsAbstractor< cWindowToolbar >::OnDoubleClick( IWindow & Window, float X, float Y, unsigned long Button )
  649. {
  650. return false;
  651. }
  652. bool MouseEventsAbstractor< cWindowToolbar >::OnMouseWheel( IWindow & Window, float X, float Y, unsigned long Button )
  653. {
  654. return false;
  655. }
  656. bool MouseEventsAbstractor< cWindowToolbar >::OnMouseDown( IWindow & Window, float X, float Y, unsigned long Button )
  657. {
  658. return false;
  659. }
  660. bool MouseEventsAbstractor< cWindowToolbar >::OnMouseUp( IWindow & Window, float X, float Y, unsigned long Button )
  661. {
  662. return false;
  663. }
  664. bool MouseEventsAbstractor< cWindowToolbar >::OnMouseMove( IWindow & Window, float X, float Y, unsigned long Button )
  665. {
  666. return false;
  667. }
  668. bool MouseEventsAbstractor< cWindowToolbar >::OnMouseEnter( IWindow & Window, float X, float Y, unsigned long Button )
  669. {
  670. return false;
  671. }
  672. bool MouseEventsAbstractor< cWindowToolbar >::OnMouseExit( IWindow & Window, float X, float Y, unsigned long Button )
  673. {
  674. return false;
  675. }
  676. bool RenderEventAbstractor< cWindowToolbar >::OnRender( IWindow & Window, double TimeSlice )
  677. {
  678. UpdateVisibles();
  679. return true;
  680. }
  681. private:
  682. void UpdateVisibles()
  683. {
  684. for (std::vector<stWindowEntry>::iterator i = Windows.begin(); i != Windows.end(); i++)
  685. {
  686. i->Visible = i->WindowPtr->GetVisible();
  687. i->PicBox->SetTransparency( i->Visible ? 1.0f : 0.5f );
  688. i->Caption->SetTextColor( i->Visible ? 0xFFFFFFFF : 0xFF808080 );
  689. }
  690. }
  691. struct stWindowEntry
  692. {
  693. cMovableWindow * WindowPtr;
  694. cPictureBox *PicBox;
  695. cStaticText *Caption;
  696. DWORD Icon;
  697. std::string Title;
  698. bool Visible;
  699. };
  700. std::vector<stWindowEntry> Windows;
  701. };
  702. class cMinimap : public cMovableWindow, private RenderEventAbstractor< cMinimap >, private MouseEventsAbstractor< cMinimap > {
  703. public:
  704. cMinimap()
  705. {
  706. m_pbMap.SetPosition(0,0);
  707. m_pbMap.SetSize(m_wClientArea.GetWidth(),m_wClientArea.GetHeight());
  708. m_pbMap.SetAnchorTop(true);
  709. m_pbMap.SetAnchorBottom(true);
  710. m_pbMap.SetAnchorLeft(true);
  711. m_pbMap.SetAnchorRight(true);
  712. m_pbMap.SetPicture(0x06000261);
  713. m_pbMap.SetVisible(true);
  714. m_pbMap.SetTransparency(0.7f);
  715. AddClientChild(m_pbMap);
  716. m_pbCursor.SetPosition(0,0);
  717. m_pbCursor.SetSize(10, 10);
  718. m_pbCursor.SetPicture(0x060011F9);
  719. m_pbCursor.SetVisible(true);
  720. m_pbMap.AddChild(m_pbCursor);
  721. m_pbCursor2.SetPosition(0,0);
  722. m_pbCursor2.SetSize(4, 4);
  723. m_pbCursor2.SetPicture(0x06001377);
  724. m_pbCursor2.SetVisible(true);
  725. m_pbCursor.AddChild(m_pbCursor2);
  726. m_p3dPosition = cPoint3D(0,0,0);
  727. bClickedPos = false;
  728. AddRenderEventHandler( *(RenderEventAbstractor< cMinimap > *)this );
  729. AddMouseEventHandler( *(MouseEventsAbstractor< cMinimap > *)this );
  730. m_pbMap.AddMouseEventHandler( *(MouseEventsAbstractor< cMinimap > *)this );
  731. m_pbCursor.AddMouseEventHandler( *(MouseEventsAbstractor< cMinimap > *)this );
  732. m_pbCursor2.AddMouseEventHandler( *(MouseEventsAbstractor< cMinimap > *)this );
  733. }
  734. ~cMinimap()
  735. {
  736. }
  737. private:
  738. bool RenderEventAbstractor< cMinimap >::OnRender(IWindow & Window, double TimeSlice)
  739. {
  740. return true;
  741. }
  742. public:
  743. void SetPlayerPosition(cPoint3D NewPos, float fRotation)
  744. {
  745. m_p3dPosition = NewPos;
  746. m_fRotation = fRotation;
  747. m_pbCursor.SetPosition(m_pbMap.GetWidth()*((m_p3dPosition.x+101.95f)/(2*101.95f)) - 5, m_pbMap.GetHeight()*((-m_p3dPosition.y+101.95f)/(2*101.95f)) - 5);
  748. cPoint3D tp = cPoint3D(5,1,0);
  749. tp.RotateAround(cPoint3D(5,5,0), cPoint3D(0,0,-m_fRotation));
  750. m_pbCursor2.SetPosition(tp.x-2, tp.y-2);
  751. char coords[50], ns[2] = { 'N', 0 }, ew[2] = { 'E', 0 };
  752. if (m_p3dPosition.x < 0) ew[0] = 'W';
  753. if (m_p3dPosition.y < 0) ns[0] = 'S';
  754. _snprintf(coords, 50, "Minimap - %3.2f%s %3.2f%s", fabs(m_p3dPosition.y), ns, fabs(m_p3dPosition.x), ew);
  755. SetTitle(coords);
  756. }
  757. private:
  758. bool MouseEventsAbstractor< cMinimap >::OnClick( IWindow & Window, float X, float Y, unsigned long Button )
  759. {
  760. // if ((X >= m_wClientArea.GetLeft()) && (X <= m_wClientArea.GetLeft() + m_wClientArea.GetWidth()) &&
  761. // (Y >= m_wClientArea.GetTop()) && (Y <= m_wClientArea.GetTop() + m_wClientArea.GetHeight()))
  762. {
  763. X += m_wClientArea.GetLeft();
  764. Y += m_wClientArea.GetTop();
  765. NewPos = POINTf((203.9*(-0.5*m_pbMap.GetWidth()+X-4))/m_pbMap.GetWidth(), -(203.9*(-0.5*m_pbMap.GetHeight()+Y-16))/m_pbMap.GetHeight());
  766. bClickedPos = true;
  767. }
  768. return true;
  769. }
  770. bool MouseEventsAbstractor< cMinimap >::OnDoubleClick( IWindow &Window, float X, float Y, unsigned long Button )
  771. {
  772. return false;
  773. }
  774. bool MouseEventsAbstractor< cMinimap >::OnMouseWheel( IWindow &Window, float X, float Y, unsigned long Button )
  775. {
  776. return false;
  777. }
  778. bool MouseEventsAbstractor< cMinimap >::OnMouseDown( IWindow &Window, float X, float Y, unsigned long Button )
  779. {
  780. return false;
  781. }
  782. bool MouseEventsAbstractor< cMinimap >::OnMouseUp( IWindow &Window, float X, float Y, unsigned long Button )
  783. {
  784. return false;
  785. }
  786. bool MouseEventsAbstractor< cMinimap >::OnMouseMove( IWindow &Window, float X, float Y, unsigned long Button )
  787. {
  788. return false;
  789. }
  790. bool MouseEventsAbstractor< cMinimap >::OnMouseEnter( IWindow &Window, float X, float Y, unsigned long Button )
  791. {
  792. return false;
  793. }
  794. bool MouseEventsAbstractor< cMinimap >::OnMouseExit( IWindow &Window, float X, float Y, unsigned long Button )
  795. {
  796. return false;
  797. }
  798. public:
  799. bool GetClicked(POINTf *out)
  800. {
  801. if (bClickedPos)
  802. {
  803. memcpy(out, &NewPos, sizeof(POINTf));
  804. bClickedPos = false;
  805. return true;
  806. }
  807. return false;
  808. }
  809. private:
  810. cPictureBox m_pbMap;
  811. cPictureBox m_pbCursor, m_pbCursor2;
  812. cPoint3D m_p3dPosition;
  813. float m_fRotation;
  814. POINTf NewPos;
  815. bool bClickedPos;
  816. };
  817. class cRadar : public cMovableWindow, private RenderEventAbstractor< cRadar > {
  818. public:
  819. cRadar()
  820. {
  821. m_fRange = 0.3f;
  822. m_ObjectDB = 0;
  823. m_RadarBG.SetPicture(0x06004CC1);
  824. // m_RadarBG.SetVisible(true);
  825. m_RadarBG.SetSize(m_wClientArea.GetWidth(), m_wClientArea.GetHeight());
  826. m_RadarBG.SetPosition(0,0);
  827. m_RadarBG.SetAnchorTop(true);
  828. m_RadarBG.SetAnchorBottom(true);
  829. m_RadarBG.SetAnchorLeft(true);
  830. m_RadarBG.SetAnchorRight(true);
  831. AddClientChild(m_RadarBG);
  832. AddRenderEventHandler( *(RenderEventAbstractor< cRadar > *)this );
  833. }
  834. ~cRadar()
  835. {
  836. }
  837. void SetObjectDB(cObjectDB *ObjectDB)
  838. {
  839. m_ObjectDB = ObjectDB;
  840. }
  841. void SetChar(DWORD Char)
  842. {
  843. m_dwChar = Char;
  844. }
  845. bool RenderEventAbstractor< cRadar >::OnRender(IWindow & Window, double TimeSlice)
  846. {
  847. float iLeft = m_wClientArea.GetAbsoluteLeft(),
  848. iRight = iLeft + m_wClientArea.GetWidth(),
  849. iTop = m_wClientArea.GetAbsoluteTop(),
  850. iBottom = iTop + m_wClientArea.GetHeight(),
  851. iWidth = m_wClientArea.GetWidth(),
  852. iHeight = m_wClientArea.GetHeight();
  853. //icons
  854. cWObject *woMyself = m_ObjectDB->FindObject(m_dwChar);
  855. if (woMyself)
  856. {
  857. m_ObjectDB->Lock();
  858. cPoint3D p3dMyself = woMyself->GetPosition();
  859. float fHead = woMyself->GetHeading();
  860. m_ObjectDB->Unlock();
  861. std::list<cWObject *> * SortList = m_ObjectDB->GetObjectsWithin(p3dMyself, m_fRange);
  862. m_ObjectDB->Lock();
  863. float fMaxDist = 100.0f;
  864. DWORD dwClosest = 0;
  865. for (std::list<cWObject *>::iterator i = SortList->begin(); i != SortList->end(); i++)
  866. {
  867. int tpColor = -1;
  868. DWORD dwGUID = (*i)->GetGUID();
  869. std::string tp = (*i)->GetName();
  870. DWORD dwOverride = (*i)->GetRadarOverride();
  871. if (dwOverride)
  872. {
  873. if (dwOverride == 1)
  874. tpColor = eLightBlue;
  875. if (dwOverride == 8)
  876. tpColor = eYellow;
  877. }
  878. else
  879. {
  880. DWORD dwFlags = (*i)->GetObjectFlags2();
  881. if (dwFlags & 8)
  882. tpColor = eWhite;
  883. else if (dwFlags & 0x10)
  884. tpColor = eLightBrown;
  885. }
  886. if (tpColor == -1)
  887. continue;
  888. cPoint3D p3dPos = (*i)->GetPosition();
  889. p3dPos -= p3dMyself;
  890. p3dPos.RotateAround(cPoint3D(0,0,0),cPoint3D(0,0,-fHead));
  891. POINTf ptF( iLeft + (iWidth/2) + (p3dPos.x/(1.18f*m_fRange))*(iWidth/2),
  892. iTop + (iHeight/2) - (p3dPos.y/(1.18f*m_fRange))*(iHeight/2) );
  893. //draw dot
  894. glBindTexture(GL_TEXTURE_2D, 0);
  895. glColor4ub(cColor[tpColor][0],cColor[tpColor][1],cColor[tpColor][2], (BYTE) (m_fTrans*255));
  896. glBegin(GL_QUADS);
  897. glVertex2f(ptF.x - 1, ptF.y - 1);
  898. glVertex2f(ptF.x + 1, ptF.y - 1);
  899. glVertex2f(ptF.x + 1, ptF.y + 1);
  900. glVertex2f(ptF.x - 1, ptF.y + 1);
  901. glEnd();
  902. }
  903. m_ObjectDB->Unlock();
  904. delete SortList;
  905. }
  906. return true;
  907. }
  908. private:
  909. float m_fRange;
  910. cObjectDB *m_ObjectDB;
  911. DWORD m_dwChar;
  912. cPictureBox m_RadarBG;
  913. };
  914. class cChatWindow : public cMovableWindow {
  915. public:
  916. cChatWindow()
  917. {
  918. m_ebChatlog.SetVisible(true);
  919. m_ebChatlog.SetPosition(0, 0);
  920. m_ebChatlog.SetAnchorTop(true);
  921. m_ebChatlog.SetAnchorBottom(true);
  922. m_ebChatlog.SetAnchorRight(true);
  923. m_ebChatlog.SetSize(m_wClientArea.GetWidth(), m_wClientArea.GetHeight() - 16);
  924. m_ebChatlog.SetAddReverse(true);
  925. m_ebChatlog.SetShowReverse(true);
  926. m_ebChatlog.SetReadOnly(true);
  927. m_ebChatlog.SetMultiLine(true);
  928. AddClientChild(m_ebChatlog);
  929. m_ebTextLine.SetVisible(true);
  930. m_ebTextLine.SetPosition(0, m_wClientArea.GetHeight()-16);
  931. m_ebTextLine.SetAnchorTop(false);
  932. m_ebTextLine.SetAnchorBottom(true);
  933. m_ebTextLine.SetAnchorRight(true);
  934. m_ebTextLine.SetSize(m_wClientArea.GetWidth(), 16);
  935. m_ebTextLine.SetReadOnly(false);
  936. m_ebTextLine.SetMultiLine(false);
  937. AddClientChild(m_ebTextLine);
  938. }
  939. ~cChatWindow()
  940. {
  941. }
  942. void OutputString(std::string NewLine, int Color)
  943. {
  944. m_ebChatlog.AddLine(NewLine, Color);
  945. }
  946. bool GetNeedSend() const
  947. {
  948. return m_ebTextLine.NeedSubmit();
  949. }
  950. std::string GetTextLine()
  951. {
  952. return m_ebTextLine.GetSubmit();
  953. }
  954. private:
  955. cEditBox m_ebTextLine, m_ebChatlog;
  956. };
  957. class cVitalsWindow : public cMovableWindow, private RenderEventAbstractor< cVitalsWindow >, private ResizeEventAbstractor< cVitalsWindow > {
  958. public:
  959. cVitalsWindow()
  960. {
  961. for (int i=0;i<3;i++)
  962. {
  963. m_pbVitals[i].SetAnchorRight(true);
  964. m_pbVitals[i].SetVisible(true);
  965. m_pbVitals[i].SetWidth(m_wClientArea.GetWidth());
  966. AddClientChild(m_pbVitals[i]);
  967. m_stVitals[i].SetTextColor(0xFFFFFF);
  968. m_stVitals[i].SetAnchorBottom(true);
  969. m_stVitals[i].SetAnchorRight(true);
  970. m_stVitals[i].SetSize(m_pbVitals[i].GetWidth(), m_pbVitals[i].GetHeight());
  971. m_stVitals[i].SetPosition(0, 0);
  972. m_stVitals[i].SetVisible(true);
  973. m_stVitals[i].SetTextHAlign(eCenter);
  974. m_pbVitals[i].AddChild(m_stVitals[i]);
  975. }
  976. m_pbVitals[0].SetColor(0x0000FF);
  977. m_pbVitals[1].SetColor(0x10F0F0);
  978. m_pbVitals[2].SetColor(0xFF0000);
  979. AddResizeEventHandler( *(ResizeEventAbstractor< cVitalsWindow > *)this );
  980. AddRenderEventHandler( *(RenderEventAbstractor< cVitalsWindow > *)this );
  981. }
  982. ~cVitalsWindow()
  983. {
  984. }
  985. private:
  986. bool ResizeEventAbstractor< cVitalsWindow >::OnResize( IWindow & Window, float NewWidth, float NewHeight )
  987. {
  988. if (NewWidth < 50) return false;
  989. if (NewHeight < 40) return false;
  990. return true;
  991. }
  992. bool ResizeEventAbstractor< cVitalsWindow >::OnResized( IWindow & Window )
  993. {
  994. float ih = m_wClientArea.GetHeight();
  995. for (int i=0;i<3;i++)
  996. m_pbVitals[i].SetHeight((1.0f/3.0f)*ih);
  997. m_pbVitals[0].SetPosition(0, 0);
  998. m_pbVitals[1].SetPosition(0, (1.0f/3.0f)*ih);
  999. m_pbVitals[2].SetPosition(0, (2.0f/3.0f)*ih);
  1000. return true;
  1001. }
  1002. bool RenderEventAbstractor< cVitalsWindow >::OnRender( IWindow & Window, double TimeSlice )
  1003. {
  1004. //update stats
  1005. for (int i=2;i<=6;i+=2)
  1006. {
  1007. stSecStatInfo *tpVital = m_CharInfo->GetSecStat(i);
  1008. char tpstr[50];
  1009. sprintf(tpstr, "%i/%i", tpVital->dwCurrent, tpVital->dwBuffed);
  1010. m_stVitals[(i >> 1) - 1].SetText(tpstr);
  1011. m_pbVitals[(i >> 1) - 1].SetLimits(0, (float) tpVital->dwBuffed);
  1012. m_pbVitals[(i >> 1) - 1].SetCurrent((float) tpVital->dwCurrent);
  1013. }
  1014. return true;
  1015. }
  1016. public:
  1017. void SetCharInfo(cCharInfo *CharInfo)
  1018. {
  1019. m_CharInfo = CharInfo;
  1020. }
  1021. private:
  1022. bool m_bMini;
  1023. cCharInfo *m_CharInfo;
  1024. cProgressBar m_pbVitals[3];
  1025. cStaticText m_stVitals[3];
  1026. };