CCEventAssetsManagerEx.cpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. #include "CCEventAssetsManagerEx.h"
  22. #include "base/ccMacros.h"
  23. #include <functional>
  24. #include "AssetsManagerEx.h"
  25. NS_CC_EXT_BEGIN
  26. EventAssetsManagerEx::EventAssetsManagerEx(const std::string& eventName, cocos2d::extension::AssetsManagerEx *manager, const EventCode &code, const std::string& assetId/* = "" */, const std::string& message/* = "" */, int curle_code/* = CURLE_OK*/, int curlm_code/* = CURLM_OK*/)
  27. : _code(code)
  28. , _manager(manager)
  29. , _message(message)
  30. , _assetId(assetId)
  31. , _curle_code(curle_code)
  32. , _curlm_code(curlm_code)
  33. {
  34. }
  35. bool EventAssetsManagerEx::isResuming() const
  36. {
  37. return _manager->isResuming();
  38. }
  39. float EventAssetsManagerEx::getPercent() const
  40. {
  41. return _manager->getDownloadedBytes() / _manager->getTotalBytes();
  42. }
  43. float EventAssetsManagerEx::getPercentByFile() const
  44. {
  45. return (float)(_manager->getDownloadedFiles()) / _manager->getTotalFiles();
  46. }
  47. double EventAssetsManagerEx::getDownloadedBytes() const
  48. {
  49. return _manager->getDownloadedBytes();
  50. }
  51. double EventAssetsManagerEx::getTotalBytes() const
  52. {
  53. return _manager->getTotalBytes();
  54. }
  55. int EventAssetsManagerEx::getDownloadedFiles() const
  56. {
  57. return _manager->getDownloadedFiles();
  58. }
  59. int EventAssetsManagerEx::getTotalFiles() const
  60. {
  61. return _manager->getTotalFiles();
  62. }
  63. NS_CC_EXT_END