Merge branch 'master' of https://github.com/natural-law/cocos2d-x into natural-law-master

This commit is contained in:
walzer 2011-01-26 15:48:02 +08:00
commit a732665b85
9 changed files with 88 additions and 10 deletions

View File

@ -238,11 +238,21 @@ bool CCParticleSystem::initWithDictionary(NSDictionary<std::string, NSObject*> *
// texture
// Try to get the texture from the cache
char *textureName = (char *)valueForKey("textureFileName", dictionary);
std::string fullpath = CCFileUtils::fullPathFromRelativeFile(textureName, m_sPlistFile.c_str());
this->m_pTexture = CCTextureCache::sharedTextureCache()->addImage(fullpath.c_str());
std::string fullpath = CCFileUtils::fullPathFromRelativeFile(textureName, m_sPlistFile.c_str());
if (strlen(textureName) > 0)
{
// set not pop-up message box when load image failed
bool bNotify = UIImage::getIsPopupNotify();
UIImage::setIsPopupNotify(false);
this->m_pTexture = CCTextureCache::sharedTextureCache()->addImage(fullpath.c_str());
// reset the value of UIImage notify
UIImage::setIsPopupNotify(bNotify);
}
// if it fails, try to get it from the base64-gzipped data
char *textureData = NULL;;
char *textureData = NULL;
if ( ! m_pTexture &&
(textureData = (char *)valueForKey("textureImageData", dictionary)))
{

View File

@ -297,5 +297,14 @@ bool UIImage::initWithBuffer(int tx, int ty, unsigned char *pBuffer)
return false;
}
void UIImage::setIsPopupNotify(bool bNotify)
{
s_bPopupNotify = bNotify;
}
bool UIImage::getIsPopupNotify()
{
return s_bPopupNotify;
}
}//namespace cocos2d

View File

@ -95,6 +95,14 @@ public:
/** get the image data */
unsigned char* getData(void);
/**
@brief Set/Get whether pop-up a message box when the image load failed
@todo not implement now
*/
static void setIsPopupNotify(bool bNotify);
static bool getIsPopupNotify();
static bool s_bPopupNotify;
private:
bool loadPngFromStream(unsigned char *data, int nLength);
bool loadJpgFromStream(unsigned char *data, unsigned long nSize);

View File

@ -95,6 +95,14 @@ public:
/** get the image data */
unsigned char* getData(void);
/**
@brief Set/Get whether pop-up a message box when the image load failed
@todo not implement now
*/
static void setIsPopupNotify(bool bNotify);
static bool getIsPopupNotify();
static bool s_bPopupNotify;
private:
tImageInfo m_imageInfo;
};

View File

@ -388,5 +388,14 @@ bool UIImage::initWithBuffer(int tx, int ty, unsigned char *pBuffer)
return false;
}
void UIImage::setIsPopupNotify(bool bNotify)
{
s_bPopupNotify = bNotify;
}
bool UIImage::getIsPopupNotify()
{
return s_bPopupNotify;
}
}//namespace cocos2d

View File

@ -53,6 +53,7 @@ typedef struct
int offset;
}tImageSource;
bool UIImage::s_bPopupNotify = true;
// because we do not want to include "png.h" in CCXUIImage_uphone.h, so we implement
// the function as a static function
@ -148,8 +149,7 @@ bool UIImage::initWithContentsOfFile(const string &strPath, eImageFormat imageTy
}
}
#if defined(COCOS2D_DEBUG)
if (!bRet)
if (!bRet && s_bPopupNotify)
{
std::string strErr = "Load ";
strErr += strPath;
@ -158,7 +158,6 @@ bool UIImage::initWithContentsOfFile(const string &strPath, eImageFormat imageTy
TUString::StrUtf8ToStrUnicode(szText,(Char*)strErr.c_str());
TApplication::GetCurrentApplication()->MessageBox(szText,NULL,WMB_OK);
}
#endif
return bRet;
}
@ -412,4 +411,15 @@ bool UIImage::initWithBitmap(const TBitmap* pBmp)
return bRet;
}
void UIImage::setIsPopupNotify(bool bNotify)
{
s_bPopupNotify = bNotify;
}
bool UIImage::getIsPopupNotify()
{
return s_bPopupNotify;
}
}//namespace cocos2d

View File

@ -97,6 +97,13 @@ public:
/** get the image data */
unsigned char* getData(void);
/**
@brief Set/Get whether pop-up a message box when the image load failed
*/
static void setIsPopupNotify(bool bNotify);
static bool getIsPopupNotify();
static bool s_bPopupNotify;
private:
bool loadPngFromStream(unsigned char *data, int nLength);
bool loadJpgFromStream(unsigned char *data, unsigned long nSize);

View File

@ -51,6 +51,7 @@ typedef struct
int offset;
}tImageSource;
bool UIImage::s_bPopupNotify = true;
// because we do not want to include "png.h" in CCXUIImage_uphone.h, so we implement
// the function as a static function
@ -153,9 +154,8 @@ bool UIImage::initWithContentsOfFile(const string &strPath, eImageFormat imageTy
bRet = false;
break;
}
#if defined(COCOS2D_DEBUG)
if (!bRet)
if (!bRet && s_bPopupNotify)
{
// notify the loading error
std::string strErr = "Load ";
@ -165,7 +165,7 @@ bool UIImage::initWithContentsOfFile(const string &strPath, eImageFormat imageTy
std::copy(strErr.begin(), strErr.end(), wsErr.begin());
MessageBox(NULL, wsErr.c_str(), L"cocos2d-x error", MB_OK);
}
#endif
return bRet;
}
@ -442,4 +442,14 @@ bool UIImage::initWithBuffer(int tx, int ty, unsigned char *pBuffer)
return false;
}
void UIImage::setIsPopupNotify(bool bNotify)
{
s_bPopupNotify = bNotify;
}
bool UIImage::getIsPopupNotify()
{
return s_bPopupNotify;
}
}//namespace cocos2d

View File

@ -98,6 +98,13 @@ public:
/** get the image data */
unsigned char* getData(void);
/**
@brief Set/Get whether pop-up a message box when the image load failed
*/
static void setIsPopupNotify(bool bNotify);
static bool getIsPopupNotify();
static bool s_bPopupNotify;
private:
bool loadPng(const char* strFileName);
bool loadPngFromStream(unsigned char *data, int nLength);