HintSpy.cpp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. // HintSpy.cpp
  24. // The HintSpy sits on the message stream and watches for certain messages,
  25. // for which it then generates visual "hints".
  26. // Author: Michael S. Booth, March 2001
  27. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  28. #include "Common/MessageStream.h"
  29. #include "GameClient/HintSpy.h"
  30. #include "GameClient/GameWindowManager.h"
  31. #include "GameClient/GameWindow.h"
  32. #include "GameClient/GameClient.h"
  33. #include "GameClient/Drawable.h"
  34. /**
  35. * This message handler displays UI "hints" (ie: a rectangle for drag selection) based
  36. * upon the messages that pass through it.
  37. */
  38. GameMessageDisposition HintSpyTranslator::translateGameMessage(const GameMessage *msg)
  39. {
  40. GameMessageDisposition disp = KEEP_MESSAGE;
  41. /// @todo Create an automated way to associate method callbacks with messages
  42. switch( msg->getType() )
  43. {
  44. //-----------------------------------------------------------------------------
  45. case GameMessage::MSG_MOUSEOVER_DRAWABLE_HINT:
  46. {
  47. TheInGameUI->createMouseoverHint( msg );
  48. disp = DESTROY_MESSAGE; //hint no longer needed by anyone. Eat it.
  49. }
  50. break;
  51. case GameMessage::MSG_MOUSEOVER_LOCATION_HINT:
  52. {
  53. TheInGameUI->createMouseoverHint( msg );
  54. disp = DESTROY_MESSAGE; //hint no longer needed by anyone. Eat it.
  55. }
  56. break;
  57. //-----------------------------------------------------------------------------
  58. case GameMessage::MSG_DEFECTOR_HINT:
  59. disp = DESTROY_MESSAGE; //hint no longer needed by anyone. Eat it.
  60. case GameMessage::MSG_DO_MOVETO_HINT:
  61. case GameMessage::MSG_DO_ATTACKMOVETO_HINT:
  62. case GameMessage::MSG_DO_ATTACK_OBJECT_HINT:
  63. case GameMessage::MSG_DO_ATTACK_OBJECT_AFTER_MOVING_HINT:
  64. case GameMessage::MSG_DO_FORCE_ATTACK_OBJECT_HINT:
  65. case GameMessage::MSG_DO_FORCE_ATTACK_GROUND_HINT:
  66. case GameMessage::MSG_ADD_WAYPOINT_HINT:
  67. case GameMessage::MSG_GET_REPAIRED_HINT:
  68. case GameMessage::MSG_DOCK_HINT:
  69. case GameMessage::MSG_GET_HEALED_HINT:
  70. case GameMessage::MSG_DO_REPAIR_HINT:
  71. case GameMessage::MSG_RESUME_CONSTRUCTION_HINT:
  72. case GameMessage::MSG_ENTER_HINT:
  73. case GameMessage::MSG_HIJACK_HINT:
  74. case GameMessage::MSG_SABOTAGE_HINT:
  75. case GameMessage::MSG_CONVERT_TO_CARBOMB_HINT:
  76. #ifdef ALLOW_SURRENDER
  77. case GameMessage::MSG_PICK_UP_PRISONER_HINT:
  78. #endif
  79. case GameMessage::MSG_VALID_GUICOMMAND_HINT:
  80. case GameMessage::MSG_INVALID_GUICOMMAND_HINT:
  81. case GameMessage::MSG_CAPTUREBUILDING_HINT:
  82. case GameMessage::MSG_HACK_HINT:
  83. case GameMessage::MSG_SET_RALLY_POINT_HINT:
  84. case GameMessage::MSG_IMPOSSIBLE_ATTACK_HINT:
  85. case GameMessage::MSG_DO_SPECIAL_POWER_OVERRIDE_DESTINATION_HINT:
  86. case GameMessage::MSG_DO_SALVAGE_HINT:
  87. case GameMessage::MSG_DO_INVALID_HINT:
  88. TheInGameUI->createCommandHint( msg );
  89. disp = DESTROY_MESSAGE; //hint no longer needed by anyone. Eat it.
  90. break;
  91. //-----------------------------------------------------------------------------
  92. case GameMessage::MSG_AREA_SELECTION_HINT:
  93. TheInGameUI->beginAreaSelectHint( msg );
  94. break;
  95. //-----------------------------------------------------------------------------
  96. // An AREA_SELECTION_HINT is always followed by an AREA_SELECTION, so
  97. // watch for it to stop hinting.
  98. case GameMessage::MSG_AREA_SELECTION:
  99. TheInGameUI->endAreaSelectHint( msg );
  100. break;
  101. //-----------------------------------------------------------------------------
  102. case GameMessage::MSG_DO_MOVETO:
  103. case GameMessage::MSG_DO_ATTACKMOVETO:
  104. case GameMessage::MSG_DO_FORCEMOVETO:
  105. case GameMessage::MSG_ADD_WAYPOINT:
  106. TheInGameUI->createMoveHint( msg );
  107. break;
  108. //-----------------------------------------------------------------------------
  109. case GameMessage::MSG_DO_ATTACK_OBJECT:
  110. TheInGameUI->createAttackHint( msg );
  111. break;
  112. //-----------------------------------------------------------------------------
  113. case GameMessage::MSG_DO_FORCE_ATTACK_GROUND:
  114. case GameMessage::MSG_DO_FORCE_ATTACK_OBJECT:
  115. TheInGameUI->createForceAttackHint( msg );
  116. break;
  117. //-----------------------------------------------------------------------------
  118. case GameMessage::MSG_ENTER:
  119. TheInGameUI->createGarrisonHint( msg );
  120. break;
  121. }
  122. return disp;
  123. }