shortcutbarctrl.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Combat *
  23. * *
  24. * $Archive:: /Commando/Code/wwui/shortcutbarctrl.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 11/13/01 9:58a $*
  29. * *
  30. * $Revision:: 8 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. // Disable warning about exception handling not being enabled. It's used as part of STL - in a part of STL we don't use.
  36. #pragma warning(disable : 4530)
  37. #include "shortcutbarctrl.h"
  38. #include "assetmgr.h"
  39. #include "refcount.h"
  40. #include "mousemgr.h"
  41. #include "ww3d.h"
  42. #include "dialogmgr.h"
  43. #include "dialogbase.h"
  44. #include "stylemgr.h"
  45. #include "vector4.h"
  46. ////////////////////////////////////////////////////////////////
  47. // Local constants
  48. ////////////////////////////////////////////////////////////////
  49. static const float BORDER_X = 10.0F;
  50. static const float BORDER_Y = BORDER_X * 0.75F;
  51. static const float TEXT_BORDER_Y = 6.0F;
  52. static const float FULL_WIDTH = 200.0F;
  53. static const RectClass BAR_TOP_UVS (1, 3, 13, 44);
  54. static const RectClass BAR_BOTTOM_UVS (14, 4, 26, 44);
  55. static const RectClass BAR_TILE_UVS (27, 10, 39, 37);
  56. ////////////////////////////////////////////////////////////////
  57. //
  58. // ShortcutBarCtrlClass
  59. //
  60. ////////////////////////////////////////////////////////////////
  61. ShortcutBarCtrlClass::ShortcutBarCtrlClass (void) :
  62. FullRect (0, 0, 0, 0),
  63. IsHiddenState (true),
  64. CurrSel (-1),
  65. BarOpacity (1.0F),
  66. PulseDirection (-1.0F)
  67. {
  68. //
  69. // Set the font for the text renderers
  70. //
  71. StyleMgrClass::Assign_Font (&TextRenderer, StyleMgrClass::FONT_CONTROLS);
  72. StyleMgrClass::Assign_Font (&GlowRenderer, StyleMgrClass::FONT_HEADER);
  73. StyleMgrClass::Assign_Font (&HilightRenderer, StyleMgrClass::FONT_HEADER);
  74. StyleMgrClass::Configure_Renderer (&ControlRenderer);
  75. StyleMgrClass::Configure_Renderer (&TexturedControlRenderer);
  76. //
  77. // Configure the textured renderer
  78. //
  79. TextureClass *texture = WW3DAssetManager::Get_Instance ()->Get_Texture ("if_bar.tga", TextureClass::MIP_LEVELS_1);
  80. TexturedControlRenderer.Set_Texture (texture);
  81. REF_PTR_RELEASE (texture);
  82. return ;
  83. }
  84. ////////////////////////////////////////////////////////////////
  85. //
  86. // ~ShortcutBarCtrlClass
  87. //
  88. ////////////////////////////////////////////////////////////////
  89. ShortcutBarCtrlClass::~ShortcutBarCtrlClass (void)
  90. {
  91. return ;
  92. }
  93. ////////////////////////////////////////////////////////////////
  94. //
  95. // Create_Text_Renderers
  96. //
  97. ////////////////////////////////////////////////////////////////
  98. void
  99. ShortcutBarCtrlClass::Create_Text_Renderers (void)
  100. {
  101. //
  102. // Start fresh
  103. //
  104. TextRenderer.Reset ();
  105. GlowRenderer.Reset ();
  106. HilightRenderer.Reset ();
  107. //
  108. // Don't do anything if the control is "hidden"
  109. //
  110. if (IsHiddenState) {
  111. return ;
  112. }
  113. //
  114. // Draw each button
  115. //
  116. for (int index = 0; index < ShortcutList.Count (); index ++) {
  117. //
  118. // Get the rectangle for this button
  119. //
  120. RectClass text_rect;
  121. Get_Entry_Rect (index, text_rect);
  122. //
  123. // Get a pointer to the text for this entry
  124. //
  125. const WCHAR *text = ShortcutList[index].text;
  126. //
  127. // Is this the hilighted button?
  128. //
  129. if (index == CurrSel) {
  130. //
  131. // Render the text for this button
  132. //
  133. StyleMgrClass::Render_Text (text, &HilightRenderer, StyleMgrClass::Get_Tab_Text_Color (),
  134. StyleMgrClass::Get_Text_Shadow_Color (), text_rect, true, true,
  135. StyleMgrClass::CENTER_JUSTIFY);
  136. //
  137. // Render its "glow"
  138. //
  139. GlowRenderer.Build_Sentence (text);
  140. StyleMgrClass::Render_Glow (text, &GlowRenderer, text_rect, 7, 7,
  141. StyleMgrClass::Get_Tab_Glow_Color (), StyleMgrClass::CENTER_JUSTIFY);
  142. } else {
  143. //
  144. // Render the text for this button
  145. //
  146. StyleMgrClass::Render_Text (text, &TextRenderer, text_rect, true, true,
  147. StyleMgrClass::CENTER_JUSTIFY);
  148. }
  149. }
  150. return ;
  151. }
  152. ////////////////////////////////////////////////////////////////
  153. //
  154. // Create_Control_Renderers
  155. //
  156. ////////////////////////////////////////////////////////////////
  157. void
  158. ShortcutBarCtrlClass::Create_Control_Renderers (void)
  159. {
  160. //
  161. // Configure this renderer
  162. //
  163. ControlRenderer.Reset ();
  164. TexturedControlRenderer.Reset ();
  165. ControlRenderer.Enable_Texturing (false);
  166. if (IsHiddenState) {
  167. Create_Hidden_State_Renderers ();
  168. } else {
  169. Create_Displayed_State_Renderers ();
  170. }
  171. return ;
  172. }
  173. ////////////////////////////////////////////////////////////////
  174. //
  175. // Create_Hidden_State_Renderers
  176. //
  177. ////////////////////////////////////////////////////////////////
  178. void
  179. ShortcutBarCtrlClass::Create_Hidden_State_Renderers (void)
  180. {
  181. //
  182. // Determine which color to draw the outline in
  183. //
  184. //int color = StyleMgrClass::Get_Line_Color ();
  185. //int bkcolor = StyleMgrClass::Get_Bk_Color ();
  186. //
  187. // Draw the outline
  188. //
  189. //ControlRenderer.Add_Rect (Rect, 1.0F, color, bkcolor);
  190. Render_Strip (Rect, false);
  191. return ;
  192. }
  193. ////////////////////////////////////////////////////////////////
  194. //
  195. // Render_Strip
  196. //
  197. ////////////////////////////////////////////////////////////////
  198. void
  199. ShortcutBarCtrlClass::Render_Strip (const RectClass &screen_rect, bool flip_uvs)
  200. {
  201. RectClass bar_top_uvs = BAR_TOP_UVS;
  202. RectClass bar_tile_uvs = BAR_TILE_UVS;
  203. RectClass bar_bottom_uvs = BAR_BOTTOM_UVS;
  204. bar_top_uvs.Inverse_Scale (Vector2 (64, 64));
  205. bar_tile_uvs.Inverse_Scale (Vector2 (64, 64));
  206. bar_bottom_uvs.Inverse_Scale (Vector2 (64, 64));
  207. //
  208. // Flip the UVs if necessary
  209. //
  210. if (flip_uvs) {
  211. float temp = bar_top_uvs.Right;
  212. bar_top_uvs.Right = bar_top_uvs.Left;
  213. bar_top_uvs.Left = temp;
  214. temp = bar_tile_uvs.Right;
  215. bar_tile_uvs.Right = bar_tile_uvs.Left;
  216. bar_tile_uvs.Left = temp;
  217. temp = bar_bottom_uvs.Right;
  218. bar_bottom_uvs.Right = bar_bottom_uvs.Left;
  219. bar_bottom_uvs.Left = temp;
  220. }
  221. //
  222. // Render the top of the bar
  223. //
  224. RectClass rect = screen_rect;
  225. rect.Bottom = int(rect.Top + BAR_TOP_UVS.Height ());
  226. TexturedControlRenderer.Add_Quad (rect, bar_top_uvs);
  227. //
  228. // Render the center (tileable) section
  229. //
  230. float height = (screen_rect.Bottom - BAR_BOTTOM_UVS.Height ()) - rect.Bottom;
  231. while (height > 0) {
  232. float tile_height = BAR_TILE_UVS.Height ();
  233. tile_height = min (tile_height, height);
  234. //
  235. // Render this section of the bar
  236. //
  237. rect.Top = rect.Bottom;
  238. rect.Bottom = int (rect.Top + tile_height);
  239. TexturedControlRenderer.Add_Quad (rect, bar_tile_uvs);
  240. //
  241. // Decrement the total height left
  242. //
  243. height -= tile_height;
  244. }
  245. //
  246. // Render the bottom of the bar
  247. //
  248. rect.Top = rect.Bottom;
  249. rect.Bottom = screen_rect.Bottom;
  250. TexturedControlRenderer.Add_Quad (rect, bar_bottom_uvs);
  251. return ;
  252. }
  253. ////////////////////////////////////////////////////////////////
  254. //
  255. // Create_Displayed_State_Renderers
  256. //
  257. ////////////////////////////////////////////////////////////////
  258. void
  259. ShortcutBarCtrlClass::Create_Displayed_State_Renderers (void)
  260. {
  261. //
  262. // Determine which color to draw the outline in
  263. //
  264. int color = StyleMgrClass::Get_Line_Color ();
  265. int bkcolor = StyleMgrClass::Get_Bk_Color ();
  266. //
  267. // Darken the background...
  268. //
  269. ControlRenderer.Add_Quad (FullRect, RGBA_TO_INT32 (0, 0, 0, 170));
  270. //
  271. // Draw the outline
  272. //
  273. ControlRenderer.Add_Rect (FullRect, 1.0F, color, bkcolor);
  274. //
  275. // Render the left strip
  276. //
  277. RectClass rect = Rect;
  278. rect.Left -= 1.0F;
  279. rect.Right -= 1.0F;
  280. rect.Top -= (6.0F * StyleMgrClass::Get_Y_Scale ());
  281. rect.Bottom += (6.0F * StyleMgrClass::Get_Y_Scale ());
  282. Render_Strip (rect, true);
  283. //
  284. // Render the right strip
  285. //
  286. rect.Right = FullRect.Right;
  287. rect.Left = FullRect.Right - Rect.Width ();
  288. Render_Strip (rect, false);
  289. return ;
  290. }
  291. ////////////////////////////////////////////////////////////////
  292. //
  293. // On_Set_Cursor
  294. //
  295. ////////////////////////////////////////////////////////////////
  296. void
  297. ShortcutBarCtrlClass::On_Set_Cursor (const Vector2 &mouse_pos)
  298. {
  299. //
  300. // Change the mouse cursor
  301. //
  302. MouseMgrClass::Set_Cursor (MouseMgrClass::CURSOR_ACTION);
  303. return ;
  304. }
  305. ////////////////////////////////////////////////////////////////
  306. //
  307. // Update_Client_Rect
  308. //
  309. ////////////////////////////////////////////////////////////////
  310. void
  311. ShortcutBarCtrlClass::Update_Client_Rect (void)
  312. {
  313. //
  314. // Set the client area
  315. //
  316. ClientRect = Rect;
  317. //
  318. // Determine what scale to use
  319. //
  320. float scale_x = Render2DClass::Get_Screen_Resolution().Width () / 800.0F;
  321. //
  322. // Calculate the display rectangle
  323. //
  324. FullRect = Rect;
  325. FullRect.Right = FullRect.Left + int(FULL_WIDTH * scale_x);
  326. Set_Dirty ();
  327. return ;
  328. }
  329. ////////////////////////////////////////////////////////////////
  330. //
  331. // Render
  332. //
  333. ////////////////////////////////////////////////////////////////
  334. void
  335. ShortcutBarCtrlClass::Render (void)
  336. {
  337. //
  338. // Recreate the renderers (if necessary)
  339. //
  340. if (IsDirty) {
  341. Create_Control_Renderers ();
  342. Create_Text_Renderers ();
  343. }
  344. //
  345. // Render the background and text for the current state
  346. //
  347. ControlRenderer.Render ();
  348. TexturedControlRenderer.Render ();
  349. GlowRenderer.Render ();
  350. TextRenderer.Render ();
  351. HilightRenderer.Render ();
  352. DialogControlClass::Render ();
  353. return ;
  354. }
  355. ////////////////////////////////////////////////////////////////
  356. //
  357. // On_LButton_Down
  358. //
  359. ////////////////////////////////////////////////////////////////
  360. void
  361. ShortcutBarCtrlClass::On_LButton_Down (const Vector2 &mouse_pos)
  362. {
  363. int new_sel = Entry_From_Pos (mouse_pos);
  364. if (new_sel != -1) {
  365. Set_Curr_Sel (new_sel);
  366. Send_Command ();
  367. }
  368. return ;
  369. }
  370. ////////////////////////////////////////////////////////////////
  371. //
  372. // On_LButton_Up
  373. //
  374. ////////////////////////////////////////////////////////////////
  375. void
  376. ShortcutBarCtrlClass::On_LButton_Up (const Vector2 &mouse_pos)
  377. {
  378. return ;
  379. }
  380. ////////////////////////////////////////////////////////////////
  381. //
  382. // On_Mouse_Move
  383. //
  384. ////////////////////////////////////////////////////////////////
  385. void
  386. ShortcutBarCtrlClass::On_Mouse_Move (const Vector2 &mouse_pos)
  387. {
  388. //
  389. // Check to see if the user moved the mouse off of the control
  390. //
  391. if (IsHiddenState == false && FullRect.Contains (mouse_pos) == false) {
  392. Set_Hidden_State (true);
  393. } else if (IsHiddenState && FullRect.Contains (mouse_pos)) {
  394. Set_Hidden_State (false);
  395. } else if (IsHiddenState == false) {
  396. //
  397. // Ensure we have the input focus captured
  398. //
  399. if (DialogMgrClass::Get_Focus () != this) {
  400. Set_Focus ();
  401. Set_Capture ();
  402. }
  403. //
  404. // Change the selection
  405. //
  406. int new_sel = Entry_From_Pos (mouse_pos);
  407. Set_Curr_Sel (new_sel);
  408. }
  409. return ;
  410. }
  411. ////////////////////////////////////////////////////////////////
  412. //
  413. // On_Set_Focus
  414. //
  415. ////////////////////////////////////////////////////////////////
  416. void
  417. ShortcutBarCtrlClass::On_Set_Focus (void)
  418. {
  419. DialogControlClass::On_Set_Focus ();
  420. return ;
  421. }
  422. ////////////////////////////////////////////////////////////////
  423. //
  424. // On_Kill_Focus
  425. //
  426. ////////////////////////////////////////////////////////////////
  427. void
  428. ShortcutBarCtrlClass::On_Kill_Focus (DialogControlClass *focus)
  429. {
  430. Set_Hidden_State (true);
  431. DialogControlClass::On_Kill_Focus (focus);
  432. return ;
  433. }
  434. ////////////////////////////////////////////////////////////////
  435. //
  436. // On_Key_Down
  437. //
  438. ////////////////////////////////////////////////////////////////
  439. bool
  440. ShortcutBarCtrlClass::On_Key_Down (uint32 key_id, uint32 key_data)
  441. {
  442. bool handled = true;
  443. switch (key_id)
  444. {
  445. case VK_SPACE:
  446. case VK_RETURN:
  447. Send_Command ();
  448. break;
  449. case VK_UP:
  450. case VK_LEFT:
  451. Set_Curr_Sel (CurrSel - 1, true);
  452. break;
  453. case VK_DOWN:
  454. case VK_RIGHT:
  455. Set_Curr_Sel (CurrSel + 1, true);
  456. break;
  457. default:
  458. handled = false;
  459. break;
  460. }
  461. return handled;
  462. }
  463. ////////////////////////////////////////////////////////////////
  464. //
  465. // On_Create
  466. //
  467. ////////////////////////////////////////////////////////////////
  468. void
  469. ShortcutBarCtrlClass::On_Create (void)
  470. {
  471. return ;
  472. }
  473. ////////////////////////////////////////////////////////////////
  474. //
  475. // Set_Hidden_State
  476. //
  477. ////////////////////////////////////////////////////////////////
  478. void
  479. ShortcutBarCtrlClass::Set_Hidden_State (bool onoff)
  480. {
  481. //
  482. // Set the dirty flag if we've changed states
  483. //
  484. if (IsHiddenState != onoff) {
  485. IsHiddenState = onoff;
  486. Set_Dirty ();
  487. //
  488. // Capture the mouse so we can tell when the user
  489. // moves the mouse off of the control
  490. //
  491. if (IsHiddenState == false) {
  492. //
  493. // Snap the mouse to the first entry
  494. //
  495. //RectClass text_rect;
  496. //Get_Entry_Rect (0, text_rect);
  497. //Vector3 center (FullRect.Center ().X, DialogMgrClass::Get_Mouse_Pos ().Y, 0);
  498. //DialogMgrClass::Set_Mouse_Pos (center);
  499. //
  500. // Capture the input focus
  501. //
  502. Set_Focus ();
  503. Set_Capture ();
  504. } else {
  505. Release_Capture ();
  506. }
  507. }
  508. return ;
  509. }
  510. ////////////////////////////////////////////////////////////////
  511. //
  512. // Add_Button
  513. //
  514. ////////////////////////////////////////////////////////////////
  515. void
  516. ShortcutBarCtrlClass::Add_Button (int ctrl_id, const WCHAR *text)
  517. {
  518. ShortcutList.Add (ShortcutInfoStruct (ctrl_id, text));
  519. Set_Dirty ();
  520. return ;
  521. }
  522. ////////////////////////////////////////////////////////////////
  523. //
  524. // Remove_Button
  525. //
  526. ////////////////////////////////////////////////////////////////
  527. void
  528. ShortcutBarCtrlClass::Remove_Button (int ctrl_id)
  529. {
  530. for (int index = 0; index < ShortcutList.Count (); index ++) {
  531. //
  532. // Remove the entry from the list...
  533. //
  534. if (ShortcutList[index].ctrl_id == ctrl_id) {
  535. ShortcutList.Delete (index);
  536. Set_Dirty ();
  537. break;
  538. }
  539. }
  540. return ;
  541. }
  542. ////////////////////////////////////////////////////////////////
  543. //
  544. // Get_Entry_Rect
  545. //
  546. ////////////////////////////////////////////////////////////////
  547. void
  548. ShortcutBarCtrlClass::Get_Entry_Rect (int index, RectClass &rect)
  549. {
  550. float start_y_pos = Rect.Top + BORDER_Y * StyleMgrClass::Get_Y_Scale ();
  551. float entry_height = TextRenderer.Get_Text_Extents (L"W").Y;
  552. entry_height += TEXT_BORDER_Y * StyleMgrClass::Get_Y_Scale () * 2.0F;
  553. //
  554. // Simply calculate the rectangle for this entry and return it
  555. // to the caller
  556. //
  557. rect.Left = FullRect.Left + int(BORDER_X * StyleMgrClass::Get_X_Scale ());
  558. rect.Right = FullRect.Right - int(BORDER_X * StyleMgrClass::Get_X_Scale ());
  559. rect.Top = int(start_y_pos + (index * entry_height));
  560. rect.Bottom = int(rect.Top + entry_height);
  561. return ;
  562. }
  563. ////////////////////////////////////////////////////////////////
  564. //
  565. // Entry_From_Pos
  566. //
  567. ////////////////////////////////////////////////////////////////
  568. int
  569. ShortcutBarCtrlClass::Entry_From_Pos (const Vector2 &mouse_pos)
  570. {
  571. int retval = -1;
  572. for (int index = 0; index < ShortcutList.Count (); index ++) {
  573. //
  574. // Get the rectangle for this button
  575. //
  576. RectClass text_rect;
  577. Get_Entry_Rect (index, text_rect);
  578. //
  579. // Is this the entry we're looking for?
  580. //
  581. if (text_rect.Contains (mouse_pos)) {
  582. retval = index;
  583. break;
  584. }
  585. }
  586. return retval;
  587. }
  588. ////////////////////////////////////////////////////////////////
  589. //
  590. // Set_Curr_Sel
  591. //
  592. ////////////////////////////////////////////////////////////////
  593. void
  594. ShortcutBarCtrlClass::Set_Curr_Sel (int index, bool snap_mouse)
  595. {
  596. //
  597. // Ensure the new index is in range
  598. //
  599. if (index < 0) {
  600. index = ShortcutList.Count () - 1;
  601. } else if (index >= ShortcutList.Count ()) {
  602. index = 0;
  603. }
  604. //
  605. // Did the selection change?
  606. //
  607. if (index != CurrSel) {
  608. CurrSel = index;
  609. Set_Dirty ();
  610. if (snap_mouse) {
  611. //
  612. // Snap the mouse to the entry
  613. //
  614. RectClass text_rect;
  615. Get_Entry_Rect (CurrSel, text_rect);
  616. Vector3 center (text_rect.Center ().X, text_rect.Center ().Y, 0);
  617. DialogMgrClass::Set_Mouse_Pos (center);
  618. }
  619. }
  620. return ;
  621. }
  622. ////////////////////////////////////////////////////////////////
  623. //
  624. // On_Mouse_Wheel
  625. //
  626. ////////////////////////////////////////////////////////////////
  627. void
  628. ShortcutBarCtrlClass::On_Mouse_Wheel (int direction)
  629. {
  630. if (IsHiddenState == false) {
  631. if (direction > 0) {
  632. Set_Curr_Sel (CurrSel + 1, true);
  633. } else {
  634. Set_Curr_Sel (CurrSel - 1, true);
  635. }
  636. }
  637. return ;
  638. }
  639. ////////////////////////////////////////////////////////////////
  640. //
  641. // Get_Window_Rect
  642. //
  643. ////////////////////////////////////////////////////////////////
  644. const RectClass &
  645. ShortcutBarCtrlClass::Get_Window_Rect (void) const
  646. {
  647. const RectClass *retval = &Rect;
  648. //
  649. // If the bar is completely displayed, then return
  650. // the full rectangle instead of the screen rectangle.
  651. //
  652. if (IsHiddenState == false) {
  653. retval = &FullRect;
  654. }
  655. return (*retval);
  656. }
  657. ////////////////////////////////////////////////////////////////
  658. //
  659. // Send_Command
  660. //
  661. ////////////////////////////////////////////////////////////////
  662. void
  663. ShortcutBarCtrlClass::Send_Command (void)
  664. {
  665. if (CurrSel >= 0 && CurrSel < ShortcutList.Count ()) {
  666. Parent->On_Command (ShortcutList[CurrSel].ctrl_id, BN_CLICKED, 0);
  667. }
  668. return ;
  669. }
  670. ////////////////////////////////////////////////////////////////
  671. //
  672. // Update_Pulse
  673. //
  674. ////////////////////////////////////////////////////////////////
  675. void
  676. ShortcutBarCtrlClass::Update_Pulse (void)
  677. {
  678. if (IsHiddenState == false) {
  679. return ;
  680. }
  681. const float PULSE_RATE = 0.5F;
  682. const float MIN_OPACITY = 0.65F;
  683. const float MAX_OPACITY = 1.00F;
  684. //
  685. // Pulse the bar
  686. //
  687. float delta = PULSE_RATE * (DialogMgrClass::Get_Frame_Time () / 1000.0F);
  688. BarOpacity += PulseDirection * delta;
  689. //
  690. // Clamp the opacity
  691. //
  692. if (BarOpacity <= MIN_OPACITY) {
  693. BarOpacity = MIN_OPACITY;
  694. PulseDirection = 1.0F;
  695. } else if (BarOpacity >= MAX_OPACITY) {
  696. BarOpacity = MAX_OPACITY;
  697. PulseDirection = -1.0F;
  698. }
  699. int bar_color = VRGBA_TO_INT32 (Vector4 (1.0F, 1.0F, 1.0F, BarOpacity));
  700. //
  701. // Update the color vector array
  702. //
  703. DynamicVectorClass<unsigned long> &color_array = TexturedControlRenderer.Get_Color_Array ();
  704. for (int index = 0; index < color_array.Count (); index ++) {
  705. color_array[index] = bar_color;
  706. }
  707. return ;
  708. }
  709. ////////////////////////////////////////////////////////////////
  710. //
  711. // On_Frame_Update
  712. //
  713. ////////////////////////////////////////////////////////////////
  714. void
  715. ShortcutBarCtrlClass::On_Frame_Update (void)
  716. {
  717. Update_Pulse ();
  718. DialogControlClass::On_Frame_Update ();
  719. return ;
  720. }