SIDEBAR.H (14859B)
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/SIDEBAR.H 1 3/03/97 10:25a 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 : SIDEBAR.H * 24 * * 25 * Programmer : Joe L. Bostic * 26 * * 27 * Start Date : October 20, 1994 * 28 * * 29 * Last Update : October 20, 1994 [JLB] * 30 * * 31 *---------------------------------------------------------------------------------------------* 32 * Functions: * 33 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 34 35 #ifndef SIDEBAR_H 36 #define SIDEBAR_H 37 38 #include "function.h" 39 #include "power.h" 40 #include "factory.h" 41 42 class InitClass {}; 43 44 class SidebarClass: public PowerClass 45 { 46 public: 47 /* 48 ** These constants are used to control the sidebar rendering. They are instantiated 49 ** as enumerations since C++ cannot use "const" in this context. 50 */ 51 enum SideBarClassEnums { 52 BUTTON_ACTIVATOR=100, // Button ID for the activator. 53 SIDE_X=320-80, // The X position of sidebar upper left corner. 54 SIDE_Y=7+70, // The Y position of sidebar upper left corner. 55 SIDE_WIDTH=SIDEBAR_WID, // Width of the entire sidebar (in pixels). 56 SIDE_HEIGHT=200-(7+70), // Height of the entire sidebar (in pixels). 57 TOP_HEIGHT=13, // Height of top section (with repair/sell buttons). 58 COLUMN_ONE_X=(320-80)+8, // Sidestrip upper left coordinates... 59 COLUMN_ONE_Y=int(SIDE_Y)+int(TOP_HEIGHT), 60 COLUMN_TWO_X=(320-80)+8+((80-16)/2)+3, 61 COLUMN_TWO_Y=7+70+13, 62 63 //BGA: changes to all buttons 64 #ifdef GERMAN 65 BUTTON_ONE_WIDTH=20, // Button width. 66 BUTTON_TWO_WIDTH=27, // Button width. 67 BUTTON_THREE_WIDTH=26, // Button width. 68 BUTTON_HEIGHT=9, // Button height. 69 BUTTON_ONE_X=SIDE_X+2, // Left button X coordinate. 70 BUTTON_ONE_Y=SIDE_Y+2, // Left button Y coordinate. 71 BUTTON_TWO_X=SIDE_X+24, // Right button X coordinate. 72 BUTTON_TWO_Y=SIDE_Y+2, // Right button Y coordinate. 73 BUTTON_THREE_X=SIDE_X+53, // Right button X coordinate. 74 BUTTON_THREE_Y=SIDE_Y+2, // Right button Y coordinate. 75 #endif 76 77 #ifdef FRENCH 78 BUTTON_ONE_WIDTH=20, // Button width. 79 BUTTON_TWO_WIDTH=27, // Button width. 80 BUTTON_THREE_WIDTH=26, // Button width. 81 BUTTON_HEIGHT=9, // Button height. 82 BUTTON_ONE_X=SIDE_X+2, // Left button X coordinate. 83 BUTTON_ONE_Y=SIDE_Y+2, // Left button Y coordinate. 84 BUTTON_TWO_X=SIDE_X+24, // Right button X coordinate. 85 BUTTON_TWO_Y=SIDE_Y+2, // Right button Y coordinate. 86 BUTTON_THREE_X=SIDE_X+53, // Right button X coordinate. 87 BUTTON_THREE_Y=SIDE_Y+2, // Right button Y coordinate. 88 #endif 89 90 #ifdef ENGLISH 91 BUTTON_ONE_WIDTH=32, // Button width. 92 BUTTON_TWO_WIDTH=20, // Button width. 93 BUTTON_THREE_WIDTH=20, // Button width. 94 BUTTON_HEIGHT=9, // Button height. 95 BUTTON_ONE_X=(int)SIDE_X+2, // Left button X coordinate. 96 BUTTON_ONE_Y=(int)SIDE_Y+2, // Left button Y coordinate. 97 BUTTON_TWO_X=(int)SIDE_X+36, // Right button X coordinate. 98 BUTTON_TWO_Y=(int)SIDE_Y+2, // Right button Y coordinate. 99 BUTTON_THREE_X=(int)SIDE_X+58, // Right button X coordinate. 100 BUTTON_THREE_Y=(int)SIDE_Y+2, // Right button Y coordinate. 101 #endif 102 103 COLUMNS=2 // Number of side strips on sidebar. 104 }; 105 106 static void * SidebarShape; 107 static void * SidebarMiddleShape; //Only used in Win95 version 108 static void * SidebarBottomShape; //Only used in Win95 version 109 110 SidebarClass(void); 111 SidebarClass(NoInitClass const & x); 112 113 /* 114 ** Initialization 115 */ 116 virtual void One_Time(void); // One-time inits 117 virtual void Init_Clear(void); // Clears all to known state 118 virtual void Init_IO(void); // Inits button list 119 virtual void Init_Theater(TheaterType theater); // Theater-specific inits 120 void Reload_Sidebar(void); // Loads house-specific sidebar art 121 122 virtual void AI(KeyNumType & input, int x, int y); 123 virtual void Draw_It(bool complete); 124 virtual void Refresh_Cells(CELL cell, short const *list); 125 126 void Zoom_Mode_Control(void); 127 bool Abandon_Production(RTTIType type, int factory); 128 bool Activate(int control); 129 bool Add(RTTIType type, int ID, bool via_capture = false); // Added via_capture for new sidebar functionality. ST - 9/24/2019 3:15PM ); 130 bool Sidebar_Click(KeyNumType & input, int x, int y); 131 void Recalc(void); 132 bool Factory_Link(int factory, RTTIType type, int id); 133 134 /* 135 ** Each side strip is managed by this class. It handles all strip specific 136 ** actions. 137 */ 138 class StripClass : public StageClass 139 { 140 class SelectClass : public ControlClass 141 { 142 public: 143 SelectClass(void); 144 SelectClass(NoInitClass const & x) : ControlClass(x) {}; 145 146 void Set_Owner(StripClass & strip, int index); 147 148 StripClass * Strip; 149 int Index; 150 151 protected: 152 virtual int Action(unsigned flags, KeyNumType & key); 153 }; 154 155 public: 156 StripClass(void) {} 157 StripClass(InitClass const &); 158 StripClass(NoInitClass const & ) {}; 159 160 bool Add(RTTIType type, int ID, bool via_capture); // Added via_capture for new sidebar functionality. ST - 9/24/2019 3:15PM ); 161 bool Abandon_Production(int factory); 162 bool Scroll(bool up); 163 bool AI(KeyNumType & input, int x, int y); 164 void Draw_It(bool complete); 165 void One_Time(int id); 166 void Init_Clear(void); 167 void Init_IO(int id); 168 void Init_Theater(TheaterType theater); 169 void Reload_LogoShapes(void); 170 bool Recalc(void); 171 void Activate(void); 172 void Deactivate(void); 173 void Flag_To_Redraw(void); 174 bool Factory_Link(int factory, RTTIType type, int id); 175 void const * Get_Special_Cameo(SpecialWeaponType type); 176 177 /* 178 ** File I/O. 179 */ 180 bool Load(Straw & file); 181 bool Save(Pipe & file) const; 182 183 /* 184 ** Working numbers used when rendering and processing the side strip. 185 */ 186 enum SideBarGeneralEnums { 187 BUTTON_UP=200, 188 BUTTON_DOWN=210, 189 BUTTON_SELECT=220, 190 MAX_BUILDABLES=75, // Maximum number of object types in sidebar. 191 OBJECT_HEIGHT=24, // Pixel height of each buildable object. 192 OBJECT_WIDTH=32, // Pixel width of each buildable object. 193 STRIP_WIDTH=35, // Width of strip (not counting border lines). 194 MAX_VISIBLE=4, // Number of object slots visible at any one time. 195 #ifdef WIN32 196 SCROLL_RATE=12, // The pixel jump while scrolling (larger is faster). 197 #else 198 SCROLL_RATE=8, // The pixel jump while scrolling (larger is faster). 199 #endif 200 UP_X_OFFSET=2, // Scroll up arrow coordinates. 201 #ifdef WIN32 202 UP_Y_OFFSET=int(MAX_VISIBLE)*int(OBJECT_HEIGHT)+1, 203 #else 204 UP_Y_OFFSET=int(MAX_VISIBLE)*int(OBJECT_HEIGHT)+2, 205 #endif 206 DOWN_X_OFFSET=18, // Scroll down arrow coordinates. 207 DOWN_Y_OFFSET=UP_Y_OFFSET,//BGint(MAX_VISIBLE)*int(OBJECT_HEIGHT)+1, 208 SBUTTON_WIDTH=16, // Width of the mini-scroll button. 209 SBUTTON_HEIGHT=12, // Height of the mini-scroll button. 210 LEFT_EDGE_OFFSET=2, // Offset from left edge for building shapes. 211 TEXT_X_OFFSET=18, // X offset to print "ready" text. 212 TEXT_Y_OFFSET=15, // Y offset to print "ready" text. 213 TEXT_COLOR=255 // Color to use for the "Ready" text. 214 }; 215 216 /* 217 ** This is the coordinate of the upper left corner that this side strip 218 ** uses for rendering. 219 */ 220 int X,Y; 221 222 /* 223 ** This is a unique identifier for the sidebar strip. Using this identifier, 224 ** it is possible to differentiate the button messages that arrive from the 225 ** common input button list. It >MUST< be equal to the strip's index into 226 ** the Column[] array, because the strip uses it to access the stripclass 227 ** buttons. 228 */ 229 int ID; 230 231 /* 232 ** Shape numbers for the shapes in the STRIP.SHP file. 233 */ 234 enum SideBarStipShapeEnums { 235 SB_BLANK, // The blank rectangle to use if there are no objects present. 236 SB_FRAME 237 }; 238 239 /* 240 ** If this particular side strip needs to be redrawn, then this flag 241 ** will be true. 242 */ 243 unsigned IsToRedraw:1; 244 245 /* 246 ** If construction is in progress (no other objects in this strip can 247 ** be started), then this flag will be true. It will be cleared when 248 ** the strip is free to start production again. 249 */ 250 unsigned IsBuilding:1; 251 252 /* 253 ** This controls the sidebar slide direction. If this is true, then the sidebar 254 ** will scroll downward -- revealing previous objects. 255 */ 256 unsigned IsScrollingDown:1; 257 258 /* 259 ** If the sidebar is scrolling, then this flag is true. Otherwise it is false. 260 */ 261 unsigned IsScrolling:1; 262 263 /* 264 ** This is the object (sidebar slot) that is flashing. Only one slot can be flashing 265 ** at any one instant. This is usually the result of a click on the slot and construction 266 ** has commenced. 267 */ 268 int Flasher; 269 270 /* 271 ** As the sidebar scrolls up and down, this variable holds the index for the topmost 272 ** visible sidebar slot. 273 */ 274 int TopIndex; 275 276 /* 277 ** This is the queued scroll direction and amount. The sidebar 278 ** will scroll the number of slots indicated by this value. This 279 ** value is set according to the scroll buttons. 280 */ 281 int Scroller; 282 283 /* 284 ** The sidebar has smooth scrolling. This is the number of pixels the sidebar 285 ** has slide down. Thus, if this value were 5, then there would be 5 pixels of 286 ** the TopIndex-1 sidebar object visible. When the Slid value reaches 24, then 287 ** the value resets to zero and the TopIndex is decremented. For sliding in the 288 ** opposite direction, change the IsScrollingDown flag. 289 */ 290 int Slid; 291 292 /* 293 ** The value of Slid the last time we rendered the sidebar. 294 */ 295 int LastSlid; 296 297 /* 298 ** This is the count of the number of sidebar slots that are active. 299 */ 300 int BuildableCount; 301 302 /* 303 ** This is the array of buildable object types. This array is sorted in the order 304 ** that it is to be displayed. This array keeps track of which objects are building 305 ** and ready to be placed. The very nature of this method precludes simultaneous 306 ** construction of the same object type. 307 */ 308 typedef struct BuildType { 309 int BuildableID; 310 RTTIType BuildableType; 311 int Factory; // Production manager. 312 bool BuildableViaCapture; // Added for new sidebar functionality. ST - 9/24/2019 3:10PM 313 } BuildType; 314 BuildType Buildables[MAX_BUILDABLES]; 315 316 /* 317 ** Pointer to the shape data for small versions of the logos. These are used as 318 ** placeholder pieces on the side bar. 319 */ 320 static void * LogoShapes; 321 322 /* 323 ** This points to the animation sequence of frames used to mark the passage of time 324 ** as an object is undergoing construction. 325 */ 326 static void const * ClockShapes; 327 328 /* 329 ** This points to the animation sequence which deals with special 330 ** shapes which handle non-production based icons. 331 */ 332 static void const * SpecialShapes[SPC_COUNT]; 333 334 /* 335 ** This is the last theater that the special palette remap table was loaded 336 ** for. If the current theater differs from this recorded value, then the 337 ** remap tables are reloaded. 338 */ 339 // static TheaterType LastTheater; 340 341 static ShapeButtonClass UpButton[COLUMNS]; 342 static ShapeButtonClass DownButton[COLUMNS]; 343 static SelectClass SelectButton[COLUMNS][MAX_VISIBLE]; 344 345 /* 346 ** This points to the shapes that are used for the clock overlay. This displays 347 ** progress of construction. 348 */ 349 static char ClockTranslucentTable[(1+1)*256]; 350 351 } Column[COLUMNS]; 352 353 354 /* 355 ** If the sidebar is active then this flag is true. 356 */ 357 unsigned IsSidebarActive:1; 358 359 /* 360 ** This flag tells the rendering system that the sidebar needs to be redrawn. 361 */ 362 unsigned IsToRedraw:1; 363 364 class SBGadgetClass: public GadgetClass { 365 public: 366 //#ifdef WIN32 367 SBGadgetClass(void) : GadgetClass((int)((int)SIDE_X+8)*RESFACTOR, (int)SIDE_Y*RESFACTOR, (int)((int)SIDE_WIDTH-1)*RESFACTOR-1, (int)((int)SIDE_HEIGHT-1)*RESFACTOR, LEFTUP) {}; 368 //#else 369 // SBGadgetClass(void) : GadgetClass((int)SIDE_X+8, (int)SIDE_Y, (int)SIDE_WIDTH-1, (int)SIDE_HEIGHT-1, LEFTUP) {}; 370 //#endif 371 protected: 372 virtual int Action(unsigned flags, KeyNumType & key); 373 }; 374 375 /* 376 ** This is the button that is used to collapse and expand the sidebar. 377 ** These buttons must be available to derived classes, for Save/Load. 378 */ 379 static ShapeButtonClass Repair; 380 static ShapeButtonClass Upgrade; 381 static ShapeButtonClass Zoom; 382 static SBGadgetClass Background; 383 384 bool Scroll(bool up, int column); 385 386 private: 387 bool Activate_Repair(int control); 388 bool Activate_Upgrade(int control); 389 bool Activate_Demolish(int control); 390 int Which_Column(RTTIType type); 391 392 unsigned IsRepairActive:1; 393 unsigned IsUpgradeActive:1; 394 unsigned IsDemolishActive:1; 395 }; 396 397 #endif