cocos2d-x
3.3
|
This class is used to auto update resources, such as pictures or scripts. More...
#include <AssetsManagerEx.h>
Public Types | |
enum | State { UNCHECKED, PREDOWNLOAD_VERSION, DOWNLOADING_VERSION, VERSION_LOADED, PREDOWNLOAD_MANIFEST, DOWNLOADING_MANIFEST, MANIFEST_LOADED, NEED_UPDATE, UPDATING, UP_TO_DATE, FAIL_TO_UPDATE } |
Update states. More... | |
Public Member Functions | |
void | checkUpdate () |
Check out if there is a new version of manifest. More... | |
void | update () |
Update with the current local manifest. More... | |
void | downloadFailedAssets () |
Reupdate all failed assets under the current AssetsManagerEx context. More... | |
State | getState () const |
Gets the current update state. More... | |
const std::string & | getStoragePath () const |
Gets storage path. More... | |
const Manifest * | getLocalManifest () const |
Function for retrieve the local manifest object. More... | |
const Manifest * | getRemoteManifest () const |
Function for retrieve the remote manifest object. More... | |
virtual | ~AssetsManagerEx () |
![]() | |
void | retain () |
Retains the ownership. More... | |
void | release () |
Releases the ownership immediately. More... | |
Ref * | autorelease () |
Releases the ownership sometime soon automatically. More... | |
unsigned int | getReferenceCount () const |
Returns the Ref's current reference count. More... | |
virtual | ~Ref () |
NA NA More... | |
Static Public Member Functions | |
static AssetsManagerEx * | create (const std::string &manifestUrl, const std::string &storagePath) |
Create function for creating a new AssetsManagerEx. More... | |
Public Attributes | |
CC_CONSTRUCTOR_ACCESS | __pad0__: AssetsManagerEx(const std::string& manifestUrl |
CC_CONSTRUCTOR_ACCESS const std::string & | storagePath |
Static Public Attributes | |
static const std::string | VERSION_ID |
static const std::string | MANIFEST_ID |
static const std::string | BATCH_UPDATE_ID |
Protected Member Functions | |
std::string | basename (const std::string &path) const |
std::string | get (const std::string &key) const |
void | initManifests (const std::string &manifestUrl) |
void | loadLocalManifest (const std::string &manifestUrl) |
void | prepareLocalManifest () |
void | setStoragePath (const std::string &storagePath) |
void | adjustPath (std::string &path) |
void | dispatchUpdateEvent (EventAssetsManagerEx::EventCode code, const std::string &message="", const std::string &assetId="", int curle_code=0, int curlm_code=0) |
void | downloadVersion () |
void | parseVersion () |
void | downloadManifest () |
void | parseManifest () |
void | startUpdate () |
void | updateSucceed () |
bool | decompress (const std::string &filename) |
void | decompressDownloadedZip () |
void | updateAssets (const Downloader::DownloadUnits &assets) |
Update a list of assets under the current AssetsManagerEx context. More... | |
const Downloader::DownloadUnits & | getFailedAssets () const |
Retrieve all failed assets during the last update. More... | |
void | destroyDownloadedVersion () |
Function for destorying the downloaded version file and manifest file. More... | |
virtual void | onError (const Downloader::Error &error) |
Call back function for error handling, the error will then be reported to user's listener registed in addUpdateEventListener. More... | |
virtual void | onProgress (double total, double downloaded, const std::string &url, const std::string &customId) |
Call back function for recording downloading percent of the current asset, the progression will then be reported to user's listener registed in addUpdateProgressEventListener. More... | |
virtual void | onSuccess (const std::string &srcUrl, const std::string &storagePath, const std::string &customId) |
Call back function for success of the current asset the success event will then be send to user's listener registed in addUpdateEventListener. More... | |
![]() | |
Ref () | |
Constructor. More... | |
Friends | |
class | Downloader |
int | downloadProgressFunc (Downloader::ProgressData *ptr, double totalToDownload, double nowDownloaded, double totalToUpLoad, double nowUpLoaded) |
Additional Inherited Members | |
![]() | |
unsigned int | _referenceCount |
count of references More... | |
This class is used to auto update resources, such as pictures or scripts.
|
strong |
|
virtual |
|
protected |
|
protected |
void checkUpdate | ( | ) |
Check out if there is a new version of manifest.
You may use this method before updating, then let user determine whether he wants to update resources.
|
static |
Create function for creating a new AssetsManagerEx.
manifestUrl | The url for the local manifest file |
storagePath | The storage path for downloaded assetes |
|
protected |
|
protected |
|
protected |
Function for destorying the downloaded version file and manifest file.
|
protected |
void downloadFailedAssets | ( | ) |
Reupdate all failed assets under the current AssetsManagerEx context.
|
protected |
|
protected |
|
protected |
|
protected |
Retrieve all failed assets during the last update.
const Manifest* getLocalManifest | ( | ) | const |
Function for retrieve the local manifest object.
const Manifest* getRemoteManifest | ( | ) | const |
Function for retrieve the remote manifest object.
State getState | ( | ) | const |
Gets the current update state.
const std::string& getStoragePath | ( | ) | const |
Gets storage path.
|
protected |
|
protected |
|
protectedvirtual |
Call back function for error handling, the error will then be reported to user's listener registed in addUpdateEventListener.
error | The error object contains ErrorCode, message, asset url, asset key |
|
protectedvirtual |
Call back function for recording downloading percent of the current asset, the progression will then be reported to user's listener registed in addUpdateProgressEventListener.
total | Total size to download for this asset |
downloaded | Total size already downloaded for this asset |
url | The url of this asset |
customId | The key of this asset |
|
protectedvirtual |
Call back function for success of the current asset the success event will then be send to user's listener registed in addUpdateEventListener.
srcUrl | The url of this asset |
customId | The key of this asset |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
void update | ( | ) |
Update with the current local manifest.
|
protected |
Update a list of assets under the current AssetsManagerEx context.
|
protected |
|
friend |
|
friend |
CC_CONSTRUCTOR_ACCESS __pad0__ |
|
static |
|
static |
CC_CONSTRUCTOR_ACCESS const std::string& storagePath |
|
static |