DisplayString.cpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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: DisplayString.cpp ////////////////////////////////////////////////////
  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: DisplayString.cpp
  36. //
  37. // Created: Colin Day, July 2001
  38. //
  39. // Desc: Contstuct for holding double byte game string data and being
  40. // able to draw that text to the screen.
  41. //
  42. //-----------------------------------------------------------------------------
  43. ///////////////////////////////////////////////////////////////////////////////
  44. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  45. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  46. // USER INCLUDES //////////////////////////////////////////////////////////////
  47. #include "Common/Debug.h"
  48. #include "Common/Language.h"
  49. #include "GameClient/DisplayString.h"
  50. // DEFINES ////////////////////////////////////////////////////////////////////
  51. // PRIVATE TYPES //////////////////////////////////////////////////////////////
  52. // PRIVATE DATA ///////////////////////////////////////////////////////////////
  53. // PUBLIC DATA ////////////////////////////////////////////////////////////////
  54. // PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
  55. // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
  56. ///////////////////////////////////////////////////////////////////////////////
  57. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
  58. ///////////////////////////////////////////////////////////////////////////////
  59. // DisplayString::DisplayString ===============================================
  60. /** */
  61. //=============================================================================
  62. DisplayString::DisplayString( void )
  63. {
  64. // m_textString = ""; // not necessary, done by default
  65. m_font = NULL;
  66. m_next = NULL;
  67. m_prev = NULL;
  68. } // end DisplayString
  69. // DisplayString::~DisplayString ==============================================
  70. /** */
  71. //=============================================================================
  72. DisplayString::~DisplayString( void )
  73. {
  74. // free any data
  75. reset();
  76. } // end ~DisplayString
  77. // DisplayString::setText =====================================================
  78. /** Copy the text to this instance */
  79. //=============================================================================
  80. void DisplayString::setText( UnicodeString text )
  81. {
  82. if (text == m_textString)
  83. return;
  84. m_textString = text;
  85. // our text has now changed
  86. notifyTextChanged();
  87. } // end setText
  88. // DisplayString::reset =======================================================
  89. /** Free and reset all the data for this string, effectively making this
  90. * instance like brand new */
  91. //=============================================================================
  92. void DisplayString::reset( void )
  93. {
  94. m_textString.clear();
  95. // no font
  96. m_font = NULL;
  97. } // end reset
  98. // DisplayString::removeLastChar ==============================================
  99. /** Remove the last character from the string text */
  100. //=============================================================================
  101. void DisplayString::removeLastChar( void )
  102. {
  103. m_textString.removeLastChar();
  104. // our text has now changed
  105. notifyTextChanged();
  106. } // end removeLastChar
  107. // DisplayString::appendChar ==================================================
  108. /** Append character to the end of the string */
  109. //=============================================================================
  110. void DisplayString::appendChar( WideChar c )
  111. {
  112. m_textString.concat(c);
  113. // text has now changed
  114. notifyTextChanged();
  115. } // end appendchar