SIDEBAR.H 15 KB

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