TAB.CPP 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. /*
  2. ** Command & Conquer Red Alert(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: /CounterStrike/TAB.CPP 1 3/03/97 10:25a 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 : September 20, 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::One_Time -- Performs one time initialization of tab handler class. *
  38. * TabClass::Set_Active -- Activates a "filefolder tab" button. *
  39. * TabClass::TabClass -- Default construct for the tab button class. *
  40. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  41. #include "function.h"
  42. void const * TabClass::TabShape = NULL;
  43. /***********************************************************************************************
  44. * TabClass::TabClass -- Default construct for the tab button class. *
  45. * *
  46. * The default constructor merely sets the tab buttons to default non-selected state. *
  47. * *
  48. * INPUT: none *
  49. * *
  50. * OUTPUT: none *
  51. * *
  52. * WARNINGS: none *
  53. * *
  54. * HISTORY: *
  55. * 12/15/1994 JLB : Created. *
  56. *=============================================================================================*/
  57. TabClass::TabClass(void) :
  58. FlasherTimer(0),
  59. IsToRedraw(false),
  60. MoneyFlashTimer(0)
  61. {
  62. }
  63. /***********************************************************************************************
  64. * TabClass::Draw_It -- Displays the tab buttons as necessary. *
  65. * *
  66. * This routine is called whenever the display is being redrawn (in some fashion). The *
  67. * parameter can be used to force the tab buttons to redraw completely. The default action *
  68. * is to only redraw if the tab buttons have been explicitly flagged to be redraw. The *
  69. * result of this is the elimination of unnecessary redraws. *
  70. * *
  71. * INPUT: complete -- bool; Force redraw of the entire tab button graphics? *
  72. * *
  73. * OUTPUT: none *
  74. * *
  75. * WARNINGS: none *
  76. * *
  77. * HISTORY: *
  78. * 12/15/1994 JLB : Created. *
  79. * 05/19/1995 JLB : New EVA style. *
  80. *=============================================================================================*/
  81. #define EVA_WIDTH 80
  82. #define TAB_HEIGHT 8
  83. void TabClass::Draw_It(bool complete)
  84. {
  85. SidebarClass::Draw_It(complete);
  86. if (Debug_Map) {
  87. return;
  88. }
  89. /*
  90. ** Redraw the top bar imagery if flagged to do so or if the entire display needs
  91. ** to be redrawn.
  92. */
  93. if ((complete || IsToRedraw) && LogicPage->Lock()) {
  94. int width = SeenBuff.Get_Width();
  95. int rightx = width - 1;
  96. int tab_height = TAB_HEIGHT * RESFACTOR;
  97. LogicPage->Fill_Rect(0, 0, rightx, tab_height-1, BLACK);
  98. // LogicPage->Fill_Rect(0, 0, rightx, tab_height-(2 * RESFACTOR), BLACK);
  99. #ifdef WIN32
  100. /*
  101. ** Use the new sidebar art for 640x400
  102. */
  103. CC_Draw_Shape(TabShape, 0, 0, 0, WINDOW_MAIN, SHAPE_NORMAL);
  104. #else
  105. CC_Draw_Shape(TabShape, 2, 0, 0, WINDOW_MAIN, SHAPE_NORMAL);
  106. #endif
  107. Draw_Credits_Tab();
  108. LogicPage->Draw_Line(0, tab_height-(1* RESFACTOR), rightx, tab_height-(1 * RESFACTOR), BLACK);
  109. #ifdef WIN32
  110. Fancy_Text_Print(TXT_TAB_BUTTON_CONTROLS, (EVA_WIDTH/2) * RESFACTOR, 0, &MetalScheme, TBLACK, TPF_METAL12 | TPF_CENTER | TPF_USE_GRAD_PAL);
  111. #else
  112. // Fancy_Text_Print(TXT_TAB_BUTTON_CONTROLS, (EVA_WIDTH/2) * RESFACTOR, 0, &ColorRemaps[PCOLOR_GREY], TBLACK, TPF_6PT_GRAD|TPF_NOSHADOW|TPF_CENTER|TPF_BRIGHT_COLOR);
  113. Fancy_Text_Print(TXT_TAB_BUTTON_CONTROLS, (EVA_WIDTH/2) * RESFACTOR, 0, &ColorRemaps[PCOLOR_GREY], TBLACK, TPF_METAL12|TPF_NOSHADOW|TPF_CENTER|TPF_BRIGHT_COLOR);
  114. #endif //WIN32
  115. if (IsSidebarActive) {
  116. #ifndef WIN32
  117. TabClass::Hilite_Tab(1);
  118. #endif //WIN32
  119. } else {
  120. CC_Draw_Shape(TabShape, 0, width-(EVA_WIDTH * RESFACTOR), 0, WINDOW_MAIN, SHAPE_NORMAL);
  121. Fancy_Text_Print(TXT_TAB_SIDEBAR, width-((EVA_WIDTH/2) * RESFACTOR), 0, &ColorRemaps[PCOLOR_GREY], TBLACK, TPF_METAL12|TPF_NOSHADOW|TPF_CENTER|TPF_BRIGHT_COLOR);
  122. }
  123. LogicPage->Unlock();
  124. }
  125. Credits.Graphic_Logic(complete || IsToRedraw);
  126. IsToRedraw = false;
  127. }
  128. void TabClass::Draw_Credits_Tab(void)
  129. {
  130. #ifdef WIN32
  131. /*
  132. ** Use the new sidebar art for 640x400
  133. */
  134. CC_Draw_Shape(TabShape, Map.MoneyFlashTimer > 1 ? 8 : 6, (320-EVA_WIDTH) * RESFACTOR, 0, WINDOW_MAIN, SHAPE_NORMAL);
  135. #else
  136. CC_Draw_Shape(TabShape, 4, (320-(EVA_WIDTH*2)) * RESFACTOR, 0, WINDOW_MAIN, SHAPE_NORMAL);
  137. #endif
  138. if (Scen.MissionTimer.Is_Active()) {
  139. bool light = (Scen.MissionTimer < TICKS_PER_MINUTE * Rule.TimerWarning) || Map.FlasherTimer > 0;
  140. #ifdef WIN32
  141. CC_Draw_Shape(TabShape, light ? 4 : 2, 320, 0, WINDOW_MAIN, SHAPE_NORMAL);
  142. #else
  143. CC_Draw_Shape(TabShape, light ? 6 : 5, EVA_WIDTH * RESFACTOR, 0, WINDOW_MAIN, SHAPE_NORMAL);
  144. #endif
  145. }
  146. }
  147. void TabClass::Hilite_Tab(int tab)
  148. {
  149. int xpos = 0;
  150. int text = TXT_TAB_BUTTON_CONTROLS;
  151. int textx = (EVA_WIDTH/2) * RESFACTOR;
  152. if (tab) {
  153. xpos = (320-EVA_WIDTH) * RESFACTOR;
  154. text = TXT_TAB_SIDEBAR;
  155. textx = (320-(EVA_WIDTH/2)) * RESFACTOR;
  156. }
  157. #ifdef WIN32
  158. /*
  159. ** Use the new sidebar art for 640x400
  160. */
  161. CC_Draw_Shape(TabShape, 1, xpos, 0, WINDOW_MAIN, SHAPE_NORMAL);
  162. MetalScheme.Color = 128+6;
  163. Fancy_Text_Print(TXT_TAB_BUTTON_CONTROLS, (EVA_WIDTH/2) * RESFACTOR, 0, &MetalScheme, TBLACK, TPF_METAL12 | TPF_CENTER | TPF_USE_GRAD_PAL);
  164. MetalScheme.Color = 128;
  165. #else
  166. CC_Draw_Shape(TabShape, 1 + (tab ? 0 : 2), xpos, 0, WINDOW_MAIN, SHAPE_NORMAL);
  167. Fancy_Text_Print(text, textx, 0, &ColorRemaps[PCOLOR_GREY], TBLACK, TPF_METAL12|TPF_NOSHADOW|TPF_CENTER|TPF_BRIGHT_COLOR);
  168. // Fancy_Text_Print(text, textx, 0, &ColorRemaps[PCOLOR_GREY], TBLACK, TPF_6PT_GRAD|TPF_NOSHADOW|TPF_CENTER|TPF_BRIGHT_COLOR);
  169. #endif
  170. }
  171. /***********************************************************************************************
  172. * TabClass::AI -- Handles player I/O with the tab buttons. *
  173. * *
  174. * This routine is called every game tick and passed whatever key the player has supplied. *
  175. * If the input selects a tab button, then the graphic gets updated accordingly. *
  176. * *
  177. * INPUT: input -- The player's input character (might be mouse click). *
  178. * *
  179. * x,y -- Mouse coordinates at time of input. *
  180. * *
  181. * OUTPUT: none *
  182. * *
  183. * WARNINGS: none *
  184. * *
  185. * HISTORY: *
  186. * 12/15/1994 JLB : Created. *
  187. * 12/31/1994 JLB : Uses mouse coordinate parameters. *
  188. * 05/31/1995 JLB : Fixed to handle mouse shape properly. *
  189. * 08/25/1995 JLB : Handles new scrolling option. *
  190. *=============================================================================================*/
  191. void TabClass::AI(KeyNumType &input, int x, int y)
  192. {
  193. if (y >= 0 && y < (TAB_HEIGHT * RESFACTOR) && x < (SeenBuff.Get_Width() - 1) && x > 0) {
  194. bool ok = false;
  195. int width = SeenBuff.Get_Width();
  196. /*
  197. ** If the mouse is at the top of the screen, then the tab bars only work
  198. ** in certain areas. If the special scroll modification is not active, then
  199. ** the tabs never work when the mouse is at the top of the screen.
  200. */
  201. if (y > 0) {
  202. ok = true;
  203. }
  204. if (ok) {
  205. if (input == KN_LMOUSE) {
  206. int sel = -1;
  207. if (x < EVA_WIDTH * RESFACTOR) sel = 0;
  208. #ifndef WIN32 // No Sidebar tab in hires - sidebar is always active.
  209. if (x > (320-80) * RESFACTOR) sel = 1;
  210. #endif //WIN32
  211. if (sel >= 0) {
  212. Set_Active(sel);
  213. input = KN_NONE;
  214. }
  215. }
  216. Override_Mouse_Shape(MOUSE_NORMAL, false);
  217. }
  218. }
  219. if (MoneyFlashTimer == 1) {
  220. IsToRedraw = true;
  221. Flag_To_Redraw(false);
  222. }
  223. Credits.AI();
  224. SidebarClass::AI(input, x, y);
  225. }
  226. /***********************************************************************************************
  227. * TabClass::Set_Active -- Activates a "filefolder tab" button. *
  228. * *
  229. * This function is used to activate one of the file folder tab buttons that appear at the *
  230. * top edge of the screen. *
  231. * *
  232. * INPUT: select -- The button to activate. 0 = left button, 1=next button, etc. *
  233. * *
  234. * OUTPUT: none *
  235. * *
  236. * WARNINGS: none *
  237. * *
  238. * HISTORY: *
  239. * 12/15/1994 JLB : Created. *
  240. *=============================================================================================*/
  241. void TabClass::Set_Active(int select)
  242. {
  243. switch (select) {
  244. case 0:
  245. Queue_Options();
  246. break;
  247. case 1:
  248. Map.SidebarClass::Activate(-1);
  249. break;
  250. default:
  251. break;
  252. }
  253. }
  254. /***********************************************************************************************
  255. * TabClass::One_Time -- Performs one time initialization of tab handler class. *
  256. * *
  257. * This routine will perform any one time initializations of the tab handler class. This *
  258. * typically includes the loading of the shapes that appear on it. *
  259. * *
  260. * INPUT: none *
  261. * *
  262. * OUTPUT: none *
  263. * *
  264. * WARNINGS: none *
  265. * *
  266. * HISTORY: *
  267. * 09/20/1995 JLB : Created. *
  268. *=============================================================================================*/
  269. void TabClass::One_Time(void)
  270. {
  271. SidebarClass::One_Time();
  272. RawFileClass file("tabs.shp");
  273. TabShape = MFCD::Retrieve("TABS.SHP");
  274. }
  275. void TabClass::Flash_Money(void)
  276. {
  277. IsToRedraw = true;
  278. Flag_To_Redraw(false);
  279. MoneyFlashTimer = 7;
  280. }