Advertisement
Guest User

Untitled

a guest
Jul 13th, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 75.63 KB | None | 0 0
  1. /***********************************************
  2. * Filename: UIManager.cpp
  3. * Author: Jason Rhode
  4. ************************************************/
  5.  
  6. #include "stdafx.h"
  7. #include "UIManager.h"
  8. #include "..\Entities\Player\Player.h"
  9. #include "..\Entities\AI\AIManager.h"
  10. #include "..\States\StateManager.h"
  11. #include "..\States\GameplayState.h"
  12. #include "..\Entities\Orb.h"
  13. #include "UIObject.h"
  14. #include "..\Entities\EntityManager.h"
  15. #include "..\Entities\Score.h"
  16. #include "../Engine/AssetManager.h"
  17. #include "../Engine/GameSave.h"
  18. #include "../Engine/Renderer/C3DManager.h"
  19. #include "../Entities/Fountain.h"
  20. #include "../Entities/FountainInfluence.h"
  21.  
  22. CUIManager::CUIManager()
  23. {
  24. eCurrentState = STATE_MENU;
  25. fInstrFS = 0.0f;
  26. }
  27.  
  28. CUIManager::~CUIManager()
  29. {
  30.  
  31. }
  32.  
  33. bool CUIManager::Initialize( void )
  34. {
  35.  
  36. m_cInput = &CStateManager::GetInstance()->m_cInput;
  37. Shutdown();
  38.  
  39. TiXmlDocument tDoc;
  40.  
  41. if(tDoc.LoadFile("..\\Core\\Game\\Scripts\\ResolutionChange.xml") == false)
  42. {
  43. return false;
  44. }
  45.  
  46. TiXmlElement* tRoot = tDoc.RootElement(); // Resolution
  47.  
  48. if(tRoot == nullptr )
  49. {
  50. return false;
  51. }
  52.  
  53. TiXmlElement* tSizeOne = tRoot->FirstChildElement("Size");
  54. int nUIWidth, nUIHeight;
  55. tSizeOne->Attribute("Width", &nUIWidth);
  56. tSizeOne->Attribute("Height", &nUIHeight);
  57.  
  58. TiXmlElement* tSize = nullptr;
  59. // Res is 1024 x 768
  60. if( nUIWidth != CStateManager::GetInstance()->GetWindowWidth() && nUIHeight != CStateManager::GetInstance()->GetWindowHeight() )
  61. {
  62. TiXmlElement* tSizeTwo = tSizeOne->NextSiblingElement("Size");
  63. tSize = tSizeTwo;
  64. }
  65. else
  66. {
  67. tSize = tSizeOne;
  68. }
  69.  
  70. TiXmlElement* tPrimaryScreen = tSize->FirstChildElement("Screen");
  71.  
  72. int nNumButtons, nValue, nNameCount;
  73. double dValue;
  74. TiXmlElement* tPrimary;
  75. TiXmlElement* tSecondary;
  76. std::string szScreen;
  77. float fTempScale;
  78. RECT tLoad;
  79.  
  80. // Load in button info for all buttons on all screens.
  81. RECT rBGRect;
  82.  
  83. if(CStateManager::GetInstance()->GetWindowWidth() == 1024)
  84. {
  85. fInstrFS = .35f;
  86. fTempScale = .45f;
  87. RECT rSize = { 0, 0, 1024, 768 };
  88. rBGRect = rSize;
  89. }
  90. else
  91. {
  92. fInstrFS = .5f;
  93. fTempScale = .65f;
  94. RECT rSize = { 0, 0, 1920, 1080 };
  95. rBGRect = rSize;
  96. }
  97.  
  98.  
  99. // Main Menu
  100. tButton tMenuButton;
  101. szScreen = tPrimaryScreen->Attribute("Title");
  102. tPrimaryScreen->Attribute("Num", &nNumButtons);
  103.  
  104. tMenuButton.m_szFunction = szScreen;
  105. tMenuButton.m_nButtonNum = MM_PLAY;
  106. tMenuButton.m_nTotalButtons = nNumButtons;
  107. tMenuButton.m_bHidden = false;
  108. tMenuButton.m_nParentButton = 0;
  109.  
  110. tPrimary = tPrimaryScreen->FirstChildElement("Rect");
  111. tMenuButton.m_tClickArea = LoadRECT(tPrimary);
  112.  
  113. tPrimary = tPrimary->NextSiblingElement("Pos");
  114. tPrimary->Attribute("X", &nValue);
  115. tMenuButton.m_tPos.x = (float)nValue;
  116. tPrimary->Attribute("Y", &nValue);
  117. tMenuButton.m_tPos.y = (float)nValue;
  118.  
  119. tLoad.left = 0;
  120. tLoad.right = 295;
  121. tLoad.top = 0;
  122. tLoad.bottom = 54;
  123.  
  124. tPrimary = tPrimary->NextSiblingElement("Other");
  125. tPrimary->Attribute("Incr", &dValue);
  126. tMenuButton.m_fIncrement = (float)dValue;
  127.  
  128. tMenuButton.m_ButtonWidth = static_cast<float>(tMenuButton.m_tClickArea.bottom - tMenuButton.m_tClickArea.top);
  129.  
  130. tMenuButton.m_cBackgroundImg.Create(rBGRect, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_MENU]->m_tImages[UI_BG], 0.8f);
  131. tMenuButton.m_cButtonImg.Create(tLoad, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_MENU]->m_tImages[UI_SELECT], 0.7f);
  132.  
  133. tPrimary = tPrimary->NextSiblingElement("Label");
  134. tPrimary->Attribute("Num", &nNameCount);
  135. tPrimary = tPrimary->FirstChildElement("Name");
  136.  
  137. for (int i = 0; i < nNameCount; i++)
  138. {
  139. tText tNewLabel;
  140. int nValue = 0;
  141. tNewLabel.m_szLabel = tPrimary->Attribute("Text");
  142. tPrimary->Attribute("XOffset", &nValue);
  143. tNewLabel.m_tTexPos.x = tMenuButton.m_tPos.x + 50 + nValue;
  144. tPrimary->Attribute("YOffset", &nValue);
  145. tNewLabel.m_tTexPos.y = ( tMenuButton.m_tPos.y + ( tMenuButton.m_ButtonWidth + tMenuButton.m_fIncrement ) * i ) + nValue;
  146. tNewLabel.m_fScale = fTempScale;
  147. tMenuButton.m_tButtonNames.push_back(tNewLabel);
  148. tPrimary = tPrimary->NextSiblingElement("Name");
  149. }
  150.  
  151. UpdateButton(&tMenuButton);
  152. tButtonCollection[STATE_MENU] = new tButton(tMenuButton);
  153. /// Main Menu
  154.  
  155.  
  156. // Options
  157. tPrimaryScreen = tPrimaryScreen->NextSiblingElement("Screen");
  158. tButton tOptionsButton;
  159. szScreen = tPrimaryScreen->Attribute("Title");
  160. tPrimaryScreen->Attribute("Num", &nNumButtons);
  161.  
  162. tOptionsButton.m_szFunction = szScreen;
  163. tOptionsButton.m_nButtonNum = OPT_CONTROLS;
  164. tOptionsButton.m_nTotalButtons = nNumButtons;
  165. tOptionsButton.m_bHidden = false;
  166. tOptionsButton.m_nParentButton = 0;
  167. tOptionsButton.m_nCurrentAttached = 0;
  168.  
  169. tPrimary = tPrimaryScreen->FirstChildElement("Rect");
  170. tOptionsButton.m_tClickArea = LoadRECT(tPrimary);
  171.  
  172. tPrimary = tPrimary->NextSiblingElement("Pos");
  173. tPrimary->Attribute("X", &nValue);
  174. tOptionsButton.m_tPos.x = (float)nValue;
  175. tPrimary->Attribute("Y", &nValue);
  176. tOptionsButton.m_tPos.y = (float)nValue;
  177.  
  178. tLoad.left = 0;
  179. tLoad.right = 295;
  180. tLoad.top = 0;
  181. tLoad.bottom = 54;
  182.  
  183. tPrimary = tPrimary->NextSiblingElement("Other");
  184. tPrimary->Attribute("Incr", &dValue);
  185. tOptionsButton.m_fIncrement = (float)dValue;
  186.  
  187. tOptionsButton.m_ButtonWidth = static_cast<float>(tOptionsButton.m_tClickArea.bottom - tOptionsButton.m_tClickArea.top);
  188.  
  189. tOptionsButton.m_cBackgroundImg.Create(rBGRect, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_OPTIONS]->m_tImages[UI_CON], 0.8f);
  190. tOptionsButton.m_cButtonImg.Create(tLoad, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_OPTIONS]->m_tImages[UI_SELECT], 0.7f);
  191.  
  192. tPrimary = tPrimary->NextSiblingElement("Label");
  193. tPrimary->Attribute("Num", &nNameCount);
  194. tSecondary = tPrimary->FirstChildElement("Name");
  195.  
  196. for (int i = 0; i < nNameCount; i++)
  197. {
  198. tText tNewLabel;
  199. int nValue = 0;
  200. tNewLabel.m_szLabel = tSecondary->Attribute("Text");
  201. tSecondary->Attribute("XOffset", &nValue);
  202. tNewLabel.m_tTexPos.x = tOptionsButton.m_tPos.x + 50 + nValue;
  203. tSecondary->Attribute("YOffset", &nValue);
  204. tNewLabel.m_tTexPos.y = ( tOptionsButton.m_tPos.y + ( tOptionsButton.m_ButtonWidth + tOptionsButton.m_fIncrement ) * i ) + nValue;
  205. tNewLabel.m_fScale = fTempScale;
  206. tOptionsButton.m_tButtonNames.push_back(tNewLabel);
  207. tSecondary = tSecondary->NextSiblingElement("Name");
  208. }
  209.  
  210. UpdateButton(&tOptionsButton);
  211. tSecondary = tPrimary->NextSiblingElement("Additional");
  212.  
  213. for (int i = 0; i < 8; i++)
  214. {
  215. szScreen = tSecondary->Attribute("Title");
  216. tSecondary->Attribute("Num", &nNumButtons);
  217.  
  218. tButton tNewButton;
  219. tNewButton.m_szFunction = szScreen;
  220. tNewButton.m_nButtonNum = i;
  221. if( i < 3 )
  222. tNewButton.m_nTotalButtons = 1;
  223. else
  224. tNewButton.m_nTotalButtons = 1;
  225. tNewButton.m_bHidden = false;
  226.  
  227. if(i < 3)
  228. tNewButton.m_nParentButton = OPT_AUDIO;
  229. else
  230. tNewButton.m_nParentButton = OPT_VIDEO;
  231.  
  232.  
  233. TiXmlElement* Additional = tSecondary->FirstChildElement("Rect");
  234. tNewButton.m_tClickArea = LoadRECT(Additional);
  235.  
  236. int nPos = 0;
  237. Additional = Additional->NextSiblingElement("Pos");
  238. Additional->Attribute("X", &nPos);
  239. tNewButton.m_tPos.x = (float)nPos;
  240. Additional->Attribute("Y", &nPos);
  241. tNewButton.m_tPos.y = (float)nPos;
  242. tNewButton.m_ButtonWidth = static_cast<float>(tNewButton.m_tClickArea.bottom - tNewButton.m_tClickArea.top);
  243.  
  244. if(i < 4)
  245. {
  246.  
  247. tSlider tNewS;
  248. tNewS.bMoving = false;
  249.  
  250. Additional = Additional->NextSiblingElement("Slider");
  251. XMFLOAT2 tLine;
  252. Additional->Attribute("XOne", &nValue );
  253. tLine.x = static_cast<float> (nValue);
  254. Additional->Attribute("XTwo", &nValue );
  255. tLine.y = static_cast<float> (nValue);
  256.  
  257. tNewS.tSBoundry = tLine;
  258. if( i == AUD_MASTER)
  259. tNewS.tSPos.x = DeterminePosition(tLine, CStateManager::GetInstance()->GetGameSave()->GetMasterVolume() );
  260. if( i == AUD_MUSIC)
  261. tNewS.tSPos.x = DeterminePosition(tLine, CStateManager::GetInstance()->GetGameSave()->GetMusicVolume() );
  262. if( i == AUD_SFX)
  263. tNewS.tSPos.x = DeterminePosition(tLine, CStateManager::GetInstance()->GetGameSave()->GetSFXVolume() );
  264. if( i == VID_GAMMA)
  265. tNewS.tSPos.x = DeterminePosition(tLine, CStateManager::GetInstance()->GetGammaLevel() );
  266. Additional->Attribute("Y", &nValue );
  267. tNewS.tSPos.y = static_cast<float> (nValue);
  268.  
  269. tNewButton.m_tPos = tNewS.tSPos;
  270.  
  271. m_tSliders[i] = new tSlider(tNewS);
  272.  
  273. tLoad.left = 0;
  274. tLoad.right = 41;
  275. tLoad.top = 0;
  276. tLoad.bottom = 41;
  277.  
  278. tNewButton.m_cButtonImg.Create(tLoad, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_OPTIONS]->m_tImages[UI_MOD], 0.6f);
  279. }
  280. else if(i < 6)
  281. {
  282. tLoad.left = 0;
  283. tLoad.right = 103;
  284. tLoad.top = 0;
  285. tLoad.bottom = 87;
  286.  
  287. tNewButton.m_cButtonImg.Create(tLoad, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_OPTIONS]->m_tImages[UI_CIRCLE], 0.6f);
  288.  
  289. }
  290. else if( i < 8 )
  291. {
  292. tLoad.left = 0;
  293. tLoad.right = 21;
  294. tLoad.top = 0;
  295. tLoad.bottom = 19;
  296.  
  297. if(i == 6)
  298. tNewButton.m_cButtonImg.Create(tLoad, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_OPTIONS]->m_tImages[UI_LEFT], 0.6f);
  299. else
  300. tNewButton.m_cButtonImg.Create(tLoad, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_OPTIONS]->m_tImages[UI_RIGHT], 0.6f);
  301.  
  302. }
  303.  
  304.  
  305.  
  306. //tSecondary = tSecondary->NextSiblingElement("Label");
  307. //tSecondary->Attribute("Num", &nNameCount);
  308. //TiXmlElement = tSecondary->FirstChildElement("Name");
  309. //tText tNewLabel;
  310. //int nValue2 = 0;
  311. //tNewLabel.m_szLabel = tSecondary->Attribute("Text");
  312. //tSecondary->Attribute("XOffset", &nValue2);
  313. //tNewLabel.m_tTexPos.x = tNewButton.m_tPos.x + 50 + nValue2;
  314. //tSecondary->Attribute("YOffset", &nValue2);
  315. //tNewLabel.m_tTexPos.y = tNewButton.m_tPos.y - nValue2;
  316. //tNewLabel.m_fScale = fTempScale;
  317. //tNewButton.m_tButtonNames.push_back(tNewLabel);
  318. UpdateButton(&tNewButton);
  319.  
  320. tOptionsButton.m_tAttachedButtons[i] = new tButton(tNewButton);
  321. tSecondary = tSecondary->NextSiblingElement("Additional");
  322.  
  323. }
  324.  
  325. tButtonCollection[STATE_OPTIONS] = new tButton(tOptionsButton);
  326. /// Options
  327.  
  328. // Game Select
  329. tPrimaryScreen = tPrimaryScreen->NextSiblingElement("Screen");
  330. tButton tGameSelectButton;
  331. szScreen = tPrimaryScreen->Attribute("Title");
  332. tPrimaryScreen->Attribute("Num", &nNumButtons);
  333.  
  334. tGameSelectButton.m_szFunction = szScreen;
  335. tGameSelectButton.m_nButtonNum = GS_SOLO;
  336. tGameSelectButton.m_nTotalButtons = nNumButtons;
  337. tGameSelectButton.m_bHidden = false;
  338. tGameSelectButton.m_nParentButton = 0;
  339.  
  340. tPrimary = tPrimaryScreen->FirstChildElement("Rect");
  341. tGameSelectButton.m_tClickArea = LoadRECT(tPrimary);
  342.  
  343. tPrimary = tPrimary->NextSiblingElement("Pos");
  344. tPrimary->Attribute("X", &nValue);
  345. tGameSelectButton.m_tPos.x = (float)nValue;
  346. tPrimary->Attribute("Y", &nValue);
  347. tGameSelectButton.m_tPos.y = (float)nValue;
  348.  
  349. tLoad.left = 0;
  350. tLoad.right = 295;
  351. tLoad.top = 0;
  352. tLoad.bottom = 54;
  353.  
  354. tPrimary = tPrimary->NextSiblingElement("Other");
  355. tPrimary->Attribute("Incr", &dValue);
  356. tGameSelectButton.m_fIncrement = (float)dValue;
  357.  
  358. tGameSelectButton.m_ButtonWidth = static_cast<float>(tGameSelectButton.m_tClickArea.bottom - tGameSelectButton.m_tClickArea.top);
  359.  
  360. tGameSelectButton.m_cBackgroundImg.Create(rBGRect, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAME_SELECT]->m_tImages[UI_BG], 0.8f);
  361. tGameSelectButton.m_cButtonImg.Create(tLoad, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAME_SELECT]->m_tImages[UI_SELECT], 0.7f);
  362.  
  363. tPrimary = tPrimary->NextSiblingElement("Label");
  364. tPrimary->Attribute("Num", &nNameCount);
  365. tPrimary = tPrimary->FirstChildElement("Name");
  366.  
  367. for (int i = 0; i < nNameCount; i++)
  368. {
  369. tText tNewLabel;
  370. int nValue = 0;
  371. tNewLabel.m_szLabel = tPrimary->Attribute("Text");
  372. tPrimary->Attribute("XOffset", &nValue);
  373. tNewLabel.m_tTexPos.x = tGameSelectButton.m_tPos.x + 50 + nValue;
  374. tPrimary->Attribute("YOffset", &nValue);
  375. tNewLabel.m_tTexPos.y = ( tGameSelectButton.m_tPos.y + ( tGameSelectButton.m_ButtonWidth + tGameSelectButton.m_fIncrement ) * i ) + nValue;
  376. tNewLabel.m_fScale = fTempScale;
  377. tGameSelectButton.m_tButtonNames.push_back(tNewLabel);
  378. tPrimary = tPrimary->NextSiblingElement("Name");
  379. }
  380.  
  381. UpdateButton(&tGameSelectButton);
  382. tButtonCollection[STATE_GAME_SELECT] = new tButton(tGameSelectButton);
  383. /// Game Select
  384.  
  385. // Level Select
  386. tPrimaryScreen = tPrimaryScreen->NextSiblingElement("Screen");
  387. tButton tLevelSelectButton;
  388. szScreen = tPrimaryScreen->Attribute("Title");
  389. tPrimaryScreen->Attribute("Num", &nNumButtons);
  390.  
  391. tLevelSelectButton.m_szFunction = szScreen;
  392. tLevelSelectButton.m_nButtonNum = LS_PLAY;
  393. tLevelSelectButton.m_nTotalButtons = nNumButtons;
  394. tLevelSelectButton.m_bHidden = false;
  395. tLevelSelectButton.m_nParentButton = 0;
  396. tLevelSelectButton.m_nCurrentAttached = LS_ONE;
  397.  
  398. tPrimary = tPrimaryScreen->FirstChildElement("Rect");
  399. tLevelSelectButton.m_tClickArea = LoadRECT(tPrimary);
  400.  
  401. tPrimary = tPrimary->NextSiblingElement("Pos");
  402. tPrimary->Attribute("X", &nValue);
  403. tLevelSelectButton.m_tPos.x = (float)nValue;
  404. tPrimary->Attribute("Y", &nValue);
  405. tLevelSelectButton.m_tPos.y = (float)nValue;
  406.  
  407. tLoad.left = 0;
  408. tLoad.right = 295;
  409. tLoad.top = 0;
  410. tLoad.bottom = 54;
  411.  
  412. tPrimary = tPrimary->NextSiblingElement("Other");
  413. tPrimary->Attribute("Incr", &dValue);
  414. tLevelSelectButton.m_fIncrement = (float)dValue;
  415.  
  416. tLevelSelectButton.m_ButtonWidth = static_cast<float>(tLevelSelectButton.m_tClickArea.bottom - tLevelSelectButton.m_tClickArea.top);
  417.  
  418. tLevelSelectButton.m_cBackgroundImg.Create(rBGRect, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_LEVEL_SELECT]->m_tImages[UI_BG], 0.8f);
  419. tLevelSelectButton.m_cButtonImg.Create(tLoad, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_LEVEL_SELECT]->m_tImages[UI_SELECT], 0.7f);
  420.  
  421. tPrimary = tPrimary->NextSiblingElement("Label");
  422. tPrimary->Attribute("Num", &nNameCount);
  423. tSecondary = tPrimary->FirstChildElement("Name");
  424.  
  425. for (int i = 0; i < nNameCount; i++)
  426. {
  427. tText tNewLabel;
  428. int nValue = 0;
  429. tNewLabel.m_szLabel = tSecondary->Attribute("Text");
  430. tSecondary->Attribute("XOffset", &nValue);
  431. tNewLabel.m_tTexPos.x = tLevelSelectButton.m_tPos.x + 50 + nValue;
  432. tSecondary->Attribute("YOffset", &nValue);
  433. tNewLabel.m_tTexPos.y = ( tLevelSelectButton.m_tPos.y + ( tLevelSelectButton.m_ButtonWidth + tLevelSelectButton.m_fIncrement ) * i ) + nValue;
  434. tNewLabel.m_fScale = fTempScale;
  435. tLevelSelectButton.m_tButtonNames.push_back(tNewLabel);
  436. tSecondary = tSecondary->NextSiblingElement("Name");
  437. }
  438.  
  439. UpdateButton(&tLevelSelectButton);
  440. tSecondary = tPrimary->NextSiblingElement("Additional");
  441.  
  442. for (int i = 0; i < 3; i++)
  443. {
  444. szScreen = tSecondary->Attribute("Title");
  445. tSecondary->Attribute("Num", &nNumButtons);
  446.  
  447. tButton tNewButton;
  448. tNewButton.m_szFunction = szScreen;
  449. tNewButton.m_nButtonNum = i;
  450. tNewButton.m_nTotalButtons = 1;
  451. if(i == 0)
  452. tNewButton.m_bHidden = false;
  453. else
  454. tNewButton.m_bHidden = true;
  455.  
  456. tNewButton.m_nParentButton = LS_PLAY;
  457.  
  458. TiXmlElement* Additional = tSecondary->FirstChildElement("Rect");
  459. tNewButton.m_tClickArea = LoadRECT(Additional);
  460.  
  461. int nPos = 0;
  462. Additional = Additional->NextSiblingElement("Pos");
  463. Additional->Attribute("X", &nPos);
  464. tNewButton.m_tPos.x = (float)nPos;
  465. Additional->Attribute("Y", &nPos);
  466. tNewButton.m_tPos.y = (float)nPos;
  467.  
  468. tLoad.left = 0;
  469. tLoad.right = 534;
  470. tLoad.top = 0;
  471. tLoad.bottom = 330;
  472.  
  473. tNewButton.m_ButtonWidth = static_cast<float>(tNewButton.m_tClickArea.bottom - tNewButton.m_tClickArea.top);
  474.  
  475. tNewButton.m_cButtonImg.Create(tLoad, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_LEVEL_SELECT]->m_tImages[UI_LSELECT], 0.6f);
  476.  
  477. //tSecondary = tSecondary->NextSiblingElement("Label");
  478. //tSecondary->Attribute("Num", &nNameCount);
  479. //TiXmlElement = tSecondary->FirstChildElement("Name");
  480. //tText tNewLabel;
  481. //int nValue2 = 0;
  482. //tNewLabel.m_szLabel = tSecondary->Attribute("Text");
  483. //tSecondary->Attribute("XOffset", &nValue2);
  484. //tNewLabel.m_tTexPos.x = tNewButton.m_tPos.x + 50 + nValue2;
  485. //tSecondary->Attribute("YOffset", &nValue2);
  486. //tNewLabel.m_tTexPos.y = tNewButton.m_tPos.y - nValue2;
  487. //tNewLabel.m_fScale = fTempScale;
  488. //tNewButton.m_tButtonNames.push_back(tNewLabel);
  489. UpdateButton(&tNewButton);
  490.  
  491. tLevelSelectButton.m_tAttachedButtons[i] = new tButton(tNewButton);
  492. tSecondary = tSecondary->NextSiblingElement("Additional");
  493.  
  494. }
  495.  
  496.  
  497.  
  498. tButtonCollection[STATE_LEVEL_SELECT] = new tButton(tLevelSelectButton);
  499. /// Level Select
  500.  
  501. // Pause
  502. tPrimaryScreen = tPrimaryScreen->NextSiblingElement("Screen");
  503. tButton tPauseButton;
  504. szScreen = tPrimaryScreen->Attribute("Title");
  505. tPrimaryScreen->Attribute("Num", &nNumButtons);
  506.  
  507. tPauseButton.m_szFunction = szScreen;
  508. tPauseButton.m_nButtonNum = PAUSE_RESUME;
  509. tPauseButton.m_nTotalButtons = nNumButtons;
  510. tPauseButton.m_bHidden = false;
  511. tPauseButton.m_nParentButton = 0;
  512.  
  513. tPrimary = tPrimaryScreen->FirstChildElement("Rect");
  514. tPauseButton.m_tClickArea = LoadRECT(tPrimary);
  515.  
  516. tPrimary = tPrimary->NextSiblingElement("Pos");
  517. tPrimary->Attribute("X", &nValue);
  518. tPauseButton.m_tPos.x = (float)nValue;
  519. tPrimary->Attribute("Y", &nValue);
  520. tPauseButton.m_tPos.y = (float)nValue;
  521.  
  522. tLoad.left = 0;
  523. tLoad.right = 295;
  524. tLoad.top = 0;
  525. tLoad.bottom = 54;
  526.  
  527. tPrimary = tPrimary->NextSiblingElement("Other");
  528. tPrimary->Attribute("Incr", &dValue);
  529. tPauseButton.m_fIncrement = (float)dValue;
  530.  
  531. tPauseButton.m_ButtonWidth = static_cast<float>(tPauseButton.m_tClickArea.bottom - tPauseButton.m_tClickArea.top);
  532.  
  533. tPauseButton.m_cBackgroundImg.Create(rBGRect, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_PAUSE]->m_tImages[UI_BG], 0.8f);
  534. tPauseButton.m_cButtonImg.Create(tLoad, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_PAUSE]->m_tImages[UI_SELECT], 0.7f);
  535.  
  536. tPrimary = tPrimary->NextSiblingElement("Label");
  537. tPrimary->Attribute("Num", &nNameCount);
  538. tPrimary = tPrimary->FirstChildElement("Name");
  539.  
  540. for (int i = 0; i < nNameCount; i++)
  541. {
  542. tText tNewLabel;
  543. int nValue = 0;
  544. tNewLabel.m_szLabel = tPrimary->Attribute("Text");
  545. tPrimary->Attribute("XOffset", &nValue);
  546. tNewLabel.m_tTexPos.x = tPauseButton.m_tPos.x + 50 + nValue;
  547. tPrimary->Attribute("YOffset", &nValue);
  548. tNewLabel.m_tTexPos.y = ( tPauseButton.m_tPos.y + ( tPauseButton.m_ButtonWidth + tPauseButton.m_fIncrement ) * i ) + nValue;
  549. tNewLabel.m_fScale = fTempScale;
  550. tPauseButton.m_tButtonNames.push_back(tNewLabel);
  551. tPrimary = tPrimary->NextSiblingElement("Name");
  552. }
  553.  
  554. UpdateButton(&tPauseButton);
  555. tButtonCollection[STATE_PAUSE] = new tButton(tPauseButton);
  556.  
  557. /// Pause
  558.  
  559. // HUD - Solo
  560. tPrimaryScreen = tPrimaryScreen->NextSiblingElement("Screen");
  561. tButton tSoloButton;
  562. szScreen = tPrimaryScreen->Attribute("Title");
  563. tPrimaryScreen->Attribute("Num", &nNumButtons);
  564.  
  565. tSoloButton.m_szFunction = szScreen;
  566. tSoloButton.m_nTotalButtons = 9;
  567.  
  568. tPrimary = tPrimaryScreen->FirstChildElement("Additional");
  569.  
  570. for (int i = 0; i < nNumButtons; i++)
  571. {
  572. tButton tNewButton;
  573. tSecondary = tPrimary->FirstChildElement("Rect");
  574.  
  575. tNewButton.m_tClickArea = LoadRECT(tSecondary);
  576.  
  577. tSecondary = tSecondary->NextSiblingElement("Pos");
  578. int nPos = 0;
  579. tSecondary->Attribute("X", &nPos);
  580. tNewButton.m_tPos.x = (float)nPos;
  581. tSecondary->Attribute("Y", &nPos);
  582. tNewButton.m_tPos.y = (float)nPos;
  583.  
  584. tNewButton.m_ButtonWidth = static_cast<float>(tNewButton.m_tClickArea.bottom - tNewButton.m_tClickArea.top);
  585.  
  586. if( i < 2 )
  587. {
  588. if(i == 0)
  589. {
  590. tLoad.left = 0;
  591. tLoad.right = 355;
  592. tLoad.top = 0;
  593. tLoad.bottom = 26;
  594. }
  595. else
  596. {
  597. tLoad.left = 0;
  598. tLoad.right = 343;
  599. tLoad.top = 0;
  600. tLoad.bottom = 14;
  601. }
  602.  
  603. tNewButton.m_ButtonWidth = static_cast<float>(tNewButton.m_tClickArea.right - tNewButton.m_tClickArea.left);
  604.  
  605. tNewButton.m_cButtonImg.Create(tLoad, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[UI_HEALTH_BAR + (i)], 0.8f);
  606. }
  607. else if(i < 5)
  608. {
  609. tLoad.left = 0;
  610. tLoad.right = 64;
  611. tLoad.top = 0;
  612. tLoad.bottom = 64;
  613.  
  614. tNewButton.m_bHidden = true;
  615.  
  616. tNewButton.m_cButtonImg.Create(tLoad, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[UI_FIRE], 0.8f);
  617. }
  618. else if(i == 5)
  619. {
  620. tLoad.left = 0;
  621. tLoad.right = 99;
  622. tLoad.top = 0;
  623. tLoad.bottom = 99;
  624. tNewButton.m_cButtonImg.Create(tLoad, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[UI_ACTIVE_SLOT], 0.9f);
  625. }
  626. else if( i < 8 )
  627. {
  628. tLoad.left = 0;
  629. tLoad.right = 99;
  630. tLoad.top = 0;
  631. tLoad.bottom = 99;
  632.  
  633. tNewButton.m_cButtonImg.Create(tLoad, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[UI_INACTIVE_SLOT], 0.9f);
  634. }
  635. else if(i == 8)
  636. {
  637. tLoad.left = 0;
  638. tLoad.right = 411;
  639. tLoad.top = 0;
  640. tLoad.bottom = 90;
  641. tNewButton.m_cButtonImg.Create(tLoad, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[UI_HS_CASE], 0.9f);
  642. }
  643.  
  644. UpdateButton(&tNewButton);
  645.  
  646. tSoloButton.m_tAttachedButtons[i] = new tButton(tNewButton);
  647. tPrimary = tPrimary->NextSiblingElement("Additional");
  648. }
  649.  
  650. tButtonCollection[STATE_SOLO] = new tButton(tSoloButton);
  651.  
  652.  
  653. /// HUD
  654.  
  655. // HUD - Multi
  656. tPrimaryScreen = tPrimaryScreen->NextSiblingElement("Screen");
  657. tButton tMultiButton;
  658. szScreen = tPrimaryScreen->Attribute("Title");
  659. tPrimaryScreen->Attribute("Num", &nNumButtons);
  660.  
  661. tMultiButton.m_szFunction = szScreen;
  662. tMultiButton.m_nTotalButtons = 9;
  663.  
  664. tPrimary = tPrimaryScreen->FirstChildElement("Additional");
  665.  
  666. for (int i = 0; i < nNumButtons; i++)
  667. {
  668. tButton tNewButton;
  669. tSecondary = tPrimary->FirstChildElement("Rect");
  670.  
  671. tNewButton.m_tClickArea = LoadRECT(tSecondary);
  672.  
  673. tSecondary = tSecondary->NextSiblingElement("Pos");
  674. int nPos = 0;
  675. tSecondary->Attribute("X", &nPos);
  676. tNewButton.m_tPos.x = (float)nPos;
  677. tSecondary->Attribute("Y", &nPos);
  678. tNewButton.m_tPos.y = (float)nPos;
  679.  
  680. tNewButton.m_ButtonWidth = static_cast<float>(tNewButton.m_tClickArea.bottom - tNewButton.m_tClickArea.top);
  681.  
  682. if( i < 2 )
  683. {
  684. if(i == 0)
  685. {
  686. tLoad.left = 0;
  687. tLoad.right = 355;
  688. tLoad.top = 0;
  689. tLoad.bottom = 26;
  690. }
  691. else
  692. {
  693. tLoad.left = 0;
  694. tLoad.right = 343;
  695. tLoad.top = 0;
  696. tLoad.bottom = 14;
  697. }
  698.  
  699. tNewButton.m_ButtonWidth = static_cast<float>(tNewButton.m_tClickArea.right - tNewButton.m_tClickArea.left);
  700.  
  701. tNewButton.m_cButtonImg.Create(tLoad, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[UI_HEALTH_BAR + (i)], 0.8f);
  702. }
  703. else if(i < 5)
  704. {
  705. tLoad.left = 0;
  706. tLoad.right = 64;
  707. tLoad.top = 0;
  708. tLoad.bottom = 64;
  709.  
  710. tNewButton.m_bHidden = true;
  711.  
  712. tNewButton.m_cButtonImg.Create(tLoad, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[UI_FIRE], 0.8f);
  713. }
  714. else if(i == 5)
  715. {
  716. tLoad.left = 0;
  717. tLoad.right = 99;
  718. tLoad.top = 0;
  719. tLoad.bottom = 99;
  720. tNewButton.m_cButtonImg.Create(tLoad, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[UI_ACTIVE_SLOT], 0.9f);
  721. }
  722. else if( i < 8 )
  723. {
  724. tLoad.left = 0;
  725. tLoad.right = 99;
  726. tLoad.top = 0;
  727. tLoad.bottom = 99;
  728.  
  729. tNewButton.m_cButtonImg.Create(tLoad, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[UI_INACTIVE_SLOT], 0.9f);
  730. }
  731. else if(i == 8)
  732. {
  733. tLoad.left = 0;
  734. tLoad.right = 411;
  735. tLoad.top = 0;
  736. tLoad.bottom = 90;
  737. tNewButton.m_cButtonImg.Create(tLoad, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[UI_HS_CASE], 0.9f);
  738. }
  739.  
  740. UpdateButton(&tNewButton);
  741.  
  742. tMultiButton.m_tAttachedButtons[i] = new tButton(tNewButton);
  743. tPrimary = tPrimary->NextSiblingElement("Additional");
  744. }
  745.  
  746. tButtonCollection[STATE_MULTI] = new tButton(tMultiButton);
  747.  
  748.  
  749. /// HUD
  750.  
  751. // Lose
  752. tButton tLoseButton;
  753. tPrimaryScreen = tPrimaryScreen->NextSiblingElement("Screen");
  754.  
  755. szScreen = tPrimaryScreen->Attribute("Title");
  756. tPrimaryScreen->Attribute("Num", &nNumButtons);
  757.  
  758. tLoseButton.m_szFunction = szScreen;
  759. tLoseButton.m_nButtonNum = GOL_RESPAWN;
  760. tLoseButton.m_nTotalButtons = nNumButtons;
  761. tLoseButton.m_bHidden = false;
  762. tLoseButton.m_nParentButton = 0;
  763.  
  764. tPrimary = tPrimaryScreen->FirstChildElement("Rect");
  765. tLoseButton.m_tClickArea = LoadRECT(tPrimary);
  766.  
  767. tPrimary = tPrimary->NextSiblingElement("Pos");
  768. tPrimary->Attribute("X", &nValue);
  769. tLoseButton.m_tPos.x = (float)nValue;
  770. tPrimary->Attribute("Y", &nValue);
  771. tLoseButton.m_tPos.y = (float)nValue;
  772.  
  773. tLoad.left = 0;
  774. tLoad.right = 295;
  775. tLoad.top = 0;
  776. tLoad.bottom = 54;
  777.  
  778. tPrimary = tPrimary->NextSiblingElement("Other");
  779. tPrimary->Attribute("Incr", &dValue);
  780. tLoseButton.m_fIncrement = (float)dValue;
  781.  
  782. tLoseButton.m_ButtonWidth = static_cast<float>(tLoseButton.m_tClickArea.bottom - tLoseButton.m_tClickArea.top);
  783.  
  784. tLoseButton.m_cBackgroundImg.Create(rBGRect, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEOVER_LOSE]->m_tImages[UI_BG], 0.8f);
  785. tLoseButton.m_cButtonImg.Create(tLoad, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEOVER_LOSE]->m_tImages[UI_SELECT], 0.7f);
  786.  
  787. tPrimary = tPrimary->NextSiblingElement("Label");
  788. tPrimary->Attribute("Num", &nNameCount);
  789. tPrimary = tPrimary->FirstChildElement("Name");
  790.  
  791. for (int i = 0; i < nNameCount; i++)
  792. {
  793. tText tNewLabel;
  794. int nValue = 0;
  795. tNewLabel.m_szLabel = tPrimary->Attribute("Text");
  796. tPrimary->Attribute("XOffset", &nValue);
  797. tNewLabel.m_tTexPos.x = tLoseButton.m_tPos.x + 50 + nValue;
  798. tPrimary->Attribute("YOffset", &nValue);
  799. tNewLabel.m_tTexPos.y = ( tLoseButton.m_tPos.y + ( tLoseButton.m_ButtonWidth + tLoseButton.m_fIncrement ) * i ) + nValue;
  800. tNewLabel.m_fScale = fTempScale;
  801. tLoseButton.m_tButtonNames.push_back(tNewLabel);
  802. tPrimary = tPrimary->NextSiblingElement("Name");
  803. }
  804.  
  805. UpdateButton(&tLoseButton);
  806. tButtonCollection[STATE_GAMEOVER_LOSE] = new tButton(tLoseButton);
  807. /// Lose
  808.  
  809.  
  810. // Win
  811. tButton tWinButton;
  812. tPrimaryScreen = tPrimaryScreen->NextSiblingElement("Screen");
  813.  
  814. szScreen = tPrimaryScreen->Attribute("Title");
  815. tPrimaryScreen->Attribute("Num", &nNumButtons);
  816.  
  817. tWinButton.m_szFunction = szScreen;
  818. tWinButton.m_nButtonNum = GOW_CONTINUE;
  819. tWinButton.m_nTotalButtons = nNumButtons;
  820. tWinButton.m_bHidden = false;
  821. tWinButton.m_nParentButton = 0;
  822.  
  823. tPrimary = tPrimaryScreen->FirstChildElement("Rect");
  824. tWinButton.m_tClickArea = LoadRECT(tPrimary);
  825.  
  826. tPrimary = tPrimary->NextSiblingElement("Pos");
  827. tPrimary->Attribute("X", &nValue);
  828. tWinButton.m_tPos.x = (float)nValue;
  829. tPrimary->Attribute("Y", &nValue);
  830. tWinButton.m_tPos.y = (float)nValue;
  831.  
  832. tLoad.left = 0;
  833. tLoad.right = 295;
  834. tLoad.top = 0;
  835. tLoad.bottom = 54;
  836.  
  837. tPrimary = tPrimary->NextSiblingElement("Other");
  838. tPrimary->Attribute("Incr", &dValue);
  839. tWinButton.m_fIncrement = (float)dValue;
  840.  
  841. tWinButton.m_ButtonWidth = static_cast<float>(tWinButton.m_tClickArea.bottom - tWinButton.m_tClickArea.top);
  842.  
  843. tWinButton.m_cBackgroundImg.Create(rBGRect, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_LEVEL_COMPLETE]->m_tImages[UI_BG], 0.8f);
  844. tWinButton.m_cButtonImg.Create(tLoad, CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_LEVEL_COMPLETE]->m_tImages[UI_SELECT], 0.7f);
  845.  
  846. tPrimary = tPrimary->NextSiblingElement("Label");
  847. tPrimary->Attribute("Num", &nNameCount);
  848. tPrimary = tPrimary->FirstChildElement("Name");
  849.  
  850. for (int i = 0; i < nNameCount; i++)
  851. {
  852. tText tNewLabel;
  853. int nValue = 0;
  854. tNewLabel.m_szLabel = tPrimary->Attribute("Text");
  855. tPrimary->Attribute("XOffset", &nValue);
  856. tNewLabel.m_tTexPos.x = tWinButton.m_tPos.x + 50 + nValue;
  857. tPrimary->Attribute("YOffset", &nValue);
  858. tNewLabel.m_tTexPos.y = ( tWinButton.m_tPos.y + ( tWinButton.m_ButtonWidth + tWinButton.m_fIncrement ) * i ) + nValue;
  859. tNewLabel.m_fScale = fTempScale;
  860. tWinButton.m_tButtonNames.push_back(tNewLabel);
  861. tPrimary = tPrimary->NextSiblingElement("Name");
  862. }
  863.  
  864. UpdateButton(&tWinButton);
  865. tButtonCollection[STATE_LEVEL_COMPLETE] = new tButton(tWinButton);
  866. /// Win
  867.  
  868.  
  869. // Make this resolution-adjusted
  870. RECT rLoadingIcon = { 5, (int)(CStateManager::GetInstance()->GetWindowHeight()-170), 160, (int)(CStateManager::GetInstance()->GetWindowHeight()-15) };
  871. m_cLoadingIcon.Create(rLoadingIcon, CStateManager::GetInstance()->GetAssetManagerHandle()->tTextures["Sigil_Y.dds"]->tTexture, 0.2f);
  872. m_cLoadingIcon.SetColor(XMFLOAT4(1.0f, 1.0f, 0.4f, 1.0f));
  873.  
  874. return true;
  875. }
  876.  
  877. void CUIManager::Update( float fElapsedTime )
  878. {
  879. CGameplayState* pGPState = (CGameplayState*)(CStateManager::GetInstance()->GetGameplayStateHandle());
  880.  
  881. if(!CStateManager::GetInstance()->IsDoneLoading())
  882. {
  883. m_cLoadingIcon.SetRotation(m_cLoadingIcon.GetRotation() - fElapsedTime);
  884. }
  885. else if(CStateManager::GetInstance()->IsDoneLoading() && m_cLoadingIcon.GetScale().x > 0.0f)
  886. {
  887. m_cLoadingIcon.SetRotation(m_cLoadingIcon.GetRotation() - fElapsedTime);
  888. m_cLoadingIcon.SetScale(XMFLOAT2(m_cLoadingIcon.GetScale().x - fElapsedTime/2.25f, m_cLoadingIcon.GetScale().y - fElapsedTime/2.25f));
  889. XMFLOAT3 vPos = m_cLoadingIcon.GetPosition();
  890. m_cLoadingIcon.SetPosition(XMFLOAT3(vPos.x + fElapsedTime/2.5f, vPos.y + fElapsedTime/1.75f, vPos.z));
  891. }
  892.  
  893. if(m_tCurrentButton->m_nTotalButtons == 0)
  894. return;
  895.  
  896.  
  897. switch(eCurrentState)
  898. {
  899. case STATE_GAMEPLAY:
  900. {
  901. GameplayUpdate();
  902. }
  903. break;
  904. case STATE_OPTIONS:
  905. {
  906. if(m_cInput->GetKeyPressed(VK_DOWN) || m_cInput->GetKeyPressed('S') || m_cInput->GamepadPressed(GAMEPAD_DPAD_DOWN))
  907. {
  908. if(m_tCurrentButton->m_nButtonNum != m_tCurrentButton->m_nTotalButtons - 1)
  909. {
  910. CStateManager::GetInstance()->m_cAudioManager.PostEvent(AK::EVENTS::PLAY_HA_SFX_MENUNAVIGATE);
  911. int nNum = m_tCurrentButton->m_nButtonNum;
  912. m_tCurrentButton->m_nButtonNum++;
  913. UpdateButton(nNum);
  914.  
  915. if(m_tCurrentButton->m_nButtonNum == LS_PLAY)
  916. {
  917. m_tCurrentButton->m_tAttachedButtons[LS_ONE]->m_bHidden = false;
  918. m_tCurrentButton->m_nCurrentAttached = LS_ONE;
  919. }
  920. }
  921. }
  922. else if(m_cInput->GetKeyPressed(VK_UP) || m_cInput->GetKeyPressed('W') || m_cInput->GamepadPressed(GAMEPAD_DPAD_UP))
  923. {
  924. if(m_tCurrentButton->m_nButtonNum != 0)
  925. {
  926. CStateManager::GetInstance()->m_cAudioManager.PostEvent(AK::EVENTS::PLAY_HA_SFX_MENUNAVIGATE);
  927. int nNum = m_tCurrentButton->m_nButtonNum;
  928. m_tCurrentButton->m_nButtonNum--;
  929. UpdateButton(nNum);
  930.  
  931. if(m_tCurrentButton->m_nButtonNum == LS_PLAY)
  932. {
  933. m_tCurrentButton->m_tAttachedButtons[LS_ONE]->m_bHidden = false;
  934. m_tCurrentButton->m_nCurrentAttached = LS_ONE;
  935. }
  936. }
  937. }
  938.  
  939. int nButton = MouseIntersect(m_tCurrentButton, true);
  940. if( nButton != -1)
  941. {
  942. int nNum = m_tCurrentButton->m_nButtonNum;
  943. m_tCurrentButton->m_nButtonNum = nButton;
  944. UpdateButton(nNum);
  945. }
  946. else if( m_tCurrentButton->m_nButtonNum == OPT_AUDIO )
  947. {
  948. bool bCheck = false;
  949.  
  950. if(m_cInput->GetLButtonDown())
  951. {
  952. for (unsigned int i = 0; i < m_tSliders.size() - 1; i++)
  953. {
  954. for (unsigned int j = 0; j < m_tSliders.size() - 1; j++)
  955. {
  956. if(m_tSliders[j]->bMoving == true)
  957. {
  958. bCheck = true;
  959. break;
  960. }
  961. }
  962.  
  963. if(!bCheck)
  964. {
  965. if(MouseIntersect(true, m_tCurrentButton->m_tAttachedButtons[i]) && m_tSliders[i]->bMoving == false)
  966. {
  967. m_tSliders[i]->bMoving = true;
  968. bCheck = true;
  969. }
  970. }
  971. }
  972.  
  973. }
  974. else
  975. {
  976. for (unsigned int i = 0; i < m_tSliders.size() - 1; i++)
  977. {
  978. m_tSliders[i]->bMoving = false;
  979. }
  980. }
  981.  
  982.  
  983. //
  984. for (unsigned int i = 0; i < m_tSliders.size() - 1; i++)
  985. {
  986. if(m_tSliders[i]->bMoving)
  987. {
  988. POINT tMouse_Pos = m_cInput->GetCursorPos();
  989. int nVolumeChange = 0;
  990.  
  991. if(tMouse_Pos.x > m_tCurrentButton->m_tAttachedButtons[i]->m_tPos.x && tMouse_Pos.x <= m_tSliders[i]->tSBoundry.y)
  992. {
  993. m_tCurrentButton->m_tAttachedButtons[i]->m_tPos.x += tMouse_Pos.x - m_tCurrentButton->m_tAttachedButtons[i]->m_tPos.x;
  994. nVolumeChange = DetermineVolume( m_tCurrentButton->m_tAttachedButtons[i]->m_tPos.x - m_tSliders[i]->tSBoundry.x, m_tSliders[i]->tSBoundry.y - m_tSliders[i]->tSBoundry.x);
  995. nVolumeChange = nVolumeChange;
  996.  
  997. }
  998. else if( tMouse_Pos.x < m_tCurrentButton->m_tAttachedButtons[i]->m_tPos.x && tMouse_Pos.x >= m_tSliders[i]->tSBoundry.x)
  999. {
  1000. m_tCurrentButton->m_tAttachedButtons[i]->m_tPos.x -= m_tCurrentButton->m_tAttachedButtons[i]->m_tPos.x - tMouse_Pos.x;
  1001. nVolumeChange = DetermineVolume( m_tCurrentButton->m_tAttachedButtons[i]->m_tPos.x - m_tSliders[i]->tSBoundry.x, m_tSliders[i]->tSBoundry.y - m_tSliders[i]->tSBoundry.x);
  1002.  
  1003. if( i == AUD_MASTER)
  1004. nVolumeChange = nVolumeChange - CStateManager::GetInstance()->GetGameSave()->GetMasterVolume();
  1005. if( i == AUD_MUSIC)
  1006. nVolumeChange = nVolumeChange - CStateManager::GetInstance()->GetGameSave()->GetMusicVolume();
  1007. if( i == AUD_SFX)
  1008. nVolumeChange = nVolumeChange - CStateManager::GetInstance()->GetGameSave()->GetSFXVolume();
  1009. }
  1010.  
  1011. if( i == AUD_MASTER)
  1012. CStateManager::GetInstance()->AlterMASTERVolume((float)nVolumeChange);
  1013. if( i == AUD_MUSIC)
  1014. CStateManager::GetInstance()->AlterMUSICVolume((float)nVolumeChange);
  1015. if( i == AUD_SFX)
  1016. CStateManager::GetInstance()->AlterSFXVolume((float)nVolumeChange);
  1017.  
  1018. UpdateButton(m_tCurrentButton->m_tAttachedButtons[i]);
  1019.  
  1020. }
  1021. }
  1022. }
  1023.  
  1024. };
  1025. break;
  1026. case STATE_LEVEL_SELECT:
  1027. {
  1028. if(m_cInput->GetKeyPressed(VK_DOWN) || m_cInput->GetKeyPressed('S') || m_cInput->GamepadPressed(GAMEPAD_DPAD_DOWN))
  1029. {
  1030. if(m_tCurrentButton->m_nButtonNum != m_tCurrentButton->m_nTotalButtons - 1)
  1031. {
  1032. CStateManager::GetInstance()->m_cAudioManager.PostEvent(AK::EVENTS::PLAY_HA_SFX_MENUNAVIGATE);
  1033. int nNum = m_tCurrentButton->m_nButtonNum;
  1034. m_tCurrentButton->m_nButtonNum++;
  1035. UpdateButton(nNum);
  1036.  
  1037. if(m_tCurrentButton->m_nButtonNum == LS_PLAY)
  1038. {
  1039. m_tCurrentButton->m_tAttachedButtons[LS_ONE]->m_bHidden = false;
  1040. m_tCurrentButton->m_nCurrentAttached = LS_ONE;
  1041. }
  1042. }
  1043. }
  1044. else if(m_cInput->GetKeyPressed(VK_UP) || m_cInput->GetKeyPressed('W') || m_cInput->GamepadPressed(GAMEPAD_DPAD_UP))
  1045. {
  1046. if(m_tCurrentButton->m_nButtonNum != 0)
  1047. {
  1048. CStateManager::GetInstance()->m_cAudioManager.PostEvent(AK::EVENTS::PLAY_HA_SFX_MENUNAVIGATE);
  1049. int nNum = m_tCurrentButton->m_nButtonNum;
  1050. m_tCurrentButton->m_nButtonNum--;
  1051. UpdateButton(nNum);
  1052.  
  1053. if(m_tCurrentButton->m_nButtonNum == LS_PLAY)
  1054. {
  1055. m_tCurrentButton->m_tAttachedButtons[LS_ONE]->m_bHidden = false;
  1056. m_tCurrentButton->m_nCurrentAttached = LS_ONE;
  1057. }
  1058. }
  1059. }
  1060.  
  1061. if(m_tCurrentButton->m_nButtonNum == LS_PLAY)
  1062. {
  1063. if(m_cInput->GetKeyPressed(VK_RIGHT) || m_cInput->GetKeyPressed('D') || m_cInput->GamepadPressed(GAMEPAD_DPAD_RIGHT))
  1064. {
  1065. CStateManager::GetInstance()->m_cAudioManager.PostEvent(AK::EVENTS::PLAY_HA_SFX_MENUNAVIGATE);
  1066.  
  1067. m_tCurrentButton->m_tAttachedButtons[m_tCurrentButton->m_nCurrentAttached]->m_bHidden = true;
  1068. m_tCurrentButton->m_nCurrentAttached++;
  1069. if(m_tCurrentButton->m_nCurrentAttached > 2)
  1070. m_tCurrentButton->m_nCurrentAttached = 0;
  1071. m_tCurrentButton->m_tAttachedButtons[m_tCurrentButton->m_nCurrentAttached]->m_bHidden = false;
  1072.  
  1073. }
  1074. else if(m_cInput->GetKeyPressed(VK_LEFT) || m_cInput->GetKeyPressed('A') || m_cInput->GamepadPressed(GAMEPAD_DPAD_LEFT))
  1075. {
  1076. CStateManager::GetInstance()->m_cAudioManager.PostEvent(AK::EVENTS::PLAY_HA_SFX_MENUNAVIGATE);
  1077.  
  1078. m_tCurrentButton->m_tAttachedButtons[m_tCurrentButton->m_nCurrentAttached]->m_bHidden = true;
  1079. m_tCurrentButton->m_nCurrentAttached--;
  1080. if(m_tCurrentButton->m_nCurrentAttached < 0)
  1081. m_tCurrentButton->m_nCurrentAttached = 2;
  1082.  
  1083. m_tCurrentButton->m_tAttachedButtons[m_tCurrentButton->m_nCurrentAttached]->m_bHidden = false;
  1084. }
  1085. }
  1086. else
  1087. {
  1088. for (unsigned int i = 0; i < m_tCurrentButton->m_tAttachedButtons.size(); i++)
  1089. {
  1090. m_tCurrentButton->m_tAttachedButtons[i]->m_bHidden = true;
  1091. }
  1092. }
  1093.  
  1094.  
  1095. int nButton = MouseIntersect(m_tCurrentButton, true);
  1096. if( nButton != -1)
  1097. {
  1098. int nNum = m_tCurrentButton->m_nButtonNum;
  1099. m_tCurrentButton->m_nButtonNum = nButton;
  1100.  
  1101. if(nButton == 0)
  1102. {
  1103. m_tCurrentButton->m_tAttachedButtons[m_tCurrentButton->m_nCurrentAttached]->m_bHidden = false;
  1104. }
  1105.  
  1106. UpdateButton(nNum);
  1107. }
  1108.  
  1109. if(MouseIntersect(m_tCurrentButton->m_tAttachedButtons[LS_ONE], false))
  1110. {
  1111. m_tCurrentButton->m_tAttachedButtons[LS_ONE]->m_bHidden = false;
  1112. m_tCurrentButton->m_nCurrentAttached = LS_ONE;
  1113. m_tCurrentButton->m_nButtonNum = LS_PLAY;
  1114. }
  1115. else if(MouseIntersect(m_tCurrentButton->m_tAttachedButtons[LS_TWO], false))
  1116. {
  1117. m_tCurrentButton->m_tAttachedButtons[LS_TWO]->m_bHidden = false;
  1118. m_tCurrentButton->m_nCurrentAttached = LS_TWO;
  1119. m_tCurrentButton->m_nButtonNum = LS_PLAY;
  1120. }
  1121. else if(MouseIntersect(m_tCurrentButton->m_tAttachedButtons[LS_THREE], false))
  1122. {
  1123. m_tCurrentButton->m_tAttachedButtons[LS_THREE]->m_bHidden = false;
  1124. m_tCurrentButton->m_nCurrentAttached = LS_THREE;
  1125. m_tCurrentButton->m_nButtonNum = LS_PLAY;
  1126. }
  1127.  
  1128.  
  1129. };
  1130. break;
  1131. default:
  1132. {
  1133.  
  1134. if(m_cInput->GetKeyPressed(VK_DOWN) || m_cInput->GetKeyPressed('S') || m_cInput->GamepadPressed(GAMEPAD_DPAD_DOWN))
  1135. {
  1136. if(m_tCurrentButton->m_nButtonNum != m_tCurrentButton->m_nTotalButtons - 1)
  1137. {
  1138. CStateManager::GetInstance()->m_cAudioManager.PostEvent(AK::EVENTS::PLAY_HA_SFX_MENUNAVIGATE);
  1139. int nNum = m_tCurrentButton->m_nButtonNum;
  1140. m_tCurrentButton->m_nButtonNum++;
  1141. UpdateButton(nNum);
  1142. }
  1143. }
  1144. else if(m_cInput->GetKeyPressed(VK_UP) || m_cInput->GetKeyPressed('W') || m_cInput->GamepadPressed(GAMEPAD_DPAD_UP))
  1145. {
  1146. if(m_tCurrentButton->m_nButtonNum != 0)
  1147. {
  1148. CStateManager::GetInstance()->m_cAudioManager.PostEvent(AK::EVENTS::PLAY_HA_SFX_MENUNAVIGATE);
  1149. int nNum = m_tCurrentButton->m_nButtonNum;
  1150. m_tCurrentButton->m_nButtonNum--;
  1151. UpdateButton(nNum);
  1152. }
  1153. }
  1154.  
  1155. int nButton = MouseIntersect(m_tCurrentButton, true);
  1156. if( nButton != -1)
  1157. {
  1158. int nNum = m_tCurrentButton->m_nButtonNum;
  1159. m_tCurrentButton->m_nButtonNum = nButton;
  1160. UpdateButton(nNum);
  1161. }
  1162. }
  1163. break;
  1164. };
  1165.  
  1166. }
  1167.  
  1168. void CUIManager::Render( void )
  1169. {
  1170. CGameplayState* pGPState = (CGameplayState*)(CStateManager::GetInstance()->GetGameplayStateHandle());
  1171.  
  1172. C3DManager& renderer = C3DManager::GetInstance();
  1173.  
  1174. renderer.Begin2DRendering();
  1175.  
  1176. if( eCurrentState != STATE_GAMEPLAY && eCurrentState != STATE_PAUSE && eCurrentState != STATE_OPTIONS && eCurrentState != STATE_GAMEOVER_LOSE && eCurrentState != STATE_LEVEL_COMPLETE )
  1177. {
  1178. CStateManager::GetInstance()->m_cBitmapFont.SetColor(XMFLOAT4(0.0f, 0.0f, 0.0f, 1.0f));
  1179.  
  1180. if( CStateManager::GetInstance()->m_cInput.GetIsConnected() ) // Render controller instructions if controller connected, otherwise render keyboard instructions
  1181. {
  1182. CStateManager::GetInstance()->m_cBitmapFont.Draw("Use D-Pad to navigate menu \nand A button to select ",
  1183. CStateManager::GetInstance()->GetWindowWidth() - (int)(CStateManager::GetInstance()->GetWindowWidth()*0.24f ),
  1184. CStateManager::GetInstance()->GetWindowHeight() - (int)(CStateManager::GetInstance()->GetWindowHeight()*0.35f), fInstrFS);
  1185. }
  1186. else
  1187. {
  1188. CStateManager::GetInstance()->m_cBitmapFont.Draw("Use Arrow keys to navigate \nmenu and Enter to select ",
  1189. CStateManager::GetInstance()->GetWindowWidth() - (int)(CStateManager::GetInstance()->GetWindowWidth()*0.24f ),
  1190. CStateManager::GetInstance()->GetWindowHeight() - (int)(CStateManager::GetInstance()->GetWindowHeight()*0.35f), fInstrFS);
  1191. }
  1192.  
  1193. CStateManager::GetInstance()->m_cBitmapFont.SetColor(XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f));
  1194. }
  1195.  
  1196. // Loading sigil icon
  1197. if(!CStateManager::GetInstance()->IsDoneLoading())
  1198. {
  1199. CStateManager::GetInstance()->m_cBitmapFont.SetColor(XMFLOAT4(0.0f, 0.0f, 0.0f, 1.0f));
  1200.  
  1201. // Scrolling ellipsis
  1202. if(GetTickCount() % 1000 < 250)
  1203. CStateManager::GetInstance()->m_cBitmapFont.Draw("Loading", 70, (int)(CStateManager::GetInstance()->GetWindowHeight()-108), 1.0f);
  1204. else if(GetTickCount() % 1000 < 500)
  1205. CStateManager::GetInstance()->m_cBitmapFont.Draw("Loading.", 70, (int)(CStateManager::GetInstance()->GetWindowHeight()-108), 1.0f);
  1206. else if(GetTickCount() % 1000 < 750)
  1207. CStateManager::GetInstance()->m_cBitmapFont.Draw("Loading..", 70, (int)(CStateManager::GetInstance()->GetWindowHeight()-108), 1.0f);
  1208. else
  1209. CStateManager::GetInstance()->m_cBitmapFont.Draw("Loading...", 70, (int)(CStateManager::GetInstance()->GetWindowHeight()-108), 1.0f);
  1210.  
  1211. CStateManager::GetInstance()->m_cBitmapFont.SetColor(XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f));
  1212.  
  1213. m_cLoadingIcon.Render();
  1214. }
  1215. else if(m_cLoadingIcon.GetScale().x > 0.01f)
  1216. m_cLoadingIcon.Render();
  1217.  
  1218.  
  1219. if(m_tCurrentButton->m_nTotalButtons == 0)
  1220. return;
  1221.  
  1222.  
  1223.  
  1224. //for (int i = 0; i < m_tCurrentButton->>m_tAttachedButtons.size(); i++)
  1225. //{
  1226. // if( !m_tCurrentButton->>m_tAttachedButtons[i]->m_bHidden )
  1227. // {
  1228. // m_tCurrentButton->>m_tAttachedButtons[i]->m_cButtonImg.Render();
  1229. // }
  1230. //}
  1231. switch(eCurrentState)
  1232. {
  1233. case STATE_GAMEPLAY:
  1234. {
  1235. GameplayRender();
  1236. }
  1237. break;
  1238. case STATE_LEVEL_SELECT:
  1239. {
  1240. CStateManager::GetInstance()->m_cBitmapFont.SetColor(XMFLOAT4(0.0f, 0.0f, 0.0f, 1.0f));
  1241. for (unsigned int i = 0; i < m_tCurrentButton->m_tButtonNames.size(); i++)
  1242. {
  1243. CStateManager::GetInstance()->m_cBitmapFont.Draw(m_tCurrentButton->m_tButtonNames[i].m_szLabel.c_str(), (int)m_tCurrentButton->m_tButtonNames[i].m_tTexPos.x, (int)m_tCurrentButton->m_tButtonNames[i].m_tTexPos.y, m_tCurrentButton->m_tButtonNames[i].m_fScale);
  1244. }
  1245. CStateManager::GetInstance()->m_cBitmapFont.SetColor(XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f));
  1246.  
  1247. m_tCurrentButton->m_cButtonImg.Render();
  1248.  
  1249. if(!m_tCurrentButton->m_tAttachedButtons[m_tCurrentButton->m_nCurrentAttached]->m_bHidden)
  1250. m_tCurrentButton->m_tAttachedButtons[m_tCurrentButton->m_nCurrentAttached]->m_cButtonImg.Render();
  1251.  
  1252. m_tCurrentButton->m_cBackgroundImg.Render();
  1253.  
  1254. }
  1255. break;
  1256. case STATE_OPTIONS:
  1257. {
  1258. //UpdateButton(m_tCurrentButton->m_nButtonNum);
  1259.  
  1260. OptionsRender();
  1261.  
  1262. if(CStateManager::GetInstance()->GetPrevState() == CStateManager::GetInstance()->GetMenuStateHandle())
  1263. {
  1264. //UpdateButton(tButtonCollection[STATE_MENU]);
  1265. BaseRender(tButtonCollection[STATE_MENU]);
  1266. }
  1267. else
  1268. {
  1269. tButton tHold = *m_tCurrentButton;
  1270. m_tCurrentButton = tButtonCollection[STATE_SOLO];
  1271. GameplayRender();
  1272. m_tCurrentButton = &tHold;
  1273. }
  1274.  
  1275.  
  1276. }
  1277. break;
  1278. default:
  1279. {
  1280. BaseRender(m_tCurrentButton);
  1281.  
  1282. if(eCurrentState == STATE_PAUSE)
  1283. {
  1284. tButton tHold = *m_tCurrentButton;
  1285. m_tCurrentButton = tButtonCollection[STATE_SOLO];
  1286. GameplayRender();
  1287. m_tCurrentButton = &tHold;
  1288. }
  1289.  
  1290. }
  1291. break;
  1292. };
  1293.  
  1294.  
  1295. renderer.GetRenderController().PushRenderListClear();
  1296. renderer.End2DRendering();
  1297.  
  1298. }
  1299.  
  1300. void CUIManager::Shutdown( void )
  1301. {
  1302. // Clear out Map
  1303.  
  1304. for (auto tButtonIter = tButtonCollection.begin(); tButtonIter != tButtonCollection.end(); ++tButtonIter)
  1305. {
  1306. for (auto tAttachedIter = (*tButtonIter).second->m_tAttachedButtons.begin(); tAttachedIter != (*tButtonIter).second->m_tAttachedButtons.end(); ++tAttachedIter)
  1307. {
  1308. delete (*tAttachedIter).second;
  1309. (*tAttachedIter).second = nullptr;
  1310. }
  1311. delete (*tButtonIter).second;
  1312. (*tButtonIter).second = nullptr;
  1313. }
  1314.  
  1315. tButtonCollection.clear();
  1316.  
  1317.  
  1318. for (auto tButtonIter = m_tSliders.begin(); tButtonIter != m_tSliders.end(); ++tButtonIter)
  1319. {
  1320. delete (*tButtonIter).second;
  1321. (*tButtonIter).second = nullptr;
  1322. }
  1323.  
  1324. m_tSliders.clear();
  1325.  
  1326.  
  1327.  
  1328. }
  1329.  
  1330. void CUIManager::SetCurrentState( eStates nState )
  1331. {
  1332. eCurrentState = nState;
  1333. CGameplayState* pGPState = (CGameplayState*)(CStateManager::GetInstance()->GetGameplayStateHandle());
  1334.  
  1335. switch (eCurrentState)
  1336. {
  1337. case STATE_GAMEPLAY:
  1338. {
  1339. m_tCurrentButton = tButtonCollection[STATE_SOLO];
  1340. m_tMultiCurrentButton = tButtonCollection[STATE_MULTI];
  1341.  
  1342. }
  1343. break;
  1344. case STATE_LEVEL_COMPLETE:
  1345. {
  1346. if(pGPState->GetCurrLevel() == 3)
  1347. {
  1348. m_tCurrentButton = tButtonCollection[STATE_LEVEL_COMPLETE];
  1349. m_tCurrentButton->m_nTotalButtons = 1;
  1350. m_tCurrentButton->m_tButtonNames[1].m_szLabel = "";
  1351.  
  1352. }
  1353. else
  1354. m_tCurrentButton = tButtonCollection[STATE_LEVEL_COMPLETE];
  1355.  
  1356. };
  1357. break;
  1358. default:
  1359. {
  1360. m_tCurrentButton = tButtonCollection[eCurrentState];
  1361. }
  1362. break;
  1363. }
  1364.  
  1365. }
  1366.  
  1367. void CUIManager::UpdateButton(tButton *tLoadButton)
  1368. {
  1369.  
  1370. XMFLOAT3 tNewPos;
  1371. tNewPos.x = tLoadButton->m_tPos.x;
  1372. tNewPos.y = tLoadButton->m_tPos.y;
  1373. tNewPos.z = 0.0;
  1374.  
  1375. RECT tClient;
  1376.  
  1377. GetClientRect(CStateManager::GetInstance()->m_hWnd, &tClient );
  1378.  
  1379. int nWidth = tClient.right;
  1380. int nHieght = tClient.bottom;
  1381.  
  1382. // int nWidth = CStateManager::GetInstance()->GetWindowWidth();
  1383. // int nHieght = CStateManager::GetInstance()->GetWindowHeight();
  1384. //tLoadButton.m_tClickArea.left += tLoadButton.m_tPos.x;
  1385. //tLoadButton.m_tClickArea.right += tLoadButton.m_tPos.x;
  1386. //tLoadButton.m_tClickArea.top += tLoadButton.m_tPos.y;
  1387. //tLoadButton.m_tClickArea.bottom += tLoadButton.m_tPos.y;
  1388.  
  1389.  
  1390. tNewPos.x = 2 * tNewPos.x / nWidth - 1;
  1391. tNewPos.y = 1 - 2 * tNewPos.y / nHieght;
  1392.  
  1393. tLoadButton->m_cButtonImg.SetScale(tLoadButton->m_tClickArea);
  1394. tLoadButton->m_cButtonImg.SetPosition(tNewPos);
  1395.  
  1396. //tLoadButton.m_tClickArea.left -= tLoadButton.m_tPos.x;
  1397. //tLoadButton.m_tClickArea.right -= tLoadButton.m_tPos.x;
  1398. //tLoadButton.m_tClickArea.top -= tLoadButton.m_tPos.y;
  1399. //tLoadButton.m_tClickArea.bottom -= tLoadButton.m_tPos.y;
  1400.  
  1401.  
  1402. }
  1403.  
  1404. void CUIManager::UpdateButton(int nNum)
  1405. {
  1406. m_tCurrentButton->m_tPos.y -= ( m_tCurrentButton->m_ButtonWidth + m_tCurrentButton->m_fIncrement ) * nNum;
  1407. m_tCurrentButton->m_tPos.y += ( m_tCurrentButton->m_ButtonWidth + m_tCurrentButton->m_fIncrement ) * m_tCurrentButton->m_nButtonNum;
  1408.  
  1409.  
  1410. XMFLOAT3 tNewPos;
  1411. tNewPos.x = m_tCurrentButton->m_tPos.x;
  1412. tNewPos.y = m_tCurrentButton->m_tPos.y;
  1413. tNewPos.z = 0.0;
  1414.  
  1415. RECT tClient;
  1416.  
  1417. GetClientRect(CStateManager::GetInstance()->m_hWnd, &tClient );
  1418.  
  1419. int nWidth = tClient.right;
  1420. int nHieght = tClient.bottom;
  1421.  
  1422. //int nWidth = CStateManager::GetInstance()->GetWindowWidth();
  1423. //int nHieght = CStateManager::GetInstance()->GetWindowHeight();
  1424. //m_tCurrentButton->m_tClickArea.left += m_tCurrentButton->m_tPos.x;
  1425. //m_tCurrentButton->m_tClickArea.right += m_tCurrentButton->m_tPos.x;
  1426. //m_tCurrentButton->m_tClickArea.top += m_tCurrentButton->m_tPos.y;
  1427. //m_tCurrentButton->m_tClickArea.bottom += m_tCurrentButton->m_tPos.y;
  1428.  
  1429.  
  1430. tNewPos.x = 2 * tNewPos.x / nWidth - 1;
  1431. tNewPos.y = 1 - 2 * tNewPos.y / nHieght;
  1432.  
  1433. //m_tCurrentButton->m_cButtonImg.SetScale(m_tCurrentButton->m_tClickArea);
  1434. m_tCurrentButton->m_cButtonImg.SetPosition(tNewPos);
  1435.  
  1436. //m_tCurrentButton->m_tClickArea.left -= m_tCurrentButton->m_tPos.x;
  1437. //m_tCurrentButton->m_tClickArea.right -= m_tCurrentButton->m_tPos.x;
  1438. //m_tCurrentButton->m_tClickArea.top -= m_tCurrentButton->m_tPos.y;
  1439. //m_tCurrentButton->m_tClickArea.bottom -= m_tCurrentButton->m_tPos.y;
  1440.  
  1441.  
  1442. }
  1443.  
  1444. int CUIManager::MouseIntersect(tButton *tButtonCheck, bool bCheck)
  1445. {
  1446. // Make Button button one no matter what.
  1447.  
  1448.  
  1449. tButtonCheck->m_tPos.y -= ( tButtonCheck->m_ButtonWidth + tButtonCheck->m_fIncrement ) * tButtonCheck->m_nButtonNum;
  1450.  
  1451. POINT tMouse_Pos = m_cInput->GetCursorPos();
  1452.  
  1453. for (int i = 0; i < tButtonCheck->m_nTotalButtons; i++)
  1454. {
  1455. tButtonCheck->m_tPos.y += ( tButtonCheck->m_ButtonWidth + tButtonCheck->m_fIncrement ) * i;
  1456.  
  1457. tButtonCheck->m_tClickArea.left += static_cast<LONG> (tButtonCheck->m_tPos.x);
  1458. tButtonCheck->m_tClickArea.right += static_cast<LONG> (tButtonCheck->m_tPos.x);
  1459. tButtonCheck->m_tClickArea.top += static_cast<LONG> (tButtonCheck->m_tPos.y);
  1460. tButtonCheck->m_tClickArea.bottom += static_cast<LONG> (tButtonCheck->m_tPos.y);
  1461.  
  1462.  
  1463. if(tMouse_Pos.x >= tButtonCheck->m_tClickArea.left && tMouse_Pos.x <= tButtonCheck->m_tClickArea.right)
  1464. {
  1465. if(tMouse_Pos.y >= tButtonCheck->m_tClickArea.top && tMouse_Pos.y <= tButtonCheck->m_tClickArea.bottom)
  1466. {
  1467. tButtonCheck->m_tClickArea.left -= static_cast<LONG> (tButtonCheck->m_tPos.x);
  1468. tButtonCheck->m_tClickArea.right -= static_cast<LONG> (tButtonCheck->m_tPos.x);
  1469. tButtonCheck->m_tClickArea.top -= static_cast<LONG> (tButtonCheck->m_tPos.y);
  1470. tButtonCheck->m_tClickArea.bottom -= static_cast<LONG> (tButtonCheck->m_tPos.y);
  1471.  
  1472.  
  1473. tButtonCheck->m_tPos.y -= ( tButtonCheck->m_ButtonWidth + tButtonCheck->m_fIncrement ) * i;
  1474.  
  1475. tButtonCheck->m_tPos.y += ( tButtonCheck->m_ButtonWidth + tButtonCheck->m_fIncrement ) * tButtonCheck->m_nButtonNum;
  1476.  
  1477. if(bCheck)
  1478. {
  1479. return i;
  1480. }
  1481. else
  1482. {
  1483. return 1;
  1484. }
  1485. }
  1486. }
  1487.  
  1488. tButtonCheck->m_tClickArea.left -= static_cast<LONG> (tButtonCheck->m_tPos.x);
  1489. tButtonCheck->m_tClickArea.right -= static_cast<LONG> (tButtonCheck->m_tPos.x);
  1490. tButtonCheck->m_tClickArea.top -= static_cast<LONG> (tButtonCheck->m_tPos.y);
  1491. tButtonCheck->m_tClickArea.bottom -= static_cast<LONG> (tButtonCheck->m_tPos.y);
  1492.  
  1493. tButtonCheck->m_tPos.y -= ( tButtonCheck->m_ButtonWidth + tButtonCheck->m_fIncrement ) * i;
  1494.  
  1495. }
  1496.  
  1497. tButtonCheck->m_tPos.y += ( tButtonCheck->m_ButtonWidth + tButtonCheck->m_fIncrement ) * tButtonCheck->m_nButtonNum;
  1498.  
  1499. if(bCheck)
  1500. {
  1501. return -1;
  1502. }
  1503. else
  1504. return 0;
  1505. }
  1506.  
  1507. bool CUIManager::MouseIntersect(tButton *tButtonCheck)
  1508. {
  1509. // Make Button button one no matter what.
  1510.  
  1511. tButtonCheck->m_tPos.y -= ( tButtonCheck->m_ButtonWidth + tButtonCheck->m_fIncrement ) * tButtonCheck->m_nButtonNum;
  1512.  
  1513. POINT tMouse_Pos = m_cInput->GetCursorPos();
  1514.  
  1515. for (int i = 0; i < tButtonCheck->m_nTotalButtons; i++)
  1516. {
  1517. tButtonCheck->m_tPos.y += ( tButtonCheck->m_ButtonWidth + tButtonCheck->m_fIncrement ) * i;
  1518.  
  1519. tButtonCheck->m_tClickArea.left += static_cast<LONG> (tButtonCheck->m_tPos.x);
  1520. tButtonCheck->m_tClickArea.right += static_cast<LONG> (tButtonCheck->m_tPos.x);
  1521. tButtonCheck->m_tClickArea.top += static_cast<LONG> (tButtonCheck->m_tPos.y);
  1522. tButtonCheck->m_tClickArea.bottom += static_cast<LONG> (tButtonCheck->m_tPos.y);
  1523.  
  1524.  
  1525. if(tMouse_Pos.x >= tButtonCheck->m_tClickArea.left && tMouse_Pos.x <= tButtonCheck->m_tClickArea.right)
  1526. {
  1527. if(tMouse_Pos.y >= tButtonCheck->m_tClickArea.top && tMouse_Pos.y <= tButtonCheck->m_tClickArea.bottom)
  1528. {
  1529. tButtonCheck->m_tClickArea.left -= static_cast<LONG> (tButtonCheck->m_tPos.x);
  1530. tButtonCheck->m_tClickArea.right -= static_cast<LONG> (tButtonCheck->m_tPos.x);
  1531. tButtonCheck->m_tClickArea.top -= static_cast<LONG> (tButtonCheck->m_tPos.y);
  1532. tButtonCheck->m_tClickArea.bottom -= static_cast<LONG> (tButtonCheck->m_tPos.y);
  1533.  
  1534.  
  1535. tButtonCheck->m_tPos.y -= ( tButtonCheck->m_ButtonWidth + tButtonCheck->m_fIncrement ) * i;
  1536.  
  1537. tButtonCheck->m_tPos.y += ( tButtonCheck->m_ButtonWidth + tButtonCheck->m_fIncrement ) * tButtonCheck->m_nButtonNum;
  1538.  
  1539. return true;
  1540. }
  1541. }
  1542.  
  1543. tButtonCheck->m_tClickArea.left -= static_cast<LONG> (tButtonCheck->m_tPos.x);
  1544. tButtonCheck->m_tClickArea.right -= static_cast<LONG> (tButtonCheck->m_tPos.x);
  1545. tButtonCheck->m_tClickArea.top -= static_cast<LONG> (tButtonCheck->m_tPos.y);
  1546. tButtonCheck->m_tClickArea.bottom -= static_cast<LONG> (tButtonCheck->m_tPos.y);
  1547.  
  1548.  
  1549. tButtonCheck->m_tPos.y -= ( tButtonCheck->m_ButtonWidth + tButtonCheck->m_fIncrement ) * i;
  1550.  
  1551. }
  1552.  
  1553. tButtonCheck->m_tPos.y += ( tButtonCheck->m_ButtonWidth + tButtonCheck->m_fIncrement ) * tButtonCheck->m_nButtonNum;
  1554.  
  1555. return false;
  1556.  
  1557. }
  1558.  
  1559. bool CUIManager::MouseIntersect(bool bCheck, tButton *tButtonCheck)
  1560. {
  1561. POINT tMouse_Pos = m_cInput->GetCursorPos();
  1562.  
  1563. tButtonCheck->m_tClickArea.left += static_cast<LONG> (tButtonCheck->m_tPos.x);
  1564. tButtonCheck->m_tClickArea.right += static_cast<LONG> (tButtonCheck->m_tPos.x);
  1565. tButtonCheck->m_tClickArea.top += static_cast<LONG> (tButtonCheck->m_tPos.y);
  1566. tButtonCheck->m_tClickArea.bottom += static_cast<LONG> (tButtonCheck->m_tPos.y);
  1567.  
  1568. if(tMouse_Pos.x >= tButtonCheck->m_tClickArea.left && tMouse_Pos.x <= tButtonCheck->m_tClickArea.right)
  1569. {
  1570. if(tMouse_Pos.y >= tButtonCheck->m_tClickArea.top && tMouse_Pos.y <= tButtonCheck->m_tClickArea.bottom)
  1571. {
  1572. tButtonCheck->m_tClickArea.left -= static_cast<LONG> (tButtonCheck->m_tPos.x);
  1573. tButtonCheck->m_tClickArea.right -= static_cast<LONG> (tButtonCheck->m_tPos.x);
  1574. tButtonCheck->m_tClickArea.top -= static_cast<LONG> (tButtonCheck->m_tPos.y);
  1575. tButtonCheck->m_tClickArea.bottom -= static_cast<LONG> (tButtonCheck->m_tPos.y);
  1576.  
  1577. return true;
  1578. }
  1579. }
  1580.  
  1581. tButtonCheck->m_tClickArea.left -= static_cast<LONG> (tButtonCheck->m_tPos.x);
  1582. tButtonCheck->m_tClickArea.right -= static_cast<LONG> (tButtonCheck->m_tPos.x);
  1583. tButtonCheck->m_tClickArea.top -= static_cast<LONG> (tButtonCheck->m_tPos.y);
  1584. tButtonCheck->m_tClickArea.bottom -= static_cast<LONG> (tButtonCheck->m_tPos.y);
  1585. return false;
  1586. }
  1587.  
  1588. RECT CUIManager::LoadRECT(TiXmlElement* tElement )
  1589. {
  1590. int nValue;
  1591. tButton tNewButton;
  1592.  
  1593. tElement->Attribute("Left", &nValue);
  1594. tNewButton.m_tClickArea.left = static_cast<long>(nValue);
  1595. tElement->Attribute("Right", &nValue);
  1596. tNewButton.m_tClickArea.right = static_cast<long>(nValue);
  1597. tElement->Attribute("Top", &nValue);
  1598. tNewButton.m_tClickArea.top = static_cast<long>(nValue);
  1599. tElement->Attribute("Bottom", &nValue);
  1600. tNewButton.m_tClickArea.bottom = static_cast<long>(nValue);
  1601.  
  1602. return tNewButton.m_tClickArea;
  1603. }
  1604.  
  1605. float CUIManager::DeterminePosition(XMFLOAT2 tLine, int nVolume)
  1606. {
  1607. float fReturn = tLine.x;
  1608. int nPos = nVolume;
  1609. nPos *= static_cast<int>(tLine.y - tLine.x);
  1610. nPos /= 100;
  1611. fReturn += static_cast<float>(nPos);
  1612.  
  1613. return fReturn;
  1614. }
  1615.  
  1616. int CUIManager::DetermineVolume( float NewPos, float fBoundry)
  1617. {
  1618. int nVolume;
  1619. nVolume = static_cast<int>(NewPos);
  1620. nVolume *= 100;
  1621. nVolume /= static_cast<int>(fBoundry);
  1622.  
  1623. return nVolume;
  1624. }
  1625.  
  1626. void CUIManager::GameplayUpdate( void )
  1627. {
  1628. CGameplayState* pGPState = (CGameplayState*)(CStateManager::GetInstance()->GetGameplayStateHandle());
  1629.  
  1630. CPlayer* pUIPlayer;
  1631.  
  1632. if(pGPState->GetPlayer() == nullptr)
  1633. return;
  1634. else
  1635. pUIPlayer = pGPState->GetPlayer();
  1636.  
  1637. int nNum = 1;
  1638. tButton tHold = *m_tCurrentButton;
  1639.  
  1640. if(CStateManager::GetInstance()->GetCoop())
  1641. {
  1642. nNum = 2;
  1643. }
  1644.  
  1645. for (int nPlayers = 0; nPlayers < nNum; nPlayers++)
  1646. {
  1647. if(nPlayers == 1)
  1648. {
  1649. m_tCurrentButton = m_tMultiCurrentButton;
  1650. pUIPlayer = pGPState->GetPlayer2();
  1651. }
  1652.  
  1653.  
  1654. for (unsigned int i = 0; i < m_tCurrentButton->m_tAttachedButtons.size(); i++)
  1655. {
  1656. switch(i)
  1657. {
  1658. case HUD_ORB_ONE:
  1659. {
  1660. eOrbType eCatchOne = pUIPlayer->GetOrbs()[0];
  1661. if(eCatchOne == ORB_FIRE)
  1662. {
  1663. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.SetDiffuseTexture( CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[ UI_FIRE ] );
  1664. m_tCurrentButton->m_tAttachedButtons[i]->m_bHidden = false;
  1665. }
  1666. else if(eCatchOne == ORB_LIGHT)
  1667. {
  1668. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.SetDiffuseTexture( CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[ UI_LIGHT ] );
  1669. m_tCurrentButton->m_tAttachedButtons[i]->m_bHidden = false;
  1670. }
  1671. else if(eCatchOne == ORB_STONE)
  1672. {
  1673. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.SetDiffuseTexture( CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[ UI_STONE ] );
  1674. m_tCurrentButton->m_tAttachedButtons[i]->m_bHidden = false;
  1675. }
  1676. else if(eCatchOne == ORB_LIGHTNING)
  1677. {
  1678. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.SetDiffuseTexture( CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[ UI_LIGHTNING ] );
  1679. m_tCurrentButton->m_tAttachedButtons[i]->m_bHidden = false;
  1680. }
  1681. else if(eCatchOne == ORB_TAR)
  1682. {
  1683. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.SetDiffuseTexture( CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[ UI_TAR ] );
  1684. m_tCurrentButton->m_tAttachedButtons[i]->m_bHidden = false;
  1685. }
  1686. else
  1687. {
  1688. m_tCurrentButton->m_tAttachedButtons[i]->m_bHidden = true;
  1689. }
  1690. };
  1691. break;
  1692. case HUD_ORB_TWO:
  1693. {
  1694. eOrbType eCatchOne = pUIPlayer->GetOrbs()[1];
  1695. if(eCatchOne == ORB_FIRE)
  1696. {
  1697. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.SetDiffuseTexture( CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[ UI_FIRE ] );
  1698. m_tCurrentButton->m_tAttachedButtons[i]->m_bHidden = false;
  1699. }
  1700. else if(eCatchOne == ORB_LIGHT)
  1701. {
  1702. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.SetDiffuseTexture( CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[ UI_LIGHT ] );
  1703. m_tCurrentButton->m_tAttachedButtons[i]->m_bHidden = false;
  1704. }
  1705. else if(eCatchOne == ORB_STONE)
  1706. {
  1707. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.SetDiffuseTexture( CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[ UI_STONE ] );
  1708. m_tCurrentButton->m_tAttachedButtons[i]->m_bHidden = false;
  1709. }
  1710. else if(eCatchOne == ORB_LIGHTNING)
  1711. {
  1712. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.SetDiffuseTexture( CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[ UI_LIGHTNING ] );
  1713. m_tCurrentButton->m_tAttachedButtons[i]->m_bHidden = false;
  1714. }
  1715. else if(eCatchOne == ORB_TAR)
  1716. {
  1717. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.SetDiffuseTexture( CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[ UI_TAR ] );
  1718. m_tCurrentButton->m_tAttachedButtons[i]->m_bHidden = false;
  1719. }
  1720. else
  1721. {
  1722. m_tCurrentButton->m_tAttachedButtons[i]->m_bHidden = true;
  1723. }
  1724. };
  1725. break;
  1726. case HUD_ORB_THREE:
  1727. {
  1728. eOrbType eCatchOne = pUIPlayer->GetOrbs()[2];
  1729. if(eCatchOne == ORB_FIRE)
  1730. {
  1731. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.SetDiffuseTexture( CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[ UI_FIRE ] );
  1732. m_tCurrentButton->m_tAttachedButtons[i]->m_bHidden = false;
  1733. }
  1734. else if(eCatchOne == ORB_LIGHT)
  1735. {
  1736. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.SetDiffuseTexture( CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[ UI_LIGHT ] );
  1737. m_tCurrentButton->m_tAttachedButtons[i]->m_bHidden = false;
  1738. }
  1739. else if(eCatchOne == ORB_STONE)
  1740. {
  1741. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.SetDiffuseTexture( CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[ UI_STONE ] );
  1742. m_tCurrentButton->m_tAttachedButtons[i]->m_bHidden = false;
  1743. }
  1744. else if(eCatchOne == ORB_LIGHTNING)
  1745. {
  1746. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.SetDiffuseTexture( CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[ UI_LIGHTNING ] );
  1747. m_tCurrentButton->m_tAttachedButtons[i]->m_bHidden = false;
  1748. }
  1749. else if(eCatchOne == ORB_TAR)
  1750. {
  1751. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.SetDiffuseTexture( CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[ UI_TAR ] );
  1752. m_tCurrentButton->m_tAttachedButtons[i]->m_bHidden = false;
  1753. }
  1754. else
  1755. {
  1756. m_tCurrentButton->m_tAttachedButtons[i]->m_bHidden = true;
  1757. }
  1758. };
  1759. break;
  1760. case HUD_SLOT_ONE:
  1761. {
  1762. if(pUIPlayer->GetActiveSlot() == 0)
  1763. {
  1764. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.SetDiffuseTexture( CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[UI_ACTIVE_SLOT] );
  1765. }
  1766. else
  1767. {
  1768. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.SetDiffuseTexture( CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[UI_INACTIVE_SLOT] );
  1769. }
  1770. };
  1771. break;
  1772. case HUD_SLOT_TWO:
  1773. {
  1774. if(pUIPlayer->GetActiveSlot() == 1)
  1775. {
  1776. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.SetDiffuseTexture( CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[UI_ACTIVE_SLOT] );
  1777. }
  1778. else
  1779. {
  1780. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.SetDiffuseTexture( CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[UI_INACTIVE_SLOT] );
  1781. }
  1782. };
  1783. break;
  1784. case HUD_SLOT_THREE:
  1785. {
  1786. if(pUIPlayer->GetActiveSlot() == 2)
  1787. {
  1788. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.SetDiffuseTexture( CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[UI_ACTIVE_SLOT] );
  1789. }
  1790. else
  1791. {
  1792. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.SetDiffuseTexture( CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_GAMEPLAY]->m_tImages[UI_INACTIVE_SLOT] );
  1793. }
  1794. };
  1795. break;
  1796. };
  1797.  
  1798. }
  1799.  
  1800. // Health Modify
  1801. float fHealth = pUIPlayer->GetCurrHealth();
  1802. fHealth *= (m_tCurrentButton->m_tAttachedButtons[HUD_HEALTH_BAR]->m_ButtonWidth);
  1803. fHealth /= 100;
  1804. m_tCurrentButton->m_tAttachedButtons[HUD_HEALTH_BAR]->m_tClickArea.right = (static_cast<LONG> (fHealth) );
  1805.  
  1806. UpdateButton(m_tCurrentButton->m_tAttachedButtons[HUD_HEALTH_BAR]);
  1807.  
  1808.  
  1809. // Stamina Modify
  1810. float fStamina = pUIPlayer->GetCurrStamina();
  1811. fStamina *= (m_tCurrentButton->m_tAttachedButtons[HUD_STAMINA_BAR]->m_ButtonWidth);
  1812. fStamina /= 100;
  1813. m_tCurrentButton->m_tAttachedButtons[HUD_STAMINA_BAR]->m_tClickArea.right = (static_cast<LONG> (fStamina) );
  1814.  
  1815. UpdateButton(m_tCurrentButton->m_tAttachedButtons[HUD_STAMINA_BAR]);
  1816. }
  1817.  
  1818. m_tCurrentButton = &tHold;
  1819.  
  1820. }
  1821.  
  1822. void CUIManager::GameplayRender( void )
  1823. {
  1824. CGameplayState* pGPState = (CGameplayState*)(CStateManager::GetInstance()->GetGameplayStateHandle());
  1825.  
  1826. CPlayer* pUIPlayer;
  1827.  
  1828. if(pGPState->GetPlayer() == nullptr)
  1829. return;
  1830. else
  1831. pUIPlayer = pGPState->GetPlayer();
  1832.  
  1833. int nNum = 1;
  1834. tButton tHold = *m_tCurrentButton;
  1835.  
  1836. if(CStateManager::GetInstance()->GetCoop())
  1837. {
  1838. nNum = 2;
  1839. }
  1840.  
  1841. for (int nPlayers = 0; nPlayers < nNum; nPlayers++)
  1842. {
  1843. if(nPlayers == 1)
  1844. {
  1845. m_tCurrentButton = m_tMultiCurrentButton;
  1846. pUIPlayer = pGPState->GetPlayer2();
  1847. }
  1848.  
  1849.  
  1850. // Render HUD Elements
  1851. m_tCurrentButton->m_tAttachedButtons[HUD_HEALTH_BAR]->m_cButtonImg.Render();
  1852. m_tCurrentButton->m_tAttachedButtons[HUD_STAMINA_BAR]->m_cButtonImg.Render();
  1853.  
  1854. if(!m_tCurrentButton->m_tAttachedButtons[HUD_ORB_ONE]->m_bHidden)
  1855. m_tCurrentButton->m_tAttachedButtons[HUD_ORB_ONE]->m_cButtonImg.Render();
  1856.  
  1857. if(!m_tCurrentButton->m_tAttachedButtons[HUD_ORB_TWO]->m_bHidden)
  1858. m_tCurrentButton->m_tAttachedButtons[HUD_ORB_TWO]->m_cButtonImg.Render();
  1859.  
  1860. if(!m_tCurrentButton->m_tAttachedButtons[HUD_ORB_THREE]->m_bHidden)
  1861. m_tCurrentButton->m_tAttachedButtons[HUD_ORB_THREE]->m_cButtonImg.Render();
  1862.  
  1863.  
  1864. m_tCurrentButton->m_tAttachedButtons[HUD_SLOT_ONE]->m_cButtonImg.Render();
  1865. m_tCurrentButton->m_tAttachedButtons[HUD_SLOT_TWO]->m_cButtonImg.Render();
  1866. m_tCurrentButton->m_tAttachedButtons[HUD_SLOT_THREE]->m_cButtonImg.Render();
  1867.  
  1868.  
  1869. m_tCurrentButton->m_tAttachedButtons[HUD_HS_CASE]->m_cButtonImg.Render();
  1870.  
  1871.  
  1872.  
  1873.  
  1874.  
  1875. if(!CStateManager::GetInstance()->InLevelEditor())
  1876. {
  1877. //if( pGPState->GetCurrLevel() == 1 || pGPState->GetCurrLevel() == 4 || pGPState->GetCurrLevel() == 5 )
  1878. {
  1879. if( pGPState->GetCurrLevel() == 1 || pGPState->GetCurrLevel() == 4 || pGPState->GetCurrLevel() == 5 )
  1880. CStateManager::GetInstance()->m_cBitmapFont.SetColor(XMFLOAT4(0.0f, 0.0f, 0.0f, 1.0f));
  1881.  
  1882. // Messages
  1883. /*
  1884. if(CStateManager::GetInstance()->GetWindowHeight() == 768 )
  1885. {
  1886. CStateManager::GetInstance()->m_cBitmapFont.Draw( pGPState->GetPrimaryMessage().c_str(), 15, 70, pGPState->GetPrimarySize());
  1887. CStateManager::GetInstance()->m_cBitmapFont.Draw( pGPState->GetSecondaryMessage().c_str(), 15, 105, pGPState->GetSecondarySize());
  1888. }
  1889. else
  1890. {
  1891. CStateManager::GetInstance()->m_cBitmapFont.Draw( pGPState->GetPrimaryMessage().c_str(), 20, 95, pGPState->GetPrimarySize());
  1892. CStateManager::GetInstance()->m_cBitmapFont.Draw( pGPState->GetSecondaryMessage().c_str(), 20, 130, pGPState->GetSecondarySize());
  1893.  
  1894. }
  1895. */
  1896. // Short version of Score Display code
  1897.  
  1898.  
  1899. char buffer[20];
  1900. _itoa_s(CStateManager::GetInstance()->GetEntityManager()->GetPlayerScore()->GetScore(), buffer, 10);
  1901. std::string szScore = buffer;
  1902.  
  1903. _itoa_s(CStateManager::GetInstance()->GetEntityManager()->GetPlayerScore()->GetMultiplier(), buffer, 10);
  1904. std::string szMult = buffer;
  1905.  
  1906. /*
  1907. CStateManager::GetInstance()->m_cBitmapFont.Draw("Score: ", CStateManager::GetInstance()->GetWindowWidth() - (40 * szScore.length()) - 125, 5, .75);
  1908. CStateManager::GetInstance()->m_cBitmapFont.Draw(szScore.c_str(), CStateManager::GetInstance()->GetWindowWidth() - (40 * szScore.length()), 5, 1);
  1909. CStateManager::GetInstance()->m_cBitmapFont.Draw("x", CStateManager::GetInstance()->GetWindowWidth() - (40 * (szMult.length() + 1)), 65, .75);
  1910. CStateManager::GetInstance()->m_cBitmapFont.Draw(szMult.c_str(), CStateManager::GetInstance()->GetWindowWidth() - (40 * szMult.length()), 55, 1);
  1911. */
  1912.  
  1913. if( nPlayers == 0 )
  1914. {
  1915. XMFLOAT2 tScorePos;
  1916. tScorePos.x = m_tCurrentButton->m_tAttachedButtons[HUD_SLOT_THREE]->m_tClickArea.right + m_tCurrentButton->m_tAttachedButtons[HUD_SLOT_THREE]->m_tPos.x + 20;
  1917. tScorePos.y = m_tCurrentButton->m_tAttachedButtons[HUD_SLOT_THREE]->m_tPos.y;
  1918.  
  1919. CStateManager::GetInstance()->m_cBitmapFont.Draw("Score: ",(int)tScorePos.x, (int)tScorePos.y, .75);
  1920. CStateManager::GetInstance()->m_cBitmapFont.Draw(szScore.c_str(),(int)tScorePos.x + 110, (int)tScorePos.y, 1);
  1921.  
  1922. tScorePos.x = m_tCurrentButton->m_tAttachedButtons[HUD_HS_CASE]->m_tClickArea.right + m_tCurrentButton->m_tAttachedButtons[HUD_HS_CASE]->m_tPos.x + 10;
  1923. tScorePos.y = m_tCurrentButton->m_tAttachedButtons[HUD_HS_CASE]->m_tPos.y;
  1924.  
  1925. CStateManager::GetInstance()->m_cBitmapFont.Draw("x", (int)tScorePos.x, (int)tScorePos.y, .75);
  1926. CStateManager::GetInstance()->m_cBitmapFont.Draw(szMult.c_str(), (int)tScorePos.x + 30, (int)tScorePos.y, 1);
  1927. }
  1928. else
  1929. {
  1930. XMFLOAT2 tScorePos;
  1931. tScorePos.x = m_tCurrentButton->m_tAttachedButtons[HUD_SLOT_ONE]->m_tPos.x - 10;
  1932. tScorePos.y = m_tCurrentButton->m_tAttachedButtons[HUD_SLOT_ONE]->m_tPos.y;
  1933.  
  1934. CStateManager::GetInstance()->m_cBitmapFont.Draw("Score: ", (int)tScorePos.x - (25 * szScore.length()) - 110, (int)tScorePos.y, .75);
  1935. CStateManager::GetInstance()->m_cBitmapFont.Draw(szScore.c_str(), (int)tScorePos.x - (25 * szScore.length()), (int)tScorePos.y, 1);
  1936.  
  1937. tScorePos.x = m_tCurrentButton->m_tAttachedButtons[HUD_HS_CASE]->m_tPos.x - 10;
  1938. tScorePos.y = m_tCurrentButton->m_tAttachedButtons[HUD_HS_CASE]->m_tPos.y;
  1939.  
  1940. CStateManager::GetInstance()->m_cBitmapFont.Draw("x", (int)tScorePos.x - (25 * (szMult.length() + 1)), (int)tScorePos.y, .75);
  1941. CStateManager::GetInstance()->m_cBitmapFont.Draw(szMult.c_str(), (int)tScorePos.x - (25 * szMult.length()), (int)tScorePos.y, 1);
  1942. }
  1943.  
  1944.  
  1945.  
  1946. if( pGPState->GetCurrLevel() == 1 || pGPState->GetCurrLevel() == 4 || pGPState->GetCurrLevel() == 5 )
  1947. CStateManager::GetInstance()->m_cBitmapFont.SetColor(XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f));
  1948.  
  1949. }
  1950. }
  1951. else
  1952. {
  1953. LevelEditorRender();
  1954. }
  1955.  
  1956. CPlayer* pPlayer = ((CGameplayState*)CStateManager::GetInstance()->GetGameplayStateHandle())->GetPlayer();
  1957. if(pPlayer->GetCurrPriorityOrb() != nullptr && pPlayer->GetCurrPriorityOrb()->GetPriority() == true )
  1958. {
  1959. eOrbType* eCurrOrbs = pPlayer->GetOrbs();
  1960. if(eCurrOrbs[2] == ORB_EMPTY ||eCurrOrbs[1] == ORB_EMPTY ||eCurrOrbs[0] == ORB_EMPTY)
  1961. {
  1962. if( CStateManager::GetInstance()->m_cInput.GetIsConnected() )
  1963. {
  1964. CStateManager::GetInstance()->m_cBitmapFont.Draw("Press 'A' to pick up Orb",
  1965. 15, 15, 0.60f);
  1966. }
  1967. else
  1968. {
  1969. CStateManager::GetInstance()->m_cBitmapFont.Draw("Right Click to pick up Orb",
  1970. 15, 15, 0.60f);
  1971. }
  1972. }
  1973. }
  1974.  
  1975. vector<CFountain*> fountainList = ((CGameplayState*)CStateManager::GetInstance()->GetGameplayStateHandle())->m_tFountains;
  1976. for(size_t i = 0; i < fountainList.size(); ++i)
  1977. {
  1978. if( !fountainList[i]->GetIsActive() && fountainList[i]->GetCorruptLevel() > 0.0f && fountainList[i]->GetInfluence()->GetNumPlayersWithin() > 0 )
  1979. {
  1980. if( CStateManager::GetInstance()->m_cInput.GetIsConnected() )
  1981. {
  1982. CStateManager::GetInstance()->m_cBitmapFont.Draw("Press 'A' to activate Fountain",
  1983. 15, 15, 0.60f);
  1984. }
  1985. else
  1986. {
  1987. CStateManager::GetInstance()->m_cBitmapFont.Draw("Right Click to activate Fountain",
  1988. 15, 15, 0.60f);
  1989. }
  1990. }
  1991. }
  1992.  
  1993. }
  1994.  
  1995. m_tCurrentButton = &tHold;
  1996. }
  1997.  
  1998. void CUIManager::LevelEditorRender(void)
  1999. {
  2000. CGameplayState* pGPState = (CGameplayState*)(CStateManager::GetInstance()->GetGameplayStateHandle());
  2001.  
  2002. switch (CStateManager::GetInstance()->GetEntityManager()->GetPlayer()->GetLevelEditorType())
  2003. {
  2004. case LEP_DAMNED_TANK:
  2005. CStateManager::GetInstance()->m_cBitmapFont.Draw("Tank Damned", CStateManager::GetInstance()->GetWindowWidth() - (40 * 4) - 125, 5, .75);
  2006. break;
  2007. case LEP_DAMNED_FAST:
  2008. CStateManager::GetInstance()->m_cBitmapFont.Draw("Fast Damned", CStateManager::GetInstance()->GetWindowWidth() - (40 * 4) - 125, 5, .75);
  2009. break;
  2010. case LEP_DAMNED:
  2011. CStateManager::GetInstance()->m_cBitmapFont.Draw("Damned", CStateManager::GetInstance()->GetWindowWidth() - (40 * 3) - 125, 5, .75);
  2012. break;
  2013. case LEP_DAMNED_DUMMY:
  2014. CStateManager::GetInstance()->m_cBitmapFont.Draw("Dummy Damned", CStateManager::GetInstance()->GetWindowWidth() - (40 * 5) - 125, 5, .75);
  2015. break;
  2016. case LEP_GOATIMP_BIG:
  2017. CStateManager::GetInstance()->m_cBitmapFont.Draw("Big Goat Imp", CStateManager::GetInstance()->GetWindowWidth() - (40 * 4) - 125, 5, .75);
  2018. break;
  2019. case LEP_GOATIMP_TRI:
  2020. CStateManager::GetInstance()->m_cBitmapFont.Draw("Tri Goat Imp", CStateManager::GetInstance()->GetWindowWidth() - (40 * 4) - 125, 5, .75);
  2021. break;
  2022. case LEP_GOATIMP:
  2023. CStateManager::GetInstance()->m_cBitmapFont.Draw("Goat Imp", CStateManager::GetInstance()->GetWindowWidth() - (40 * 3) - 125, 5, .75);
  2024. break;
  2025. case LEP_GOATIMP_DUMMY:
  2026. CStateManager::GetInstance()->m_cBitmapFont.Draw("Dummy Goat Imp", CStateManager::GetInstance()->GetWindowWidth() - (40 * 5) - 125, 5, .75);
  2027. break;
  2028. case LEP_PIGGLY:
  2029. CStateManager::GetInstance()->m_cBitmapFont.Draw("Piggly", CStateManager::GetInstance()->GetWindowWidth() - (40 * 3) - 125, 5, .75);
  2030. break;
  2031. case LEP_PIGGLY_DUMMY:
  2032. CStateManager::GetInstance()->m_cBitmapFont.Draw("Dummy Piggly", CStateManager::GetInstance()->GetWindowWidth() - (40 * 3) - 125, 5, .75);
  2033. break;
  2034. case LEP_DEMONLORD:
  2035. CStateManager::GetInstance()->m_cBitmapFont.Draw("Demon Lord", CStateManager::GetInstance()->GetWindowWidth() - (40 * 3) - 125, 5, .75);
  2036. break;
  2037. case LEP_LUCIFER:
  2038. CStateManager::GetInstance()->m_cBitmapFont.Draw("Lucifer", CStateManager::GetInstance()->GetWindowWidth() - (40 * 3) - 125, 5, .75);
  2039. break;
  2040. case LEP_GATE:
  2041. CStateManager::GetInstance()->m_cBitmapFont.Draw("Gate", CStateManager::GetInstance()->GetWindowWidth() - (40 * 3) - 125, 5, .75);
  2042. break;
  2043. case LEP_FOUNTAIN:
  2044. CStateManager::GetInstance()->m_cBitmapFont.Draw("Fountain", CStateManager::GetInstance()->GetWindowWidth() - (40 * 3) - 125, 5, .75);
  2045. break;
  2046. default:
  2047. break;
  2048. }
  2049. char buffer[20];
  2050. _itoa_s((int)(CStateManager::GetInstance()->GetEntityManager()->GetPlayer()->GetLevelEditorArea()), buffer, 10);
  2051. CStateManager::GetInstance()->m_cBitmapFont.Draw("Area: ", CStateManager::GetInstance()->GetWindowWidth() - 180, 65, 0.75);
  2052. CStateManager::GetInstance()->m_cBitmapFont.Draw(buffer, CStateManager::GetInstance()->GetWindowWidth() - 40, 55, 0.75);
  2053. _itoa_s((int)(CStateManager::GetInstance()->GetEntityManager()->GetPlayer()->GetLevelEditorWave()), buffer, 10);
  2054. CStateManager::GetInstance()->m_cBitmapFont.Draw("Wave: ", CStateManager::GetInstance()->GetWindowWidth() - 180, 95, 0.75);
  2055. CStateManager::GetInstance()->m_cBitmapFont.Draw(buffer, CStateManager::GetInstance()->GetWindowWidth() - 40, 95, 0.75);
  2056.  
  2057. _itoa_s((int)(pGPState->GetCurrSub()), buffer, 10);
  2058. CStateManager::GetInstance()->m_cBitmapFont.Draw("Sub: ", CStateManager::GetInstance()->GetWindowWidth() - 180, 125, 0.75);
  2059. CStateManager::GetInstance()->m_cBitmapFont.Draw(buffer, CStateManager::GetInstance()->GetWindowWidth() - 40, 125, 0.75);
  2060. }
  2061.  
  2062. void CUIManager::OptionsRender(void)
  2063. {
  2064. CStateManager::GetInstance()->m_cBitmapFont.SetColor(XMFLOAT4(0.0f, 0.0f, 0.0f, 1.0f));
  2065. for (unsigned int i = 0; i < m_tCurrentButton->m_tButtonNames.size(); i++)
  2066. {
  2067. CStateManager::GetInstance()->m_cBitmapFont.Draw(m_tCurrentButton->m_tButtonNames[i].m_szLabel.c_str(), (int)m_tCurrentButton->m_tButtonNames[i].m_tTexPos.x, (int)m_tCurrentButton->m_tButtonNames[i].m_tTexPos.y, m_tCurrentButton->m_tButtonNames[i].m_fScale);
  2068. }
  2069. CStateManager::GetInstance()->m_cBitmapFont.SetColor(XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f));
  2070.  
  2071. if(m_tCurrentButton->m_nButtonNum == OPT_VIDEO)
  2072. {
  2073. if(CStateManager::GetInstance()->GetWindowWidth() == 1024)
  2074. {
  2075. CStateManager::GetInstance()->m_cBitmapFont.Draw("1024x768",(int)(m_tCurrentButton->m_tAttachedButtons[VID_RES_ONE]->m_tClickArea.right + m_tCurrentButton->m_tAttachedButtons[VID_RES_ONE]->m_tPos.x + 20), (int)m_tCurrentButton->m_tAttachedButtons[VID_RES_ONE]->m_tPos.y, 0.35f);
  2076. }
  2077. else
  2078. {
  2079. CStateManager::GetInstance()->m_cBitmapFont.Draw("1920x1080",(int)(m_tCurrentButton->m_tAttachedButtons[VID_RES_ONE]->m_tClickArea.right + m_tCurrentButton->m_tAttachedButtons[VID_RES_ONE]->m_tPos.x + 35), (int)m_tCurrentButton->m_tAttachedButtons[VID_RES_ONE]->m_tPos.y, 0.6f);
  2080. }
  2081. }
  2082.  
  2083. if(m_tCurrentButton->m_nButtonNum == OPT_CONTROLS)
  2084. m_tCurrentButton->m_cBackgroundImg.SetDiffuseTexture(CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_OPTIONS]->m_tImages[UI_CON]);
  2085. else if(m_tCurrentButton->m_nButtonNum == OPT_AUDIO)
  2086. m_tCurrentButton->m_cBackgroundImg.SetDiffuseTexture(CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_OPTIONS]->m_tImages[UI_AUD]);
  2087. else if(m_tCurrentButton->m_nButtonNum == OPT_VIDEO)
  2088. m_tCurrentButton->m_cBackgroundImg.SetDiffuseTexture(CStateManager::GetInstance()->GetAssetManagerHandle()->tUI[STATE_OPTIONS]->m_tImages[UI_VID]);
  2089.  
  2090. for (unsigned int i = 0; i < m_tCurrentButton->m_tAttachedButtons.size(); i++)
  2091. {
  2092. if(m_tCurrentButton->m_tAttachedButtons[i]->m_nParentButton == m_tCurrentButton->m_nButtonNum)
  2093. {
  2094. if(CStateManager::GetInstance()->GetIsFullscreen())
  2095. {
  2096. if(m_tCurrentButton->m_tAttachedButtons[i]->m_nButtonNum != VID_FS_OFF)
  2097. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.Render();
  2098. }
  2099. else
  2100. {
  2101. if(m_tCurrentButton->m_tAttachedButtons[i]->m_nButtonNum != VID_FS_ON)
  2102. m_tCurrentButton->m_tAttachedButtons[i]->m_cButtonImg.Render();
  2103. }
  2104. }
  2105. }
  2106. m_tCurrentButton->m_cButtonImg.Render();
  2107.  
  2108. m_tCurrentButton->m_cBackgroundImg.Render();
  2109. }
  2110.  
  2111. void CUIManager::BaseRender(tButton* tRender)
  2112. {
  2113. CStateManager::GetInstance()->m_cBitmapFont.SetColor(XMFLOAT4(0.0f, 0.0f, 0.0f, 1.0f));
  2114. for (unsigned int i = 0; i < tRender->m_tButtonNames.size(); i++)
  2115. {
  2116. CStateManager::GetInstance()->m_cBitmapFont.Draw(tRender->m_tButtonNames[i].m_szLabel.c_str(), (int)tRender->m_tButtonNames[i].m_tTexPos.x, (int)tRender->m_tButtonNames[i].m_tTexPos.y, tRender->m_tButtonNames[i].m_fScale);
  2117. }
  2118. CStateManager::GetInstance()->m_cBitmapFont.SetColor(XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f));
  2119.  
  2120.  
  2121. tRender->m_cButtonImg.Render();
  2122.  
  2123. tRender->m_cBackgroundImg.Render();
  2124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement