CCApplication-mac.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /****************************************************************************
  2. Copyright (c) 2010-2012 cocos2d-x.org
  3. Copyright (c) 2013-2016 Chukong Technologies Inc.
  4. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  5. http://www.cocos2d-x.org
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. THE SOFTWARE.
  21. ****************************************************************************/
  22. #ifndef __CC_APPLICATION_MAC_H__
  23. #define __CC_APPLICATION_MAC_H__
  24. #include "platform/CCPlatformConfig.h"
  25. #if CC_TARGET_PLATFORM == CC_PLATFORM_MAC
  26. #include "platform/CCCommon.h"
  27. #include "platform/CCApplicationProtocol.h"
  28. #include <string>
  29. NS_CC_BEGIN
  30. class CC_DLL Application : public ApplicationProtocol
  31. {
  32. public:
  33. /**
  34. * @js ctor
  35. */
  36. Application();
  37. /**
  38. * @js NA
  39. * @lua NA
  40. */
  41. virtual ~Application();
  42. /**
  43. @brief Callback by Director for limit FPS.
  44. @param interval The time, which expressed in second in second, between current frame and next.
  45. */
  46. virtual void setAnimationInterval(float interval) override;
  47. virtual void setAnimationInterval(float interval, SetIntervalReason reason) override;
  48. /**
  49. @brief Run the message loop.
  50. * @js NA
  51. * @lua NA
  52. */
  53. int run();
  54. /**
  55. @brief Get current application instance.
  56. @return Current application instance pointer.
  57. */
  58. static Application* getInstance();
  59. /** @deprecated Use getInstance() instead */
  60. CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication();
  61. /**
  62. @brief Get current language config
  63. @return Current language config
  64. */
  65. virtual LanguageType getCurrentLanguage() override;
  66. /**
  67. @brief Get current language iso 639-1 code
  68. @return Current language iso 639-1 code
  69. */
  70. virtual const char * getCurrentLanguageCode() override;
  71. /**
  72. @brief Get target platform
  73. */
  74. virtual Platform getTargetPlatform() override;
  75. /**
  76. @brief Get application version.
  77. */
  78. virtual std::string getVersion() override;
  79. /**
  80. @brief Open url in default browser
  81. @param String with url to open.
  82. @return true if the resource located by the URL was successfully opened; otherwise false.
  83. */
  84. virtual bool openURL(const std::string &url) override;
  85. /**
  86. * Sets the Resource root path.
  87. * @deprecated Please use FileUtils::getInstance()->setSearchPaths() instead.
  88. */
  89. CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir);
  90. /**
  91. * Gets the Resource root path.
  92. * @deprecated Please use FileUtils::getInstance()->getSearchPaths() instead.
  93. */
  94. CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void);
  95. void setStartupScriptFilename(const std::string& startupScriptFile);
  96. const std::string& getStartupScriptFilename(void);
  97. protected:
  98. static Application * sm_pSharedApplication;
  99. long _animationInterval; //micro second
  100. std::string _resourceRootPath;
  101. std::string _startupScriptFilename;
  102. };
  103. NS_CC_END
  104. #endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC
  105. #endif // end of __CC_APPLICATION_MAC_H__;