WOLMessageWindow.cpp 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. ** Command & Conquer Generals(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: WOLMessageWindow.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/IPEnumeration.h"
  39. //#include "GameNetwork/WOL.h"
  40. // PRIVATE DATA ///////////////////////////////////////////////////////////////////////////////////
  41. // window ids ------------------------------------------------------------------------------
  42. static NameKeyType parentWOLMessageWindowID = NAMEKEY_INVALID;
  43. static NameKeyType buttonCancelID = NAMEKEY_INVALID;
  44. // Window Pointers ------------------------------------------------------------------------
  45. static GameWindow *parentWOLMessageWindow = NULL;
  46. static GameWindow *buttonCancel = NULL;
  47. //-------------------------------------------------------------------------------------------------
  48. /** Initialize the WOLMessage Window */
  49. //-------------------------------------------------------------------------------------------------
  50. void WOLMessageWindowInit( WindowLayout *layout, void *userData )
  51. {
  52. parentWOLMessageWindowID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLMessageWindow.wnd:WOLMessageWindowParent" ) );
  53. buttonCancelID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLMessageWindow.wnd:ButtonCancel" ) );
  54. parentWOLMessageWindow = TheWindowManager->winGetWindowFromId( NULL, parentWOLMessageWindowID );
  55. buttonCancel = TheWindowManager->winGetWindowFromId( NULL, buttonCancelID);
  56. // Show Menu
  57. layout->hide( FALSE );
  58. // Set Keyboard to Main Parent
  59. TheWindowManager->winSetFocus( parentWOLMessageWindow );
  60. } // WOLMessageWindowInit
  61. //-------------------------------------------------------------------------------------------------
  62. /** WOLMessage Window shutdown method */
  63. //-------------------------------------------------------------------------------------------------
  64. void WOLMessageWindowShutdown( WindowLayout *layout, void *userData )
  65. {
  66. // hide menu
  67. layout->hide( TRUE );
  68. // our shutdown is complete
  69. TheShell->shutdownComplete( layout );
  70. } // WOLMessageWindowShutdown
  71. //-------------------------------------------------------------------------------------------------
  72. /** WOLMessage Window update method */
  73. //-------------------------------------------------------------------------------------------------
  74. void WOLMessageWindowUpdate( WindowLayout * layout, void *userData)
  75. {
  76. /*
  77. if (WOL::TheWOL)
  78. WOL::TheWOL->update();
  79. */
  80. }// WOLMessageWindowUpdate
  81. //-------------------------------------------------------------------------------------------------
  82. /** WOLMessage Window input callback */
  83. //-------------------------------------------------------------------------------------------------
  84. WindowMsgHandledType WOLMessageWindowInput( GameWindow *window, UnsignedInt msg,
  85. WindowMsgData mData1, WindowMsgData mData2 )
  86. {
  87. switch( msg )
  88. {
  89. // --------------------------------------------------------------------------------------------
  90. case GWM_CHAR:
  91. {
  92. UnsignedByte key = mData1;
  93. UnsignedByte state = mData2;
  94. switch( key )
  95. {
  96. // ----------------------------------------------------------------------------------------
  97. case KEY_ESC:
  98. {
  99. //
  100. // send a simulated selected event to the parent window of the
  101. // back/exit button
  102. //
  103. if( BitTest( state, KEY_STATE_UP ) )
  104. {
  105. TheWindowManager->winSendSystemMsg( window, GBM_SELECTED,
  106. (WindowMsgData)buttonCancel, buttonCancelID );
  107. } // end if
  108. // don't let key fall through anywhere else
  109. return MSG_HANDLED;
  110. } // end escape
  111. } // end switch( key )
  112. } // end char
  113. } // end switch( msg )
  114. return MSG_IGNORED;
  115. }// WOLMessageWindowInput
  116. //-------------------------------------------------------------------------------------------------
  117. /** WOLMessage Window window system callback */
  118. //-------------------------------------------------------------------------------------------------
  119. WindowMsgHandledType WOLMessageWindowSystem( GameWindow *window, UnsignedInt msg,
  120. WindowMsgData mData1, WindowMsgData mData2 )
  121. {
  122. UnicodeString txtInput;
  123. switch( msg )
  124. {
  125. case GWM_CREATE:
  126. {
  127. break;
  128. } // case GWM_DESTROY:
  129. case GWM_DESTROY:
  130. {
  131. break;
  132. } // case GWM_DESTROY:
  133. case GWM_INPUT_FOCUS:
  134. {
  135. // if we're givin the opportunity to take the keyboard focus we must say we want it
  136. if( mData1 == TRUE )
  137. *(Bool *)mData2 = TRUE;
  138. return MSG_HANDLED;
  139. }//case GWM_INPUT_FOCUS:
  140. case GBM_SELECTED:
  141. {
  142. break;
  143. }// case GBM_SELECTED:
  144. case GEM_EDIT_DONE:
  145. {
  146. break;
  147. }
  148. default:
  149. return MSG_IGNORED;
  150. }//Switch
  151. return MSG_HANDLED;
  152. }// WOLMessageWindowSystem