textdisplay.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Commando/textdisplay.h $*
  25. * *
  26. * $Author:: Jani_p $*
  27. * *
  28. * $Modtime:: 9/27/01 9:41a $*
  29. * *
  30. * $Revision:: 29 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef TEXTDISPLAY_H
  36. #define TEXTDISPLAY_H
  37. #ifndef ALWAYS_H
  38. #include "always.h"
  39. #endif
  40. #ifndef GAMEMODE_H
  41. #include "gamemode.h"
  42. #endif
  43. #ifndef SLIST_H
  44. #include "slist.h"
  45. #endif
  46. #ifndef WWSTRING_H
  47. #include "wwstring.h"
  48. #endif
  49. #ifndef DEBUG_H
  50. #include "debug.h"
  51. #endif
  52. #ifndef VECTOR2_H
  53. #include "vector2.h"
  54. #endif
  55. #ifndef VECTOR4_H
  56. #include "vector4.h"
  57. #endif
  58. class Font3DInstanceClass;
  59. class Render2DTextClass;
  60. /*
  61. **
  62. */
  63. class TextDebugDisplayHandlerClass : public DebugDisplayHandlerClass {
  64. public:
  65. virtual void Display_Text( const char * string, const Vector4 & color = Vector4( 1,1,1,1 ) );
  66. virtual void Display_Text( const WideStringClass & string, const Vector4 & color = Vector4( 1,1,1,1 ) );
  67. };
  68. /*
  69. ** TextDisplayLine
  70. */
  71. class TextDisplayLine {
  72. public:
  73. TextDisplayLine( const WideStringClass & text, unsigned long color );
  74. float Update_Time( float seconds ) { Time += seconds; return Time; }
  75. int Get_Line_Count( void ) { return LineCount; }
  76. WideStringClass Text;
  77. unsigned long Color;
  78. float Time;
  79. int LineCount;
  80. };
  81. /*
  82. ** TextDisplayGameMode - Game (Sub) Mode to display text
  83. */
  84. #define Get_Text_Display() TextDisplayGameModeClass::Get_Instance()
  85. class TextDisplayGameModeClass : public GameModeClass {
  86. public:
  87. virtual const char *Name() { return "TextDisplay"; } // the name of this mode
  88. virtual void Init(); // called when the mode is activated
  89. virtual void Shutdown(); // called when the mode is deactivated
  90. virtual void Think(); // called each time through the main loop
  91. virtual void Render(); // called each time through the main loop
  92. static TextDisplayGameModeClass * Get_Instance() { return Instance; }
  93. void Flush( void );
  94. /*
  95. ** Scrolling Lines
  96. */
  97. void Set_Max_Scroll_Lines( int count ) { MaxScrollLines = count; }
  98. int Get_Max_Scroll_Lines( void ) { return MaxScrollLines; }
  99. void Set_Scroll_Lines_Persist_Time( float time ) { ScrollLinesPersistTime = time; }
  100. float Get_Scroll_Lines_Persist_Time( void ) { return ScrollLinesPersistTime; }
  101. void Print( const char * text, const Vector4 & color = Vector4( 1,1,1,1 ) );
  102. void Print( const WideStringClass & text, const Vector4 & color = Vector4( 1,1,1,1 ) );
  103. void Print( const char * text, const Vector3 & color = Vector3( 1,1,1 ) );
  104. void Print( const WideStringClass & text, const Vector3 & color = Vector3( 1,1,1 ) );
  105. void Print_System( const char * text, ... );
  106. void Print_System( const WideStringClass & string );
  107. void Print_Informational( const char * text, ... );
  108. void Print_Informational( const WideStringClass & string );
  109. void Set_Input_Text( const char * text )
  110. {
  111. TextChanged|=InputText!=text;
  112. InputText = text;
  113. }
  114. void Set_Help_Text( const char * text )
  115. {
  116. TextChanged|=HelpText!=text;
  117. HelpText = text;
  118. }
  119. void Set_Verbose_Help_Text( const char * text )
  120. {
  121. VerboseTextChanged|=VerboseHelpText!=text;
  122. VerboseHelpText = text;
  123. }
  124. void Display_Vis_Warning( bool on ) { DisplayVisWarning = on; }
  125. private:
  126. Font3DInstanceClass * Font;
  127. Font3DInstanceClass * MonoFont;
  128. Render2DTextClass * Display;
  129. Render2DTextClass * VerboseDisplay;
  130. Render2DTextClass * StatisticsDisplay;
  131. DynamicVectorClass<WideStringClass> RendererLines;
  132. DynamicVectorClass<unsigned long> RendererColors;
  133. float DisplayY;
  134. SList<TextDisplayLine> ScrollLines;
  135. StringClass InputText;
  136. StringClass HelpText;
  137. StringClass VerboseHelpText;
  138. bool TextChanged;
  139. bool VerboseTextChanged;
  140. bool DisplayVisWarning;
  141. int MaxScrollLines;
  142. float ScrollLinesPersistTime;
  143. float VerticalScroll;
  144. static TextDisplayGameModeClass * Instance;
  145. /*
  146. */
  147. int Count_Scroll_Lines( void );
  148. void Load_Registry_Keys(void);
  149. void Save_Registry_Keys(void);
  150. };
  151. /*
  152. ** Statistics Display
  153. */
  154. class StatisticsDisplayManager {
  155. public:
  156. static void Render( Render2DTextClass * renderer );
  157. static void Set_Display( const char * title );
  158. static bool Is_Current_Display( const char* title); // Returns true if "title" is currently active
  159. static void Set_Stat( const char * title, const char * text, unsigned long color = 0xffffffff, const Vector2& location = Vector2( 0, -240 ) );
  160. };
  161. #endif