PlayerMenuServiceProtocol.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /****************************************************************************
  2. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  3. http://www.cocos2d-x.org
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. THE SOFTWARE.
  19. ****************************************************************************/
  20. #ifndef __PLAYER_MENU_SERVICE_PROTOCOL_H
  21. #define __PLAYER_MENU_SERVICE_PROTOCOL_H
  22. #include <string>
  23. #include "cocos2d.h"
  24. #include "PlayerMacros.h"
  25. #include "PlayerServiceProtocol.h"
  26. #include "SimulatorExport.h"
  27. PLAYER_NS_BEGIN
  28. #define kPlayerSuperModifyKey "super"
  29. #define kPlayerShiftModifyKey "shift"
  30. #define kPlayerCtrlModifyKey "ctrl"
  31. #define kPlayerAltModifyKey "alt"
  32. class CC_LIBSIM_DLL PlayerMenuItem : public cocos2d::Ref
  33. {
  34. public:
  35. virtual ~PlayerMenuItem();
  36. std::string getMenuId() const;
  37. std::string getTitle() const;
  38. int getOrder() const;
  39. bool isGroup() const;
  40. bool isEnabled() const;
  41. bool isChecked() const;
  42. std::string getShortcut() const;
  43. virtual void setTitle(const std::string &title) = 0;
  44. virtual void setEnabled(bool enabled) = 0;
  45. virtual void setChecked(bool checked) = 0;
  46. virtual void setShortcut(const std::string &shortcut) = 0;
  47. protected:
  48. PlayerMenuItem();
  49. std::string _menuId;
  50. std::string _title;
  51. int _order;
  52. bool _isGroup;
  53. bool _isEnabled;
  54. bool _isChecked; // ignored when isGroup = true
  55. std::string _shortcut; // ignored when isGroup = true
  56. };
  57. class PlayerMenuServiceProtocol : public PlayerServiceProtocol
  58. {
  59. public:
  60. static const int MAX_ORDER = 9999;
  61. virtual PlayerMenuItem *addItem(const std::string &menuId,
  62. const std::string &title,
  63. const std::string &parentId,
  64. int order = MAX_ORDER) = 0;
  65. virtual PlayerMenuItem *addItem(const std::string &menuId,
  66. const std::string &title) = 0;
  67. virtual PlayerMenuItem *getItem(const std::string &menuId) = 0;
  68. virtual bool removeItem(const std::string &menuId) = 0;
  69. virtual void setMenuBarEnabled(bool enabled) = 0;
  70. };
  71. PLAYER_NS_END
  72. #endif // __PLAYER_MENU_SERVICE_PROTOCOL_H