CreditsMenu.cpp 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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: CreditsMenu.cpp /////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Electronic Arts Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2002 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // created: Dec 2002
  34. //
  35. // Filename: CreditsMenu.cpp
  36. //
  37. // author: Chris Huybregts
  38. //
  39. // purpose: The credits screen...yay
  40. //
  41. //-----------------------------------------------------------------------------
  42. ///////////////////////////////////////////////////////////////////////////////
  43. //-----------------------------------------------------------------------------
  44. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  45. //-----------------------------------------------------------------------------
  46. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  47. #ifdef _INTERNAL
  48. // for occasional debugging...
  49. //#pragma optimize("", off)
  50. //#pragma message("************************************** WARNING, optimization disabled for debugging purposes")
  51. #endif
  52. //-----------------------------------------------------------------------------
  53. // USER INCLUDES //////////////////////////////////////////////////////////////
  54. //-----------------------------------------------------------------------------
  55. #include "Common/GameAudio.h"
  56. #include "Common/AudioEventRTS.h"
  57. #include "Common/AudioHandleSpecialValues.h"
  58. #include "GameClient/Credits.h"
  59. #include "GameClient/WindowLayout.h"
  60. #include "GameClient/Gadget.h"
  61. #include "GameClient/Shell.h"
  62. #include "GameClient/KeyDefs.h"
  63. #include "GameClient/GameWindowManager.h"
  64. //-----------------------------------------------------------------------------
  65. // DEFINES ////////////////////////////////////////////////////////////////////
  66. //-----------------------------------------------------------------------------
  67. static NameKeyType parentMainMenuID = NAMEKEY_INVALID;
  68. // window pointers --------------------------------------------------------------------------------
  69. static GameWindow *parentMainMenu = NULL;
  70. //-----------------------------------------------------------------------------
  71. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
  72. //-----------------------------------------------------------------------------
  73. //-------------------------------------------------------------------------------------------------
  74. /** Initialize the single player menu */
  75. //-------------------------------------------------------------------------------------------------
  76. void CreditsMenuInit( WindowLayout *layout, void *userData )
  77. {
  78. TheShell->showShellMap(FALSE);
  79. if(TheCredits)
  80. delete TheCredits;
  81. TheCredits = new CreditsManager;
  82. TheCredits->load();
  83. TheCredits->init();
  84. parentMainMenuID = TheNameKeyGenerator->nameToKey( AsciiString("CreditsMenu.wnd:ParentCreditsWindow") );
  85. parentMainMenu = TheWindowManager->winGetWindowFromId( NULL, parentMainMenuID );
  86. // show menu
  87. layout->hide( FALSE );
  88. // set keyboard focus to main parent
  89. TheWindowManager->winSetFocus( parentMainMenu );
  90. TheAudio->removeAudioEvent( AHSV_StopTheMusicFade );
  91. AudioEventRTS event( AsciiString( "Credits" ) );
  92. event.setShouldFade( TRUE );
  93. TheAudio->addAudioEvent( &event );
  94. } // end CreditsMenuInit
  95. //-------------------------------------------------------------------------------------------------
  96. /** single player menu shutdown method */
  97. //-------------------------------------------------------------------------------------------------
  98. void CreditsMenuShutdown( WindowLayout *layout, void *userData )
  99. {
  100. TheCredits->reset();
  101. delete TheCredits;
  102. TheCredits = NULL;
  103. TheShell->showShellMap(TRUE);
  104. // hide menu
  105. layout->hide( TRUE );
  106. // our shutdown is complete
  107. TheShell->shutdownComplete( layout );
  108. TheAudio->removeAudioEvent( AHSV_StopTheMusicFade );
  109. } // end CreditsMenuShutdown
  110. //-------------------------------------------------------------------------------------------------
  111. /** single player menu update method */
  112. //-------------------------------------------------------------------------------------------------
  113. void CreditsMenuUpdate( WindowLayout *layout, void *userData )
  114. {
  115. if(TheCredits)
  116. {
  117. TheWindowManager->winSetFocus( parentMainMenu );
  118. TheCredits->update();
  119. if(TheCredits->isFinished())
  120. TheShell->pop();
  121. }
  122. else
  123. TheShell->pop();
  124. } // end CreditsMenuUpdate
  125. //-------------------------------------------------------------------------------------------------
  126. /** Replay menu input callback */
  127. //-------------------------------------------------------------------------------------------------
  128. WindowMsgHandledType CreditsMenuInput( GameWindow *window, UnsignedInt msg,
  129. WindowMsgData mData1, WindowMsgData mData2 )
  130. {
  131. switch( msg )
  132. {
  133. // --------------------------------------------------------------------------------------------
  134. case GWM_CHAR:
  135. {
  136. UnsignedByte key = mData1;
  137. UnsignedByte state = mData2;
  138. switch( key )
  139. {
  140. // ----------------------------------------------------------------------------------------
  141. case KEY_ESC:
  142. {
  143. //
  144. // send a simulated selected event to the parent window of the
  145. // back/exit button
  146. //
  147. if( BitTest( state, KEY_STATE_UP ) )
  148. {
  149. TheShell->pop();
  150. } // end if
  151. // don't let key fall through anywhere else
  152. return MSG_HANDLED;
  153. } // end escape
  154. } // end switch( key )
  155. } // end char
  156. } // end switch( msg )
  157. return MSG_IGNORED;
  158. } // end CreditsMenuInput
  159. //-------------------------------------------------------------------------------------------------
  160. /** single player menu window system callback */
  161. //-------------------------------------------------------------------------------------------------
  162. WindowMsgHandledType CreditsMenuSystem( GameWindow *window, UnsignedInt msg,
  163. WindowMsgData mData1, WindowMsgData mData2 )
  164. {
  165. switch( msg )
  166. {
  167. // --------------------------------------------------------------------------------------------
  168. case GWM_CREATE:
  169. {
  170. break;
  171. } // end create
  172. //---------------------------------------------------------------------------------------------
  173. case GWM_DESTROY:
  174. {
  175. break;
  176. } // end case
  177. // --------------------------------------------------------------------------------------------
  178. case GWM_INPUT_FOCUS:
  179. {
  180. // if we're givin the opportunity to take the keyboard focus we must say we want it
  181. if( mData1 == TRUE )
  182. *(Bool *)mData2 = TRUE;
  183. return MSG_HANDLED;
  184. } // end input
  185. //---------------------------------------------------------------------------------------------
  186. case GBM_SELECTED:
  187. {
  188. break;
  189. } // end selected
  190. default:
  191. return MSG_IGNORED;
  192. } // end switch
  193. return MSG_HANDLED;
  194. } // end CreditsMenuSystem
  195. //-----------------------------------------------------------------------------
  196. // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
  197. //-----------------------------------------------------------------------------