ControlBarBeacon.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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: ControlBarBeacon.cpp /////////////////////////////////////////////////////////////////////
  24. // Author: Colin Day, March 2002
  25. // Desc: Methods specific to the control bar beacon display
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. // USER INCLUDES //////////////////////////////////////////////////////////////////////////////////
  28. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  29. #include "Common/NameKeyGenerator.h"
  30. #include "Common/ThingTemplate.h"
  31. #include "GameClient/ControlBar.h"
  32. #include "GameClient/Drawable.h"
  33. #include "GameClient/GameWindow.h"
  34. #include "GameClient/GadgetTextEntry.h"
  35. #include "GameClient/InGameUI.h"
  36. #include "GameLogic/Object.h"
  37. //-------------------------------------------------------------------------------------------------
  38. //-------------------------------------------------------------------------------------------------
  39. void ControlBar::populateBeacon( Object *beacon )
  40. {
  41. // set the portrait for the thing being constructed
  42. setPortraitByObject( beacon );
  43. static NameKeyType textID = NAMEKEY("ControlBar.wnd:EditBeaconText");
  44. static NameKeyType staticTextID = NAMEKEY("ControlBar.wnd:StaticTextBeaconLabel");
  45. static NameKeyType clearButtonID = NAMEKEY("ControlBar.wnd:ButtonClearBeaconText");
  46. GameWindow *textEntryWin = TheWindowManager->winGetWindowFromId(NULL, textID);
  47. GameWindow *staticTextWin = TheWindowManager->winGetWindowFromId(NULL, staticTextID);
  48. GameWindow *buttonWin = TheWindowManager->winGetWindowFromId(NULL, clearButtonID);
  49. if (beacon->isLocallyControlled())
  50. {
  51. if (textEntryWin)
  52. {
  53. textEntryWin->winHide(FALSE);
  54. GadgetTextEntrySetText( textEntryWin, beacon->getDrawable()->getCaptionText() );
  55. TheWindowManager->winSetFocus( textEntryWin );
  56. }
  57. if (staticTextWin)
  58. staticTextWin->winHide(FALSE);
  59. if (buttonWin)
  60. buttonWin->winHide(FALSE);
  61. }
  62. else
  63. {
  64. if (textEntryWin)
  65. textEntryWin->winHide(TRUE);
  66. if (staticTextWin)
  67. staticTextWin->winHide(TRUE);
  68. if (buttonWin)
  69. buttonWin->winHide(TRUE);
  70. }
  71. } // end populateBeacon
  72. //-------------------------------------------------------------------------------------------------
  73. //-------------------------------------------------------------------------------------------------
  74. void ControlBar::updateContextBeacon( void )
  75. {
  76. } // end updateContextBeacon
  77. //-------------------------------------------------------------------------------------------------
  78. //-------------------------------------------------------------------------------------------------
  79. WindowMsgHandledType BeaconWindowInput( GameWindow *window, UnsignedInt msg,
  80. WindowMsgData mData1, WindowMsgData mData2 )
  81. {
  82. if (msg == GWM_CHAR && mData1 == KEY_ESC)
  83. {
  84. TheInGameUI->deselectAllDrawables(TRUE); // there should only be one beacon and nothing else selected
  85. return MSG_HANDLED;
  86. }
  87. return MSG_IGNORED;
  88. } // end InGameChatInput