WinInstanceData.cpp 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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: WinInstanceData.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: WinInstanceData.cpp
  36. //
  37. // Created: Colin Day, July 2001
  38. //
  39. // Desc: Game window instance data
  40. //
  41. //-----------------------------------------------------------------------------
  42. ///////////////////////////////////////////////////////////////////////////////
  43. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  44. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  45. // USER INCLUDES //////////////////////////////////////////////////////////////
  46. #include "GameClient/WinInstanceData.h"
  47. #include "GameClient/GameWindow.h"
  48. #include "GameClient/DisplayStringManager.h"
  49. #include "Common/Debug.h"
  50. // DEFINES ////////////////////////////////////////////////////////////////////
  51. // PRIVATE TYPES //////////////////////////////////////////////////////////////
  52. // PRIVATE DATA ///////////////////////////////////////////////////////////////
  53. // PUBLIC DATA ////////////////////////////////////////////////////////////////
  54. // PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
  55. // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
  56. ///////////////////////////////////////////////////////////////////////////////
  57. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
  58. ///////////////////////////////////////////////////////////////////////////////
  59. // WinInstanceData::WinInstanceData ===========================================
  60. //=============================================================================
  61. WinInstanceData::WinInstanceData( void )
  62. {
  63. // we don't allocate strings unless we need them
  64. m_text = NULL;
  65. m_tooltip = NULL;
  66. m_videoBuffer = NULL;
  67. init();
  68. } // end WinInstanceData
  69. // WinInstanceData::~WinInstanceData ==========================================
  70. //=============================================================================
  71. WinInstanceData::~WinInstanceData( void )
  72. {
  73. if( m_text )
  74. TheDisplayStringManager->freeDisplayString( m_text );
  75. if( m_tooltip )
  76. TheDisplayStringManager->freeDisplayString( m_tooltip );
  77. m_videoBuffer = NULL; //Video Buffer needs to be clean up by the control that is in charge of the video.
  78. } // end ~WinInstanceData
  79. // WinInstanceData::init ======================================================
  80. /** Set initial values for instance data if desired */
  81. //=============================================================================
  82. void WinInstanceData::init( void )
  83. {
  84. Int i;
  85. // init our draw data images/colors for the states
  86. for( i = 0; i < MAX_DRAW_DATA; i++ )
  87. {
  88. m_enabledDrawData[ i ].image = NULL;
  89. m_enabledDrawData[ i ].color = WIN_COLOR_UNDEFINED;
  90. m_enabledDrawData[ i ].borderColor = WIN_COLOR_UNDEFINED;
  91. m_disabledDrawData[ i ].image = NULL;
  92. m_disabledDrawData[ i ].color = WIN_COLOR_UNDEFINED;
  93. m_disabledDrawData[ i ].borderColor = WIN_COLOR_UNDEFINED;
  94. m_hiliteDrawData[ i ].image = NULL;
  95. m_hiliteDrawData[ i ].color = WIN_COLOR_UNDEFINED;
  96. m_hiliteDrawData[ i ].borderColor = WIN_COLOR_UNDEFINED;
  97. } // end for i
  98. // initialize text colors
  99. m_enabledText.color = WIN_COLOR_UNDEFINED;
  100. m_enabledText.borderColor = WIN_COLOR_UNDEFINED;
  101. m_disabledText.color = WIN_COLOR_UNDEFINED;
  102. m_disabledText.borderColor = WIN_COLOR_UNDEFINED;
  103. m_hiliteText.color = WIN_COLOR_UNDEFINED;
  104. m_hiliteText.borderColor = WIN_COLOR_UNDEFINED;
  105. m_id = 0;
  106. m_state = 0;
  107. m_style = 0;
  108. m_status = WIN_STATUS_NONE;
  109. m_owner = NULL;
  110. m_textLabelString.clear();
  111. m_tooltipString.clear();
  112. m_tooltipDelay = -1; ///< default value
  113. m_decoratedNameString.clear();
  114. m_imageOffset.x = 0;
  115. m_imageOffset.y = 0;
  116. // reset all data for the text display strings and font for window
  117. m_font = NULL;
  118. if( m_text )
  119. {
  120. TheDisplayStringManager->freeDisplayString( m_text );
  121. m_text = NULL;
  122. } // end if
  123. if( m_tooltip )
  124. {
  125. TheDisplayStringManager->freeDisplayString( m_tooltip );
  126. m_tooltip = NULL;
  127. } // end if
  128. m_videoBuffer = NULL;
  129. } // end init
  130. // WinInstanceData::setTooltipText ============================================
  131. //=============================================================================
  132. void WinInstanceData::setTooltipText( UnicodeString tip )
  133. {
  134. // allocate a text tooltip string if needed
  135. if( m_tooltip == NULL )
  136. m_tooltip = TheDisplayStringManager->newDisplayString();
  137. DEBUG_ASSERTCRASH( m_tooltip, ("no tooltip") );
  138. // set text
  139. m_tooltip->setText( tip );
  140. } // end setTooltipText
  141. // WinInstanceData:setText ====================================================
  142. /** Set the text for this window instance data */
  143. //=============================================================================
  144. void WinInstanceData::setText( UnicodeString text )
  145. {
  146. // allocate a text instance if needed
  147. if( m_text == NULL )
  148. m_text = TheDisplayStringManager->newDisplayString();
  149. DEBUG_ASSERTCRASH( m_text, ("no text") );
  150. // set the text
  151. m_text->setText( text );
  152. } // end set text
  153. // WinInstanceData:setText ====================================================
  154. /** Set the text for this window instance data */
  155. //=============================================================================
  156. void WinInstanceData::setVideoBuffer( VideoBuffer * videoBuffer )
  157. {
  158. m_videoBuffer = videoBuffer;
  159. }