HotKey.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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: HotKey.h /////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Electronic Arts Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2002 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // created: Sep 2002
  34. //
  35. // Filename: HotKey.h
  36. //
  37. // author: Chris Huybregts
  38. //
  39. // purpose:
  40. //
  41. //-----------------------------------------------------------------------------
  42. ///////////////////////////////////////////////////////////////////////////////
  43. #pragma once
  44. #ifndef __HOT_KEY_H_
  45. #define __HOT_KEY_H_
  46. //-----------------------------------------------------------------------------
  47. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  48. //-----------------------------------------------------------------------------
  49. //-----------------------------------------------------------------------------
  50. // USER INCLUDES //////////////////////////////////////////////////////////////
  51. //-----------------------------------------------------------------------------
  52. #include "Common/SubsystemInterface.h"
  53. #include "Common/MessageStream.h"
  54. //-----------------------------------------------------------------------------
  55. // FORWARD REFERENCES /////////////////////////////////////////////////////////
  56. //-----------------------------------------------------------------------------
  57. class AsciiString;
  58. class GameWindow;
  59. //-----------------------------------------------------------------------------
  60. // TYPE DEFINES ///////////////////////////////////////////////////////////////
  61. //-----------------------------------------------------------------------------
  62. class HotKeyTranslator : public GameMessageTranslator
  63. {
  64. public:
  65. virtual GameMessageDisposition translateGameMessage(const GameMessage *msg);
  66. virtual ~HotKeyTranslator() { }
  67. };
  68. //-----------------------------------------------------------------------------
  69. class HotKey
  70. {
  71. public:
  72. HotKey( void );
  73. GameWindow *m_win;
  74. AsciiString m_key;
  75. // we may need a checkmark system.
  76. };
  77. //-----------------------------------------------------------------------------
  78. class HotKeyManager : public SubsystemInterface
  79. {
  80. public:
  81. HotKeyManager( void );
  82. ~HotKeyManager( void );
  83. // Inherited from subsystem interface -----------------------------------------------------------
  84. virtual void init( void ); ///< Initialize the Hotkey system
  85. virtual void update( void ) {} ///< A No-op for us
  86. virtual void reset( void ); ///< Reset
  87. //-----------------------------------------------------------------------------------------------
  88. void addHotKey( GameWindow *win, const AsciiString& key);
  89. Bool executeHotKey( const AsciiString& key); // called fromt eh HotKeyTranslator
  90. AsciiString searchHotKey( const AsciiString& label);
  91. AsciiString searchHotKey( const UnicodeString& uStr );
  92. private:
  93. typedef std::map<AsciiString, HotKey> HotKeyMap;
  94. HotKeyMap m_hotKeyMap;
  95. };
  96. extern HotKeyManager *TheHotKeyManager;
  97. //-----------------------------------------------------------------------------
  98. // INLINING ///////////////////////////////////////////////////////////////////
  99. //-----------------------------------------------------------------------------
  100. //-----------------------------------------------------------------------------
  101. // EXTERNALS //////////////////////////////////////////////////////////////////
  102. //-----------------------------------------------------------------------------
  103. #endif // __HOT_KEY_H_