ControlBarScheme.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: ControlBarScheme.h /////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Electronic Arts Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2002 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // created: Apr 2002
  34. //
  35. // Filename: ControlBarScheme.h
  36. //
  37. // author: Chris Huybregts
  38. //
  39. // purpose:
  40. //
  41. //-----------------------------------------------------------------------------
  42. ///////////////////////////////////////////////////////////////////////////////
  43. #pragma once
  44. #ifndef __CONTROL_BAR_SCHEME_H_
  45. #define __CONTROL_BAR_SCHEME_H_
  46. //-----------------------------------------------------------------------------
  47. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  48. //-----------------------------------------------------------------------------
  49. //-----------------------------------------------------------------------------
  50. // USER INCLUDES //////////////////////////////////////////////////////////////
  51. //-----------------------------------------------------------------------------
  52. #include "GameClient/Color.h"
  53. //-----------------------------------------------------------------------------
  54. // FORWARD REFERENCES /////////////////////////////////////////////////////////
  55. //-----------------------------------------------------------------------------
  56. class AsciiString;
  57. class playerTemplate;
  58. class Image;
  59. enum TimeOfDay;
  60. //-----------------------------------------------------------------------------
  61. // TYPE DEFINES ///////////////////////////////////////////////////////////////
  62. //-----------------------------------------------------------------------------
  63. #define MAX_CONTROL_BAR_SCHEME_IMAGE_LAYERS 6
  64. #define CONTROL_BAR_SCHEME_FOREGROUND_IMAGE_LAYERS 3
  65. // Class that holds the images the control bar will draw
  66. //-----------------------------------------------------------------------------
  67. class ControlBarSchemeImage
  68. {
  69. public:
  70. ControlBarSchemeImage( void );
  71. ~ControlBarSchemeImage( void );
  72. AsciiString m_name; ///< Name of the image
  73. ICoord2D m_position; ///< the position we'll draw it at
  74. ICoord2D m_size; ///< the size of the image needed when we draw it
  75. Image *m_image; ///< the actual pointer to the mapped image
  76. // m_layer is where the image will get drawn, everything in layer 0-2 gets drawn during the forground draw
  77. // the layers 3-5 gets drawn during the background draw
  78. Int m_layer; //layer means how deep the image will be drawn, it's a number between 0-5 with 0 being on top
  79. };
  80. // Class that will hold the information needed for the animations
  81. //-----------------------------------------------------------------------------
  82. class ControlBarSchemeAnimation
  83. {
  84. public:
  85. ControlBarSchemeAnimation( void );
  86. ~ControlBarSchemeAnimation( void );
  87. /// Enum that will contain all the kinds of animations we have... make sure in ControlBarScheme.cpp there's a
  88. /// mapping for it for the INI translation
  89. enum
  90. {
  91. CB_ANIM_SLIDE_RIGHT = 0,
  92. CB_ANIM_MAX
  93. };
  94. AsciiString m_name; ///< Current animation name
  95. Int m_animType; ///< Type of animation that this will follow
  96. ControlBarSchemeImage *m_animImage; ///< Pointer of the image that this animation will act on
  97. UnsignedInt m_animDuration; ///< Contians how long the animation should take based off game frames
  98. ICoord2D m_finalPos; ///< The final position when we hit the m_animDuration frame
  99. UnsignedInt getCurrentFrame(void) { return m_currentFrame; }
  100. void setCurrentFrame( UnsignedInt currentFrame ) { m_currentFrame = currentFrame; }
  101. ICoord2D getStartPos( void ) { return m_startPos; }
  102. void setStartPos(ICoord2D startPos) { m_startPos = startPos; }
  103. private:
  104. ICoord2D m_startPos; ///< set when we first begin an animation
  105. UnsignedInt m_currentFrame; ///< This is the last frame (a value between 0 and m_animDuration)
  106. };
  107. // Class that each scheme will have. Contains all information about that scheme
  108. //-----------------------------------------------------------------------------
  109. class ControlBarScheme
  110. {
  111. public:
  112. ControlBarScheme( void );
  113. ~ControlBarScheme( void );
  114. void init( void );
  115. void update( void );
  116. void drawForeground( Coord2D multi, ICoord2D offset ); ///< draw function to be called within a w3d draw procedure for the foreground
  117. void drawBackground( Coord2D multi, ICoord2D offset ); ///< draw function to be called within a w3d draw procedure for the background
  118. void reset( void );
  119. void addAnimation( ControlBarSchemeAnimation *schemeAnim );
  120. void addImage( ControlBarSchemeImage *schemeImage);
  121. void updateAnim (ControlBarSchemeAnimation * anim);
  122. AsciiString m_name; ///< it's name
  123. ICoord2D m_ScreenCreationRes; ///< Used to determine what screen res this will look the best on
  124. AsciiString m_side; ///< contain what faction type this command bar was made for (used when selecting command bar by template
  125. Image *m_buttonQueueImage; ///< We'll probably want each one to have it's own image.
  126. Image *m_rightHUDImage; ///< We'll probably want each one to have it's own right HUD image.
  127. Color m_buildUpClockColor; ///< we can setup the color for the buildup clock if we want
  128. Color m_borderBuildColor; ///< we can setup the color for the button border colors
  129. Color m_borderActionColor; ///< we can setup the color for the button border colors
  130. Color m_borderUpgradeColor; ///< we can setup the color for the button border colors
  131. Color m_borderSystemColor; ///< we can setup the color for the button border colors
  132. Color m_commandBarBorderColor;
  133. Image *m_optionsButtonEnable;
  134. Image *m_optionsButtonHightlited;
  135. Image *m_optionsButtonPushed;
  136. Image *m_optionsButtonDisabled;
  137. Image *m_idleWorkerButtonEnable;
  138. Image *m_idleWorkerButtonHightlited;
  139. Image *m_idleWorkerButtonPushed;
  140. Image *m_idleWorkerButtonDisabled;
  141. Image *m_buddyButtonEnable;
  142. Image *m_buddyButtonHightlited;
  143. Image *m_buddyButtonPushed;
  144. Image *m_buddyButtonDisabled;
  145. Image *m_beaconButtonEnable;
  146. Image *m_beaconButtonHightlited;
  147. Image *m_beaconButtonPushed;
  148. Image *m_beaconButtonDisabled;
  149. Image *m_genBarButtonIn;
  150. Image *m_genBarButtonOn;
  151. Image *m_toggleButtonUpIn;
  152. Image *m_toggleButtonUpOn;
  153. Image *m_toggleButtonUpPushed;
  154. Image *m_toggleButtonDownIn;
  155. Image *m_toggleButtonDownOn;
  156. Image *m_toggleButtonDownPushed;
  157. Image *m_generalButtonEnable;
  158. Image *m_generalButtonHightlited;
  159. Image *m_generalButtonPushed;
  160. Image *m_generalButtonDisabled;
  161. Image *m_uAttackButtonEnable;
  162. Image *m_uAttackButtonHightlited;
  163. Image *m_uAttackButtonPushed;
  164. Image *m_minMaxButtonEnable;
  165. Image *m_minMaxButtonHightlited;
  166. Image *m_minMaxButtonPushed;
  167. Image *m_genArrow;
  168. ICoord2D m_moneyUL;
  169. ICoord2D m_moneyLR;
  170. ICoord2D m_minMaxUL;
  171. ICoord2D m_minMaxLR;
  172. ICoord2D m_generalUL;
  173. ICoord2D m_generalLR;
  174. ICoord2D m_uAttackUL;
  175. ICoord2D m_uAttackLR;
  176. ICoord2D m_optionsUL;
  177. ICoord2D m_optionsLR;
  178. ICoord2D m_workerUL;
  179. ICoord2D m_workerLR;
  180. ICoord2D m_chatUL;
  181. ICoord2D m_chatLR;
  182. ICoord2D m_beaconUL;
  183. ICoord2D m_beaconLR;
  184. ICoord2D m_powerBarUL;
  185. ICoord2D m_powerBarLR;
  186. Image *m_expBarForeground;
  187. Image *m_commandMarkerImage;
  188. Image *m_powerPurchaseImage;
  189. typedef std::list< ControlBarSchemeImage* > ControlBarSchemeImageList;
  190. ControlBarSchemeImageList m_layer[MAX_CONTROL_BAR_SCHEME_IMAGE_LAYERS];
  191. typedef std::list< ControlBarSchemeAnimation* > ControlBarSchemeAnimationList;
  192. ControlBarSchemeAnimationList m_animations;
  193. };
  194. class ControlBarSchemeManager
  195. {
  196. public:
  197. ControlBarSchemeManager( void );
  198. ~ControlBarSchemeManager( void );
  199. void init( void ); ///< Initialize from the INI files
  200. void update( void ); ///< move the animations if we have any
  201. void drawForeground( ICoord2D offset ); ///< draw function to be called within a w3d draw procedure for the foreground
  202. void drawBackground( ICoord2D offset ); ///< draw function to be called within a w3d draw procedure for the background
  203. void setControlBarSchemeByPlayer(Player *p); ///< Based off the playerTemplate, pick the right scheme for the control bar
  204. void setControlBarSchemeByPlayerTemplate( const PlayerTemplate *pt, Bool useSmall = FALSE);
  205. void setControlBarScheme(AsciiString schemeName); ///< SchemeName must be a valid INI entry
  206. // parse Functions for the INI file
  207. const FieldParse *getFieldParse() const { return m_controlBarSchemeFieldParseTable; } ///< returns the parsing fields
  208. static const FieldParse m_controlBarSchemeFieldParseTable[]; ///< the parse table
  209. static void parseImagePart( INI* ini, void *instance, void *store, const void *userData ); ///< Parse the image part of the INI file
  210. static void parseAnimatingPart( INI* ini, void *instance, void *store, const void *userData ); ///< Parse the animation part of the INI file
  211. static void parseAnimatingPartImage( INI* ini, void *instance, void *store, const void *userData ); ///< parse the image part of the animation part :)
  212. ControlBarScheme *findControlBarScheme( AsciiString name ); ///< attempt to find the control bar scheme by it's name
  213. ControlBarScheme *newControlBarScheme( AsciiString name ); ///< create a new control bar scheme and return it.
  214. void preloadAssets( TimeOfDay timeOfDay ); ///< preload the assets
  215. private:
  216. ControlBarScheme *m_currentScheme; ///< the current scheme that everythign uses
  217. Coord2D m_multiplyer;
  218. typedef std::list< ControlBarScheme* > ControlBarSchemeList; ///< list of control bar schemes
  219. ControlBarSchemeList m_schemeList;
  220. };
  221. //-----------------------------------------------------------------------------
  222. // INLINING ///////////////////////////////////////////////////////////////////
  223. //-----------------------------------------------------------------------------
  224. //-----------------------------------------------------------------------------
  225. // EXTERNALS //////////////////////////////////////////////////////////////////
  226. //-----------------------------------------------------------------------------
  227. #endif // __CONTROL_BAR_SCHEME_H_