SIDEBAR.H 14 KB

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