stylemgr.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*
  2. ** Command & Conquer Renegade(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. *** 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 ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Combat *
  23. * *
  24. * $Archive:: /Commando/Code/wwui/stylemgr.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 1/26/02 1:21p $*
  29. * *
  30. * $Revision:: 16 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __STYLE_MGR_H
  39. #define __STYLE_MGR_H
  40. #include "bittype.h"
  41. #include "widestring.h"
  42. #include "vector.h"
  43. ////////////////////////////////////////////////////////////////
  44. // Forward declarations
  45. ////////////////////////////////////////////////////////////////
  46. class TextureClass;
  47. class Render2DClass;
  48. class Render2DSentenceClass;
  49. class FontCharsClass;
  50. class RectClass;
  51. ////////////////////////////////////////////////////////////////
  52. //
  53. // StyleMgrClass
  54. //
  55. ////////////////////////////////////////////////////////////////
  56. class StyleMgrClass
  57. {
  58. public:
  59. ////////////////////////////////////////////////////////////////
  60. // Public constants
  61. ////////////////////////////////////////////////////////////////
  62. typedef enum
  63. {
  64. FONT_TITLE = 0,
  65. FONT_LG_CONTROLS,
  66. FONT_CONTROLS,
  67. FONT_LISTS,
  68. FONT_TOOLTIPS,
  69. FONT_MENU,
  70. FONT_SM_MENU,
  71. FONT_HEADER,
  72. FONT_BIG_HEADER,
  73. FONT_CREDITS,
  74. FONT_CREDITS_BOLD,
  75. FONT_INGAME_TXT,
  76. FONT_INGAME_BIG_TXT,
  77. FONT_INGAME_SUBTITLE_TXT,
  78. FONT_INGAME_HEADER_TXT,
  79. FONT_MAX
  80. } FONT_STYLE;
  81. typedef enum
  82. {
  83. LEFT_JUSTIFY = 0,
  84. RIGHT_JUSTIFY,
  85. CENTER_JUSTIFY
  86. } JUSTIFICATION;
  87. typedef enum
  88. {
  89. EVENT_MOUSE_CLICK = 0,
  90. EVENT_MOUSE_OVER,
  91. EVENT_MENU_BACK,
  92. EVENT_POPUP,
  93. EVENT_AUDIO_MAX
  94. } EVENT_AUDIO;
  95. ////////////////////////////////////////////////////////////////
  96. // Public methods
  97. ////////////////////////////////////////////////////////////////
  98. //
  99. // Initialization
  100. //
  101. static void Initialize (void);
  102. static void Initialize_From_INI (const char *filename);
  103. static void Shutdown (void);
  104. //
  105. // Font methods
  106. //
  107. static FontCharsClass * Get_Font (FONT_STYLE style);
  108. static FontCharsClass * Peek_Font (FONT_STYLE style) { return Fonts[style]; }
  109. static void Assign_Font (Render2DSentenceClass *renderer, FONT_STYLE style);
  110. //
  111. // Sound methods
  112. //
  113. static void Play_Sound (EVENT_AUDIO event);
  114. //
  115. // Configuration methods
  116. //
  117. static void Configure_Renderer (Render2DClass *renderer);
  118. //
  119. // Scale support
  120. //
  121. static float Get_X_Scale (void) { return ScaleX; }
  122. static float Get_Y_Scale (void) { return ScaleY; }
  123. //
  124. // Color methods
  125. //
  126. static uint32 Get_Text_Color (void) { return TextColor; }
  127. static uint32 Get_Text_Shadow_Color (void) { return TextShadowColor; }
  128. static uint32 Get_Disabled_Text_Color (void) { return DisabledTextColor; }
  129. static uint32 Get_Disabled_Text_Shadow_Color (void) { return DisabledTextShadowColor; }
  130. static uint32 Get_Line_Color (void) { return LineColor; }
  131. static uint32 Get_Bk_Color (void) { return BkColor; }
  132. static uint32 Get_Disabled_Line_Color (void) { return DisabledLineColor; }
  133. static uint32 Get_Disabled_Bk_Color (void) { return DisabledBkColor; }
  134. static uint32 Get_Tab_Text_Color (void) { return TabTextColor; }
  135. static uint32 Get_Tab_Glow_Color (void) { return TabGlowColor; }
  136. //
  137. // Backdrop support
  138. //
  139. static void Render_Backdrop (Render2DClass *renderer, const RectClass &rect);
  140. //
  141. // Text support
  142. //
  143. static void Render_Text (const WCHAR *text, Render2DSentenceClass *renderer, uint32 text_color, uint32 shadow_color, const RectClass &rect, bool do_shadow = false, bool do_clip = true, JUSTIFICATION justify = LEFT_JUSTIFY, bool is_vcentered = true);
  144. static void Render_Text (const WCHAR *text, Render2DSentenceClass *renderer, const RectClass &rect, bool do_shadow = false, bool do_clip = true, JUSTIFICATION justify = LEFT_JUSTIFY, bool is_enabled = true, bool is_vcentered = true);
  145. static void Render_Title_Text (const WCHAR *text, Render2DSentenceClass *renderer, const RectClass &rect);
  146. static void Render_Wrapped_Text (const WCHAR *text, Render2DSentenceClass *renderer, uint32 text_color, uint32 shadow_color, const RectClass &rect, bool do_shadow = false, bool do_vcenter = false);
  147. static void Render_Wrapped_Text (const WCHAR *text, Render2DSentenceClass *renderer, const RectClass &rect, bool do_shadow = false, bool do_vcenter = false, bool is_enabled = true);
  148. static void Render_Wrapped_Text_Ex (const WCHAR *text, Render2DSentenceClass *renderer, const RectClass &rect, bool do_shadow = false, bool do_vcenter = false, bool is_enabled = true, JUSTIFICATION justify = LEFT_JUSTIFY);
  149. static void Render_Wrapped_Text_Ex (const WCHAR *text, Render2DSentenceClass *renderer, uint32 text_color, uint32 shadow_color, const RectClass &rect, bool do_shadow = false, bool do_vcenter = false, JUSTIFICATION justify = LEFT_JUSTIFY);
  150. //
  151. // Hilight support
  152. //
  153. static void Configure_Hilighter (Render2DClass *renderer);
  154. static void Render_Hilight (Render2DClass *renderer, const RectClass &rect);
  155. //
  156. // Text "glow" support
  157. //
  158. static void Render_Glow (const WCHAR *text, Render2DSentenceClass *renderer, const RectClass &rect, int radius_x, int radius_y, int color, JUSTIFICATION justify = LEFT_JUSTIFY);
  159. private:
  160. ////////////////////////////////////////////////////////////////
  161. // Private member data
  162. ////////////////////////////////////////////////////////////////
  163. static TextureClass * BackdropTexture;
  164. static uint32 TitleColor;
  165. static uint32 TitleHilightColor;
  166. static uint32 TitleShadowColor;
  167. static uint32 TextColor;
  168. static uint32 TextShadowColor;
  169. static uint32 LineColor;
  170. static uint32 BkColor;
  171. static uint32 DisabledTextColor;
  172. static uint32 DisabledTextShadowColor;
  173. static uint32 DisabledLineColor;
  174. static uint32 DisabledBkColor;
  175. static uint32 HilightColor;
  176. static uint32 TabTextColor;
  177. static uint32 TabGlowColor;
  178. static FontCharsClass * Fonts[FONT_MAX];
  179. static float ScaleX;
  180. static float ScaleY;
  181. static DynamicVectorClass<StringClass> FontFileList;
  182. static StringClass EventAudioList[EVENT_AUDIO_MAX];
  183. };
  184. #endif //__STYLE_MGR_H