CCEventAssetsManagerEx.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /****************************************************************************
  2. Copyright (c) 2014-2016 Chukong Technologies Inc.
  3. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  4. http://www.cocos2d-x.org
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. ****************************************************************************/
  21. #ifndef __cocos2d_libs__CCEventAssetsManagerEx__
  22. #define __cocos2d_libs__CCEventAssetsManagerEx__
  23. #include <string>
  24. #include "base/CCRef.h"
  25. #include "extensions/ExtensionMacros.h"
  26. #include "extensions/ExtensionExport.h"
  27. NS_CC_EXT_BEGIN
  28. class AssetsManagerEx;
  29. class CC_EX_DLL EventAssetsManagerEx : public cocos2d::Ref
  30. {
  31. public:
  32. //! Update events code
  33. enum class EventCode
  34. {
  35. ERROR_NO_LOCAL_MANIFEST,
  36. ERROR_DOWNLOAD_MANIFEST,
  37. ERROR_PARSE_MANIFEST,
  38. NEW_VERSION_FOUND,
  39. ALREADY_UP_TO_DATE,
  40. UPDATE_PROGRESSION,
  41. ASSET_UPDATED,
  42. ERROR_UPDATING,
  43. UPDATE_FINISHED,
  44. UPDATE_FAILED,
  45. ERROR_DECOMPRESS
  46. };
  47. inline EventCode getEventCode() const { return _code; };
  48. inline int getCURLECode() const { return _curle_code; };
  49. inline int getCURLMCode() const { return _curlm_code; };
  50. inline std::string getMessage() const { return _message; };
  51. inline std::string getAssetId() const { return _assetId; };
  52. inline cocos2d::extension::AssetsManagerEx *getAssetsManagerEx() const { return _manager; };
  53. bool isResuming() const;
  54. float getPercent() const;
  55. float getPercentByFile() const;
  56. double getDownloadedBytes() const;
  57. double getTotalBytes() const;
  58. int getDownloadedFiles() const;
  59. int getTotalFiles() const;
  60. public:
  61. /** Constructor */
  62. EventAssetsManagerEx(const std::string& eventName, cocos2d::extension::AssetsManagerEx *manager, const EventCode &code, const std::string& assetId = "", const std::string& message = "", int curle_code = 0, int curlm_code = 0);
  63. private:
  64. virtual ~EventAssetsManagerEx() {}
  65. EventCode _code;
  66. cocos2d::extension::AssetsManagerEx *_manager;
  67. std::string _message;
  68. std::string _assetId;
  69. int _curle_code;
  70. int _curlm_code;
  71. };
  72. NS_CC_EXT_END
  73. #endif /* defined(__cocos2d_libs__CCEventAssetsManagerEx__) */