PopupCommunicator.cpp 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. // FILE: PopupCommunicator.cpp /////////////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Electronic Arts Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2002 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // Project: RTS3
  34. //
  35. // File name: PopupCommunicator.cpp
  36. //
  37. // Created: Chris Brue, July 2002
  38. //
  39. // Desc: Electronic Arts instant messaging system
  40. //
  41. //-----------------------------------------------------------------------------
  42. ///////////////////////////////////////////////////////////////////////////////
  43. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  44. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  45. #include "GameClient/GUICallbacks.h"
  46. #include "GameClient/GameWindowManager.h"
  47. // PRIVATE DATA ///////////////////////////////////////////////////////////////////////////////////
  48. static NameKeyType buttonOkID = NAMEKEY_INVALID;
  49. static GameWindow *buttonOk = NULL;
  50. static GameWindow *parent = NULL;
  51. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////////////////////////
  52. //-------------------------------------------------------------------------------------------------
  53. /** Initialize the Popup Communicator */
  54. //-------------------------------------------------------------------------------------------------
  55. void PopupCommunicatorInit( WindowLayout *layout, void *userData )
  56. {
  57. //set keyboard focus to main parent and set modal
  58. NameKeyType parentID = TheNameKeyGenerator->nameToKey("PopupCommunicator.wnd:PopupCommunicator");
  59. parent = TheWindowManager->winGetWindowFromId( NULL, parentID );
  60. TheWindowManager->winSetFocus( parent );
  61. TheWindowManager->winSetModal( parent );
  62. // get ids for our children controls
  63. buttonOkID = TheNameKeyGenerator->nameToKey( AsciiString("PopupCommunicator.wnd:ButtonOk") );
  64. buttonOk = TheWindowManager->winGetWindowFromId( parent, buttonOkID );
  65. } // end PopupCommunicatorInit
  66. //-------------------------------------------------------------------------------------------------
  67. /** Popup Communicator shutdown method */
  68. //-------------------------------------------------------------------------------------------------
  69. void PopupCommunicatorShutdown( WindowLayout *layout, void *userData )
  70. {
  71. } // end PopupCommunicatorShutdown
  72. //-------------------------------------------------------------------------------------------------
  73. /** Popup Communicator update method */
  74. //-------------------------------------------------------------------------------------------------
  75. void PopupcommunicatorUpdate( WindowLayout *layout, void *userData )
  76. {
  77. } // end PopupCommunicatorUpdate
  78. //-------------------------------------------------------------------------------------------------
  79. /** Popup Communicator input callback */
  80. //-------------------------------------------------------------------------------------------------
  81. WindowMsgHandledType PopupCommunicatorInput( GameWindow *window, UnsignedInt msg,
  82. WindowMsgData mData1, WindowMsgData mData2 )
  83. {
  84. switch( msg )
  85. {
  86. // --------------------------------------------------------------------------------------------
  87. case GWM_CHAR:
  88. {
  89. UnsignedByte key = mData1;
  90. UnsignedByte state = mData2;
  91. switch( key )
  92. {
  93. // ----------------------------------------------------------------------------------------
  94. case KEY_ESC:
  95. {
  96. //
  97. // send a simulated selected event to the parent window of the
  98. // back/exit button
  99. //
  100. if( BitTest( state, KEY_STATE_UP ) )
  101. {
  102. TheWindowManager->winSendSystemMsg( window, GBM_SELECTED,
  103. (WindowMsgData)buttonOk, buttonOkID );
  104. } // end if
  105. // don't let key fall through anywhere else
  106. return MSG_HANDLED;
  107. } // end escape
  108. } // end switch( key )
  109. } // end char
  110. } // end switch( msg )
  111. return MSG_IGNORED;
  112. } // end PopupCommunicatorInput
  113. //-------------------------------------------------------------------------------------------------
  114. /** Popup Communicator window system callback */
  115. //-------------------------------------------------------------------------------------------------
  116. WindowMsgHandledType PopupCommunicatorSystem( GameWindow *window, UnsignedInt msg,
  117. WindowMsgData mData1, WindowMsgData mData2 )
  118. {
  119. switch( msg )
  120. {
  121. // --------------------------------------------------------------------------------------------
  122. case GWM_CREATE:
  123. {
  124. break;
  125. } // end create
  126. //---------------------------------------------------------------------------------------------
  127. case GWM_DESTROY:
  128. {
  129. break;
  130. } // end case
  131. //----------------------------------------------------------------------------------------------
  132. case GWM_INPUT_FOCUS:
  133. {
  134. // if we're givin the opportunity to take the keyboard focus we must say we want it
  135. if( mData1 == TRUE )
  136. *(Bool *)mData2 = TRUE;
  137. break;
  138. } // end input
  139. //---------------------------------------------------------------------------------------------
  140. case GBM_SELECTED:
  141. {
  142. GameWindow *control = (GameWindow *)mData1;
  143. Int controlID = control->winGetWindowId();
  144. if( controlID == buttonOkID )
  145. {
  146. WindowLayout *popupCommunicatorLayout = window->winGetLayout();
  147. popupCommunicatorLayout->destroyWindows();
  148. popupCommunicatorLayout->deleteInstance();
  149. popupCommunicatorLayout = NULL;
  150. } // end if
  151. break;
  152. } // end selected
  153. default:
  154. return MSG_IGNORED;
  155. } // end switch
  156. return MSG_HANDLED;
  157. }