TAB.CPP 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /*
  2. ** Command & Conquer(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. /* $Header: F:\projects\c&c\vcs\code\tab.cpv 2.18 16 Oct 1995 16:52:04 JOE_BOSTIC $ */
  19. /***********************************************************************************************
  20. *** 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 ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Command & Conquer *
  24. * *
  25. * File Name : TAB.CPP *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : 12/15/94 *
  30. * *
  31. * Last Update : August 25, 1995 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * TabClass::AI -- Handles player I/O with the tab buttons. *
  36. * TabClass::Draw_It -- Displays the tab buttons as necessary. *
  37. * TabClass::Set_Active -- Activates a "filefolder tab" button. *
  38. * TabClass::TabClass -- Default construct for the tab button class. *
  39. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  40. #include "function.h"
  41. void const * TabClass::TabShape = NULL;
  42. /***********************************************************************************************
  43. * TabClass::TabClass -- Default construct for the tab button class. *
  44. * *
  45. * The default constructor merely sets the tab buttons to default non-selected state. *
  46. * *
  47. * INPUT: none *
  48. * *
  49. * OUTPUT: none *
  50. * *
  51. * WARNINGS: none *
  52. * *
  53. * HISTORY: *
  54. * 12/15/1994 JLB : Created. *
  55. *=============================================================================================*/
  56. TabClass::TabClass(void)
  57. {
  58. IsToRedraw = false;
  59. // Select = -1;
  60. }
  61. /***********************************************************************************************
  62. * TabClass::Draw_It -- Displays the tab buttons as necessary. *
  63. * *
  64. * This routine is called whenever the display is being redrawn (in some fashion). The *
  65. * parameter can be used to force the tab buttons to redraw completely. The default action *
  66. * is to only redraw if the tab buttons have been explicitly flagged to be redraw. The *
  67. * result of this is the elimination of unnecessary redraws. *
  68. * *
  69. * INPUT: complete -- bool; Force redraw of the entire tab button graphics? *
  70. * *
  71. * OUTPUT: none *
  72. * *
  73. * WARNINGS: none *
  74. * *
  75. * HISTORY: *
  76. * 12/15/1994 JLB : Created. *
  77. * 05/19/1995 JLB : New EVA style. *
  78. *=============================================================================================*/
  79. void TabClass::Draw_It(bool complete)
  80. {
  81. SidebarClass::Draw_It(complete);
  82. if (Debug_Map){
  83. //HidPage.Unlock();
  84. return;
  85. }
  86. /*
  87. ** Redraw the top bar imagery if flagged to do so or if the entire display needs
  88. ** to be redrawn.
  89. */
  90. int width = SeenBuff.Get_Width();
  91. int rightx = width - 1;
  92. if (complete || IsToRedraw) {
  93. if (LogicPage->Lock()){
  94. LogicPage->Fill_Rect(0, 0, rightx, Tab_Height-2, BLACK);
  95. CC_Draw_Shape(TabShape, 0, 0, 0, WINDOW_MAIN, SHAPE_NORMAL);
  96. CC_Draw_Shape(TabShape, 0, width-Eva_Width, 0, WINDOW_MAIN, SHAPE_NORMAL);
  97. Draw_Credits_Tab();
  98. LogicPage->Draw_Line(0, Tab_Height-1, rightx, Tab_Height-1, BLACK);
  99. Fancy_Text_Print(TXT_TAB_BUTTON_CONTROLS, Eva_Width/2, 0, 11, TBLACK, TPF_GREEN12_GRAD|TPF_CENTER | TPF_USE_GRAD_PAL);
  100. Fancy_Text_Print(TXT_TAB_SIDEBAR, width-(Eva_Width/2), 0, 11, TBLACK, TPF_GREEN12_GRAD|TPF_CENTER | TPF_USE_GRAD_PAL);
  101. }
  102. LogicPage->Unlock();
  103. }
  104. Credits.Graphic_Logic(complete || IsToRedraw);
  105. IsToRedraw = false;
  106. }
  107. void TabClass::Draw_Credits_Tab(void)
  108. {
  109. CC_Draw_Shape(TabShape, 0, 320, 0, WINDOW_MAIN, SHAPE_NORMAL);
  110. }
  111. /***********************************************************************************************
  112. * TC::Hilite_Tab -- Draw a tab in its depressed state *
  113. * *
  114. * *
  115. * *
  116. * INPUT: Tab to draw (not used) *
  117. * *
  118. * OUTPUT: Nothing *
  119. * *
  120. * WARNINGS: None *
  121. * *
  122. * HISTORY: *
  123. * 5/21/96 10:47AM ST : Created *
  124. *=============================================================================================*/
  125. void TabClass::Hilite_Tab(int tab)
  126. {
  127. int xpos = 0;
  128. int text = TXT_TAB_BUTTON_CONTROLS;
  129. tab = tab;
  130. CC_Draw_Shape(TabShape, 1 , xpos, 0, WINDOW_MAIN, SHAPE_NORMAL);
  131. Fancy_Text_Print(TXT_TAB_BUTTON_CONTROLS, 80, 0, 11, TBLACK, TPF_GREEN12|TPF_CENTER | TPF_USE_GRAD_PAL);
  132. }
  133. /***********************************************************************************************
  134. * TabClass::AI -- Handles player I/O with the tab buttons. *
  135. * *
  136. * This routine is called every game tick and passed whatever key the player has supplied. *
  137. * If the input selects a tab button, then the graphic gets updated accordingly. *
  138. * *
  139. * INPUT: input -- The player's input character (might be mouse click). *
  140. * *
  141. * x,y -- Mouse coordinates at time of input. *
  142. * *
  143. * OUTPUT: none *
  144. * *
  145. * WARNINGS: none *
  146. * *
  147. * HISTORY: *
  148. * 12/15/1994 JLB : Created. *
  149. * 12/31/1994 JLB : Uses mouse coordinate parameters. *
  150. * 05/31/1995 JLB : Fixed to handle mouse shape properly. *
  151. * 08/25/1995 JLB : Handles new scrolling option. *
  152. *=============================================================================================*/
  153. void TabClass::AI(KeyNumType &input, int x, int y)
  154. {
  155. if (y >= 0 && y < Tab_Height && x < (SeenBuff.Get_Width() - 1) && x > 0) {
  156. bool ok = false;
  157. int width = SeenBuff.Get_Width();
  158. /*
  159. ** If the mouse is at the top of the screen, then the tab bars only work
  160. ** in certain areas. If the special scroll modification is not active, then
  161. ** the tabs never work when the mouse is at the top of the screen.
  162. */
  163. if (y > 0 || (Special.IsScrollMod && ((x > 3 && x < Eva_Width) || (x < width-3 && x > width-Eva_Width)))) {
  164. ok = true;
  165. }
  166. if (ok) {
  167. if (input == KN_LMOUSE) {
  168. int sel = -1;
  169. if (x < Eva_Width) sel = 0;
  170. if (x > width-Eva_Width) sel = 1;
  171. if (sel >= 0) {
  172. Set_Active(sel);
  173. input = KN_NONE;
  174. }
  175. }
  176. Override_Mouse_Shape(MOUSE_NORMAL, false);
  177. }
  178. }
  179. Credits.AI();
  180. SidebarClass::AI(input, x, y);
  181. }
  182. /***********************************************************************************************
  183. * TabClass::Set_Active -- Activates a "filefolder tab" button. *
  184. * *
  185. * This function is used to activate one of the file folder tab buttons that appear at the *
  186. * top edge of the screen. *
  187. * *
  188. * INPUT: select -- The button to activate. 0 = left button, 1=next button, etc. *
  189. * *
  190. * OUTPUT: none *
  191. * *
  192. * WARNINGS: none *
  193. * *
  194. * HISTORY: *
  195. * 12/15/1994 JLB : Created. *
  196. *=============================================================================================*/
  197. void TabClass::Set_Active(int select)
  198. {
  199. switch (select) {
  200. case 0:
  201. Queue_Options();
  202. break;
  203. case 1:
  204. Map.SidebarClass::Activate(-1);
  205. break;
  206. default:
  207. break;
  208. }
  209. }
  210. void TabClass::One_Time(void)
  211. {
  212. int factor = (SeenBuff.Get_Width() == 320) ? 1 : 2;
  213. Eva_Width = 80 * factor;
  214. Tab_Height = 8 * factor;
  215. SidebarClass::One_Time();
  216. TabShape = Hires_Retrieve("TABS.SHP");
  217. }