RADAR.H 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /* $Header: /CounterStrike/RADAR.H 1 3/03/97 10:25a Joe_bostic $ */
  15. /***********************************************************************************************
  16. *** 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 ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : RADAR.H *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : 12/15/94 *
  26. * *
  27. * Last Update : December 15, 1994 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  32. #ifndef RADAR_H
  33. #define RADAR_H
  34. #include "display.h"
  35. class RadarClass: public DisplayClass
  36. {
  37. public:
  38. RadarClass(void);
  39. RadarClass(NoInitClass const & x) : DisplayClass(x) {};
  40. /*
  41. ** The dimensions and coordinates of the radar map.
  42. */
  43. int RadX;
  44. int RadOffX;
  45. int RadY;
  46. int RadOffY;
  47. int RadWidth;
  48. int RadHeight;
  49. int RadIWidth;
  50. int RadIHeight;
  51. int RadPWidth;
  52. int RadPHeight;
  53. /*
  54. ** Initialization
  55. */
  56. virtual void One_Time(void); // One-time inits
  57. virtual void Init_Clear(void); // Clears all to known state
  58. virtual void Flag_Cell(CELL cell);
  59. virtual bool Map_Cell(CELL cell, HouseClass *house, bool check_radar_spied = true, bool and_for_allies = true); // Added check_radar_spied parameter to prevent recursion. ST - 8/6/2019 10:16AM. Added and_for_allies ST - 10/31/2019 1:18PM
  60. virtual bool Jam_Cell(CELL cell, HouseClass * house);
  61. virtual bool UnJam_Cell(CELL cell, HouseClass * house);
  62. virtual CELL Click_Cell_Calc(int x, int y) const;
  63. virtual void AI(KeyNumType &input, int x, int y);
  64. virtual void Draw_It(bool complete=false);
  65. virtual void Refresh_Cells(CELL cell, short const *list);
  66. virtual void Set_Map_Dimensions(int x, int y, int w, int h);
  67. virtual void Set_Tactical_Position(COORDINATE coord);
  68. void Zoom_Mode(CELL cell);
  69. int Click_In_Radar(int &x, int &y, bool change=false) const;
  70. void Cell_XY_To_Radar_Pixel(int cellx, int celly, int &x, int &y);
  71. bool Is_Zoomable(void) const;
  72. void Set_Radar_Position(CELL cell);
  73. CELL Radar_Position(void);
  74. bool Radar_Activate(int control);
  75. void Plot_Radar_Pixel(CELL cell);
  76. void Radar_Pixel(CELL cell);
  77. void Coord_To_Radar_Pixel(COORDINATE coord, int &x, int &y);
  78. void Cursor_Cell(CELL cell, int value);
  79. void RadarClass::Mark_Radar(int x1, int y1, int x2, int y2, int value, int barlen);
  80. void Radar_Cursor(int forced = false);
  81. void Render_Terrain(CELL cell, int x, int y, int size);
  82. bool Cell_On_Radar(CELL cell);
  83. void Render_Infantry(CELL cell, int x, int y, int size);
  84. void Render_Overlay(CELL cell, int x, int y, int size);
  85. void Radar_Anim(void);
  86. bool Is_Radar_Active(void);
  87. bool Is_Radar_Activating(void);
  88. bool Is_Radar_Existing(void);
  89. /*
  90. ** Toggles player names on & off
  91. */
  92. void Player_Names(bool on);
  93. int Is_Player_Names(void) {return IsPlayerNames;}
  94. bool Spying_On_House(void) {return IsHouseSpy;}
  95. void Draw_Names(void);
  96. bool Draw_House_Info(void);
  97. int Is_Zoomed(void) {return IsZoomed;}
  98. bool Get_Jammed(HousesType house) const;
  99. bool Get_Jammed(HouseClass *player) const;
  100. void Set_Jammed(HousesType house, bool jam);
  101. void Set_Jammed(HouseClass *player, bool jam);
  102. bool Spy_Next_House(void);
  103. void Activate_Pulse(void);
  104. protected:
  105. /*
  106. ** Radar map constant values.
  107. */
  108. enum RadarClassEnums {
  109. RADAR_ACTIVATED_FRAME=22,
  110. MAX_RADAR_FRAMES = 41
  111. };
  112. /*
  113. ** If the radar map must be completely redrawn, then this flag will be true.
  114. ** Typical causes of this would be when the radar first appears, or when the
  115. ** screen has been damaged.
  116. */
  117. unsigned IsToRedraw:1;
  118. unsigned RadarCursorRedraw:1;
  119. /*
  120. ** If the radar map is visible then this flag is true.
  121. */
  122. unsigned DoesRadarExist:1;
  123. unsigned IsRadarActive:1;
  124. unsigned IsRadarActivating:1;
  125. unsigned IsRadarDeactivating:1;
  126. /*
  127. ** Per-player radar jammed flag.
  128. */
  129. unsigned int IsRadarJammedByPlayerMask;
  130. /*
  131. ** Flag to tell whether sonar pulse should be displayed on radar map
  132. */
  133. unsigned IsPulseActive:1;
  134. int RadarPulseFrame;
  135. /*
  136. ** Special radar frame is set when a new location is selected on the
  137. ** radar map. It counts down through the special radar cursors until
  138. ** either the radar cursor becomes normal or the radar cursor is moved
  139. ** again.
  140. */
  141. int SpecialRadarFrame;
  142. int RadarAnimFrame;
  143. static void const * RadarAnim;
  144. static void const * RadarPulse;
  145. static void const * RadarFrame;
  146. /*
  147. ** This gadget class is used for capturing input to the tactical map. All mouse input
  148. ** will be routed through this gadget.
  149. */
  150. class RTacticalClass : public GadgetClass {
  151. public:
  152. RTacticalClass(void) : GadgetClass(0,0,0,0,LEFTPRESS|LEFTRELEASE|LEFTHELD|LEFTUP|RIGHTPRESS,true) {};
  153. protected:
  154. virtual int Action(unsigned flags, KeyNumType & key);
  155. friend class RadarClass;
  156. };
  157. friend class RTacticalClass;
  158. /*
  159. ** This is the "button" that tracks all input to the tactical map.
  160. ** It must be available to derived classes, for Save/Load purposes.
  161. */
  162. static RTacticalClass RadarButton;
  163. private:
  164. /*
  165. ** The current radar position as the upper left corner cell for the
  166. ** radar map display. The width and height is controlled by the
  167. ** actual dimensions of the radar map display box (in pixels).
  168. */
  169. unsigned RadarX;
  170. unsigned RadarY;
  171. unsigned RadarCellWidth;
  172. unsigned RadarCellHeight;
  173. unsigned RadarCell;
  174. /*
  175. ** This is the origin (pixel offsets) for the upper left corner
  176. ** of the radar map within the full radar map area of the screen.
  177. ** This is biased so that the radar map, when smaller than full
  178. ** size will appear centered.
  179. */
  180. unsigned BaseX;
  181. unsigned BaseY;
  182. unsigned RadarWidth;
  183. unsigned RadarHeight;
  184. /*
  185. ** If the radar map is in zoom mode, then this value will be true.
  186. */
  187. unsigned IsZoomed:1;
  188. /*
  189. ** This flag is true if the radar map is in its special show-the-player
  190. ** names mode.
  191. */
  192. unsigned IsPlayerNames:1;
  193. /*
  194. ** This flag is true if the radar map is in its special show-the-units
  195. ** of-another-house mode.
  196. */
  197. unsigned IsHouseSpy:1;
  198. /*
  199. ** This is the zoom factor to use. This value is the number of pixels wide
  200. ** each cell will occupy on the radar map. Completely zoomed out would be a
  201. ** value of 1.
  202. */
  203. int ZoomFactor;
  204. /*
  205. ** If we're spying on a house's radar facility, this field shows the
  206. ** name of the house we're spying on.
  207. */
  208. HousesType SpyingOn;
  209. /*
  210. ** This is the list of radar pixels that need to be updated. Only a partial
  211. ** list is maintained for maximum speed.
  212. */
  213. unsigned PixelPtr;
  214. enum PixelStackEnums {PIXELSTACK=400};
  215. CELL PixelStack[PIXELSTACK];
  216. };
  217. #endif