GameWindowGlobal.cpp 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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: GameWindowGlobal.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: GameWindowGlobal.cpp
  36. //
  37. // Created: Colin Day, June 2001
  38. //
  39. // Desc: These are some global functions that every game using this
  40. // window system must implement for their current technology
  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/Language.h"
  48. #include "GameClient/Image.h"
  49. #include "GameClient/Display.h"
  50. #include "GameClient/GameWindowManager.h"
  51. #include "GameClient/GameFont.h"
  52. // DEFINES ////////////////////////////////////////////////////////////////////
  53. // PRIVATE TYPES //////////////////////////////////////////////////////////////
  54. // PRIVATE DATA ///////////////////////////////////////////////////////////////
  55. // PUBLIC DATA ////////////////////////////////////////////////////////////////
  56. // PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
  57. // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
  58. ///////////////////////////////////////////////////////////////////////////////
  59. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
  60. ///////////////////////////////////////////////////////////////////////////////
  61. // GameWindowManager::winDrawImage ============================================
  62. /** draw image, coord are in screen and should be kepth within
  63. * that box specified */
  64. //=============================================================================
  65. void GameWindowManager::winDrawImage( const Image *image, Int startX, Int startY,
  66. Int endX, Int endY, Color color )
  67. {
  68. TheDisplay->drawImage( image, startX, startY, endX, endY, color );
  69. } // end WinDrawImage
  70. // GameWindowManager::winFillRect =============================================
  71. /** draw filled rect, coords are absolute screen coords */
  72. //=============================================================================
  73. void GameWindowManager::winFillRect( Color color, Real width,
  74. Int startX, Int startY,
  75. Int endX, Int endY )
  76. {
  77. TheDisplay->drawFillRect( startX, startY,
  78. endX - startX, endY - startY,
  79. color );
  80. } // end WinFillRect
  81. // GameWindowManager::winOpenRect =============================================
  82. /** draw rect outline, coords are absolute screen coords */
  83. //=============================================================================
  84. void GameWindowManager::winOpenRect( Color color, Real width,
  85. Int startX, Int startY,
  86. Int endX, Int endY )
  87. {
  88. TheDisplay->drawOpenRect( startX, startY,
  89. endX - startX, endY - startY,
  90. width, color );
  91. } // end WinOpenRect
  92. // GameWindowManager::winDrawLine =============================================
  93. /** draw line, coords are absolute screen coords */
  94. //=============================================================================
  95. void GameWindowManager::winDrawLine( Color color, Real width,
  96. Int startX, Int startY,
  97. Int endX, Int endY )
  98. {
  99. TheDisplay->drawLine( startX, startY, endX, endY, width, color );
  100. } // end WinDrawLine
  101. // GameWindowManager::winFindImage ============================================
  102. /** Given an image name, return an image loc to that image information.
  103. * You may reorganize the image loc structure however you like to suit
  104. * your individual project */
  105. //=============================================================================
  106. const Image *GameWindowManager::winFindImage( const char *name )
  107. {
  108. assert( TheMappedImageCollection );
  109. if( TheMappedImageCollection )
  110. return TheMappedImageCollection->findImageByName( AsciiString( name ) );
  111. return NULL;
  112. } // end WinFindImage
  113. // GameWindowManager::winMakeColor ============================================
  114. /** Given RGBA, make a color, you can change color representation for your
  115. * individual project needs */
  116. //=============================================================================
  117. Color GameWindowManager::winMakeColor( UnsignedByte red,
  118. UnsignedByte green,
  119. UnsignedByte blue,
  120. UnsignedByte alpha )
  121. {
  122. return GameMakeColor( red, green, blue, alpha );
  123. } // end WinMakeColor
  124. // GameWindowManager::winFormatText ===========================================
  125. /** draw text to the screen */
  126. //=============================================================================
  127. void GameWindowManager::winFormatText( GameFont *font, UnicodeString text, Color color,
  128. Int x, Int y, Int width, Int height )
  129. {
  130. /// @todo make all display string rendering go through here!
  131. } // end WinFormatText
  132. // GameWindowManager::winGetTextSize ==========================================
  133. /** get the extent size of text */
  134. //=============================================================================
  135. void GameWindowManager::winGetTextSize( GameFont *font, UnicodeString text,
  136. Int *width, Int *height, Int maxWidth )
  137. {
  138. /// @todo make display string size stuff go through here
  139. if( width )
  140. *width = 0;
  141. if( height )
  142. *height = 0;
  143. } // end WinGetTextSize
  144. // GameWindowManager::winFontHeight ===========================================
  145. /** Return the font height in pixels */
  146. //=============================================================================
  147. Int GameWindowManager::winFontHeight( GameFont *font )
  148. {
  149. return font->height;
  150. } // end WinFontHeight
  151. // GameWindowManager::winIsDigit ==============================================
  152. /** You implementation of whether or not character is a digit */
  153. //=============================================================================
  154. Int GameWindowManager::winIsDigit( Int c )
  155. {
  156. return GameIsDigit( c );
  157. } // end WinIsDigit
  158. // GameWindowManager::winIsAscii ==============================================
  159. /** You implementation of whether or not character is ascii */
  160. //=============================================================================
  161. Int GameWindowManager::winIsAscii( Int c )
  162. {
  163. return GameIsAscii( c );
  164. } // end WinIsDigit
  165. // GameWindowManager::winIsAlNum ==============================================
  166. /** Your implementation of whether or not character is alpha numeric */
  167. //=============================================================================
  168. Int GameWindowManager::winIsAlNum( Int c )
  169. {
  170. return GameIsAlNum( c );
  171. } // end WinIsAlNum
  172. // GameWindowManager::winFindFont =============================================
  173. /** Get a font */
  174. //=============================================================================
  175. GameFont *GameWindowManager::winFindFont( AsciiString fontName,
  176. Int pointSize,
  177. Bool bold )
  178. {
  179. assert( TheFontLibrary );
  180. if( TheFontLibrary )
  181. return TheFontLibrary->getFont( fontName, pointSize, bold );
  182. return NULL;
  183. } // end WinFindFont