WOLStatusMenu.cpp 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. ///////////////////////////////////////////////////////////////////////////////////////
  24. // FILE: WOLLoginMenu.cpp
  25. // Author: Chris Huybregts, November 2001
  26. // Description: Lan Lobby Menu
  27. ///////////////////////////////////////////////////////////////////////////////////////
  28. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  29. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  30. #include "Common/GameEngine.h"
  31. #include "GameClient/WindowLayout.h"
  32. #include "GameClient/Gadget.h"
  33. #include "GameClient/Shell.h"
  34. #include "GameClient/KeyDefs.h"
  35. #include "GameClient/GameWindowManager.h"
  36. #include "GameClient/GadgetListBox.h"
  37. #include "GameClient/GadgetTextEntry.h"
  38. //#include "GameNetwork/WOL.h"
  39. //#include "GameNetwork/WOLmenus.h"
  40. // PRIVATE DATA ///////////////////////////////////////////////////////////////////////////////////
  41. // window ids ------------------------------------------------------------------------------
  42. static NameKeyType parentWOLStatusID = NAMEKEY_INVALID;
  43. static NameKeyType buttonDisconnectID = NAMEKEY_INVALID;
  44. // Window Pointers ------------------------------------------------------------------------
  45. static GameWindow *parentWOLStatus = NULL;
  46. static GameWindow *buttonDisconnect = NULL;
  47. GameWindow *progressTextWindow = NULL;
  48. //-------------------------------------------------------------------------------------------------
  49. /** Initialize the WOL Status Menu */
  50. //-------------------------------------------------------------------------------------------------
  51. void WOLStatusMenuInit( WindowLayout *layout, void *userData )
  52. {
  53. parentWOLStatusID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLStatusMenu.wnd:WOLStatusMenuParent" ) );
  54. buttonDisconnectID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLStatusMenu.wnd:ButtonDisconnect" ) );
  55. parentWOLStatus = TheWindowManager->winGetWindowFromId( NULL, parentWOLStatusID );
  56. buttonDisconnect = TheWindowManager->winGetWindowFromId( NULL, buttonDisconnectID);
  57. progressTextWindow = TheWindowManager->winGetWindowFromId( NULL,
  58. TheNameKeyGenerator->nameToKey( AsciiString( "WOLStatusMenu.wnd:ListboxStatus" ) ) );
  59. // Show Menu
  60. layout->hide( FALSE );
  61. // Set Keyboard to Main Parent
  62. TheWindowManager->winSetFocus( parentWOLStatus );
  63. //progressLayout = TheShell->top();
  64. //WOL::raiseWOLMessageBox();
  65. } // WOLStatusMenuInit
  66. //-------------------------------------------------------------------------------------------------
  67. /** WOL Status Menu shutdown method */
  68. //-------------------------------------------------------------------------------------------------
  69. void WOLStatusMenuShutdown( WindowLayout *layout, void *userData )
  70. {
  71. // hide menu
  72. layout->hide( TRUE );
  73. // our shutdown is complete
  74. TheShell->shutdownComplete( layout );
  75. //progressLayout = NULL;
  76. //WOL::raiseWOLMessageBox();
  77. } // WOLStatusMenuShutdown
  78. //-------------------------------------------------------------------------------------------------
  79. /** WOL Status Menu update method */
  80. //-------------------------------------------------------------------------------------------------
  81. void WOLStatusMenuUpdate( WindowLayout * layout, void *userData)
  82. {
  83. //if (WOL::TheWOL)
  84. //WOL::TheWOL->update();
  85. }// WOLStatusMenuUpdate
  86. //-------------------------------------------------------------------------------------------------
  87. /** WOL Status Menu input callback */
  88. //-------------------------------------------------------------------------------------------------
  89. WindowMsgHandledType WOLStatusMenuInput( GameWindow *window, UnsignedInt msg,
  90. WindowMsgData mData1, WindowMsgData mData2 )
  91. {
  92. switch( msg )
  93. {
  94. // --------------------------------------------------------------------------------------------
  95. case GWM_CHAR:
  96. {
  97. UnsignedByte key = mData1;
  98. UnsignedByte state = mData2;
  99. switch( key )
  100. {
  101. // ----------------------------------------------------------------------------------------
  102. case KEY_ESC:
  103. {
  104. //
  105. // send a simulated selected event to the parent window of the
  106. // back/exit button
  107. //
  108. if( BitTest( state, KEY_STATE_UP ) )
  109. {
  110. TheWindowManager->winSendSystemMsg( window, GBM_SELECTED,
  111. (WindowMsgData)buttonDisconnect, buttonDisconnectID );
  112. } // end if
  113. // don't let key fall through anywhere else
  114. return MSG_HANDLED;
  115. } // end escape
  116. } // end switch( key )
  117. } // end char
  118. } // end switch( msg )
  119. return MSG_IGNORED;
  120. }// WOLStatusMenuInput
  121. //-------------------------------------------------------------------------------------------------
  122. /** WOL Status Menu window system callback */
  123. //-------------------------------------------------------------------------------------------------
  124. WindowMsgHandledType WOLStatusMenuSystem( GameWindow *window, UnsignedInt msg,
  125. WindowMsgData mData1, WindowMsgData mData2 )
  126. {
  127. UnicodeString txtInput;
  128. switch( msg )
  129. {
  130. case GWM_CREATE:
  131. {
  132. break;
  133. } // case GWM_DESTROY:
  134. case GWM_DESTROY:
  135. {
  136. break;
  137. } // case GWM_DESTROY:
  138. case GWM_INPUT_FOCUS:
  139. {
  140. // if we're givin the opportunity to take the keyboard focus we must say we want it
  141. if( mData1 == TRUE )
  142. *(Bool *)mData2 = TRUE;
  143. return MSG_HANDLED;
  144. }//case GWM_INPUT_FOCUS:
  145. case GBM_SELECTED:
  146. {
  147. /*
  148. GameWindow *control = (GameWindow *)mData1;
  149. Int controlID = control->winGetWindowId();
  150. if ( controlID == buttonDisconnectID )
  151. {
  152. //TheShell->pop();
  153. if (WOL::TheWOL->setState( WOL::WOLAPI_FATAL_ERROR ))
  154. {
  155. WOL::TheWOL->addCommand( WOL::WOLCOMMAND_RESET ); // don't display an error, log out, or anything
  156. }
  157. } //if ( controlID == buttonDisconnect )
  158. */
  159. break;
  160. }// case GBM_SELECTED:
  161. case GEM_EDIT_DONE:
  162. {
  163. break;
  164. }
  165. default:
  166. return MSG_IGNORED;
  167. }//Switch
  168. return MSG_HANDLED;
  169. }// WOLStatusMenuSystem