W3DDisplayString.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. ** Command & Conquer Generals(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: W3DDisplayString.h ///////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Westwood Studios Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2001 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // Project: RTS3
  34. //
  35. // File name: W3DDisplayString.h
  36. //
  37. // Created: Colin Day, July 2001
  38. //
  39. // Desc: Display string W3D implementation, display strings hold
  40. // double byte characters and all the data we need to render
  41. // those strings to the screen.
  42. //
  43. //-----------------------------------------------------------------------------
  44. ///////////////////////////////////////////////////////////////////////////////
  45. #pragma once
  46. #ifndef __W3DDISPLAYSTRING_H_
  47. #define __W3DDISPLAYSTRING_H_
  48. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  49. // USER INCLUDES //////////////////////////////////////////////////////////////
  50. #include "Common/GameMemory.h"
  51. #include "GameClient/DisplayString.h"
  52. #include "WW3D2/Render2DSentence.h"
  53. // FORWARD REFERENCES /////////////////////////////////////////////////////////
  54. class W3DDisplayStringManager;
  55. // TYPE DEFINES ///////////////////////////////////////////////////////////////
  56. // W3DDisplayString -----------------------------------------------------------
  57. /** */
  58. //-----------------------------------------------------------------------------
  59. class W3DDisplayString : public DisplayString
  60. {
  61. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( W3DDisplayString, "W3DDisplayString" )
  62. public:
  63. friend W3DDisplayStringManager;
  64. W3DDisplayString( void );
  65. // ~W3DDisplayString( void ); // destructor defined by memory pool
  66. void notifyTextChanged( void ); ///< called when text contents change
  67. void draw( Int x, Int y, Color color, Color dropColor ); ///< render text
  68. void draw( Int x, Int y, Color color, Color dropColor, Int xDrop, Int yDrop ); ///< render text with the drop shadow being at the offsets passed in
  69. void getSize( Int *width, Int *height ); ///< get render size
  70. Int getWidth( Int charPos = -1);
  71. void setWordWrap( Int wordWrap ); ///< set the word wrap width
  72. void setWordWrapCentered( Bool isCentered ); ///< If this is set to true, the text on a new line is centered
  73. void setFont( GameFont *font ); ///< set a font for display
  74. void setUseHotkey( Bool useHotkey, Color hotKeyColor = 0xffffffff );
  75. void setClipRegion( IRegion2D *region ); ///< clip text in this region
  76. protected:
  77. void checkForChangedTextData( void ); /**< called when we need to update our
  78. render sentence and update extents */
  79. void usingResources( UnsignedInt frame ); /**< call this whenever display
  80. resources are in use */
  81. void computeExtents( void ); ///< compupte text width and height
  82. Render2DSentenceClass m_textRenderer; ///< for drawing text
  83. Render2DSentenceClass m_textRendererHotKey; ///< for drawing text
  84. Bool m_textChanged; ///< when contents of string change this is TRUE
  85. Bool m_fontChanged; ///< when font has chagned this is TRUE
  86. UnicodeString m_hotkey; ///< holds the current hotkey marker.
  87. Bool m_useHotKey;
  88. ICoord2D m_hotKeyPos;
  89. Color m_hotKeyColor;
  90. ICoord2D m_textPos; ///< current text pos set in text renderer
  91. Color m_currTextColor, ///< current color used in text renderer
  92. m_currDropColor; ///< current color used for shadow in text
  93. ICoord2D m_size; ///< (width,height) size of rendered text
  94. IRegion2D m_clipRegion; ///< the clipping region for text
  95. UnsignedInt m_lastResourceFrame; ///< last frame resources were used on
  96. };
  97. ///////////////////////////////////////////////////////////////////////////////
  98. // INLINING ///////////////////////////////////////////////////////////////////
  99. ///////////////////////////////////////////////////////////////////////////////
  100. inline void W3DDisplayString::usingResources( UnsignedInt frame ) { m_lastResourceFrame = frame; }
  101. // EXTERNALS //////////////////////////////////////////////////////////////////
  102. #endif // __W3DDISPLAYSTRING_H_