SelectionXlat.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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: SelectionXlat.h ///////////////////////////////////////////////////////////
  24. // Author: Steven Johnson, Dec 2001
  25. #pragma once
  26. #ifndef _H_SelectionXlat
  27. #define _H_SelectionXlat
  28. #include "GameClient/InGameUI.h"
  29. class ThingTemplate;
  30. typedef std::map<const ThingTemplate *, int> SelectCountMap;
  31. typedef SelectCountMap::iterator SelectCountMapIt;
  32. //-----------------------------------------------------------------------------
  33. class SelectionTranslator : public GameMessageTranslator
  34. {
  35. // this is an evil friend wrapper due to the current limitations of Drawable iterators.
  36. friend Bool selectFriendsWrapper( Drawable *draw, void *userData );
  37. friend Bool killThemKillThemAllWrapper( Drawable *draw, void *userData );
  38. private:
  39. Bool m_leftMouseButtonIsDown;
  40. Bool m_dragSelecting;
  41. UnsignedInt m_lastGroupSelTime;
  42. Int m_lastGroupSelGroup;
  43. ICoord2D m_selectFeedbackAnchor; // Note: Used for drawing feedback only.
  44. ICoord2D m_deselectFeedbackAnchor; // Note: Used for drawing feedback only.
  45. Bool m_displayedMaxWarning; // did we already display a warning about selecting too many units?
  46. UnsignedInt m_lastClick; ///< timer used for checking double click for type selection
  47. SelectCountMap m_selectCountMap;
  48. Coord3D m_deselectDownCameraPosition;
  49. Bool selectFriends( Drawable *draw, GameMessage *createTeamMsg, Bool dragSelecting );
  50. Bool killThemKillThemAll( Drawable *draw, GameMessage *killThemAllMsg );
  51. public:
  52. SelectionTranslator();
  53. ~SelectionTranslator();
  54. virtual GameMessageDisposition translateGameMessage(const GameMessage *msg);
  55. //Added By Sadullah Nader
  56. //added for fix to the drag selection when entering control bar
  57. //changes the mode of drag selecting to it's opposite
  58. void setDragSelecting(Bool dragSelect);
  59. void setLeftMouseButton(Bool state);
  60. };
  61. Bool CanSelectDrawable( const Drawable *draw, Bool dragSelecting );
  62. extern SelectionTranslator *TheSelectionTranslator;
  63. #endif