WOLLadderScreen.cpp 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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: ReplayMenu.cpp /////////////////////////////////////////////////////////////////////
  24. // Author: Chris The masta Huybregts, December 2001
  25. // Description: Replay Menus
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  28. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  29. #include "Common/GameEngine.h"
  30. #include "GameClient/WindowLayout.h"
  31. #include "GameClient/Shell.h"
  32. #include "GameClient/KeyDefs.h"
  33. #include "GameClient/GameWindowManager.h"
  34. #include "GameClient/MessageBox.h"
  35. #include "GameNetwork/WOLBrowser/WebBrowser.h"
  36. // window ids -------------------------------------------------------------------------------------
  37. static NameKeyType parentWindowID = NAMEKEY_INVALID;
  38. static NameKeyType buttonBackID = NAMEKEY_INVALID;
  39. static NameKeyType windowLadderID = NAMEKEY_INVALID;
  40. // window pointers --------------------------------------------------------------------------------
  41. static GameWindow *parentWindow = NULL;
  42. static GameWindow *buttonBack = NULL;
  43. static GameWindow *windowLadder = NULL;
  44. //-------------------------------------------------------------------------------------------------
  45. /** Initialize the single player menu */
  46. //-------------------------------------------------------------------------------------------------
  47. void WOLLadderScreenInit( WindowLayout *layout, void *userData )
  48. {
  49. TheShell->showShellMap(TRUE);
  50. // get ids for our children controls
  51. parentWindowID = TheNameKeyGenerator->nameToKey( AsciiString("WOLLadderScreen.wnd:LadderParent") );
  52. buttonBackID = TheNameKeyGenerator->nameToKey( AsciiString("WOLLadderScreen.wnd:ButtonBack") );
  53. windowLadderID = TheNameKeyGenerator->nameToKey( AsciiString("WOLLadderScreen.wnd:WindowLadder") );
  54. parentWindow = TheWindowManager->winGetWindowFromId( NULL, parentWindowID );
  55. buttonBack = TheWindowManager->winGetWindowFromId( parentWindow, buttonBackID );
  56. windowLadder = TheWindowManager->winGetWindowFromId( parentWindow, windowLadderID );
  57. //Load the listbox shiznit
  58. // PopulateReplayFileListbox(listboxReplayFiles);
  59. //TheWebBrowser->createBrowserWindow("Westwood", windowLadder);
  60. if (TheWebBrowser != NULL)
  61. {
  62. TheWebBrowser->createBrowserWindow("MessageBoard", windowLadder);
  63. }
  64. // show menu
  65. layout->hide( FALSE );
  66. // set keyboard focus to main parent
  67. TheWindowManager->winSetFocus( parentWindow );
  68. } // end ReplayMenuInit
  69. //-------------------------------------------------------------------------------------------------
  70. /** single player menu shutdown method */
  71. //-------------------------------------------------------------------------------------------------
  72. void WOLLadderScreenShutdown( WindowLayout *layout, void *userData )
  73. {
  74. if (TheWebBrowser != NULL)
  75. {
  76. TheWebBrowser->closeBrowserWindow(windowLadder);
  77. }
  78. // hide menu
  79. layout->hide( TRUE );
  80. // our shutdown is complete
  81. TheShell->shutdownComplete( layout );
  82. } // end ReplayMenuShutdown
  83. //-------------------------------------------------------------------------------------------------
  84. /** single player menu update method */
  85. //-------------------------------------------------------------------------------------------------
  86. void WOLLadderScreenUpdate( WindowLayout *layout, void *userData )
  87. {
  88. } // end ReplayMenuUpdate
  89. //-------------------------------------------------------------------------------------------------
  90. /** Replay menu input callback */
  91. //-------------------------------------------------------------------------------------------------
  92. WindowMsgHandledType WOLLadderScreenInput( GameWindow *window, UnsignedInt msg,
  93. WindowMsgData mData1, WindowMsgData mData2 )
  94. {
  95. switch( msg )
  96. {
  97. // --------------------------------------------------------------------------------------------
  98. case GWM_CHAR:
  99. {
  100. UnsignedByte key = mData1;
  101. UnsignedByte state = mData2;
  102. switch( key )
  103. {
  104. // ----------------------------------------------------------------------------------------
  105. case KEY_ESC:
  106. {
  107. //
  108. // send a simulated selected event to the parent window of the
  109. // back/exit button
  110. //
  111. if( BitTest( state, KEY_STATE_UP ) )
  112. {
  113. TheWindowManager->winSendSystemMsg( window, GBM_SELECTED,
  114. (WindowMsgData)buttonBack, buttonBackID );
  115. } // end if
  116. // don't let key fall through anywhere else
  117. return MSG_HANDLED;
  118. } // end escape
  119. } // end switch( key )
  120. } // end char
  121. } // end switch( msg )
  122. return MSG_IGNORED;
  123. } // end ReplayMenuInput
  124. //-------------------------------------------------------------------------------------------------
  125. /** single player menu window system callback */
  126. //-------------------------------------------------------------------------------------------------
  127. WindowMsgHandledType WOLLadderScreenSystem( GameWindow *window, UnsignedInt msg,
  128. WindowMsgData mData1, WindowMsgData mData2 )
  129. {
  130. switch( msg )
  131. {
  132. // --------------------------------------------------------------------------------------------
  133. case GWM_CREATE:
  134. {
  135. break;
  136. } // end create
  137. //---------------------------------------------------------------------------------------------
  138. case GWM_DESTROY:
  139. {
  140. break;
  141. } // end case
  142. // --------------------------------------------------------------------------------------------
  143. case GWM_INPUT_FOCUS:
  144. {
  145. // if we're givin the opportunity to take the keyboard focus we must say we want it
  146. if( mData1 == TRUE )
  147. *(Bool *)mData2 = TRUE;
  148. return MSG_HANDLED;
  149. } // end input
  150. //---------------------------------------------------------------------------------------------
  151. case GBM_SELECTED:
  152. {
  153. GameWindow *control = (GameWindow *)mData1;
  154. Int controlID = control->winGetWindowId();
  155. if( controlID == buttonBackID )
  156. {
  157. // thou art directed to return to thy known solar system immediately!
  158. TheShell->pop();
  159. } // end else if
  160. break;
  161. } // end selected
  162. default:
  163. return MSG_IGNORED;
  164. } // end switch
  165. return MSG_HANDLED;
  166. } // end ReplayMenuSystem