DISPLAY.H (13389B)
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 9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 10 // in the hope that it will be useful, but with permitted additional restrictions 11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 12 // distributed with this program. You should have received a copy of the 13 // GNU General Public License along with permitted additional restrictions 14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection 15 16 /* $Header: /CounterStrike/DISPLAY.H 1 3/03/97 10:24a Joe_bostic $ */ 17 /*********************************************************************************************** 18 *** 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 *** 19 *********************************************************************************************** 20 * * 21 * Project Name : Command & Conquer * 22 * * 23 * File Name : DISPLAY.H * 24 * * 25 * Programmer : Joe L. Bostic * 26 * * 27 * Start Date : May 1, 1994 * 28 * * 29 * Last Update : May 1, 1994 [JLB] * 30 * * 31 *---------------------------------------------------------------------------------------------* 32 * Functions: * 33 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 34 35 #ifndef DISPLAY_H 36 #define DISPLAY_H 37 38 #include "map.h" 39 #include "layer.h" 40 41 42 #define ICON_PIXEL_W 24 43 #define ICON_PIXEL_H 24 44 #define ICON_LEPTON_W 256 45 #define ICON_LEPTON_H 256 46 #define CELL_PIXEL_W ICON_PIXEL_W 47 #define CELL_PIXEL_H ICON_PIXEL_H 48 #define CELL_LEPTON_W ICON_LEPTON_W 49 #define CELL_LEPTON_H ICON_LEPTON_H 50 51 // ----------------------------------------------------------- 52 #define PIXEL_LEPTON_W (ICON_LEPTON_W/ICON_PIXEL_W) 53 #define PIXEL_LEPTON_H (ICON_LEPTON_H/ICON_PIXEL_H) 54 55 #define SIDE_BAR_TAC_WIDTH 10 56 #define SIDE_BAR_TAC_HEIGHT 8 57 58 extern COORDINATE Coord_Add(COORDINATE coord1, COORDINATE coord2); 59 60 class DisplayClass: public MapClass 61 { 62 public: 63 friend class DLLExportClass; // ST - 5/13/2019 64 65 /* 66 ** The tactical map display position is indicated by the cell of the 67 ** upper left hand corner. These should not be altered directly. Use 68 ** the Set_Tactical_Position function instead. 69 */ 70 COORDINATE TacticalCoord; 71 72 /* 73 ** The dimensions (in cells) of the visible window onto the game map. This tactical 74 ** map is how the player interacts and views the game world. 75 */ 76 LEPTON TacLeptonWidth; 77 LEPTON TacLeptonHeight; 78 79 /* 80 ** These layer control elements are used to group the displayable objects 81 ** so that proper overlap can be obtained. 82 */ 83 static LayerClass Layer[LAYER_COUNT]; 84 85 /* 86 ** This records the position and shape of a placement cursor to display 87 ** over the map. This cursor is used when placing buildings and also used 88 ** extensively by the scenario editor. 89 */ 90 CELL ZoneCell; 91 short ZoneOffset; 92 short const *CursorSize; 93 short CursorShapeSave[256]; // For save/load 94 bool ProximityCheck; // Is proximity check ok? 95 96 /* 97 ** This holds the building type that is about to be placed upon the map. 98 ** It is only valid during the building placement state. The PendingLegal 99 ** flag is updated as the cursor moves and it reflects the legality of 100 ** placing the building at the desired location. 101 */ 102 ObjectClass * PendingObjectPtr; 103 ObjectTypeClass const * PendingObject; 104 HousesType PendingHouse; 105 106 static unsigned char FadingBrighten[256]; 107 static unsigned char FadingShade[256]; 108 static unsigned char FadingWayDark[256]; 109 static unsigned char FadingLight[256]; 110 static unsigned char FadingGreen[256]; 111 static unsigned char FadingYellow[256]; 112 static unsigned char FadingRed[256]; 113 static unsigned char TranslucentTable[(MAGIC_COL_COUNT+1)*256]; 114 static unsigned char WhiteTranslucentTable[(1+1)*256]; 115 static unsigned char MouseTranslucentTable[(4+1)*256]; 116 static void const *TransIconset; 117 static unsigned char UnitShadow[(USHADOW_COL_COUNT+1)*256]; 118 static unsigned char UnitShadowAir[(USHADOW_COL_COUNT+1)*256]; 119 static unsigned char SpecialGhost[2*256]; 120 121 //------------------------------------------------------------------------- 122 DisplayClass(void); 123 DisplayClass(NoInitClass const & x) : MapClass(x) {}; 124 125 virtual void Read_INI(CCINIClass & ini); 126 void Write_INI(CCINIClass & ini); 127 128 /* 129 ** Initialization 130 */ 131 virtual void One_Time(void); // One-time inits 132 virtual void Init_Clear(void); // Clears all to known state 133 virtual void Init_IO(void); // Inits button list 134 virtual void Init_Theater(TheaterType theater); // Theater-specific inits 135 136 /* 137 ** General display/map/interface support functionality. 138 */ 139 virtual void AI(KeyNumType &input, int x, int y); 140 virtual void Draw_It(bool complete=false); 141 142 /* 143 ** Added functionality. 144 */ 145 void All_To_Look(HouseClass *house, bool units_only=false); // Added house parameter so it can work for multiple players. ST - 8/6/2019 2:30PM 146 void Constrained_Look(COORDINATE coord, LEPTON distance, HouseClass *house); // Added house parameter for client/server multiplayer. ST - 8/12/2019 3:25PM 147 void Shroud_Cell(CELL cell, HouseClass *house); 148 void Encroach_Shadow(HouseClass *house); 149 COORDINATE Center_Map(COORDINATE center=0L); 150 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 151 virtual CELL Click_Cell_Calc(int x, int y) const; 152 virtual void Help_Text(int , int =-1, int =-1, int =YELLOW, bool =false) {}; 153 virtual MouseType Get_Mouse_Shape(void) const = 0; 154 virtual bool Scroll_Map(DirType facing, int & distance, bool really); 155 virtual void Refresh_Cells(CELL cell, short const *list); 156 virtual void Set_View_Dimensions(int x, int y, int width=-1, int height=-1); 157 158 /* 159 ** Pending object placement control. 160 */ 161 virtual void Put_Place_Back(TechnoClass * ) {}; // Affects 'pending' system. 162 void Cursor_Mark(CELL pos, bool on); 163 void Set_Cursor_Shape(short const * list); 164 CELL Set_Cursor_Pos(CELL pos = -1); 165 void Get_Occupy_Dimensions(int & w, int & h, short const *list) const; 166 167 /* 168 ** Tactical map only functionality. 169 */ 170 virtual void Set_Tactical_Position(COORDINATE coord); 171 void Refresh_Band(void); 172 void Select_These(COORDINATE coord1, COORDINATE coord2, bool additive = false); 173 COORDINATE Pixel_To_Coord(int x, int y) const; 174 bool Coord_To_Pixel(COORDINATE coord, int & x, int & y) const; 175 bool Push_Onto_TacMap(COORDINATE &source, COORDINATE &dest); 176 void Remove(ObjectClass const * object, LayerType layer); 177 void Submit(ObjectClass const * object, LayerType layer); 178 CELL Calculated_Cell(SourceType dir, WAYPOINT waypoint=-1, CELL cell=-1, SpeedType loco=SPEED_FOOT, bool zonecheck=true, MZoneType mzone=MZONE_NORMAL) const; 179 bool In_View(register CELL cell) const; 180 bool Passes_Proximity_Check(ObjectTypeClass const * object, HousesType house, short const * list, CELL trycell) const; 181 ObjectClass * Cell_Object(CELL cell, int x=0, int y=0) const; 182 ObjectClass * Next_Object(ObjectClass * object) const; 183 ObjectClass * Prev_Object(ObjectClass * object) const; 184 int Cell_Shadow(CELL cell, HouseClass *house) const; 185 short const * Text_Overlap_List(char const * text, int x, int y) const; 186 bool Is_Spot_Free(COORDINATE coord) const; 187 COORDINATE Closest_Free_Spot(COORDINATE coord, bool any=false) const; 188 void Sell_Mode_Control(int control); 189 void Repair_Mode_Control(int control); 190 191 virtual void Flag_Cell(CELL cell); 192 bool Is_Cell_Flagged(CELL cell) const {return CellRedraw.Is_True(cell);}; 193 194 /* 195 ** Computes starting position based on player's units' Coords. 196 */ 197 void Compute_Start_Pos(long& x, long& y); 198 199 /* 200 ** File I/O. 201 */ 202 virtual void Code_Pointers(void); 203 virtual void Decode_Pointers(void); 204 205 protected: 206 virtual void Mouse_Right_Press(void); 207 virtual void Mouse_Left_Press(int x, int y); 208 virtual void Mouse_Left_Up(CELL cell, bool shadow, ObjectClass * object, ActionType action, bool wsmall = false); 209 virtual void Mouse_Left_Held(int x, int y); 210 virtual void Mouse_Left_Release(CELL cell, int x, int y, ObjectClass * object, ActionType action, bool wsmall = false); 211 212 public: 213 /* 214 ** This is the pixel offset for the upper left corner of the tactical map. 215 */ 216 int TacPixelX; 217 int TacPixelY; 218 219 /* 220 ** This is the coordinate that the tactical map should be in at next available opportunity. 221 */ 222 COORDINATE DesiredTacticalCoord; 223 224 /* 225 ** If something in the tactical map is to be redrawn, this flag is set to true. 226 */ 227 unsigned IsToRedraw:1; 228 229 /* 230 ** If the player is currently wielding a wrench (to select buildings for repair), 231 ** then this flag is true. In such a state, normal movement and combat orders 232 ** are preempted. 233 */ 234 unsigned IsRepairMode:1; 235 236 /* 237 ** If the player is currently in "sell back" mode, then this flag will be 238 ** true. While in this mode, anything clicked on will be sold back to the 239 ** "factory". 240 */ 241 unsigned IsSellMode:1; 242 243 /* 244 ** If the player is currently in ion cannon targeting mode, then this 245 ** flag will be true. While in this mode, anything clicked on will be 246 ** be destroyed by the ION cannon. 247 */ 248 SpecialWeaponType IsTargettingMode; 249 250 protected: 251 252 /* 253 ** If it is currently in rubber band mode (multi unit selection), then this 254 ** flag will be true. While in such a mode, normal input is preempted while 255 ** the extended selection is in progress. 256 */ 257 unsigned IsRubberBand:1; 258 259 /* 260 ** The moment the mouse is held down, this flag gets set. If the mouse is dragged 261 ** a sufficient distance while held down, then true rubber band mode selection 262 ** can begin. Using a minimum distance prevents accidental rubber band selection 263 ** mode from being initiated. 264 */ 265 unsigned IsTentative:1; 266 267 /* 268 ** This gadget class is used for capturing input to the tactical map. All mouse input 269 ** will be routed through this gadget. 270 */ 271 class TacticalClass : public GadgetClass { 272 public: 273 TacticalClass(void) : GadgetClass(0,0,0,0,LEFTPRESS|LEFTRELEASE|LEFTHELD|LEFTUP|RIGHTPRESS,true) {}; 274 275 int Selection_At_Mouse(unsigned flags, KeyNumType & key); 276 int Command_Object(unsigned flags, KeyNumType & key); 277 278 protected: 279 virtual int Action(unsigned flags, KeyNumType & key); 280 }; 281 friend class TacticalClass; 282 283 /* 284 ** This is the "button" that tracks all input to the tactical map. 285 ** It must be available to derived classes, for Save/Load purposes. 286 */ 287 public: //ST - 1/21/2019 11:59AM 288 static TacticalClass TacButton; 289 290 private: 291 292 /* 293 ** This is a utility flag that is set during the icon draw process only if there 294 ** was at least one shadow icon detected that should be redrawn. When the shadow 295 ** drawing logic is to take place, but this flag is false, then the shadow drawing 296 ** will be skipped since it would perform no function. 297 */ 298 unsigned IsShadowPresent:1; 299 300 /* 301 ** Rubber band mode consists of stretching a box from the anchor point (specified 302 ** here) to the current cursor position. 303 */ 304 int BandX,BandY; 305 int NewX,NewY; 306 307 static void const *ShadowShapes; 308 static unsigned char ShadowTrans[(SHADOW_COL_COUNT+1)*256]; 309 310 void Redraw_Icons(void); 311 void Redraw_OIcons(void); 312 void Redraw_Shadow(void); 313 314 /* 315 ** This bit array is used to flag cells to be redrawn. If the icon needs to 316 ** be redrawn for a cell, then the corresponding flag will be true. 317 */ 318 static BooleanVectorClass CellRedraw; 319 320 bool Good_Reinforcement_Cell(CELL outcell, CELL incell, SpeedType loco, int zone, MZoneType mzone) const; 321 322 // 323 // We need a way to bypass visible view checks when we are running in the context of GlyphX without using the 324 // internal C&C renderer. We shouldn't know or care what the user is actually looking at 325 // ST - 4/17/2019 9:01AM 326 // 327 static bool IgnoreViewConstraints; 328 329 /* 330 ** Some additional padding in case we need to add data to the class and maintain backwards compatibility for save/load 331 */ 332 unsigned char SaveLoadPadding[1024]; 333 334 }; 335 336 337 #endif